You can now run .prune in dms to delete 100 of bot's messages
Upped version to 5.3.7 Updated commandlist
This commit is contained in:
parent
2935ae3f38
commit
ddd3441771
5 changed files with 87 additions and 13 deletions
|
@ -2,6 +2,15 @@
|
|||
|
||||
Mostly based on [keepachangelog](https://keepachangelog.com/en/1.1.0/) except date format. a-c-f-r-o
|
||||
|
||||
## [5.3.7] - 21.01.2025
|
||||
|
||||
## Changed
|
||||
|
||||
- You can now run `.prune` in DMs
|
||||
- It deletes only bot messages
|
||||
- You can't specify a number of messages to delete (100 default)
|
||||
- Updated command list
|
||||
|
||||
## [5.3.6] - 21.01.2025
|
||||
|
||||
## Added
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>true</ImplicitUsings>
|
||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||
<Version>5.3.6</Version>
|
||||
<Version>5.3.7</Version>
|
||||
|
||||
<!-- Output/build -->
|
||||
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
|
||||
|
|
|
@ -32,6 +32,25 @@ public partial class Administration
|
|||
}
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
[RequireContext(ContextType.DM)]
|
||||
[EllieOptions<PruneOptions>]
|
||||
public async Task Prune()
|
||||
{
|
||||
var progressMsg = await Response().Pending(strs.prune_progress(0, 100)).SendAsync();
|
||||
var progress = GetProgressTracker(progressMsg);
|
||||
|
||||
var result = await _service.PruneWhere(ctx.Channel,
|
||||
100,
|
||||
x => x.Author.Id == ctx.Client.CurrentUser.Id,
|
||||
progress);
|
||||
|
||||
ctx.Message.DeleteAfter(3);
|
||||
|
||||
await SendResult(result);
|
||||
await progressMsg.DeleteAsync();
|
||||
}
|
||||
|
||||
//deletes her own messages, no perm required
|
||||
[Cmd]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
|
@ -114,9 +133,9 @@ public partial class Administration
|
|||
await progressMsg.ModifyAsync(props =>
|
||||
{
|
||||
props.Embed = CreateEmbed()
|
||||
.WithPendingColor()
|
||||
.WithDescription(GetText(strs.prune_progress(deleted, total)))
|
||||
.Build();
|
||||
.WithPendingColor()
|
||||
.WithDescription(GetText(strs.prune_progress(deleted, total)))
|
||||
.Build();
|
||||
});
|
||||
}
|
||||
catch
|
||||
|
|
|
@ -18,7 +18,7 @@ public class PruneService : IEService
|
|||
}
|
||||
|
||||
public async Task<PruneResult> PruneWhere(
|
||||
ITextChannel channel,
|
||||
IMessageChannel channel,
|
||||
int amount,
|
||||
Func<IMessage, bool> predicate,
|
||||
IProgress<(int deleted, int total)> progress,
|
||||
|
@ -30,13 +30,14 @@ public class PruneService : IEService
|
|||
|
||||
var originalAmount = amount;
|
||||
|
||||
var gid = (channel as ITextChannel)?.GuildId ?? channel.Id;
|
||||
using var cancelSource = new CancellationTokenSource();
|
||||
if (!_pruningGuilds.TryAdd(channel.GuildId, cancelSource))
|
||||
if (!_pruningGuilds.TryAdd(gid, cancelSource))
|
||||
return PruneResult.AlreadyRunning;
|
||||
|
||||
try
|
||||
{
|
||||
if (!await _ps.LimitHitAsync(LimitedFeatureName.Prune, channel.Guild.OwnerId))
|
||||
if (channel is ITextChannel tc && !await _ps.LimitHitAsync(LimitedFeatureName.Prune, tc.Guild.OwnerId))
|
||||
{
|
||||
return PruneResult.FeatureLimit;
|
||||
}
|
||||
|
@ -74,9 +75,9 @@ public class PruneService : IEService
|
|||
singleDeletable.Add(x);
|
||||
}
|
||||
|
||||
if (bulkDeletable.Count > 0)
|
||||
if (channel is ITextChannel tc2 && bulkDeletable.Count > 0)
|
||||
{
|
||||
await channel.DeleteMessagesAsync(bulkDeletable);
|
||||
await tc2.DeleteMessagesAsync(bulkDeletable);
|
||||
amount -= msgs.Length;
|
||||
progress.Report((originalAmount - amount, originalAmount));
|
||||
await Task.Delay(2000, cancelSource.Token);
|
||||
|
@ -97,7 +98,7 @@ public class PruneService : IEService
|
|||
}
|
||||
finally
|
||||
{
|
||||
_pruningGuilds.TryRemove(channel.GuildId, out _);
|
||||
_pruningGuilds.TryRemove(gid, out _);
|
||||
}
|
||||
|
||||
return PruneResult.Success;
|
||||
|
|
|
@ -974,7 +974,7 @@
|
|||
"Module": "Administration",
|
||||
"Options": null,
|
||||
"Requirements": [
|
||||
"Bot Owner Only"
|
||||
"Administrator Server Permission"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -990,7 +990,7 @@
|
|||
"Module": "Administration",
|
||||
"Options": null,
|
||||
"Requirements": [
|
||||
"Bot Owner Only"
|
||||
"Administrator Server Permission"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -1008,7 +1008,7 @@
|
|||
"Module": "Administration",
|
||||
"Options": null,
|
||||
"Requirements": [
|
||||
"Bot Owner Only"
|
||||
"Administrator Server Permission"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -4044,6 +4044,51 @@
|
|||
"ManageMessages Server Permission"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Aliases": [
|
||||
".fish",
|
||||
".fi"
|
||||
],
|
||||
"Description": "Attempt to catch a fish.\nDifferent fish live in different places, at different times of day and in different weather.",
|
||||
"Usage": [
|
||||
".fish"
|
||||
],
|
||||
"Submodule": "FishCommands",
|
||||
"Module": "Games",
|
||||
"Options": null,
|
||||
"Requirements": []
|
||||
},
|
||||
{
|
||||
"Aliases": [
|
||||
".fishspot",
|
||||
".fisp",
|
||||
".fish?"
|
||||
],
|
||||
"Description": "Shows information about the current fish spot, weather and time.",
|
||||
"Usage": [
|
||||
".fishspot"
|
||||
],
|
||||
"Submodule": "FishCommands",
|
||||
"Module": "Games",
|
||||
"Options": null,
|
||||
"Requirements": []
|
||||
},
|
||||
{
|
||||
"Aliases": [
|
||||
".fishlist",
|
||||
".fili",
|
||||
".fishes",
|
||||
".fil"
|
||||
],
|
||||
"Description": "Look at your fish catalogue.\nShows how many of each fish you caught and what was the highest quality.\nFor each caught fish, it also shows its required spot, time of day and weather.",
|
||||
"Usage": [
|
||||
".fishlist"
|
||||
],
|
||||
"Submodule": "FishCommands",
|
||||
"Module": "Games",
|
||||
"Options": null,
|
||||
"Requirements": []
|
||||
},
|
||||
{
|
||||
"Aliases": [
|
||||
".hangmanlist"
|
||||
|
|
Loading…
Add table
Reference in a new issue