mirror of
https://github.com/kurbezz/discord-bot.git
synced 2025-12-06 07:05:36 +01:00
Update
This commit is contained in:
@@ -26,4 +26,10 @@ pub fn register() -> CreateCommand {
|
|||||||
)
|
)
|
||||||
.required(true)
|
.required(true)
|
||||||
)
|
)
|
||||||
|
.add_option(
|
||||||
|
CreateCommandOption::new(
|
||||||
|
CommandOptionType::String, "date", "Дата заказа"
|
||||||
|
)
|
||||||
|
.required(false)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
7
src/commands/create_message.rs
Normal file
7
src/commands/create_message.rs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
use serenity::builder::*;
|
||||||
|
|
||||||
|
|
||||||
|
pub fn register() -> CreateCommand {
|
||||||
|
CreateCommand::new("create_message")
|
||||||
|
.description("Не вызывать, только для настройки")
|
||||||
|
}
|
||||||
14
src/commands/delete_game.rs
Normal file
14
src/commands/delete_game.rs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
use serenity::builder::*;
|
||||||
|
use serenity::model::prelude::*;
|
||||||
|
|
||||||
|
|
||||||
|
pub fn register() -> CreateCommand {
|
||||||
|
CreateCommand::new("delete")
|
||||||
|
.description("Удалить игру из списока")
|
||||||
|
.add_option(
|
||||||
|
CreateCommandOption::new(
|
||||||
|
CommandOptionType::String, "game", "Игра"
|
||||||
|
)
|
||||||
|
.required(true)
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1 +1,3 @@
|
|||||||
pub mod add_game;
|
pub mod add_game;
|
||||||
|
pub mod delete_game;
|
||||||
|
pub mod create_message;
|
||||||
|
|||||||
13
src/main.rs
13
src/main.rs
@@ -1,5 +1,5 @@
|
|||||||
use reqwest::Url;
|
use reqwest::Url;
|
||||||
use serenity::all::{ActivityData, CreateInteractionResponse, CreateInteractionResponseMessage, GuildId, Interaction};
|
use serenity::all::{ActivityData, CreateMessage, GuildId};
|
||||||
use serenity::async_trait;
|
use serenity::async_trait;
|
||||||
use serenity::model::channel::Message;
|
use serenity::model::channel::Message;
|
||||||
use serenity::prelude::*;
|
use serenity::prelude::*;
|
||||||
@@ -28,11 +28,19 @@ struct Handler;
|
|||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl EventHandler for Handler {
|
impl EventHandler for Handler {
|
||||||
async fn message(&self, _ctx: Context, msg: Message) {
|
async fn message(&self, _ctx: Context, msg: Message) {
|
||||||
|
if msg.guild_id != Some(config::CONFIG.discord_guild_id.into()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if msg.channel_id == config::CONFIG.discord_channel_id {
|
if msg.channel_id == config::CONFIG.discord_channel_id {
|
||||||
send_to_telegram(&msg.content).await;
|
send_to_telegram(&msg.content).await;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if msg.content == "/create_message" {
|
||||||
|
let _ = msg.channel_id.send_message(&_ctx.http, CreateMessage::new().content("#Init")).await;
|
||||||
|
}
|
||||||
|
|
||||||
println!("{}: {}", msg.author.name, msg.content);
|
println!("{}: {}", msg.author.name, msg.content);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +52,8 @@ impl EventHandler for Handler {
|
|||||||
&ctx.http,
|
&ctx.http,
|
||||||
vec![
|
vec![
|
||||||
commands::add_game::register(),
|
commands::add_game::register(),
|
||||||
// commands::delete_game::register(),
|
commands::delete_game::register(),
|
||||||
|
commands::create_message::register()
|
||||||
]
|
]
|
||||||
).await.unwrap();
|
).await.unwrap();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user