From f7e0e635e6e39c6fa4813db6bdbba4b6a7837efd Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 11 Aug 2022 15:42:37 +0200 Subject: [PATCH] Added .threadcreate and .threaddelete commadns which create and delete public threads --- .../Modules/Administration/Administration.cs | 32 +++++++++++++++++++ src/NadekoBot/data/aliases.yml | 8 +++++ .../data/strings/commands/commands.en-US.yml | 8 +++++ 3 files changed, 48 insertions(+) diff --git a/src/NadekoBot/Modules/Administration/Administration.cs b/src/NadekoBot/Modules/Administration/Administration.cs index 05c0ba49a..9c3b112c5 100644 --- a/src/NadekoBot/Modules/Administration/Administration.cs +++ b/src/NadekoBot/Modules/Administration/Administration.cs @@ -344,4 +344,36 @@ public partial class Administration : NadekoModule await ctx.OkAsync(); } + + [Cmd] + [BotPerm(ChannelPermission.CreatePublicThreads)] + [UserPerm(ChannelPermission.CreatePublicThreads)] + public async Task ThreadCreate([Leftover] string name) + { + if (ctx.Channel is not SocketTextChannel stc) + return; + + await stc.CreateThreadAsync(name, message: ctx.Message.ReferencedMessage); + await ctx.OkAsync(); + } + + [Cmd] + [BotPerm(ChannelPermission.ManageThreads)] + [UserPerm(ChannelPermission.ManageThreads)] + public async Task ThreadDelete([Leftover] string name) + { + if (ctx.Channel is not SocketTextChannel stc) + return; + + var t = stc.Threads.FirstOrDefault(x => string.Equals(x.Name, name, StringComparison.InvariantCultureIgnoreCase)); + + if (t is null) + { + await ReplyErrorLocalizedAsync(strs.not_found); + return; + } + + await t.DeleteAsync(); + await ctx.OkAsync(); + } } \ No newline at end of file diff --git a/src/NadekoBot/data/aliases.yml b/src/NadekoBot/data/aliases.yml index 4b0761c09..4f0abd40a 100644 --- a/src/NadekoBot/data/aliases.yml +++ b/src/NadekoBot/data/aliases.yml @@ -174,6 +174,14 @@ settopic: setchanlname: - setchanlname - schn +# thread stuff +threadcreate: + - threadcreate + - thcr +threaddelete: + - threaddelete + - thdel + - thrm prune: - prune - clear diff --git a/src/NadekoBot/data/strings/commands/commands.en-US.yml b/src/NadekoBot/data/strings/commands/commands.en-US.yml index 4594e365d..e02059d18 100644 --- a/src/NadekoBot/data/strings/commands/commands.en-US.yml +++ b/src/NadekoBot/data/strings/commands/commands.en-US.yml @@ -2286,3 +2286,11 @@ bettest: - "" - "betflip 1000" - "slot 2000" +threadcreate: + desc: "Create a public thread with the specified title. You may optionally reply to a message to have it as a starting point." + args: + - "Q&A" +threaddelete: + desc: "Delete a thread with the specified name in this channel. Case insensitive." + args: + - "Q&A" \ No newline at end of file