Skip to content

Commit dc9a948

Browse files
Add duplicate detection to announcebuild (#266)
1 parent bcb665d commit dc9a948

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Commands/AnnouncementCmds.cs

+10-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public async Task AnnounceBuildSlashCommand(SlashCommandContext ctx,
2626
[Parameter("flavour_text"), Description("Extra text appended on the end of the main line, replacing :WindowsInsider: or :Windows10:")] string flavourText = "",
2727
[Parameter("autothread_name"), Description("If no thread is given, create a thread with this name.")] string autothreadName = "Build {0} ({1})",
2828

29-
[Parameter("lockdown"), Description("Set 0 to not lock. Lock the channel for a certain period of time after announcing the build.")] string lockdownTime = "auto"
30-
)
29+
[Parameter("lockdown"), Description("Set 0 to not lock. Lock the channel for a certain period of time after announcing the build.")] string lockdownTime = "auto",
30+
[Parameter("force_reannounce"), Description("Whether to ignore the check for duplicate announcements and send this one anyway.")] bool forceReannounce = false)
3131
{
3232
if (Program.cfgjson.InsidersChannel != 0 && ctx.Channel.Id != Program.cfgjson.InsidersChannel)
3333
{
@@ -45,6 +45,14 @@ public async Task AnnounceBuildSlashCommand(SlashCommandContext ctx,
4545
await ctx.RespondAsync(text: $"{Program.cfgjson.Emoji.Error} Windows 10 only has a Release Preview Channel.", ephemeral: true);
4646
return;
4747
}
48+
49+
// Avoid duplicate announcements
50+
if (await Program.db.SetContainsAsync("announcedInsiderBuilds", buildNumber) && !forceReannounce)
51+
{
52+
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} Build {buildNumber} has already been announced! If you are sure you want to announce it again, set `force_reannounce` to True.", ephemeral: true);
53+
return;
54+
}
55+
await Program.db.SetAddAsync("announcedInsiderBuilds", buildNumber);
4856

4957
if (flavourText == "" && windowsVersion == 10)
5058
{

0 commit comments

Comments
 (0)