auto-thread in blog channel impl
This commit is contained in:
parent
ae91b00730
commit
15c024e40d
3 changed files with 21 additions and 1 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
BOT_TOKEN=YOUR-BOT-TOKEN
|
BOT_TOKEN=YOUR-BOT-TOKEN
|
||||||
MEMBER_ROLE_ID=123
|
MEMBER_ROLE_ID=123
|
||||||
WELCOME_CHANNEL_ID=321
|
WELCOME_CHANNEL_ID=321
|
||||||
|
BLOG_CHANNEL_ID=987
|
||||||
ADMIN_ID=1
|
ADMIN_ID=1
|
||||||
|
|
@ -5,5 +5,6 @@ pub struct Config {
|
||||||
pub bot_token: String,
|
pub bot_token: String,
|
||||||
pub member_role_id: u64,
|
pub member_role_id: u64,
|
||||||
pub welcome_channel_id: u64,
|
pub welcome_channel_id: u64,
|
||||||
|
pub blog_channel_id: u64,
|
||||||
pub admin_id: u64,
|
pub admin_id: u64,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
20
src/main.rs
20
src/main.rs
|
|
@ -6,9 +6,11 @@ use serenity::builder::{CreateInteractionResponse, CreateInteractionResponseMess
|
||||||
use serenity::model::application::Interaction;
|
use serenity::model::application::Interaction;
|
||||||
use serenity::model::gateway::Ready;
|
use serenity::model::gateway::Ready;
|
||||||
use serenity::model::guild::Member;
|
use serenity::model::guild::Member;
|
||||||
|
use serenity::builder::{CreateThread, CreateMessage};
|
||||||
use serenity::model::id::ChannelId;
|
use serenity::model::id::ChannelId;
|
||||||
use serenity::model::channel::Message;
|
use serenity::model::channel::Message;
|
||||||
use serenity::model::user::OnlineStatus;
|
use serenity::model::user::OnlineStatus;
|
||||||
|
use serenity::all::ChannelType;
|
||||||
use serenity::gateway::ActivityData;
|
use serenity::gateway::ActivityData;
|
||||||
use serenity::prelude::*;
|
use serenity::prelude::*;
|
||||||
use tracing::{warn, error, info};
|
use tracing::{warn, error, info};
|
||||||
|
|
@ -28,6 +30,22 @@ impl EventHandler for Handler {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if msg.channel_id == self.config.blog_channel_id {
|
||||||
|
let therad_builder = CreateThread::new("Обсуждение")
|
||||||
|
.kind(ChannelType::PublicThread);
|
||||||
|
let new_thread = msg.channel_id.create_thread_from_message(&ctx.http, msg.id, therad_builder).await;
|
||||||
|
match new_thread {
|
||||||
|
Ok(guild_channel) => {
|
||||||
|
let message_builder = CreateMessage::new()
|
||||||
|
.content("ого");
|
||||||
|
guild_channel.send_message(&ctx.http, message_builder)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
},
|
||||||
|
Err(e) => error!("{}", e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if msg.content.contains(":3") {
|
if msg.content.contains(":3") {
|
||||||
if let Err(why) = msg.channel_id.say(&ctx.http, ":3").await {
|
if let Err(why) = msg.channel_id.say(&ctx.http, ":3").await {
|
||||||
error!("Error sending message: {why:?}");
|
error!("Error sending message: {why:?}");
|
||||||
|
|
@ -79,7 +97,7 @@ impl EventHandler for Handler {
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.set_presence(
|
ctx.set_presence(
|
||||||
Some(ActivityData::playing("/help")),
|
Some(ActivityData::playing("Rust 🦀")),
|
||||||
OnlineStatus::DoNotDisturb,
|
OnlineStatus::DoNotDisturb,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue