mod: refactor commands to global commands, restrict from direct messages
nix build works too
This commit is contained in:
+6
-11
@@ -11,9 +11,8 @@ use serenity::async_trait;
|
||||
use serenity::builder::{
|
||||
CreateInteractionResponse, CreateInteractionResponseMessage, EditInteractionResponse,
|
||||
};
|
||||
use serenity::model::application::Interaction;
|
||||
use serenity::model::application::{Command, Interaction, InteractionContext};
|
||||
use serenity::model::gateway::Ready;
|
||||
use serenity::model::id::GuildId;
|
||||
use serenity::prelude::*;
|
||||
use songbird::SerenityInit;
|
||||
use tokio::sync::Mutex;
|
||||
@@ -84,22 +83,18 @@ impl EventHandler for Handler {
|
||||
async fn ready(&self, ctx: Context, ready: Ready) {
|
||||
println!("{} is connected!", ready.user.name);
|
||||
|
||||
let guild_id = GuildId::new(
|
||||
env::var("GUILD_ID")
|
||||
.expect("Expected GUILD_ID in environment")
|
||||
.parse()
|
||||
.expect("GUILD_ID must be an integer"),
|
||||
);
|
||||
|
||||
let commands = vec![
|
||||
commands::start::register(),
|
||||
commands::reset::register(),
|
||||
commands::lock::register(),
|
||||
commands::unlock::register(),
|
||||
commands::stop::register(),
|
||||
];
|
||||
]
|
||||
.into_iter()
|
||||
.map(|command| command.add_context(InteractionContext::Guild))
|
||||
.collect();
|
||||
|
||||
if let Err(why) = guild_id.set_commands(&ctx.http, commands).await {
|
||||
if let Err(why) = Command::set_global_commands(&ctx.http, commands).await {
|
||||
println!("Cannot register slash commands: {why}");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user