You can now target a different channel with .repeat, for example: .repeat #some-other-channel 15m Quick reminder

This commit is contained in:
Kwoth
2024-04-24 22:59:45 +00:00
parent 49563ea6d4
commit e1d027eaf5
2 changed files with 53 additions and 15 deletions

View File

@@ -16,6 +16,7 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
- `.ga list` lists active giveaways on the current server - `.ga list` lists active giveaways on the current server
- `.ga reroll <id>` rerolls the winner on the completed giveaway. This only works for 24 hours after the giveaway has ended, or until the bot restarts. - `.ga reroll <id>` rerolls the winner on the completed giveaway. This only works for 24 hours after the giveaway has ended, or until the bot restarts.
- After the giveaway has started, user join the giveaway by adding a :tada: reaction - After the giveaway has started, user join the giveaway by adding a :tada: reaction
- You can now target a different channel with .repeat, for example `.repeat #some-other 1h Hello every hour`
## [4.3.22] - 23.04.2023 ## [4.3.22] - 23.04.2023

View File

@@ -1,4 +1,5 @@
using NadekoBot.Common.TypeReaders; using LinqToDB.Common;
using NadekoBot.Common.TypeReaders;
using NadekoBot.Common.TypeReaders.Models; using NadekoBot.Common.TypeReaders.Models;
using NadekoBot.Modules.Utility.Services; using NadekoBot.Modules.Utility.Services;
@@ -16,9 +17,9 @@ public partial class Utility
{ {
if (--index < 0) if (--index < 0)
return; return;
var result = await _service.ToggleSkipNextAsync(ctx.Guild.Id, index); var result = await _service.ToggleSkipNextAsync(ctx.Guild.Id, index);
if (result is null) if (result is null)
{ {
await ReplyErrorLocalizedAsync(strs.index_out_of_range); await ReplyErrorLocalizedAsync(strs.index_out_of_range);
@@ -34,7 +35,7 @@ public partial class Utility
await ReplyConfirmLocalizedAsync(strs.repeater_dont_skip_next); await ReplyConfirmLocalizedAsync(strs.repeater_dont_skip_next);
} }
} }
[Cmd] [Cmd]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
@@ -65,9 +66,9 @@ public partial class Utility
var description = GetRepeaterInfoString(removed); var description = GetRepeaterInfoString(removed);
await ctx.Channel.EmbedAsync(_eb.Create() await ctx.Channel.EmbedAsync(_eb.Create()
.WithOkColor() .WithOkColor()
.WithTitle(GetText(strs.repeater_removed(index + 1))) .WithTitle(GetText(strs.repeater_removed(index + 1)))
.WithDescription(description)); .WithDescription(description));
} }
[Cmd] [Cmd]
@@ -95,16 +96,30 @@ public partial class Utility
[Cmd] [Cmd]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
[Priority(-1)] [Priority(-2)]
public Task Repeat([Leftover] string message) public Task Repeat([Leftover] string message)
=> Repeat(null, null, message); => Repeat(ctx.Channel, null, null, message);
[Cmd]
[RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)]
[Priority(-1)]
public Task Repeat(ITextChannel channel, [Leftover] string message)
=> Repeat(channel, null, null, message);
[Cmd] [Cmd]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
[Priority(0)] [Priority(0)]
public Task Repeat(StoopidTime interval, [Leftover] string message) public Task Repeat(StoopidTime interval, [Leftover] string message)
=> Repeat(null, interval, message); => Repeat(ctx.Channel, null, interval, message);
[Cmd]
[RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)]
[Priority(0)]
public Task Repeat(ITextChannel ch, StoopidTime interval, [Leftover] string message)
=> Repeat(ch, null, interval, message);
[Cmd] [Cmd]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
@@ -113,12 +128,34 @@ public partial class Utility
public Task Repeat(GuildDateTime dt, [Leftover] string message) public Task Repeat(GuildDateTime dt, [Leftover] string message)
=> Repeat(dt, null, message); => Repeat(dt, null, message);
[Cmd]
[RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)]
[Priority(1)]
public Task Repeat(ITextChannel channel, GuildDateTime dt, [Leftover] string message)
=> Repeat(channel, dt, null, message);
[Cmd] [Cmd]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
[Priority(2)] [Priority(2)]
public async Task Repeat(GuildDateTime? dt, StoopidTime? interval, [Leftover] string message) public Task Repeat(GuildDateTime? dt, StoopidTime? interval, [Leftover] string message)
=> Repeat(ctx.Channel, dt, interval, message);
[Cmd]
[RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)]
[Priority(3)]
public async Task Repeat(IMessageChannel channel, GuildDateTime? dt, StoopidTime? interval,
[Leftover] string message)
{ {
if (channel is not ITextChannel txtCh || txtCh.GuildId != ctx.Guild.Id)
return;
var perms = ((IGuildUser)ctx.User).GetPermissions(txtCh);
if (!perms.SendMessages)
return;
var startTimeOfDay = dt?.InputTimeUtc.TimeOfDay; var startTimeOfDay = dt?.InputTimeUtc.TimeOfDay;
// if interval not null, that means user specified it (don't change it) // if interval not null, that means user specified it (don't change it)
@@ -137,7 +174,7 @@ public partial class Utility
? message ? message
: message.SanitizeMentions(true); : message.SanitizeMentions(true);
var runner = await _service.AddRepeaterAsync(ctx.Channel.Id, var runner = await _service.AddRepeaterAsync(channel.Id,
ctx.Guild.Id, ctx.Guild.Id,
realInterval, realInterval,
message, message,
@@ -152,9 +189,9 @@ public partial class Utility
var description = GetRepeaterInfoString(runner); var description = GetRepeaterInfoString(runner);
await ctx.Channel.EmbedAsync(_eb.Create() await ctx.Channel.EmbedAsync(_eb.Create()
.WithOkColor() .WithOkColor()
.WithTitle(GetText(strs.repeater_created)) .WithTitle(GetText(strs.repeater_created))
.WithDescription(description)); .WithDescription(description));
} }
[Cmd] [Cmd]