update serenity
This commit is contained in:
parent
f682aefc7d
commit
dac9a0c7ca
906
Cargo.lock
generated
906
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -5,7 +5,6 @@ authors = ["kageru <kageru@encode.moe>"]
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serenity = { version = "0.11", default_features = false, features = ["client", "rustls_backend", "model", "builder", "gateway", "utils", "cache"] }
|
serenity = { version = "0.12", default-features = false, features = ["client", "rustls_backend", "model", "builder", "gateway", "utils", "cache"] }
|
||||||
lazy_static = "1"
|
|
||||||
async-trait = "0.1"
|
async-trait = "0.1"
|
||||||
tokio = { version = "1", features = ["rt-multi-thread"] }
|
tokio = { version = "1", features = ["rt-multi-thread"] }
|
||||||
|
15
src/main.rs
15
src/main.rs
@ -1,5 +1,4 @@
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use lazy_static::lazy_static;
|
|
||||||
use serenity::{
|
use serenity::{
|
||||||
model::{
|
model::{
|
||||||
channel::ReactionType,
|
channel::ReactionType,
|
||||||
@ -9,14 +8,14 @@ use serenity::{
|
|||||||
prelude::*,
|
prelude::*,
|
||||||
Client,
|
Client,
|
||||||
};
|
};
|
||||||
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
struct Handler;
|
struct Handler;
|
||||||
|
|
||||||
lazy_static! {
|
static SERVER_ID: LazyLock<GuildId> =
|
||||||
static ref SERVER_ID: GuildId = GuildId(std::env::args().nth(1).unwrap().parse().unwrap());
|
LazyLock::new(|| GuildId::new(std::env::args().nth(1).unwrap().parse().unwrap()));
|
||||||
static ref MEME_CHANNEL: ChannelId =
|
static MEME_CHANNEL: LazyLock<ChannelId> =
|
||||||
ChannelId(std::env::args().nth(2).unwrap().parse().unwrap());
|
LazyLock::new(|| ChannelId::new(std::env::args().nth(2).unwrap().parse().unwrap()));
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl EventHandler for Handler {
|
impl EventHandler for Handler {
|
||||||
@ -29,7 +28,7 @@ impl EventHandler for Handler {
|
|||||||
async fn reaction_add(&self, ctx: Context, reaction: Reaction) {
|
async fn reaction_add(&self, ctx: Context, reaction: Reaction) {
|
||||||
if reaction.channel_id == *MEME_CHANNEL
|
if reaction.channel_id == *MEME_CHANNEL
|
||||||
// you know who you are
|
// you know who you are
|
||||||
&& reaction.user_id == Some(UserId(921332064056389663))
|
&& reaction.user_id == Some(UserId::new(921332064056389663))
|
||||||
{
|
{
|
||||||
if let Err(e) = reaction.delete(&ctx).await {
|
if let Err(e) = reaction.delete(&ctx).await {
|
||||||
eprintln!("Could not delete reaction spam: {e}");
|
eprintln!("Could not delete reaction spam: {e}");
|
||||||
@ -71,7 +70,7 @@ async fn react(
|
|||||||
) -> Result<(), serenity::Error> {
|
) -> Result<(), serenity::Error> {
|
||||||
let reaction = ReactionType::Custom {
|
let reaction = ReactionType::Custom {
|
||||||
animated: false,
|
animated: false,
|
||||||
id: EmojiId(emoji),
|
id: EmojiId::new(emoji),
|
||||||
name: Some(name.to_string()),
|
name: Some(name.to_string()),
|
||||||
};
|
};
|
||||||
msg.react(ctx, reaction).await?;
|
msg.react(ctx, reaction).await?;
|
||||||
|
Loading…
Reference in New Issue
Block a user