Skip to content

Commit 67dfa82

Browse files
committed
chore: Upgrade poise to use fork of serenity-next branch
This effectively upgrades the version of Serenity to use the `next` branch. We cannot use the `serenity` dependency directly due to Poise coupling the Serenity types internally, so we must rely on Poise's provided inclusion prelude of Serenity. We use a custom version of Poise which contain changes to allow for burstable cooldowns.
1 parent 028558e commit 67dfa82

8 files changed

Lines changed: 417 additions & 597 deletions

File tree

Cargo.lock

Lines changed: 295 additions & 486 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pi-bot/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ dotenv = { workspace = true }
1111
indoc = "2.0.7"
1212
log = { workspace = true, features = ["max_level_debug", "release_max_level_info"] }
1313
num-bigint = "0.4.6"
14-
poise = { git = "https://github.com/Nydauron/poise.git", branch = "feat/burstable-cooldowns", version = "0.6.1" }
15-
poise_macros = { git = "https://github.com/Nydauron/poise.git", branch = "feat/burstable-cooldowns", version = "0.6.1" }
14+
poise = { git = "https://github.com/Nydauron/poise.git", branch = "pi-bot", version = "0.6.1" }
15+
poise_macros = { git = "https://github.com/Nydauron/poise.git", branch = "pi-bot", version = "0.6.1" }
1616
rand = "0.9.2"
1717
reqwest = { workspace = true }
1818
serde = { workspace = true, features = ["derive"] }

pi-bot/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Run from root directory
2-
FROM rust:1.89-trixie AS build
2+
FROM rust:1.92-trixie AS build
33

44
# Set working directory
55
WORKDIR /usr/src/app

pi-bot/src/discord/commands/event.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ pub async fn add(
117117

118118
if should_enable_role {
119119
guild
120+
.id
120121
.create_role(ctx.http(), EditRole::new().name(&event_name))
121122
.await?;
122123
reply_message.edit(ctx, CreateReply::default().content(format!("The event `{}` has been added to the database, and the event role was created.", event_name))).await?;
@@ -257,6 +258,7 @@ async fn enable_event_role(
257258
Ok(EnableRoleResponse::RoleAlreadyEnabled)
258259
} else {
259260
guild
261+
.id
260262
.create_role(ctx.http(), EditRole::new().name(event_name))
261263
.await?;
262264
Ok(EnableRoleResponse::RoleCreated)
@@ -269,7 +271,10 @@ async fn disable_event_role(
269271
event_name: &str,
270272
) -> Result<DisableRoleResponse, Error> {
271273
if let Some(role) = guild.role_by_name(event_name) {
272-
guild.delete_role(ctx.http(), role.id).await?;
274+
guild
275+
.id
276+
.delete_role(ctx.http(), role.id, Some("Event disabled via Pi-Bot"))
277+
.await?;
273278
Ok(DisableRoleResponse::RoleRemoved)
274279
} else {
275280
Ok(DisableRoleResponse::RoleAlreadyDisabled)

pi-bot/src/discord/commands/general.rs

Lines changed: 36 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ pub async fn info(ctx: Context<'_>) -> Result<(), Error> {
196196
let animated_icon = server.icon.is_some_and(|hash| hash.is_animated());
197197
let iden = server.id;
198198
let banner = server.banner_url();
199-
let desc = server.description.clone();
199+
let desc = server.description.as_ref().map(|desc| desc.as_str());
200200
let mfa_level = server.mfa_level;
201201
let verification_level = server.verification_level;
202202
let content_filter = server.explicit_content_filter;
@@ -205,23 +205,22 @@ pub async fn info(ctx: Context<'_>) -> Result<(), Error> {
205205
let splash = server.splash_url();
206206
let premium_level = server.premium_tier;
207207
let premium_level_str = match premium_level {
208-
PremiumTier::Tier0 => "Tier 0".into(),
209-
PremiumTier::Tier1 => "Tier 1".into(),
210-
PremiumTier::Tier2 => "Tier 2".into(),
211-
PremiumTier::Tier3 => "Tier 3".into(),
212-
PremiumTier::Unknown(level) => format!("Unknown Tier ({})", level),
213-
_ => "Unknown".into(),
208+
PremiumTier::Tier0 => "Tier 0",
209+
PremiumTier::Tier1 => "Tier 1",
210+
PremiumTier::Tier2 => "Tier 2",
211+
PremiumTier::Tier3 => "Tier 3",
212+
_ => "Unknown",
214213
};
215214
let boosts = server.premium_subscription_count;
216215
let channel_count = server.channels.len();
217-
let channel_counts = server.channels(ctx.http()).await?.iter().fold(
216+
let channel_counts = server.id.channels(ctx.http()).await?.iter().fold(
218217
HashMap::from([
219218
(ChannelType::Text, 0_u32),
220219
(ChannelType::Voice, 0_u32),
221220
(ChannelType::Category, 0_u32),
222221
]),
223-
|mut acc, (_, channel)| {
224-
acc.entry(channel.kind).and_modify(|count| *count += 1);
222+
|mut acc, channel| {
223+
acc.entry(channel.base.kind).and_modify(|count| *count += 1);
225224
acc
226225
},
227226
);
@@ -230,7 +229,7 @@ pub async fn info(ctx: Context<'_>) -> Result<(), Error> {
230229
let category_count = channel_counts.get(&ChannelType::Category).unwrap();
231230
let system_channel = server
232231
.system_channel_id
233-
.map(async |id| id.to_channel(ctx.http()).await);
232+
.map(async |id| id.to_guild_channel(ctx.http(), Some(server.id)).await);
234233
let system_channel_mention = if let Some(future) = system_channel {
235234
let channel = future.await?;
236235
channel.mention().to_string()
@@ -239,7 +238,7 @@ pub async fn info(ctx: Context<'_>) -> Result<(), Error> {
239238
};
240239
let rules_channel = server
241240
.rules_channel_id
242-
.map(async |id| id.to_channel(ctx.http()).await);
241+
.map(async |id| id.to_guild_channel(ctx.http(), Some(server.id)).await);
243242
let rules_channel_mention = if let Some(future) = rules_channel {
244243
let channel = future.await?;
245244
channel.mention().to_string()
@@ -248,7 +247,7 @@ pub async fn info(ctx: Context<'_>) -> Result<(), Error> {
248247
};
249248
let public_updates_channel = server
250249
.public_updates_channel_id
251-
.map(async |id| id.to_channel(ctx.http()).await);
250+
.map(async |id| id.to_guild_channel(ctx.http(), Some(server.id)).await);
252251
let public_updates_channel_mention = if let Some(future) = public_updates_channel {
253252
let channel = future.await?;
254253
channel.mention().to_string()
@@ -280,7 +279,7 @@ pub async fn info(ctx: Context<'_>) -> Result<(), Error> {
280279
let boosters = server
281280
.members
282281
.iter()
283-
.filter_map(|(_, member)| member.premium_since.map(|_| member.mention().to_string()))
282+
.filter_map(|member| member.premium_since.map(|_| member.mention().to_string()))
284283
.collect::<Box<[_]>>()
285284
.join(", ");
286285

@@ -302,7 +301,7 @@ pub async fn info(ctx: Context<'_>) -> Result<(), Error> {
302301
)
303302
});
304303
let member_percentage = if let Some(max_members) = max_members {
305-
((member_count as f64 / max_members as f64) * 100_000_f64).round() / 1_000_f64
304+
((member_count as f64 / max_members.get() as f64) * 100_000_f64).round() / 1_000_f64
306305
} else {
307306
0_f64
308307
};
@@ -343,17 +342,15 @@ pub async fn info(ctx: Context<'_>) -> Result<(), Error> {
343342
false,
344343
),
345344
];
346-
if let Some(channel) = ctx.guild_channel().await
345+
if let Some(channel) = ctx.channel().await.unwrap().guild()
347346
&& let Some(parent_channel_id) = channel.parent_id
348347
{
349348
let parent_channel = parent_channel_id
350-
.to_channel(ctx.http())
351-
.await?
352-
.guild()
353-
.unwrap();
349+
.to_guild_channel(ctx.http(), Some(server.id))
350+
.await?;
354351
const CATEGORY_STAFF: &str = "staff";
355-
if matches!(parent_channel.kind, ChannelType::Category)
356-
&& parent_channel.name() == CATEGORY_STAFF
352+
if matches!(parent_channel.base.kind, ChannelType::Category)
353+
&& parent_channel.base.name == CATEGORY_STAFF
357354
{
358355
fields.append(&mut vec![
359356
(
@@ -369,33 +366,28 @@ pub async fn info(ctx: Context<'_>) -> Result<(), Error> {
369366
**Filesize Limit:** {} MB",
370367
owner,
371368
match mfa_level {
372-
MfaLevel::None => "None".into(),
373-
MfaLevel::Elevated => "Require 2FA".into(),
374-
MfaLevel::Unknown(level) => format!("Unknown ({})", level),
375-
_ => "Unknown".into(),
369+
MfaLevel::None => "None",
370+
MfaLevel::Elevated => "Require 2FA",
371+
_ => "Unknown",
376372
},
377373
match verification_level {
378-
VerificationLevel::None => "None".into(),
379-
VerificationLevel::Low => "Low".into(),
380-
VerificationLevel::Medium => "Medium".into(),
381-
VerificationLevel::High => "High".into(),
382-
VerificationLevel::Higher => "Higher".into(),
383-
VerificationLevel::Unknown(level) => format!("Unknown ({})", level),
384-
_ => "Unknown".into(),
374+
VerificationLevel::None => "None",
375+
VerificationLevel::Low => "Low",
376+
VerificationLevel::Medium => "Medium",
377+
VerificationLevel::High => "High",
378+
VerificationLevel::Higher => "Higher",
379+
_ => "Unknown",
385380
},
386381
match content_filter {
387-
ExplicitContentFilter::None => "None".into(),
388-
ExplicitContentFilter::WithoutRole => "Members without role".into(),
389-
ExplicitContentFilter::All => "All members".into(),
390-
ExplicitContentFilter::Unknown(level) => format!("Unknown ({})", level),
391-
_ => "Unknown".into(),
382+
ExplicitContentFilter::None => "None",
383+
ExplicitContentFilter::WithoutRole => "Members without role",
384+
ExplicitContentFilter::All => "All members",
385+
_ => "Unknown",
392386
},
393387
match default_notifs {
394-
DefaultMessageNotificationLevel::All => "All".into(),
395-
DefaultMessageNotificationLevel::Mentions => "Mentions only".into(),
396-
DefaultMessageNotificationLevel::Unknown(level) =>
397-
format!("Unknown ({})", level),
398-
_ => "Unknown".into(),
388+
DefaultMessageNotificationLevel::All => "All",
389+
DefaultMessageNotificationLevel::Mentions => "Mentions only",
390+
_ => "Unknown",
399391
},
400392
features,
401393
bitrate_limit,
@@ -449,7 +441,7 @@ pub async fn info(ctx: Context<'_>) -> Result<(), Error> {
449441

450442
let mut embed = CreateEmbed::default()
451443
.title(format!("Information for `{}`", name))
452-
.description(format!("**Description:** {}", desc.unwrap_or("".into())))
444+
.description(format!("**Description:** {}", desc.unwrap_or("")))
453445
.fields(fields);
454446
if let Some(icon) = icon {
455447
embed = embed.thumbnail(icon);

0 commit comments

Comments
 (0)