Skip to content

Commit

Permalink
Update deps and fix breaking
Browse files Browse the repository at this point in the history
  • Loading branch information
GnomedDev committed Apr 1, 2024
1 parent f436415 commit 0d35fa3
Show file tree
Hide file tree
Showing 11 changed files with 312 additions and 131 deletions.
400 changes: 289 additions & 111 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ default-features = false
features = ["macros", "postgres", "runtime-tokio-rustls"]

[workspace.dependencies.reqwest]
version = "0.11"
version = "0.12"
default-features = false
features = ["rustls-tls"]

Expand All @@ -90,3 +90,7 @@ branch = "serenity-next"
git = "https://github.com/serenity-rs/songbird"
features = ["builtin-queue"]
branch = "serenity-next"

[patch."https://github.com/serenity-rs/serenity".serenity]
git = "https://github.com/GnomedDev/serenity"
branch = "updated-deps"
4 changes: 2 additions & 2 deletions tts_commands/src/owner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,10 @@ pub async fn cache_info(ctx: Context<'_>, kind: Option<String>) -> CommandResult
guild_iter(serenity_cache).map(|g| g.get_size_details()),
)),
Some("channel") => Some(average_details(
guild_iter(serenity_cache).flat_map(|g| details_iter(g.channels.values())),
guild_iter(serenity_cache).flat_map(|g| details_iter(g.channels.iter())),
)),
Some("role") => Some(average_details(
guild_iter(serenity_cache).flat_map(|g| details_iter(g.roles.values())),
guild_iter(serenity_cache).flat_map(|g| details_iter(g.roles.iter())),
)),
Some(_) => None,
None => Some(serenity_cache.get_size_details()),
Expand Down
2 changes: 1 addition & 1 deletion tts_commands/src/settings/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async fn get_eligible_channels(
let guild = require_guild!(ctx, Ok(None));
let channels = guild
.channels
.values()
.iter()
.filter(|c| {
c.kind == serenity::ChannelType::Text
&& can_send(&guild, c, &author_member)
Expand Down
5 changes: 2 additions & 3 deletions tts_core/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ pub async fn dm_generic<'ctx, 'a>(
attachment_url: Option<&'a str>,
message: &str,
) -> Result<(String, serenity::Embed)> {
let dm_channel = target.create_dm_channel(ctx).await?;
let sent = dm_channel
.send_message(
let sent = target
.dm(
&ctx.http,
serenity::CreateMessage::default().embed({
let mut embed = serenity::CreateEmbed::default();
Expand Down
5 changes: 3 additions & 2 deletions tts_core/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ async fn handle_cooldown(
tokio::time::sleep(remaining_cooldown).await;

let ctx_discord = ctx.serenity_context();
error_message.delete(ctx_discord).await?;
error_message.delete(ctx_discord, None).await?;

let bot_user_id = ctx_discord.cache.current_user().id;
let Some(channel) = error_message.channel(ctx_discord).await?.guild() else {
Expand All @@ -342,7 +342,8 @@ async fn handle_cooldown(
.permissions_for_user(&ctx_discord.cache, bot_user_id)?
.manage_messages()
{
ctx.msg.delete(ctx_discord).await?;
let reason = "Deleting command invocation that hit cooldown";
ctx.msg.delete(ctx_discord, Some(reason)).await?;
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion tts_core/src/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl LastXsaidInfo {
fn get_vc_member_count(guild: &serenity::Guild, channel_id: serenity::ChannelId) -> usize {
guild
.voice_states
.values()
.iter()
.filter(|vs| vs.channel_id.is_some_and(|vc| vc == channel_id))
.filter_map(|vs| guild.members.get(&vs.user_id))
.filter(|member| !member.user.bot())
Expand Down
3 changes: 1 addition & 2 deletions tts_events/src/guild.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ pub async fn guild_create(
};

let data = framework_ctx.user_data();
let dm_channel = guild.owner_id.create_dm_channel(&ctx).await?;
match dm_channel.send_message(&ctx, serenity::CreateMessage::default().embed(CreateEmbed::default()
match guild.owner_id.dm(&ctx.http, serenity::CreateMessage::default().embed(CreateEmbed::default()
.title(format!("Welcome to {}!", ctx.cache.current_user().name))
.description(format!("
Hello! Someone invited me to your server `{}`!
Expand Down
4 changes: 2 additions & 2 deletions tts_events/src/member.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub async fn guild_member_removal(
}

let ctx = framework_ctx.serenity_context;
let msg = match user.dm(ctx, create_premium_notice()).await {
let msg = match user.dm(&ctx.http, create_premium_notice()).await {
Ok(msg) => msg,
Err(err) => {
// We cannot DM this premium user, just remove premium by default.
Expand Down Expand Up @@ -119,7 +119,7 @@ pub async fn guild_member_removal(
}
};

user.dm(ctx, serenity::CreateMessage::new().content(response))
user.dm(&ctx.http, serenity::CreateMessage::new().content(response))
.await?;

Ok(())
Expand Down
4 changes: 2 additions & 2 deletions tts_events/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ async fn process_mention_msg(

match message
.author
.direct_message(ctx, CreateMessage::default().content(msg))
.dm(&ctx.http, CreateMessage::default().content(msg))
.await
{
Err(serenity::Error::Http(error))
Expand Down Expand Up @@ -353,7 +353,7 @@ async fn process_support_dm(
.set_one(message.author.id.into(), "dm_welcomed", &true)
.await?;
if channel.pins(&ctx.http).await?.len() < 50 {
welcome_msg.pin(ctx).await?;
welcome_msg.pin(ctx, None).await?;
}

info!(
Expand Down
8 changes: 4 additions & 4 deletions tts_events/src/voice_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@ pub async fn voice_state_update(
{
let channel_id = old.channel_id.try_unwrap()?;
let guild = ctx.cache.guild(guild_id).try_unwrap()?;
let mut channel_members = guild.members.iter().filter(|(m, _)| {
let mut channel_members = guild.members.iter().filter(|m| {
guild
.voice_states
.get(m)
.get(&m.user.id)
.is_some_and(|v| v.channel_id == Some(channel_id))
});

// Bot is in the voice channel being left from
if channel_members.clone().all(|(_, m)| m.user.id != bot_id) {
if channel_members.clone().all(|m| m.user.id != bot_id) {
return Ok(());
}

// All the users in the vc are now bots
if channel_members.any(|(_, m)| !m.user.bot()) {
if channel_members.any(|m| !m.user.bot()) {
return Ok(());
};
}
Expand Down

0 comments on commit 0d35fa3

Please sign in to comment.