more logging. only build commands once

This commit is contained in:
jellywx 2021-09-17 10:59:42 +01:00
parent 9f7853c074
commit 8db0a05785
3 changed files with 18 additions and 12 deletions

View File

@ -44,18 +44,6 @@ impl EventHandler for Handler {
ctx.set_activity(Activity::watching("for /play")).await;
}
async fn cache_ready(&self, ctx: Context, _: Vec<GuildId>) {
let framework = ctx
.data
.read()
.await
.get::<RegexFramework>()
.cloned()
.expect("RegexFramework not found in context");
framework.build_slash(ctx).await;
}
async fn guild_create(&self, ctx: Context, guild: Guild, is_new: bool) {
if is_new {
if let Ok(token) = env::var("DISCORDBOTS_TOKEN") {

View File

@ -597,6 +597,14 @@ impl RegexFramework {
);
}
info!(
"[Shard {}] [Guild {}] /{} {:?}",
ctx.shard_id,
interaction.guild_id.unwrap(),
interaction.data.name,
args
);
(command.fun)(&ctx, &interaction, Args { args })
.await
.unwrap();
@ -682,6 +690,14 @@ impl Framework for RegexFramework {
let member = guild.member(&ctx, &msg.author).await.unwrap();
if command.check_permissions(&ctx, &guild, &member).await {
let _ = msg.channel_id.say(
&ctx,
format!(
"You **must** begin to switch to slash commands. All commands are available via slash commands now. If slash commands don't display in your server, please use this link: https://discord.com/api/oauth2/authorize?client_id={}&permissions=3165184&scope=applications.commands%20bot",
ctx.cache.current_user().id
)
).await;
(command.fun)(&ctx, &msg, Args::from(&args, command.args))
.await
.unwrap();

View File

@ -308,6 +308,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
}
}
framework_arc.build_slash(&client.cache_and_http.http).await;
if let Ok((Some(lower), Some(upper))) = env::var("SHARD_RANGE").map(|sr| {
let mut split = sr
.split(',')