|
- 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::ChannelMessageWithSource {
- data: Some(InteractionApplicationCommandCallbackData {
- tts: false,
- content: format!("Hello {}!", cmd.member.nick.unwrap_or(cmd.member.user.unwrap().username)),
- allowed_mentions: None,
- embeds: None,
- flags: None,
- }),
- }
- }
-
- // gitea-release command definition
- pub fn def_gitea_release() -> (discord::ApplicationCommand, Option<String>) {
- (discord::ApplicationCommand {
- id: None,
- application_id: None,
- name: "gitea-release".to_string(),
- description: "Display a software release".to_string(),
- options: Some(vec![
- discord::ApplicationCommandOption::String {
- name: "username".to_string(),
- description: "Gitea username".to_string(),
- required: true,
- choices: None
- },
- discord::ApplicationCommandOption::String {
- name: "repo".to_string(),
- description: "Gitea repository".to_string(),
- required: true,
- choices: None
- },
- ]),
- }, Some("616329232389505055".to_string()))
- }
-
- // gitea-issue
- pub fn def_gitea_issue() -> (discord::ApplicationCommand, Option<String>) {
- (discord::ApplicationCommand {
- id: None,
- application_id: None,
- name: "gitea-issue".to_string(),
- description: "Display an issue".to_string(),
- options: Some(vec![
- discord::ApplicationCommandOption::String {
- name: "username".to_string(),
- description: "Gitea username".to_string(),
- required: true,
- choices: None
- },
- discord::ApplicationCommandOption::String {
- name: "repo".to_string(),
- description: "Gitea repository".to_string(),
- required: true,
- choices: None
- },
- discord::ApplicationCommandOption::Integer {
- name: "issue".to_string(),
- description: "Gitea issue number".to_string(),
- required: true,
- choices: None
- },
- ]),
- }, Some("616329232389505055".to_string()))
- }
-
- // macros
-
- // cardlife macro
- pub fn def_cardlife() -> (discord::ApplicationCommand, Option<String>) {
- (discord::ApplicationCommand {
- id: None,
- application_id: None,
- name: "cardlife".to_string(),
- description: "Cardlife mod information".to_string(),
- options: None,
- }, Some("616329232389505055".to_string()))
- }
-
- // robocraft macro
- pub fn def_robocraft() -> (discord::ApplicationCommand, Option<String>) {
- (discord::ApplicationCommand {
- id: None,
- application_id: None,
- name: "robocraft".to_string(),
- description: "Robocraft mod information".to_string(),
- options: None,
- }, Some("616329232389505055".to_string()))
- }
-
- // techblox macro
- pub fn def_techblox() -> (discord::ApplicationCommand, Option<String>) {
- (discord::ApplicationCommand {
- id: None,
- application_id: None,
- name: "techblox".to_string(),
- description: "Techblox mod information".to_string(),
- options: None,
- }, Some("616329232389505055".to_string()))
- }
|