mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
fix: xplb and xpglb pagination fixed, closes #430
fix: Page number when there is an unknown number of items while paginating is now correct fix: .stm and .stma fixed and can now mention everyone as long as the user executing the command also can dev: Cleaned up/improved some code
This commit is contained in:
@@ -143,6 +143,10 @@ public partial class Searches
|
||||
if (--index < 0)
|
||||
return;
|
||||
|
||||
var canMentionEveryone = (ctx.User as IGuildUser)?.GuildPermissions.MentionEveryone ?? true;
|
||||
if (!canMentionEveryone)
|
||||
message = message?.SanitizeAllMentions();
|
||||
|
||||
if (!_service.SetStreamMessage(ctx.Guild.Id, index, message, out var fs))
|
||||
{
|
||||
await Response().Confirm(strs.stream_not_following).SendAsync();
|
||||
@@ -160,6 +164,10 @@ public partial class Searches
|
||||
[UserPerm(GuildPerm.ManageMessages)]
|
||||
public async Task StreamMessageAll([Leftover] string message)
|
||||
{
|
||||
var canMentionEveryone = (ctx.User as IGuildUser)?.GuildPermissions.MentionEveryone ?? true;
|
||||
if (!canMentionEveryone)
|
||||
message = message?.SanitizeAllMentions();
|
||||
|
||||
var count = _service.SetStreamMessageForAll(ctx.Guild.Id, message);
|
||||
|
||||
if (count == 0)
|
||||
|
@@ -294,6 +294,7 @@ public sealed class StreamNotificationService : INService, IReadyExecutor
|
||||
var msg = await _sender.Response(textChannel)
|
||||
.Embed(GetEmbed(fs.GuildId, stream, false))
|
||||
.Text(message)
|
||||
.Sanitize(false)
|
||||
.SendAsync();
|
||||
|
||||
// only cache the ids of channel/message pairs
|
||||
@@ -615,7 +616,9 @@ public sealed class StreamNotificationService : INService, IReadyExecutor
|
||||
{
|
||||
using var uow = _db.GetDbContext();
|
||||
|
||||
var all = uow.Set<FollowedStream>().ToList();
|
||||
var all = uow.Set<FollowedStream>()
|
||||
.Where(x => x.GuildId == guildId)
|
||||
.ToList();
|
||||
|
||||
if (all.Count == 0)
|
||||
return 0;
|
||||
@@ -623,6 +626,19 @@ public sealed class StreamNotificationService : INService, IReadyExecutor
|
||||
all.ForEach(x => x.Message = message);
|
||||
|
||||
uow.SaveChanges();
|
||||
|
||||
lock (_shardLock)
|
||||
{
|
||||
foreach (var fs in all)
|
||||
{
|
||||
var streams = GetLocalGuildStreams(fs.CreateKey(), guildId);
|
||||
|
||||
// message doesn't participate in equality checking
|
||||
// removing and adding = update
|
||||
streams.Remove(fs);
|
||||
streams.Add(fs);
|
||||
}
|
||||
}
|
||||
|
||||
return all.Count;
|
||||
}
|
||||
|
Reference in New Issue
Block a user