mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 17:58:26 -04:00
Removed redundant parenthesis
This commit is contained in:
@@ -25,7 +25,7 @@ public sealed class UserSpamStats : IDisposable
|
||||
lock (applyLock)
|
||||
{
|
||||
var upperMsg = message.Content.ToUpperInvariant();
|
||||
if (upperMsg != LastMessage || (string.IsNullOrWhiteSpace(upperMsg) && message.Attachments.Any()))
|
||||
if (upperMsg != LastMessage || string.IsNullOrWhiteSpace(upperMsg) && message.Attachments.Any())
|
||||
{
|
||||
LastMessage = upperMsg;
|
||||
while (timers.TryDequeue(out var old))
|
||||
|
@@ -154,7 +154,7 @@ public partial class Administration
|
||||
}
|
||||
else
|
||||
{
|
||||
var g = ((SocketGuild)ctx.Guild);
|
||||
var g = (SocketGuild)ctx.Guild;
|
||||
foreach (var rr in rrs)
|
||||
{
|
||||
var ch = g.GetTextChannel(rr.ChannelId);
|
||||
@@ -164,7 +164,7 @@ public partial class Administration
|
||||
msg = await ch.GetMessageAsync(rr.MessageId).ConfigureAwait(false) as IUserMessage;
|
||||
}
|
||||
var content = msg?.Content.TrimTo(30) ?? "DELETED!";
|
||||
embed.AddField($"**{rr.Index + 1}.** {(ch?.Name ?? "DELETED!")}",
|
||||
embed.AddField($"**{rr.Index + 1}.** {ch?.Name ?? "DELETED!"}",
|
||||
GetText(strs.reaction_roles_message(rr.ReactionRoles?.Count ?? 0, content)));
|
||||
}
|
||||
}
|
||||
@@ -197,7 +197,7 @@ public partial class Administration
|
||||
{
|
||||
var runnerUser = (IGuildUser)ctx.User;
|
||||
var runnerMaxRolePosition = runnerUser.GetRoles().Max(x => x.Position);
|
||||
if ((ctx.User.Id != ctx.Guild.OwnerId) && runnerMaxRolePosition <= roleToAdd.Position)
|
||||
if (ctx.User.Id != ctx.Guild.OwnerId && runnerMaxRolePosition <= roleToAdd.Position)
|
||||
return;
|
||||
try
|
||||
{
|
||||
@@ -271,7 +271,7 @@ public partial class Administration
|
||||
.Where(x => !x.IsManaged && x != x.Guild.EveryoneRole)
|
||||
.ToList();
|
||||
|
||||
if (user.Id == ctx.Guild.OwnerId || (ctx.User.Id != ctx.Guild.OwnerId && guser.GetRoles().Max(x => x.Position) <= userRoles.Max(x => x.Position)))
|
||||
if (user.Id == ctx.Guild.OwnerId || ctx.User.Id != ctx.Guild.OwnerId && guser.GetRoles().Max(x => x.Position) <= userRoles.Max(x => x.Position))
|
||||
return;
|
||||
try
|
||||
{
|
||||
|
@@ -81,8 +81,8 @@ public sealed class ImageOnlyChannelService : IEarlyBehavior
|
||||
var newState = false;
|
||||
using var uow = _db.GetDbContext();
|
||||
if (forceDisable
|
||||
|| (_enabledOn.TryGetValue(guildId, out var channels)
|
||||
&& channels.TryRemove(channelId)))
|
||||
|| _enabledOn.TryGetValue(guildId, out var channels)
|
||||
&& channels.TryRemove(channelId))
|
||||
{
|
||||
uow.ImageOnlyChannels.Delete(x => x.ChannelId == channelId);
|
||||
}
|
||||
|
@@ -225,7 +225,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
logSetting.LogVoicePresenceId =
|
||||
logSetting.UserMutedId =
|
||||
logSetting.LogVoicePresenceTTSId =
|
||||
(value ? channelId : (ulong?) null);
|
||||
value ? channelId : (ulong?) null;
|
||||
;
|
||||
await uow.SaveChangesAsync();
|
||||
GuildLogSettings.AddOrUpdate(guildId, id => logSetting, (id, old) => logSetting);
|
||||
@@ -244,7 +244,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
var g = after.Guild;
|
||||
|
||||
if (!GuildLogSettings.TryGetValue(g.Id, out var logSetting)
|
||||
|| (logSetting.UserUpdatedId is null))
|
||||
|| logSetting.UserUpdatedId is null)
|
||||
return;
|
||||
|
||||
ITextChannel logChannel;
|
||||
@@ -303,54 +303,54 @@ public sealed class LogCommandService : ILogCommandService
|
||||
switch (type)
|
||||
{
|
||||
case LogType.Other:
|
||||
channelId = logSetting.LogOtherId = (logSetting.LogOtherId is null ? cid : default);
|
||||
channelId = logSetting.LogOtherId = logSetting.LogOtherId is null ? cid : default;
|
||||
break;
|
||||
case LogType.MessageUpdated:
|
||||
channelId = logSetting.MessageUpdatedId = (logSetting.MessageUpdatedId is null ? cid : default);
|
||||
channelId = logSetting.MessageUpdatedId = logSetting.MessageUpdatedId is null ? cid : default;
|
||||
break;
|
||||
case LogType.MessageDeleted:
|
||||
channelId = logSetting.MessageDeletedId = (logSetting.MessageDeletedId is null ? cid : default);
|
||||
channelId = logSetting.MessageDeletedId = logSetting.MessageDeletedId is null ? cid : default;
|
||||
//logSetting.DontLogBotMessageDeleted = (options == "nobot");
|
||||
break;
|
||||
case LogType.UserJoined:
|
||||
channelId = logSetting.UserJoinedId = (logSetting.UserJoinedId is null ? cid : default);
|
||||
channelId = logSetting.UserJoinedId = logSetting.UserJoinedId is null ? cid : default;
|
||||
break;
|
||||
case LogType.UserLeft:
|
||||
channelId = logSetting.UserLeftId = (logSetting.UserLeftId is null ? cid : default);
|
||||
channelId = logSetting.UserLeftId = logSetting.UserLeftId is null ? cid : default;
|
||||
break;
|
||||
case LogType.UserBanned:
|
||||
channelId = logSetting.UserBannedId = (logSetting.UserBannedId is null ? cid : default);
|
||||
channelId = logSetting.UserBannedId = logSetting.UserBannedId is null ? cid : default;
|
||||
break;
|
||||
case LogType.UserUnbanned:
|
||||
channelId = logSetting.UserUnbannedId = (logSetting.UserUnbannedId is null ? cid : default);
|
||||
channelId = logSetting.UserUnbannedId = logSetting.UserUnbannedId is null ? cid : default;
|
||||
break;
|
||||
case LogType.UserUpdated:
|
||||
channelId = logSetting.UserUpdatedId = (logSetting.UserUpdatedId is null ? cid : default);
|
||||
channelId = logSetting.UserUpdatedId = logSetting.UserUpdatedId is null ? cid : default;
|
||||
break;
|
||||
case LogType.UserMuted:
|
||||
channelId = logSetting.UserMutedId = (logSetting.UserMutedId is null ? cid : default);
|
||||
channelId = logSetting.UserMutedId = logSetting.UserMutedId is null ? cid : default;
|
||||
break;
|
||||
case LogType.ChannelCreated:
|
||||
channelId = logSetting.ChannelCreatedId = (logSetting.ChannelCreatedId is null ? cid : default);
|
||||
channelId = logSetting.ChannelCreatedId = logSetting.ChannelCreatedId is null ? cid : default;
|
||||
break;
|
||||
case LogType.ChannelDestroyed:
|
||||
channelId = logSetting.ChannelDestroyedId =
|
||||
(logSetting.ChannelDestroyedId is null ? cid : default);
|
||||
logSetting.ChannelDestroyedId is null ? cid : default;
|
||||
break;
|
||||
case LogType.ChannelUpdated:
|
||||
channelId = logSetting.ChannelUpdatedId = (logSetting.ChannelUpdatedId is null ? cid : default);
|
||||
channelId = logSetting.ChannelUpdatedId = logSetting.ChannelUpdatedId is null ? cid : default;
|
||||
break;
|
||||
case LogType.UserPresence:
|
||||
channelId = logSetting.LogUserPresenceId =
|
||||
(logSetting.LogUserPresenceId is null ? cid : default);
|
||||
logSetting.LogUserPresenceId is null ? cid : default;
|
||||
break;
|
||||
case LogType.VoicePresence:
|
||||
channelId = logSetting.LogVoicePresenceId =
|
||||
(logSetting.LogVoicePresenceId is null ? cid : default);
|
||||
logSetting.LogVoicePresenceId is null ? cid : default;
|
||||
break;
|
||||
case LogType.VoicePresenceTTS:
|
||||
channelId = logSetting.LogVoicePresenceTTSId =
|
||||
(logSetting.LogVoicePresenceTTSId is null ? cid : default);
|
||||
logSetting.LogVoicePresenceTTSId is null ? cid : default;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -376,7 +376,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
return;
|
||||
|
||||
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out var logSetting)
|
||||
|| (logSetting.LogVoicePresenceTTSId is null))
|
||||
|| logSetting.LogVoicePresenceTTSId is null)
|
||||
return;
|
||||
|
||||
ITextChannel logChannel;
|
||||
@@ -416,7 +416,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
try
|
||||
{
|
||||
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out var logSetting)
|
||||
|| (logSetting.UserMutedId is null))
|
||||
|| logSetting.UserMutedId is null)
|
||||
return;
|
||||
|
||||
ITextChannel logChannel;
|
||||
@@ -460,7 +460,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
try
|
||||
{
|
||||
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out var logSetting)
|
||||
|| (logSetting.UserMutedId is null))
|
||||
|| logSetting.UserMutedId is null)
|
||||
return;
|
||||
|
||||
ITextChannel logChannel;
|
||||
@@ -512,7 +512,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
return;
|
||||
|
||||
if (!GuildLogSettings.TryGetValue(users.First().Guild.Id, out var logSetting)
|
||||
|| (logSetting.LogOtherId is null))
|
||||
|| logSetting.LogOtherId is null)
|
||||
return;
|
||||
ITextChannel logChannel;
|
||||
if ((logChannel = await TryGetLogChannel(users.First().Guild, logSetting, LogType.Other)
|
||||
@@ -681,7 +681,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
var after = (IGuildChannel) cafter;
|
||||
|
||||
if (!GuildLogSettings.TryGetValue(before.Guild.Id, out var logSetting)
|
||||
|| (logSetting.ChannelUpdatedId is null)
|
||||
|| logSetting.ChannelUpdatedId is null
|
||||
|| logSetting.LogIgnores.Any(ilc => ilc.LogItemId == after.Id && ilc.ItemType == IgnoredItemType.Channel))
|
||||
return;
|
||||
|
||||
@@ -732,7 +732,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
return;
|
||||
|
||||
if (!GuildLogSettings.TryGetValue(ch.Guild.Id, out var logSetting)
|
||||
|| (logSetting.ChannelDestroyedId is null)
|
||||
|| logSetting.ChannelDestroyedId is null
|
||||
|| logSetting.LogIgnores.Any(ilc => ilc.LogItemId == ch.Id && ilc.ItemType == IgnoredItemType.Channel))
|
||||
return;
|
||||
|
||||
@@ -817,7 +817,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
return;
|
||||
|
||||
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out var logSetting)
|
||||
|| (logSetting.LogVoicePresenceId is null)
|
||||
|| logSetting.LogVoicePresenceId is null
|
||||
|| logSetting.LogIgnores.Any(ilc => ilc.LogItemId == iusr.Id && ilc.ItemType == IgnoredItemType.User))
|
||||
return;
|
||||
|
||||
@@ -870,7 +870,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
try
|
||||
{
|
||||
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out var logSetting)
|
||||
|| (logSetting.UserLeftId is null)
|
||||
|| logSetting.UserLeftId is null
|
||||
|| logSetting.LogIgnores.Any(ilc => ilc.LogItemId == usr.Id && ilc.ItemType == IgnoredItemType.User))
|
||||
return;
|
||||
|
||||
@@ -905,7 +905,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
try
|
||||
{
|
||||
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out var logSetting)
|
||||
|| (logSetting.UserJoinedId is null))
|
||||
|| logSetting.UserJoinedId is null)
|
||||
return;
|
||||
|
||||
ITextChannel logChannel;
|
||||
@@ -946,7 +946,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
try
|
||||
{
|
||||
if (!GuildLogSettings.TryGetValue(guild.Id, out var logSetting)
|
||||
|| (logSetting.UserUnbannedId is null)
|
||||
|| logSetting.UserUnbannedId is null
|
||||
|| logSetting.LogIgnores.Any(ilc => ilc.LogItemId == usr.Id && ilc.ItemType == IgnoredItemType.User))
|
||||
return;
|
||||
|
||||
@@ -981,7 +981,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
try
|
||||
{
|
||||
if (!GuildLogSettings.TryGetValue(guild.Id, out var logSetting)
|
||||
|| (logSetting.UserBannedId is null)
|
||||
|| logSetting.UserBannedId is null
|
||||
|| logSetting.LogIgnores.Any(ilc => ilc.LogItemId == usr.Id && ilc.ItemType == IgnoredItemType.User))
|
||||
return;
|
||||
|
||||
@@ -1029,7 +1029,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
return;
|
||||
|
||||
if (!GuildLogSettings.TryGetValue(channel.Guild.Id, out var logSetting)
|
||||
|| (logSetting.MessageDeletedId is null)
|
||||
|| logSetting.MessageDeletedId is null
|
||||
|| logSetting.LogIgnores.Any(ilc => ilc.LogItemId == channel.Id && ilc.ItemType == IgnoredItemType.Channel))
|
||||
return;
|
||||
|
||||
@@ -1087,7 +1087,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
return;
|
||||
|
||||
if (!GuildLogSettings.TryGetValue(channel.Guild.Id, out var logSetting)
|
||||
|| (logSetting.MessageUpdatedId is null)
|
||||
|| logSetting.MessageUpdatedId is null
|
||||
|| logSetting.LogIgnores.Any(ilc => ilc.LogItemId == channel.Id && ilc.ItemType == IgnoredItemType.Channel))
|
||||
return;
|
||||
|
||||
|
@@ -299,7 +299,7 @@ public class MuteService : INService
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var toOverwrite in (await guild.GetTextChannelsAsync().ConfigureAwait(false)))
|
||||
foreach (var toOverwrite in await guild.GetTextChannelsAsync().ConfigureAwait(false))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@@ -190,7 +190,7 @@ public class RoleCommandsService : INService
|
||||
{
|
||||
var toAdd = user.Guild.GetRole(dbRero.RoleId);
|
||||
|
||||
return (toAdd != null && !user.Roles.Contains(toAdd))
|
||||
return toAdd != null && !user.Roles.Contains(toAdd)
|
||||
? user.AddRoleAsync(toAdd)
|
||||
: Task.CompletedTask;
|
||||
}
|
||||
|
@@ -320,7 +320,7 @@ WHERE GuildId={guildId}
|
||||
// these 3 don't make sense with time
|
||||
if ((punish == PunishmentAction.Softban || punish == PunishmentAction.Kick || punish == PunishmentAction.RemoveRoles) && time != null)
|
||||
return false;
|
||||
if (number <= 0 || (time != null && time.Time > TimeSpan.FromDays(49)))
|
||||
if (number <= 0 || time != null && time.Time > TimeSpan.FromDays(49))
|
||||
return false;
|
||||
|
||||
using (var uow = _db.GetDbContext())
|
||||
@@ -334,7 +334,7 @@ WHERE GuildId={guildId}
|
||||
{
|
||||
Count = number,
|
||||
Punishment = punish,
|
||||
Time = (int?)(time?.Time.TotalMinutes) ?? 0,
|
||||
Time = (int?)time?.Time.TotalMinutes ?? 0,
|
||||
RoleId = punish == PunishmentAction.AddRole ? role.Id : default(ulong?),
|
||||
});
|
||||
uow.SaveChanges();
|
||||
|
@@ -37,7 +37,7 @@ public partial class Administration
|
||||
// bot can't punish a user who is higher in the hierarchy. Discord will return 403
|
||||
// moderator can be owner, in which case role hierarchy doesn't matter
|
||||
// otherwise, moderator has to have a higher role
|
||||
if ((botMaxRole <= targetMaxRole || (ctx.User.Id != ownerId && targetMaxRole >= modMaxRole)) || target.Id == ownerId)
|
||||
if (botMaxRole <= targetMaxRole || ctx.User.Id != ownerId && targetMaxRole >= modMaxRole || target.Id == ownerId)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.hierarchy);
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user