.delete will now accept a message link

This commit is contained in:
Kwoth
2025-02-02 07:56:21 +00:00
parent 3db5a71d01
commit 556142c5ce
2 changed files with 34 additions and 14 deletions

View File

@@ -301,6 +301,16 @@ public partial class Administration : NadekoModule<AdministrationService>
public Task Delete(ulong messageId, ParsedTimespan timespan = null)
=> Delete((ITextChannel)ctx.Channel, messageId, timespan);
[Cmd]
[RequireContext(ContextType.Guild)]
public async Task Delete(MessageLink messageLink, ParsedTimespan timespan = null)
{
if (messageLink.Channel is not ITextChannel tc)
return;
await Delete(tc, messageLink.Message.Id, timespan);
}
[Cmd]
[RequireContext(ContextType.Guild)]
public async Task Delete(ITextChannel channel, ulong messageId, ParsedTimespan timespan = null)
@@ -373,7 +383,8 @@ public partial class Administration : NadekoModule<AdministrationService>
if (ctx.Channel is not SocketTextChannel stc)
return;
var t = stc.Threads.FirstOrDefault(x => string.Equals(x.Name, name, StringComparison.InvariantCultureIgnoreCase));
var t = stc.Threads.FirstOrDefault(
x => string.Equals(x.Name, name, StringComparison.InvariantCultureIgnoreCase));
if (t is null)
{
@@ -450,7 +461,8 @@ public partial class Administration : NadekoModule<AdministrationService>
public async Task SetServerBanner([Leftover] string img = null)
{
// Tier2 or higher is required to set a banner.
if (ctx.Guild.PremiumTier is PremiumTier.Tier1 or PremiumTier.None) return;
if (ctx.Guild.PremiumTier is PremiumTier.Tier1 or PremiumTier.None)
return;
var result = await _service.SetServerBannerAsync(ctx.Guild, img);

View File

@@ -4134,7 +4134,11 @@ edit:
text:
desc: "The new text content of the edited message."
delete:
desc: Deletes a single message given the channel and message ID. If channel is ommited, message will be searched for in the current channel. You can also specify time parameter after which the message will be deleted (up to 7 days). This timer won't persist through bot restarts.
desc: |-
Deletes a single message given the channel and message ID, or a message link.
If channel is omitted, message will be searched for in the current channel.
You can also specify time parameter after which the message will be deleted (up to 7 days).
This timer won't persist through bot restarts.
ex:
- '#chat 771562360594628608'
- 771562360594628608
@@ -4144,6 +4148,10 @@ delete:
desc: "The id of a specific message within a channel, used to target the deletion operation."
time:
desc: "The duration after which the message should be automatically deleted."
- messageLink:
desc: "The link of the message to delete. It must be on the same server."
time:
desc: "The duration after which the message should be automatically deleted."
- channel:
desc: "The channel where the message is located or should be searched for."
messageId: