mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
Using pattern matching for nulls where applicable, discarded unused lambda parameters, cleaned up some classes. Unignored ServerLog commands which was mistakenly ignored due to a .gitignore rule
This commit is contained in:
@@ -21,7 +21,7 @@ public partial class CustomReactions : NadekoModule<CustomReactionsService>
|
||||
|
||||
private bool AdminInGuildOrOwnerInDm()
|
||||
=> (ctx.Guild is null && _creds.IsOwner(ctx.User))
|
||||
|| (ctx.Guild != null && ((IGuildUser)ctx.User).GuildPermissions.Administrator);
|
||||
|| (ctx.Guild is not null && ((IGuildUser)ctx.User).GuildPermissions.Administrator);
|
||||
|
||||
[Cmd]
|
||||
public async partial Task AddCustReact(string key, [Leftover] string message)
|
||||
@@ -55,14 +55,14 @@ public partial class CustomReactions : NadekoModule<CustomReactionsService>
|
||||
return;
|
||||
|
||||
if ((channel is null && !_creds.IsOwner(ctx.User))
|
||||
|| (channel != null && !((IGuildUser)ctx.User).GuildPermissions.Administrator))
|
||||
|| (channel is not null && !((IGuildUser)ctx.User).GuildPermissions.Administrator))
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.insuff_perms);
|
||||
return;
|
||||
}
|
||||
|
||||
var cr = await _service.EditAsync(ctx.Guild?.Id, id, message);
|
||||
if (cr != null)
|
||||
if (cr is not null)
|
||||
await ctx.Channel.EmbedAsync(_eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle(GetText(strs.edited_cust_react))
|
||||
@@ -140,7 +140,7 @@ public partial class CustomReactions : NadekoModule<CustomReactionsService>
|
||||
|
||||
var cr = await _service.DeleteAsync(ctx.Guild?.Id, id);
|
||||
|
||||
if (cr != null)
|
||||
if (cr is not null)
|
||||
await ctx.Channel.EmbedAsync(_eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle(GetText(strs.deleted))
|
||||
|
@@ -351,7 +351,7 @@ public sealed class CustomReactionsService : IEarlyBehavior, IReadyExecutor
|
||||
if (maybeGuildId is { } guildId)
|
||||
_newGuildReactions.AddOrUpdate(guildId,
|
||||
new[] { cr },
|
||||
(key, old) =>
|
||||
(_, old) =>
|
||||
{
|
||||
var newArray = old.ToArray();
|
||||
for (var i = 0; i < newArray.Length; i++)
|
||||
@@ -375,7 +375,7 @@ public sealed class CustomReactionsService : IEarlyBehavior, IReadyExecutor
|
||||
cr.Trigger = cr.Trigger.Replace(MentionPh, _client.CurrentUser.Mention);
|
||||
|
||||
if (maybeGuildId is { } guildId)
|
||||
_newGuildReactions.AddOrUpdate(guildId, new[] { cr }, (key, old) => old.With(cr));
|
||||
_newGuildReactions.AddOrUpdate(guildId, new[] { cr }, (_, old) => old.With(cr));
|
||||
else
|
||||
return _pubSub.Pub(_gcrAddedKey, cr);
|
||||
|
||||
@@ -492,7 +492,7 @@ public sealed class CustomReactionsService : IEarlyBehavior, IReadyExecutor
|
||||
{
|
||||
using var uow = _db.GetDbContext();
|
||||
var cr = uow.CustomReactions.GetByGuildIdAndInput(guildId, input);
|
||||
return cr != null;
|
||||
return cr is not null;
|
||||
}
|
||||
|
||||
public string ExportCrs(ulong? guildId)
|
||||
|
Reference in New Issue
Block a user