Added .threadcreate and .threaddelete commadns which create and delete public threads

This commit is contained in:
Kwoth
2022-08-11 15:42:37 +02:00
parent a065189023
commit f7e0e635e6
3 changed files with 48 additions and 0 deletions

View File

@@ -344,4 +344,36 @@ public partial class Administration : NadekoModule<AdministrationService>
await ctx.OkAsync(); 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();
}
} }

View File

@@ -174,6 +174,14 @@ settopic:
setchanlname: setchanlname:
- setchanlname - setchanlname
- schn - schn
# thread stuff
threadcreate:
- threadcreate
- thcr
threaddelete:
- threaddelete
- thdel
- thrm
prune: prune:
- prune - prune
- clear - clear

View File

@@ -2286,3 +2286,11 @@ bettest:
- "" - ""
- "betflip 1000" - "betflip 1000"
- "slot 2000" - "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"