summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorseth <[email protected]>2023-06-02 19:42:26 -0400
committerseth <[email protected]>2023-06-02 19:42:26 -0400
commitbe622b9c533bb094dfedaf39bca7339c58e54456 (patch)
tree3c02eb3eb5c23ed5ce9d78f5943f74dc8e527f89 /src
parented8b784c78b759a59dbb0232e04d00604a611699 (diff)
allow other servers to use most slash commands
Diffstat (limited to 'src')
-rw-r--r--src/commands/copypasta.rs2
-rw-r--r--src/main.rs17
2 files changed, 13 insertions, 6 deletions
diff --git a/src/commands/copypasta.rs b/src/commands/copypasta.rs
index d7ec2d0..20ca144 100644
--- a/src/commands/copypasta.rs
+++ b/src/commands/copypasta.rs
@@ -28,7 +28,7 @@ pub async fn run(options: &[CommandDataOption], channel_id: ChannelId, http: &Ar
Ok(_) => continue,
Err(why) => {
println!("couldn't send message: {:?}", why);
- "something went wrong!";
+ return "something went wrong!".to_string();
}
}
}
diff --git a/src/main.rs b/src/main.rs
index 01b3fb2..22a71db 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -3,6 +3,7 @@ use regex::Regex;
use serenity::async_trait;
use serenity::framework::standard::macros::{command, group};
use serenity::framework::standard::{CommandResult, StandardFramework};
+use serenity::model::application::command::Command;
use serenity::model::application::interaction::{Interaction, InteractionResponseType};
use serenity::model::channel::Message;
use serenity::model::id::GuildId;
@@ -15,7 +16,7 @@ mod commands;
mod consts;
mod utils;
-const GUILD: u64 = 1055663552679137310;
+const TEAWIE_GUILD: u64 = 1055663552679137310;
const BOT: u64 = 1056467120986271764;
#[group]
@@ -96,19 +97,25 @@ impl EventHandler for Handler {
async fn ready(&self, ctx: Context, ready: Ready) {
println!("connected as {:?}", ready.user.name);
- let guild_id = GuildId(GUILD);
+ let guild_id = GuildId(TEAWIE_GUILD);
- let commands = GuildId::set_application_commands(&guild_id, &ctx.http, |commands| {
+ let guild_commands = GuildId::set_application_commands(&guild_id, &ctx.http, |commands| {
+ commands.create_application_command(|command| commands::copypasta::register(command))
+ })
+ .await;
+
+ println!("registered guild commands: {:#?}", guild_commands);
+
+ let commands = Command::set_global_application_commands(&ctx.http, |commands| {
commands
.create_application_command(|command| commands::ask::register(command))
.create_application_command(|command| commands::bottom::register(command))
- .create_application_command(|command| commands::copypasta::register(command))
.create_application_command(|command| commands::random_lore::register(command))
.create_application_command(|command| commands::random_teawie::register(command))
})
.await;
- println!("registered commands: {:#?}", commands);
+ println!("registered global commands: {:#?}", commands);
}
}