idk
This commit is contained in:
+75
-25
@@ -1,7 +1,7 @@
|
||||
#![feature(pattern)]
|
||||
|
||||
use dotenv::dotenv;
|
||||
use serenity::all::{MessageReaction, RoleId, User, UserId};
|
||||
use serenity::all::{Command, CreateInteractionResponse, CreateInteractionResponseFollowup, CreateInteractionResponseMessage, GuildId, Interaction, MessageReaction, RoleId, User, UserId};
|
||||
use serenity::async_trait;
|
||||
use serenity::model::channel::Message;
|
||||
use serenity::model::gateway::Ready;
|
||||
@@ -10,6 +10,8 @@ use std::env;
|
||||
use std::str::pattern::Pattern;
|
||||
use std::sync::Arc;
|
||||
|
||||
mod translate;
|
||||
|
||||
struct Handler;
|
||||
|
||||
const STEVENIST_ROLE: u64 = 1315038173730181140;
|
||||
@@ -44,7 +46,7 @@ impl EventHandler for Handler {
|
||||
.await;
|
||||
}
|
||||
|
||||
if msg.channel_id == 1315118069101629530 && !msg.is_own(ctx.clone()) {
|
||||
if msg.channel_id == 1315118069101629530 && msg.author != **ctx.cache.current_user() {
|
||||
if message != "fr" {
|
||||
let _ = msg.react(ctx.clone(), '❗').await;
|
||||
let _ = msg.reply(ctx.clone(), "NON 'FR' MESSAGE DETECTED").await;
|
||||
@@ -73,35 +75,62 @@ impl EventHandler for Handler {
|
||||
}
|
||||
|
||||
let message = parse(&message);
|
||||
|
||||
if let Some(&"<@1315046876969566218>") = message.get(0) {
|
||||
println!("detected");
|
||||
if let Some(&"judge") = message.get(1) {
|
||||
if let Some(user) = message.get(2) {
|
||||
let user_id_str = user
|
||||
.strip_prefix("<@")
|
||||
.unwrap()
|
||||
.strip_suffix(">")
|
||||
.unwrap()
|
||||
.parse::<u64>()
|
||||
.unwrap();
|
||||
println!("{}", user_id_str);
|
||||
let user_id = UserId::new(user_id_str);
|
||||
if let Ok(user) = &ctx.http.get_member(guild_id.unwrap(), user_id).await {
|
||||
if user.roles.contains(&RoleId::new(HERETIC_ROLE)) {
|
||||
let _ = msg.reply(&ctx, "Heretic").await;
|
||||
} else if user.roles.contains(&RoleId::new(STEVENIST_ROLE)) {
|
||||
let _ = msg.reply(&ctx, "A Loyal Servant of Steven.").await;
|
||||
} else {
|
||||
let _ = msg.reply(&ctx, "Not a Heretic").await;
|
||||
}
|
||||
}
|
||||
}
|
||||
judge(&ctx, &msg, &message, guild_id).await;
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(&"mods" | &"mods,") = message.get(0) {
|
||||
println!("mods");
|
||||
if let None = message.get(1) {
|
||||
msg.reply(&ctx, "...").await.unwrap();
|
||||
}
|
||||
|
||||
let verb = match *message.get(1).unwrap() {
|
||||
"drop" => "dropping".to_string(),
|
||||
"make" => "making".to_string(),
|
||||
"praise" => "praising".to_string(),
|
||||
"give" => "giving".to_string(),
|
||||
"shut" => "shutting".to_string(),
|
||||
"smite" => "smiting".to_string(),
|
||||
x => format!("{}ing", x),
|
||||
};
|
||||
|
||||
let response = verb + " " + &message[2..].join(" ");
|
||||
msg.reply(&ctx, response).await.unwrap();
|
||||
};
|
||||
}
|
||||
|
||||
async fn ready(&self, _: Context, ready: Ready) {
|
||||
async fn interaction_create(&self, ctx: Context, interaction: Interaction) {
|
||||
if let Interaction::Command(c) = interaction {
|
||||
let content = match c.data.name.as_str() {
|
||||
"say" => {
|
||||
if c.user.id != UserId::new(771822887421345812) {
|
||||
return;
|
||||
}
|
||||
|
||||
translate::run_say(c.data.options()[0].clone())
|
||||
},
|
||||
_ => String::new(),
|
||||
};
|
||||
|
||||
let _ = c.channel_id.say(&ctx.http, content).await;
|
||||
|
||||
let data = CreateInteractionResponseMessage::new().content("");
|
||||
let builder = CreateInteractionResponse::Message(data);
|
||||
let _ = c.create_response(&ctx.http, builder).await;
|
||||
};
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
async fn ready(&self, ctx: Context, ready: Ready) {
|
||||
|
||||
// set commands
|
||||
Command::create_global_command(&ctx.http, translate::register_say()).await.unwrap();
|
||||
|
||||
println!("{} is connected!", ready.user.name);
|
||||
}
|
||||
}
|
||||
@@ -126,7 +155,28 @@ async fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
fn judge(ctx: Context, msg: Message) {}
|
||||
async fn judge(ctx: &Context, msg: &Message, message: &Vec<&str>, guild_id: Option<GuildId>) {
|
||||
if let Some(user) = message.get(2) {
|
||||
let user_id_str = user
|
||||
.strip_prefix("<@")
|
||||
.unwrap()
|
||||
.strip_suffix(">")
|
||||
.unwrap()
|
||||
.parse::<u64>()
|
||||
.unwrap();
|
||||
println!("{}", user_id_str);
|
||||
let user_id = UserId::new(user_id_str);
|
||||
if let Ok(user) = &ctx.http.get_member(guild_id.unwrap(), user_id).await {
|
||||
if user.roles.contains(&RoleId::new(HERETIC_ROLE)) {
|
||||
let _ = msg.reply(&ctx, "Heretic").await;
|
||||
} else if user.roles.contains(&RoleId::new(STEVENIST_ROLE)) {
|
||||
let _ = msg.reply(&ctx, "A Loyal Servant of Steven.").await;
|
||||
} else {
|
||||
let _ = msg.reply(&ctx, "Not a Heretic").await;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parse(message: &str) -> Vec<&str> {
|
||||
message
|
||||
|
||||
Reference in New Issue
Block a user