Reading owner ID from the application info

main
Joey Pollack 2 years ago
parent 1a1be4294f
commit 3befd3f001

@ -5,7 +5,7 @@ use serenity::model::channel::Message;
use serenity::prelude::*;
use serenity::model::prelude::*;
use super::super::utils;
use crate::utils;
pub async fn parse_command(ctx: Context, msg: Message, server_id: GuildId)

@ -3,11 +3,14 @@ mod commands;
mod data_loader;
mod utils;
use std::collections::HashSet;
use serenity::async_trait;
use serenity::prelude::*;
use serenity::model::prelude::*;
use serenity::model::channel::Message;
use serenity::model::gateway::Ready;
use serenity::prelude::*;
// use serenity::model::prelude::*;
use serenity::http::Http;
struct Handler;
@ -46,6 +49,16 @@ async fn main()
Err(why) => panic!("Could not load app token: {}", why),
};
// Fetch the application owner id
let http = Http::new(&token);
let owner = match http.get_current_application_info().await
{
Ok(info) => info.owner.id,
Err(why) => panic!("Could not access application info: {:?}", why),
};
println!("Connecting...");
let intents = GatewayIntents::GUILD_MESSAGES
@ -57,6 +70,10 @@ async fn main()
// by Discord for bot users.
let mut client = Client::builder(&token, intents).event_handler(Handler).await.expect("Err creating client");
// TODO: See link for how to add global data to the client:
// https://github.com/serenity-rs/serenity/blob/current/examples/e12_global_data/src/main.rs
// client.data.write().await.insert::<UserId>(owner);
// Finally, start a single shard, and start listening to events.
//
// Shards will automatically attempt to reconnect, and will perform

Loading…
Cancel
Save