diff options
author | ashelyn ghost <git@ashen.earth> | 2024-07-11 18:04:13 -0600 |
---|---|---|
committer | Ashelyn Rose <git@ashen.earth> | 2024-07-11 18:04:13 -0600 |
commit | 8517c3946c741ea9eae1da2b539a4cb452b4f879 (patch) | |
tree | d4d5b6e992eb7af5378d9f9f28a5be0333efa9bb /src/listener.rs | |
parent | f2a579f8e76df09a5ccb56156fd232e54f05529d (diff) |
presence indicator
Diffstat (limited to 'src/listener.rs')
-rw-r--r-- | src/listener.rs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/listener.rs b/src/listener.rs index ca69466..31c134d 100644 --- a/src/listener.rs +++ b/src/listener.rs @@ -1,7 +1,7 @@ use tokio::sync::mpsc::Sender; use twilight_http::Client; use twilight_model::{channel::Message, id::{Id, marker::{ChannelMarker, MessageMarker, UserMarker}}, user::User}; -use twilight_gateway::{error::ReceiveMessageError, Intents, Shard, ShardId}; +use twilight_gateway::{error::ReceiveMessageError, Intents, MessageSender, Shard, ShardId}; use twilight_model::util::Timestamp; pub struct Listener { @@ -21,14 +21,18 @@ impl Listener { let intents = Intents::GUILD_MEMBERS | Intents::GUILD_PRESENCES | Intents::GUILD_MESSAGES | Intents::MESSAGE_CONTENT; let mut shard = Shard::new(ShardId::ONE, self.config.discord_token.clone(), intents); - let mut client = Client::new(self.config.discord_token.clone()); - + let client = Client::new(self.config.discord_token.clone()); + loop { match shard.next_event().await { Ok(event) => { match event { twilight_gateway::Event::Ready(client) => { println!("Bot started for {}#{}", client.user.name, client.user.discriminator); + channel.send(ClientEvent::Ready { + client_name: self.config.name.clone(), + send_channel: shard.sender(), + }).await; }, twilight_gateway::Event::MessageCreate(message_create) => { @@ -96,6 +100,13 @@ impl Listener { } pub enum ClientEvent { + Ready { + client_name: String, + send_channel: MessageSender, + }, + AutoproxyTimeout { + last_message: Timestamp, + }, Message { event_time: Timestamp, message: Message, |