fix: fix minor issues

This commit is contained in:
Mira 2025-05-07 20:15:26 +02:00
parent 50c60bf0da
commit 4f0bc4f6ad
Signed by untrusted user who does not match committer: Xorog
GPG key ID: 983798ED9C3E7C36
2 changed files with 16 additions and 10 deletions

View file

@ -61,7 +61,7 @@ internal sealed class JoinCommand : BaseCommand
var ToggleGlobalban = new DiscordButtonComponent((ctx.DbGuild.Join.AutoBanGlobalBans ? ButtonStyle.Danger : ButtonStyle.Success), Guid.NewGuid().ToString(), this.GetString(CommandKey.ToggleGlobalBansButton), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("🌐"))); var ToggleGlobalban = new DiscordButtonComponent((ctx.DbGuild.Join.AutoBanGlobalBans ? ButtonStyle.Danger : ButtonStyle.Success), Guid.NewGuid().ToString(), this.GetString(CommandKey.ToggleGlobalBansButton), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("🌐")));
var ChangeJoinlogChannel = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), this.GetString(CommandKey.ChangeJoinlogChannelButton), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("👋"))); var ChangeJoinlogChannel = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), this.GetString(CommandKey.ChangeJoinlogChannelButton), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("👋")));
var ChangeUserCountChannel = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), this.GetString(CommandKey.ChangeUserCountChannel), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("🔢"))); var ChangeUserCountChannel = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), this.GetString(CommandKey.ChangeUserCountChannel), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("🔢")));
var ChangeUserCountFormat = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), this.GetString(CommandKey.ChangeUserCountChannelFormat), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("🔢"))); var ChangeUserCountFormat = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), this.GetString(CommandKey.ChangeUserCountChannelFormat), ctx.DbGuild.Join.UserCountChannelId == 0, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("🔢")));
var ChangeRoleOnJoin = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), this.GetString(CommandKey.ChangeRoleButton), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("👤"))); var ChangeRoleOnJoin = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), this.GetString(CommandKey.ChangeRoleButton), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("👤")));
var ToggleReApplyRoles = new DiscordButtonComponent((ctx.DbGuild.Join.ReApplyRoles ? ButtonStyle.Danger : ButtonStyle.Success), Guid.NewGuid().ToString(), this.GetString(CommandKey.ToggleReApplyRole), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("👥"))); var ToggleReApplyRoles = new DiscordButtonComponent((ctx.DbGuild.Join.ReApplyRoles ? ButtonStyle.Danger : ButtonStyle.Success), Guid.NewGuid().ToString(), this.GetString(CommandKey.ToggleReApplyRole), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("👥")));
var ToggleReApplyName = new DiscordButtonComponent((ctx.DbGuild.Join.ReApplyNickname ? ButtonStyle.Danger : ButtonStyle.Success), Guid.NewGuid().ToString(), this.GetString(CommandKey.ToggleReApplyNickname), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("💬"))); var ToggleReApplyName = new DiscordButtonComponent((ctx.DbGuild.Join.ReApplyNickname ? ButtonStyle.Danger : ButtonStyle.Success), Guid.NewGuid().ToString(), this.GetString(CommandKey.ToggleReApplyNickname), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("💬")));
@ -201,6 +201,9 @@ internal sealed class JoinCommand : BaseCommand
ctx.DbGuild.Join.UserCountChannelId = ChannelResult.Result is null ? 0 : ChannelResult.Result.Id; ctx.DbGuild.Join.UserCountChannelId = ChannelResult.Result is null ? 0 : ChannelResult.Result.Id;
if (ChannelResult.Result is not null)
await JoinEvents.RunUserCountUpdater(ctx.Bot, ctx.Guild);
await this.ExecuteCommand(ctx, arguments); await this.ExecuteCommand(ctx, arguments);
return; return;
} }
@ -236,6 +239,9 @@ internal sealed class JoinCommand : BaseCommand
ctx.DbGuild.Join.UserCountChannelFormat = modelResult.Result.Interaction.GetModalValueByCustomId("new_format"); ctx.DbGuild.Join.UserCountChannelFormat = modelResult.Result.Interaction.GetModalValueByCustomId("new_format");
if (ctx.DbGuild.Join.UserCountChannelId != 0)
await JoinEvents.RunUserCountUpdater(ctx.Bot, ctx.Guild);
await this.ExecuteCommand(ctx, arguments); await this.ExecuteCommand(ctx, arguments);
return; return;
} }

View file

@ -54,7 +54,7 @@ internal sealed class JoinEvents(Bot bot) : RequiresTranslation(bot)
} }
} }
await this.RunUserCountUpdater(e.Guild); await RunUserCountUpdater(this.Bot, e.Guild);
await this.Bot.Guilds[e.Guild.Id].Members[e.Member.Id].PerformAutoKickChecks(e.Guild, e.Member); await this.Bot.Guilds[e.Guild.Id].Members[e.Member.Id].PerformAutoKickChecks(e.Guild, e.Member);
} }
@ -83,14 +83,14 @@ internal sealed class JoinEvents(Bot bot) : RequiresTranslation(bot)
} }
} }
await this.RunUserCountUpdater(e.Guild); await RunUserCountUpdater(this.Bot, e.Guild);
} }
private async Task RunUserCountUpdater(DiscordGuild Guild) internal static async Task RunUserCountUpdater(Bot bot, DiscordGuild Guild)
{ {
if (this.Bot.Guilds[Guild.Id].Join.UserCountChannelId != 0) if (bot.Guilds[Guild.Id].Join.UserCountChannelId != 0)
{ {
if (Guild.Channels.ContainsKey(this.Bot.Guilds[Guild.Id].Join.UserCountChannelId)) if (Guild.Channels.ContainsKey(bot.Guilds[Guild.Id].Join.UserCountChannelId))
{ {
foreach (var b in ScheduledTaskExtensions.GetScheduledTasks()) foreach (var b in ScheduledTaskExtensions.GetScheduledTasks())
{ {
@ -103,16 +103,16 @@ internal sealed class JoinEvents(Bot bot) : RequiresTranslation(bot)
_ = new Func<Task>(async () => _ = new Func<Task>(async () =>
{ {
_ = Guild.GetChannel(this.Bot.Guilds[Guild.Id].Join.UserCountChannelId).ModifyAsync(x => _ = Guild.GetChannel(bot.Guilds[Guild.Id].Join.UserCountChannelId).ModifyAsync(x =>
{ {
x.Name = (this.Bot.Guilds[Guild.Id].Join.UserCountChannelFormat is null ? "Count: %s" : this.Bot.Guilds[Guild.Id].Join.UserCountChannelFormat) x.Name = (bot.Guilds[Guild.Id].Join.UserCountChannelFormat is null ? "Count: %s" : bot.Guilds[Guild.Id].Join.UserCountChannelFormat)
.Replace("%s", Guild.MemberCount); .Replace("%s", Guild.MemberCount);
}) })
.ContinueWith(x => .ContinueWith(x =>
{ {
this.Bot.Guilds[Guild.Id].Join.UserCountChannelLastEdit = DateTime.UtcNow; bot.Guilds[Guild.Id].Join.UserCountChannelLastEdit = DateTime.UtcNow;
}); });
}).CreateScheduledTask(this.Bot.Guilds[Guild.Id].Join.UserCountChannelLastEdit.AddMinutes(5), }).CreateScheduledTask(bot.Guilds[Guild.Id].Join.UserCountChannelLastEdit.AddMinutes(5),
new ScheduledTaskIdentifier(Guild.Id, "", "usercount")); new ScheduledTaskIdentifier(Guild.Id, "", "usercount"));
} }
} }