update poise

This commit is contained in:
jude
2023-06-18 10:47:31 +01:00
parent c8c1a171d4
commit a66db37b33
9 changed files with 63 additions and 59 deletions

View File

@ -31,11 +31,12 @@ pub trait CtxData {
#[async_trait]
impl CtxData for Context<'_> {
async fn user_data<U: Into<UserId> + Send>(&self, user_id: U) -> Result<UserData, Error> {
UserData::from_user(user_id, &self.discord(), &self.data().database).await
UserData::from_user(user_id, &self.serenity_context(), &self.data().database).await
}
async fn author_data(&self) -> Result<UserData, Error> {
UserData::from_user(&self.author().id, &self.discord(), &self.data().database).await
UserData::from_user(&self.author().id, &self.serenity_context(), &self.data().database)
.await
}
async fn guild_data(&self) -> Option<Result<GuildData, Error>> {
@ -52,18 +53,18 @@ impl CtxData for Context<'_> {
async fn channel_data(&self) -> Result<ChannelData, Box<dyn std::error::Error + Sync + Send>> {
// If we're in a thread, get the parent channel.
let recv_channel = self.channel_id().to_channel(&self.discord()).await?;
let recv_channel = self.channel_id().to_channel(&self).await?;
let channel = match recv_channel.guild() {
Some(guild_channel) => {
if guild_channel.kind == ChannelType::PublicThread {
guild_channel.parent_id.unwrap().to_channel_cached(&self.discord()).unwrap()
guild_channel.parent_id.unwrap().to_channel_cached(&self).unwrap()
} else {
self.channel_id().to_channel_cached(&self.discord()).unwrap()
self.channel_id().to_channel_cached(&self).unwrap()
}
}
None => self.channel_id().to_channel_cached(&self.discord()).unwrap(),
None => self.channel_id().to_channel_cached(&self).unwrap(),
};
ChannelData::from_channel(&channel, &self.data().database).await