-
Notifications
You must be signed in to change notification settings - Fork 120
/
Copy pathuser_apps.rs
60 lines (54 loc) · 1.82 KB
/
user_apps.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
use crate::{Context, Error};
use poise::serenity_prelude as serenity;
// `install_context` determines how the bot has to be installed for a command to be available.
// `interaction_context` determines where a command can be used.
/// Available everywhere
#[poise::command(
slash_command,
install_context = "Guild|User",
interaction_context = "Guild|BotDm|PrivateChannel"
)]
pub async fn everywhere(ctx: Context<'_>) -> Result<(), Error> {
ctx.say("This command is available everywhere!").await?;
Ok(())
}
// also works with `context_menu_command`
/// Available everywhere
#[poise::command(
context_menu_command = "Everywhere",
install_context = "Guild|User",
interaction_context = "Guild|BotDm|PrivateChannel"
)]
pub async fn everywhere_context(ctx: Context<'_>, msg: serenity::Message) -> Result<(), Error> {
msg.reply(ctx, "This context menu is available everywhere!")
.await?;
Ok(())
}
/// Available with a user install only
#[poise::command(
slash_command,
install_context = "User",
interaction_context = "Guild|BotDm|PrivateChannel"
)]
pub async fn user_install(ctx: Context<'_>) -> Result<(), Error> {
ctx.say("This command is available only with a user install!")
.await?;
Ok(())
}
/// Not available in guilds
#[poise::command(
slash_command,
install_context = "User",
interaction_context = "BotDm|PrivateChannel"
)]
pub async fn not_in_guilds(ctx: Context<'_>) -> Result<(), Error> {
ctx.say("This command is not available in guilds!").await?;
Ok(())
}
/// User install only in guilds
#[poise::command(slash_command, install_context = "User", interaction_context = "Guild")]
pub async fn user_install_guild(ctx: Context<'_>) -> Result<(), Error> {
ctx.say("This command is available in guilds only with a user install!")
.await?;
Ok(())
}