From c5aeb43046c89be68c0ef7fb586b08f12f9d82ca Mon Sep 17 00:00:00 2001 From: Toastie Date: Tue, 5 Nov 2024 20:20:44 +1300 Subject: [PATCH] timely fixes --- src/EllieBot/Modules/Gambling/Gambling.cs | 23 +++++++++++++++---- .../Modules/Gambling/GamblingConfig.cs | 5 +--- src/EllieBot/data/gambling.yml | 3 +-- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/EllieBot/Modules/Gambling/Gambling.cs b/src/EllieBot/Modules/Gambling/Gambling.cs index 16dce13..5cb0b2e 100644 --- a/src/EllieBot/Modules/Gambling/Gambling.cs +++ b/src/EllieBot/Modules/Gambling/Gambling.cs @@ -215,6 +215,7 @@ public partial class Gambling : GamblingModule }); [Cmd] + [RequireContext(ContextType.Guild)] public async Task Timely() { var val = Config.Timely.Amount; @@ -259,10 +260,24 @@ public partial class Gambling : GamblingModule var val = Config.Timely.Amount; - var guildUsers = await (Config.BoostBonus - .GuildIds - ?? new()) - .Select(x => ((IGuild)_client.GetGuild(x))?.GetUserAsync(ctx.User.Id)) + var boostGuilds = Config.BoostBonus.GuildIds ?? new(); + var guildUsers = await boostGuilds + .Select(async gid => + { + try + { + var guild = await ((IDiscordClient)_client).GetGuildAsync(gid); + if (guild is null) + return null; + + var user = await guild.GetUserAsync(ctx.User.Id); + return user; + } + catch + { + return null; + } + }) .WhenAll(); var boostGuildUser = guildUsers.FirstOrDefault(x => x?.PremiumSince is not null); diff --git a/src/EllieBot/Modules/Gambling/GamblingConfig.cs b/src/EllieBot/Modules/Gambling/GamblingConfig.cs index dd0b955..7aa81b1 100644 --- a/src/EllieBot/Modules/Gambling/GamblingConfig.cs +++ b/src/EllieBot/Modules/Gambling/GamblingConfig.cs @@ -425,10 +425,7 @@ public sealed partial class BotCutConfig public sealed partial class BoostBonusConfig { [Comment("Users will receive a bonus if they boost any of these servers")] - public List GuildIds { get; set; } = - [ - 117523346618318850 - ]; + public List GuildIds { get; set; } = new(); [Comment("This bonus will be added before any other multiplier is applied to the .timely command")] diff --git a/src/EllieBot/data/gambling.yml b/src/EllieBot/data/gambling.yml index 3455517..d1a81c8 100644 --- a/src/EllieBot/data/gambling.yml +++ b/src/EllieBot/data/gambling.yml @@ -276,7 +276,6 @@ slots: # Bonus config for server boosts boostBonus: # Users will receive a bonus if they boost any of these servers - guildIds: - - 117523346618318850 + guildIds: [] # This bonus will be added before any other multiplier is applied to the .timely command baseTimelyBonus: 50