|
- use crate::discord;
- use crate::discord::{Interaction, InteractionResponse, InteractionApplicationCommandCallbackData};
-
- // fn foo() -> (definition, private?)
-
- // hello-world data for telling Discord about it
- pub fn def_hello_world() -> (discord::ApplicationCommand, Option<String>) {
- (discord::ApplicationCommand {
- id: None,
- application_id: None,
- name: "hello-world".to_string(),
- description: "Hello World".to_string(),
- options: None,
- }, Some("616329232389505055".to_string()))
- }
-
- // hello-world action when someone uses the command on Discord
- pub fn hello_world(interaction: &Interaction) -> InteractionResponse {
- let cmd = interaction.cmd().unwrap();
- InteractionResponse::ChannelMessage {
- data: Some(InteractionApplicationCommandCallbackData {
- tts: false,
- content: format!("Hello {}!", cmd.member.nick.unwrap_or(cmd.member.user.unwrap().username)),
- allowed_mentions: None,
- }),
- }
- }
|