Skip to content
This repository was archived by the owner on Jun 12, 2026. It is now read-only.

Commit 4f0bc4f

Browse files
committed
fix: fix minor issues
1 parent 50c60bf commit 4f0bc4f

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

ProjectMakoto/Commands/Configuration/JoinCommand.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ string GetCurrentConfiguration(SharedCommandContext ctx)
6161
var ToggleGlobalban = new DiscordButtonComponent((ctx.DbGuild.Join.AutoBanGlobalBans ? ButtonStyle.Danger : ButtonStyle.Success), Guid.NewGuid().ToString(), this.GetString(CommandKey.ToggleGlobalBansButton), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("🌐")));
6262
var ChangeJoinlogChannel = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), this.GetString(CommandKey.ChangeJoinlogChannelButton), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("👋")));
6363
var ChangeUserCountChannel = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), this.GetString(CommandKey.ChangeUserCountChannel), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("🔢")));
64-
var ChangeUserCountFormat = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), this.GetString(CommandKey.ChangeUserCountChannelFormat), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("🔢")));
64+
var ChangeUserCountFormat = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), this.GetString(CommandKey.ChangeUserCountChannelFormat), ctx.DbGuild.Join.UserCountChannelId == 0, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("🔢")));
6565
var ChangeRoleOnJoin = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), this.GetString(CommandKey.ChangeRoleButton), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("👤")));
6666
var ToggleReApplyRoles = new DiscordButtonComponent((ctx.DbGuild.Join.ReApplyRoles ? ButtonStyle.Danger : ButtonStyle.Success), Guid.NewGuid().ToString(), this.GetString(CommandKey.ToggleReApplyRole), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("👥")));
6767
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 @@ string GetCurrentConfiguration(SharedCommandContext ctx)
201201

202202
ctx.DbGuild.Join.UserCountChannelId = ChannelResult.Result is null ? 0 : ChannelResult.Result.Id;
203203

204+
if (ChannelResult.Result is not null)
205+
await JoinEvents.RunUserCountUpdater(ctx.Bot, ctx.Guild);
206+
204207
await this.ExecuteCommand(ctx, arguments);
205208
return;
206209
}
@@ -236,6 +239,9 @@ string GetCurrentConfiguration(SharedCommandContext ctx)
236239

237240
ctx.DbGuild.Join.UserCountChannelFormat = modelResult.Result.Interaction.GetModalValueByCustomId("new_format");
238241

242+
if (ctx.DbGuild.Join.UserCountChannelId != 0)
243+
await JoinEvents.RunUserCountUpdater(ctx.Bot, ctx.Guild);
244+
239245
await this.ExecuteCommand(ctx, arguments);
240246
return;
241247
}

ProjectMakoto/Events/JoinEvents.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ internal async Task GuildMemberAdded(DiscordClient sender, GuildMemberAddEventAr
5454
}
5555
}
5656

57-
await this.RunUserCountUpdater(e.Guild);
57+
await RunUserCountUpdater(this.Bot, e.Guild);
5858
await this.Bot.Guilds[e.Guild.Id].Members[e.Member.Id].PerformAutoKickChecks(e.Guild, e.Member);
5959
}
6060

@@ -83,14 +83,14 @@ internal async Task GuildMemberRemoved(DiscordClient sender, GuildMemberRemoveEv
8383
}
8484
}
8585

86-
await this.RunUserCountUpdater(e.Guild);
86+
await RunUserCountUpdater(this.Bot, e.Guild);
8787
}
8888

89-
private async Task RunUserCountUpdater(DiscordGuild Guild)
89+
internal static async Task RunUserCountUpdater(Bot bot, DiscordGuild Guild)
9090
{
91-
if (this.Bot.Guilds[Guild.Id].Join.UserCountChannelId != 0)
91+
if (bot.Guilds[Guild.Id].Join.UserCountChannelId != 0)
9292
{
93-
if (Guild.Channels.ContainsKey(this.Bot.Guilds[Guild.Id].Join.UserCountChannelId))
93+
if (Guild.Channels.ContainsKey(bot.Guilds[Guild.Id].Join.UserCountChannelId))
9494
{
9595
foreach (var b in ScheduledTaskExtensions.GetScheduledTasks())
9696
{
@@ -103,16 +103,16 @@ private async Task RunUserCountUpdater(DiscordGuild Guild)
103103

104104
_ = new Func<Task>(async () =>
105105
{
106-
_ = Guild.GetChannel(this.Bot.Guilds[Guild.Id].Join.UserCountChannelId).ModifyAsync(x =>
106+
_ = Guild.GetChannel(bot.Guilds[Guild.Id].Join.UserCountChannelId).ModifyAsync(x =>
107107
{
108-
x.Name = (this.Bot.Guilds[Guild.Id].Join.UserCountChannelFormat is null ? "Count: %s" : this.Bot.Guilds[Guild.Id].Join.UserCountChannelFormat)
108+
x.Name = (bot.Guilds[Guild.Id].Join.UserCountChannelFormat is null ? "Count: %s" : bot.Guilds[Guild.Id].Join.UserCountChannelFormat)
109109
.Replace("%s", Guild.MemberCount);
110110
})
111111
.ContinueWith(x =>
112112
{
113-
this.Bot.Guilds[Guild.Id].Join.UserCountChannelLastEdit = DateTime.UtcNow;
113+
bot.Guilds[Guild.Id].Join.UserCountChannelLastEdit = DateTime.UtcNow;
114114
});
115-
}).CreateScheduledTask(this.Bot.Guilds[Guild.Id].Join.UserCountChannelLastEdit.AddMinutes(5),
115+
}).CreateScheduledTask(bot.Guilds[Guild.Id].Join.UserCountChannelLastEdit.AddMinutes(5),
116116
new ScheduledTaskIdentifier(Guild.Id, "", "usercount"));
117117
}
118118
}

0 commit comments

Comments
 (0)