mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 09:18:27 -04:00
Changed all == null to is null and all !(* == null) to * is not null
This commit is contained in:
@@ -27,7 +27,7 @@ namespace NadekoBot.Core.Common.Attributes
|
|||||||
var cache = services.GetService<IDataCache>();
|
var cache = services.GetService<IDataCache>();
|
||||||
var rem = cache.TryAddRatelimit(context.User.Id, command.Name, Seconds);
|
var rem = cache.TryAddRatelimit(context.User.Id, command.Name, Seconds);
|
||||||
|
|
||||||
if(rem == null)
|
if(rem is null)
|
||||||
return Task.FromResult(PreconditionResult.FromSuccess());
|
return Task.FromResult(PreconditionResult.FromSuccess());
|
||||||
|
|
||||||
var msgContent = $"You can use this command again in {rem.Value.TotalSeconds:F1}s.";
|
var msgContent = $"You can use this command again in {rem.Value.TotalSeconds:F1}s.";
|
||||||
|
@@ -176,7 +176,7 @@ namespace NadekoBot.Common.Collections
|
|||||||
public ConcurrentHashSet(IEnumerable<T> collection, IEqualityComparer<T> comparer)
|
public ConcurrentHashSet(IEnumerable<T> collection, IEqualityComparer<T> comparer)
|
||||||
: this(comparer)
|
: this(comparer)
|
||||||
{
|
{
|
||||||
if (collection == null) throw new ArgumentNullException(nameof(collection));
|
if (collection is null) throw new ArgumentNullException(nameof(collection));
|
||||||
|
|
||||||
InitializeFromCollection(collection);
|
InitializeFromCollection(collection);
|
||||||
}
|
}
|
||||||
@@ -205,8 +205,8 @@ namespace NadekoBot.Common.Collections
|
|||||||
public ConcurrentHashSet(int concurrencyLevel, IEnumerable<T> collection, IEqualityComparer<T> comparer)
|
public ConcurrentHashSet(int concurrencyLevel, IEnumerable<T> collection, IEqualityComparer<T> comparer)
|
||||||
: this(concurrencyLevel, DefaultCapacity, false, comparer)
|
: this(concurrencyLevel, DefaultCapacity, false, comparer)
|
||||||
{
|
{
|
||||||
if (collection == null) throw new ArgumentNullException(nameof(collection));
|
if (collection is null) throw new ArgumentNullException(nameof(collection));
|
||||||
if (comparer == null) throw new ArgumentNullException(nameof(comparer));
|
if (comparer is null) throw new ArgumentNullException(nameof(comparer));
|
||||||
|
|
||||||
InitializeFromCollection(collection);
|
InitializeFromCollection(collection);
|
||||||
}
|
}
|
||||||
@@ -348,11 +348,11 @@ namespace NadekoBot.Common.Collections
|
|||||||
Node previous = null;
|
Node previous = null;
|
||||||
for (var current = tables.Buckets[bucketNo]; current != null; current = current.Next)
|
for (var current = tables.Buckets[bucketNo]; current != null; current = current.Next)
|
||||||
{
|
{
|
||||||
Debug.Assert((previous == null && current == tables.Buckets[bucketNo]) || previous.Next == current);
|
Debug.Assert((previous is null && current == tables.Buckets[bucketNo]) || previous.Next == current);
|
||||||
|
|
||||||
if (hashcode == current.Hashcode && _comparer.Equals(current.Item, item))
|
if (hashcode == current.Hashcode && _comparer.Equals(current.Item, item))
|
||||||
{
|
{
|
||||||
if (previous == null)
|
if (previous is null)
|
||||||
{
|
{
|
||||||
Volatile.Write(ref tables.Buckets[bucketNo], current.Next);
|
Volatile.Write(ref tables.Buckets[bucketNo], current.Next);
|
||||||
}
|
}
|
||||||
@@ -406,7 +406,7 @@ namespace NadekoBot.Common.Collections
|
|||||||
|
|
||||||
void ICollection<T>.CopyTo(T[] array, int arrayIndex)
|
void ICollection<T>.CopyTo(T[] array, int arrayIndex)
|
||||||
{
|
{
|
||||||
if (array == null) throw new ArgumentNullException(nameof(array));
|
if (array is null) throw new ArgumentNullException(nameof(array));
|
||||||
if (arrayIndex < 0) throw new ArgumentOutOfRangeException(nameof(arrayIndex));
|
if (arrayIndex < 0) throw new ArgumentOutOfRangeException(nameof(arrayIndex));
|
||||||
|
|
||||||
var locksAcquired = 0;
|
var locksAcquired = 0;
|
||||||
@@ -474,7 +474,7 @@ namespace NadekoBot.Common.Collections
|
|||||||
Node previous = null;
|
Node previous = null;
|
||||||
for (var current = tables.Buckets[bucketNo]; current != null; current = current.Next)
|
for (var current = tables.Buckets[bucketNo]; current != null; current = current.Next)
|
||||||
{
|
{
|
||||||
Debug.Assert((previous == null && current == tables.Buckets[bucketNo]) || previous.Next == current);
|
Debug.Assert((previous is null && current == tables.Buckets[bucketNo]) || previous.Next == current);
|
||||||
if (hashcode == current.Hashcode && _comparer.Equals(current.Item, item))
|
if (hashcode == current.Hashcode && _comparer.Equals(current.Item, item))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@@ -69,8 +69,8 @@ namespace NadekoBot.Common.Replacements
|
|||||||
public ReplacementBuilder WithServer(DiscordSocketClient client, SocketGuild g)
|
public ReplacementBuilder WithServer(DiscordSocketClient client, SocketGuild g)
|
||||||
{
|
{
|
||||||
/*OBSOLETE*/
|
/*OBSOLETE*/
|
||||||
_reps.TryAdd("%sid%", () => g == null ? "DM" : g.Id.ToString());
|
_reps.TryAdd("%sid%", () => g is null ? "DM" : g.Id.ToString());
|
||||||
_reps.TryAdd("%server%", () => g == null ? "DM" : g.Name);
|
_reps.TryAdd("%server%", () => g is null ? "DM" : g.Name);
|
||||||
_reps.TryAdd("%members%", () => g != null && g is SocketGuild sg ? sg.MemberCount.ToString() : "?");
|
_reps.TryAdd("%members%", () => g != null && g is SocketGuild sg ? sg.MemberCount.ToString() : "?");
|
||||||
_reps.TryAdd("%server_time%", () =>
|
_reps.TryAdd("%server_time%", () =>
|
||||||
{
|
{
|
||||||
@@ -86,8 +86,8 @@ namespace NadekoBot.Common.Replacements
|
|||||||
to).ToString("HH:mm ") + to.StandardName.GetInitials();
|
to).ToString("HH:mm ") + to.StandardName.GetInitials();
|
||||||
});
|
});
|
||||||
/*NEW*/
|
/*NEW*/
|
||||||
_reps.TryAdd("%server.id%", () => g == null ? "DM" : g.Id.ToString());
|
_reps.TryAdd("%server.id%", () => g is null ? "DM" : g.Id.ToString());
|
||||||
_reps.TryAdd("%server.name%", () => g == null ? "DM" : g.Name);
|
_reps.TryAdd("%server.name%", () => g is null ? "DM" : g.Name);
|
||||||
_reps.TryAdd("%server.members%", () => g != null && g is SocketGuild sg ? sg.MemberCount.ToString() : "?");
|
_reps.TryAdd("%server.members%", () => g != null && g is SocketGuild sg ? sg.MemberCount.ToString() : "?");
|
||||||
_reps.TryAdd("%server.time%", () =>
|
_reps.TryAdd("%server.time%", () =>
|
||||||
{
|
{
|
||||||
|
@@ -29,7 +29,7 @@ namespace NadekoBot.Common.TypeReaders
|
|||||||
|
|
||||||
var cmd = _cmds.Commands.FirstOrDefault(c =>
|
var cmd = _cmds.Commands.FirstOrDefault(c =>
|
||||||
c.Aliases.Select(a => a.ToUpperInvariant()).Contains(input));
|
c.Aliases.Select(a => a.ToUpperInvariant()).Contains(input));
|
||||||
if (cmd == null)
|
if (cmd is null)
|
||||||
return Task.FromResult(TypeReaderResult.FromError(CommandError.ParseFailed, "No such command found."));
|
return Task.FromResult(TypeReaderResult.FromError(CommandError.ParseFailed, "No such command found."));
|
||||||
|
|
||||||
return Task.FromResult(TypeReaderResult.FromSuccess(cmd));
|
return Task.FromResult(TypeReaderResult.FromSuccess(cmd));
|
||||||
|
@@ -17,7 +17,7 @@ namespace NadekoBot.Common.TypeReaders
|
|||||||
public override Task<TypeReaderResult> ReadAsync(ICommandContext context, string input, IServiceProvider services)
|
public override Task<TypeReaderResult> ReadAsync(ICommandContext context, string input, IServiceProvider services)
|
||||||
{
|
{
|
||||||
var gdt = Parse(services, context.Guild.Id, input);
|
var gdt = Parse(services, context.Guild.Id, input);
|
||||||
if(gdt == null)
|
if(gdt is null)
|
||||||
return Task.FromResult(TypeReaderResult.FromError(CommandError.ParseFailed, "Input string is in an incorrect format."));
|
return Task.FromResult(TypeReaderResult.FromError(CommandError.ParseFailed, "Input string is in an incorrect format."));
|
||||||
|
|
||||||
return Task.FromResult(TypeReaderResult.FromSuccess(gdt));
|
return Task.FromResult(TypeReaderResult.FromSuccess(gdt));
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (obj == null || GetType() != obj.GetType())
|
if (obj is null || GetType() != obj.GetType())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -21,7 +21,7 @@ namespace NadekoBot.Common.TypeReaders
|
|||||||
{
|
{
|
||||||
input = input.ToUpperInvariant();
|
input = input.ToUpperInvariant();
|
||||||
var module = _cmds.Modules.GroupBy(m => m.GetTopLevelModule()).FirstOrDefault(m => m.Key.Name.ToUpperInvariant() == input)?.Key;
|
var module = _cmds.Modules.GroupBy(m => m.GetTopLevelModule()).FirstOrDefault(m => m.Key.Name.ToUpperInvariant() == input)?.Key;
|
||||||
if (module == null)
|
if (module is null)
|
||||||
return Task.FromResult(TypeReaderResult.FromError(CommandError.ParseFailed, "No such module found."));
|
return Task.FromResult(TypeReaderResult.FromError(CommandError.ParseFailed, "No such module found."));
|
||||||
|
|
||||||
return Task.FromResult(TypeReaderResult.FromSuccess(module));
|
return Task.FromResult(TypeReaderResult.FromSuccess(module));
|
||||||
@@ -41,7 +41,7 @@ namespace NadekoBot.Common.TypeReaders
|
|||||||
{
|
{
|
||||||
input = input.ToUpperInvariant();
|
input = input.ToUpperInvariant();
|
||||||
var module = _cmds.Modules.GroupBy(m => m.GetTopLevelModule()).FirstOrDefault(m => m.Key.Name.ToUpperInvariant() == input)?.Key;
|
var module = _cmds.Modules.GroupBy(m => m.GetTopLevelModule()).FirstOrDefault(m => m.Key.Name.ToUpperInvariant() == input)?.Key;
|
||||||
if (module == null && input != "ACTUALCUSTOMREACTIONS")
|
if (module is null && input != "ACTUALCUSTOMREACTIONS")
|
||||||
return Task.FromResult(TypeReaderResult.FromError(CommandError.ParseFailed, "No such module found."));
|
return Task.FromResult(TypeReaderResult.FromError(CommandError.ParseFailed, "No such module found."));
|
||||||
|
|
||||||
return Task.FromResult(TypeReaderResult.FromSuccess(new ModuleOrCrInfo
|
return Task.FromResult(TypeReaderResult.FromSuccess(new ModuleOrCrInfo
|
||||||
|
@@ -28,7 +28,7 @@ namespace NadekoBot.Db
|
|||||||
.Include(y => y.StreamRole.Whitelist)
|
.Include(y => y.StreamRole.Whitelist)
|
||||||
.Include(y => y.StreamRole.Blacklist));
|
.Include(y => y.StreamRole.Blacklist));
|
||||||
|
|
||||||
if (conf.StreamRole == null)
|
if (conf.StreamRole is null)
|
||||||
conf.StreamRole = new StreamRoleSettings();
|
conf.StreamRole = new StreamRoleSettings();
|
||||||
|
|
||||||
return conf.StreamRole;
|
return conf.StreamRole;
|
||||||
@@ -79,7 +79,7 @@ namespace NadekoBot.Db
|
|||||||
{
|
{
|
||||||
GuildConfig config;
|
GuildConfig config;
|
||||||
|
|
||||||
if (includes == null)
|
if (includes is null)
|
||||||
{
|
{
|
||||||
config = ctx
|
config = ctx
|
||||||
.GuildConfigs
|
.GuildConfigs
|
||||||
@@ -92,7 +92,7 @@ namespace NadekoBot.Db
|
|||||||
config = set.FirstOrDefault(c => c.GuildId == guildId);
|
config = set.FirstOrDefault(c => c.GuildId == guildId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config == null)
|
if (config is null)
|
||||||
{
|
{
|
||||||
ctx.GuildConfigs.Add((config = new GuildConfig
|
ctx.GuildConfigs.Add((config = new GuildConfig
|
||||||
{
|
{
|
||||||
@@ -122,7 +122,7 @@ namespace NadekoBot.Db
|
|||||||
.ThenInclude(gc => gc.IgnoredChannels)
|
.ThenInclude(gc => gc.IgnoredChannels)
|
||||||
.FirstOrDefault(x => x.GuildId == guildId);
|
.FirstOrDefault(x => x.GuildId == guildId);
|
||||||
|
|
||||||
if (config == null)
|
if (config is null)
|
||||||
{
|
{
|
||||||
ctx.GuildConfigs.Add((config = new GuildConfig
|
ctx.GuildConfigs.Add((config = new GuildConfig
|
||||||
{
|
{
|
||||||
@@ -160,7 +160,7 @@ namespace NadekoBot.Db
|
|||||||
.Include(gc => gc.Permissions)
|
.Include(gc => gc.Permissions)
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
|
|
||||||
if (config == null) // if there is no guildconfig, create new one
|
if (config is null) // if there is no guildconfig, create new one
|
||||||
{
|
{
|
||||||
ctx.GuildConfigs.Add((config = new GuildConfig
|
ctx.GuildConfigs.Add((config = new GuildConfig
|
||||||
{
|
{
|
||||||
@@ -169,7 +169,7 @@ namespace NadekoBot.Db
|
|||||||
}));
|
}));
|
||||||
ctx.SaveChanges();
|
ctx.SaveChanges();
|
||||||
}
|
}
|
||||||
else if (config.Permissions == null || !config.Permissions.Any()) // if no perms, add default ones
|
else if (config.Permissions is null || !config.Permissions.Any()) // if no perms, add default ones
|
||||||
{
|
{
|
||||||
config.Permissions = Permissionv2.GetDefaultPermlist;
|
config.Permissions = Permissionv2.GetDefaultPermlist;
|
||||||
ctx.SaveChanges();
|
ctx.SaveChanges();
|
||||||
@@ -200,7 +200,7 @@ namespace NadekoBot.Db
|
|||||||
{
|
{
|
||||||
var conf = configs.FirstOrDefault(gc => gc.GuildId == id);
|
var conf = configs.FirstOrDefault(gc => gc.GuildId == id);
|
||||||
|
|
||||||
if (conf == null)
|
if (conf is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
conf.CleverbotEnabled = cleverbotEnabled;
|
conf.CleverbotEnabled = cleverbotEnabled;
|
||||||
@@ -216,7 +216,7 @@ namespace NadekoBot.Db
|
|||||||
.Include(x => x.XpSettings)
|
.Include(x => x.XpSettings)
|
||||||
.ThenInclude(x => x.ExclusionList));
|
.ThenInclude(x => x.ExclusionList));
|
||||||
|
|
||||||
if (gc.XpSettings == null)
|
if (gc.XpSettings is null)
|
||||||
gc.XpSettings = new XpSettings();
|
gc.XpSettings = new XpSettings();
|
||||||
|
|
||||||
return gc.XpSettings;
|
return gc.XpSettings;
|
||||||
|
@@ -11,7 +11,7 @@ namespace NadekoBot.Db
|
|||||||
{
|
{
|
||||||
var role = roles.FirstOrDefault(s => s.GuildId == guildId && s.RoleId == roleId);
|
var role = roles.FirstOrDefault(s => s.GuildId == guildId && s.RoleId == roleId);
|
||||||
|
|
||||||
if (role == null)
|
if (role is null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
roles.Remove(role);
|
roles.Remove(role);
|
||||||
|
@@ -13,7 +13,7 @@ namespace NadekoBot.Db
|
|||||||
{
|
{
|
||||||
var usr = ctx.UserXpStats.FirstOrDefault(x => x.UserId == userId && x.GuildId == guildId);
|
var usr = ctx.UserXpStats.FirstOrDefault(x => x.UserId == userId && x.GuildId == guildId);
|
||||||
|
|
||||||
if (usr == null)
|
if (usr is null)
|
||||||
{
|
{
|
||||||
ctx.Add(usr = new UserXpStats()
|
ctx.Add(usr = new UserXpStats()
|
||||||
{
|
{
|
||||||
|
@@ -28,7 +28,7 @@ namespace NadekoBot.Db
|
|||||||
{
|
{
|
||||||
public static WaifuInfo ByWaifuUserId(this DbSet<WaifuInfo> waifus, ulong userId, Func<DbSet<WaifuInfo>, IQueryable<WaifuInfo>> includes = null)
|
public static WaifuInfo ByWaifuUserId(this DbSet<WaifuInfo> waifus, ulong userId, Func<DbSet<WaifuInfo>, IQueryable<WaifuInfo>> includes = null)
|
||||||
{
|
{
|
||||||
if (includes == null)
|
if (includes is null)
|
||||||
{
|
{
|
||||||
return waifus.Include(wi => wi.Waifu)
|
return waifus.Include(wi => wi.Waifu)
|
||||||
.Include(wi => wi.Affinity)
|
.Include(wi => wi.Affinity)
|
||||||
|
@@ -27,7 +27,7 @@ namespace NadekoBot.Db
|
|||||||
.Skip(index)
|
.Skip(index)
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
|
|
||||||
if (warn == null || warn.Forgiven)
|
if (warn is null || warn.Forgiven)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
warn.Forgiven = true;
|
warn.Forgiven = true;
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
//// override object.Equals
|
//// override object.Equals
|
||||||
//public override bool Equals(object obj)
|
//public override bool Equals(object obj)
|
||||||
//{
|
//{
|
||||||
// if (obj == null || GetType() != obj.GetType())
|
// if (obj is null || GetType() != obj.GetType())
|
||||||
// {
|
// {
|
||||||
// return false;
|
// return false;
|
||||||
// }
|
// }
|
||||||
|
@@ -33,7 +33,7 @@ namespace NadekoBot.Core.Services.Database.Models
|
|||||||
|
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (obj == null || GetType() != obj.GetType())
|
if (obj is null || GetType() != obj.GetType())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
// override object.Equals
|
// override object.Equals
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (obj == null || GetType() != obj.GetType())
|
if (obj is null || GetType() != obj.GetType())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
// override object.Equals
|
// override object.Equals
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (obj == null || GetType() != obj.GetType())
|
if (obj is null || GetType() != obj.GetType())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -31,7 +31,7 @@ namespace NadekoBot.Core.Services.Database.Models
|
|||||||
{
|
{
|
||||||
claimer = $"{ claimerUsername }#{Claimer.Discriminator}";
|
claimer = $"{ claimerUsername }#{Claimer.Discriminator}";
|
||||||
}
|
}
|
||||||
if (AffinityId == null)
|
if (AffinityId is null)
|
||||||
{
|
{
|
||||||
status = $"... but {waifuUsername}'s heart is empty";
|
status = $"... but {waifuUsername}'s heart is empty";
|
||||||
}
|
}
|
||||||
@@ -72,7 +72,7 @@ namespace NadekoBot.Core.Services.Database.Models
|
|||||||
{
|
{
|
||||||
claimer = $"{ claimerUsername }#{ClaimerDiscrim}";
|
claimer = $"{ claimerUsername }#{ClaimerDiscrim}";
|
||||||
}
|
}
|
||||||
if (Affinity == null)
|
if (Affinity is null)
|
||||||
{
|
{
|
||||||
status = $"... but {waifuUsername}'s heart is empty";
|
status = $"... but {waifuUsername}'s heart is empty";
|
||||||
}
|
}
|
||||||
|
@@ -28,7 +28,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
public async Task Slowmode(StoopidTime time = null)
|
public async Task Slowmode(StoopidTime time = null)
|
||||||
{
|
{
|
||||||
var seconds = (int?)time?.Time.TotalSeconds ?? 0;
|
var seconds = (int?)time?.Time.TotalSeconds ?? 0;
|
||||||
if (!(time is null) && (time.Time < TimeSpan.FromSeconds(0) || time.Time > TimeSpan.FromHours(6)))
|
if (time is not null && (time.Time < TimeSpan.FromSeconds(0) || time.Time > TimeSpan.FromHours(6)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
@@ -305,13 +305,13 @@ namespace NadekoBot.Modules.Administration
|
|||||||
|
|
||||||
|
|
||||||
var msg = await channel.GetMessageAsync(messageId).ConfigureAwait(false);
|
var msg = await channel.GetMessageAsync(messageId).ConfigureAwait(false);
|
||||||
if (msg == null)
|
if (msg is null)
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync("msg_not_found").ConfigureAwait(false);
|
await ReplyErrorLocalizedAsync("msg_not_found").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (time == null)
|
if (time is null)
|
||||||
{
|
{
|
||||||
await msg.DeleteAsync().ConfigureAwait(false);
|
await msg.DeleteAsync().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
@@ -55,7 +55,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var existing = roles.Select(rid => ctx.Guild.GetRole(rid)).Where(r => !(r is null))
|
var existing = roles.Select(rid => ctx.Guild.GetRole(rid)).Where(r => r is not null)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
if (existing.Count != roles.Count)
|
if (existing.Count != roles.Count)
|
||||||
|
@@ -19,14 +19,14 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
var vch = ((IGuildUser)ctx.User).VoiceChannel;
|
var vch = ((IGuildUser)ctx.User).VoiceChannel;
|
||||||
|
|
||||||
if (vch == null)
|
if (vch is null)
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync("not_in_voice").ConfigureAwait(false);
|
await ReplyErrorLocalizedAsync("not_in_voice").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var id = _service.ToggleGameVoiceChannel(ctx.Guild.Id, vch.Id);
|
var id = _service.ToggleGameVoiceChannel(ctx.Guild.Id, vch.Id);
|
||||||
|
|
||||||
if (id == null)
|
if (id is null)
|
||||||
{
|
{
|
||||||
await ReplyConfirmLocalizedAsync("gvc_disabled").ConfigureAwait(false);
|
await ReplyConfirmLocalizedAsync("gvc_disabled").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
@@ -65,7 +65,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
var str = string.Join("\n", Enum.GetNames(typeof(LogType))
|
var str = string.Join("\n", Enum.GetNames(typeof(LogType))
|
||||||
.Select(x =>
|
.Select(x =>
|
||||||
{
|
{
|
||||||
var val = l == null ? null : GetLogProperty(l, Enum.Parse<LogType>(x));
|
var val = l is null ? null : GetLogProperty(l, Enum.Parse<LogType>(x));
|
||||||
if (val != null)
|
if (val != null)
|
||||||
return $"{Format.Bold(x)} <#{val}>";
|
return $"{Format.Bold(x)} <#{val}>";
|
||||||
return Format.Bold(x);
|
return Format.Bold(x);
|
||||||
|
@@ -59,7 +59,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
|
|
||||||
var msg = await _service.RemovePlayingAsync(index).ConfigureAwait(false);
|
var msg = await _service.RemovePlayingAsync(index).ConfigureAwait(false);
|
||||||
|
|
||||||
if (msg == null)
|
if (msg is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
await ReplyConfirmLocalizedAsync("reprm", msg).ConfigureAwait(false);
|
await ReplyConfirmLocalizedAsync("reprm", msg).ConfigureAwait(false);
|
||||||
|
@@ -113,7 +113,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(punishTime is null))
|
if (punishTime is not null)
|
||||||
{
|
{
|
||||||
if (!_service.IsDurationAllowed(action))
|
if (!_service.IsDurationAllowed(action))
|
||||||
{
|
{
|
||||||
@@ -128,7 +128,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
var stats = await _service.StartAntiRaidAsync(ctx.Guild.Id, userThreshold, seconds,
|
var stats = await _service.StartAntiRaidAsync(ctx.Guild.Id, userThreshold, seconds,
|
||||||
action, time).ConfigureAwait(false);
|
action, time).ConfigureAwait(false);
|
||||||
|
|
||||||
if (stats == null)
|
if (stats is null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -185,7 +185,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
if (messageCount < 2 || messageCount > 10)
|
if (messageCount < 2 || messageCount > 10)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!(timeData is null))
|
if (timeData is not null)
|
||||||
{
|
{
|
||||||
if (!_service.IsDurationAllowed(action))
|
if (!_service.IsDurationAllowed(action))
|
||||||
{
|
{
|
||||||
@@ -244,7 +244,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
.WithValue(GetAntiRaidString(raid).TrimTo(1024))
|
.WithValue(GetAntiRaidString(raid).TrimTo(1024))
|
||||||
.WithIsInline(true));
|
.WithIsInline(true));
|
||||||
|
|
||||||
if (!(alt is null))
|
if (alt is not null)
|
||||||
embed.AddField("Anti-Alt", GetAntiAltString(alt), true);
|
embed.AddField("Anti-Alt", GetAntiAltString(alt), true);
|
||||||
|
|
||||||
await ctx.Channel.EmbedAsync(embed).ConfigureAwait(false);
|
await ctx.Channel.EmbedAsync(embed).ConfigureAwait(false);
|
||||||
|
@@ -32,7 +32,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
var msgs = await ((SocketTextChannel)ctx.Channel).GetMessagesAsync().FlattenAsync().ConfigureAwait(false);
|
var msgs = await ((SocketTextChannel)ctx.Channel).GetMessagesAsync().FlattenAsync().ConfigureAwait(false);
|
||||||
var prev = (IUserMessage)msgs.FirstOrDefault(x => x is IUserMessage && x.Id != ctx.Message.Id);
|
var prev = (IUserMessage)msgs.FirstOrDefault(x => x is IUserMessage && x.Id != ctx.Message.Id);
|
||||||
|
|
||||||
if (prev == null)
|
if (prev is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (input.Length % 2 != 0)
|
if (input.Length % 2 != 0)
|
||||||
@@ -144,7 +144,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
var ch = g.GetTextChannel(rr.ChannelId);
|
var ch = g.GetTextChannel(rr.ChannelId);
|
||||||
IUserMessage msg = null;
|
IUserMessage msg = null;
|
||||||
if (!(ch is null))
|
if (ch is not null)
|
||||||
{
|
{
|
||||||
msg = await ch.GetMessageAsync(rr.MessageId).ConfigureAwait(false) as IUserMessage;
|
msg = await ch.GetMessageAsync(rr.MessageId).ConfigureAwait(false) as IUserMessage;
|
||||||
}
|
}
|
||||||
|
@@ -138,7 +138,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
rolesStr.AppendLine("\t\t\t\t ⟪" + groupNameText + "⟫");
|
rolesStr.AppendLine("\t\t\t\t ⟪" + groupNameText + "⟫");
|
||||||
foreach (var (Model, Role) in kvp.AsEnumerable())
|
foreach (var (Model, Role) in kvp.AsEnumerable())
|
||||||
{
|
{
|
||||||
if (Role == null)
|
if (Role is null)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@@ -58,7 +58,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
await ctx.Channel.EmbedAsync(new EmbedBuilder().WithOkColor()
|
await ctx.Channel.EmbedAsync(new EmbedBuilder().WithOkColor()
|
||||||
.WithTitle(GetText("scadd"))
|
.WithTitle(GetText("scadd"))
|
||||||
.AddField(efb => efb.WithName(GetText("server"))
|
.AddField(efb => efb.WithName(GetText("server"))
|
||||||
.WithValue(cmd.GuildId == null ? $"-" : $"{cmd.GuildName}/{cmd.GuildId}").WithIsInline(true))
|
.WithValue(cmd.GuildId is null ? $"-" : $"{cmd.GuildName}/{cmd.GuildId}").WithIsInline(true))
|
||||||
.AddField(efb => efb.WithName(GetText("channel"))
|
.AddField(efb => efb.WithName(GetText("channel"))
|
||||||
.WithValue($"{cmd.ChannelName}/{cmd.ChannelId}").WithIsInline(true))
|
.WithValue($"{cmd.ChannelName}/{cmd.ChannelId}").WithIsInline(true))
|
||||||
.AddField(efb => efb.WithName(GetText("command_text"))
|
.AddField(efb => efb.WithName(GetText("command_text"))
|
||||||
@@ -419,7 +419,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
.WithDefault(Context)
|
.WithDefault(Context)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
await _bot.SetGameAsync(game == null ? game : rep.Replace(game), type).ConfigureAwait(false);
|
await _bot.SetGameAsync(game is null ? game : rep.Replace(game), type).ConfigureAwait(false);
|
||||||
|
|
||||||
await ReplyConfirmLocalizedAsync("set_game").ConfigureAwait(false);
|
await ReplyConfirmLocalizedAsync("set_game").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
@@ -448,7 +448,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
var sid = ulong.Parse(ids[0]);
|
var sid = ulong.Parse(ids[0]);
|
||||||
var server = _client.Guilds.FirstOrDefault(s => s.Id == sid);
|
var server = _client.Guilds.FirstOrDefault(s => s.Id == sid);
|
||||||
|
|
||||||
if (server == null)
|
if (server is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var rep = new ReplacementBuilder()
|
var rep = new ReplacementBuilder()
|
||||||
@@ -459,7 +459,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
var cid = ulong.Parse(ids[1].Substring(2));
|
var cid = ulong.Parse(ids[1].Substring(2));
|
||||||
var ch = server.TextChannels.FirstOrDefault(c => c.Id == cid);
|
var ch = server.TextChannels.FirstOrDefault(c => c.Id == cid);
|
||||||
if (ch == null)
|
if (ch is null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -477,7 +477,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
var uid = ulong.Parse(ids[1].Substring(2));
|
var uid = ulong.Parse(ids[1].Substring(2));
|
||||||
var user = server.Users.FirstOrDefault(u => u.Id == uid);
|
var user = server.Users.FirstOrDefault(u => u.Id == uid);
|
||||||
if (user == null)
|
if (user is null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -102,7 +102,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
var old = conf.DelMsgOnCmdChannels.FirstOrDefault(x => x.ChannelId == chId);
|
var old = conf.DelMsgOnCmdChannels.FirstOrDefault(x => x.ChannelId == chId);
|
||||||
if (newState == Administration.State.Inherit)
|
if (newState == Administration.State.Inherit)
|
||||||
{
|
{
|
||||||
if (!(old is null))
|
if (old is not null)
|
||||||
{
|
{
|
||||||
conf.DelMsgOnCmdChannels.Remove(old);
|
conf.DelMsgOnCmdChannels.Remove(old);
|
||||||
uow.Remove(old);
|
uow.Remove(old);
|
||||||
|
@@ -53,7 +53,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
{
|
{
|
||||||
var roleIds = savedRoleIds
|
var roleIds = savedRoleIds
|
||||||
.Select(roleId => user.Guild.GetRole(roleId))
|
.Select(roleId => user.Guild.GetRole(roleId))
|
||||||
.Where(x => !(x is null))
|
.Where(x => x is not null)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
if (roleIds.Any())
|
if (roleIds.Any())
|
||||||
|
@@ -101,7 +101,7 @@ DELETE FROM Clubs;";
|
|||||||
.FirstOrDefaultAsyncEF(x => x.Waifu.UserId == userId);
|
.FirstOrDefaultAsyncEF(x => x.Waifu.UserId == userId);
|
||||||
|
|
||||||
// if it exists, delete waifu related things
|
// if it exists, delete waifu related things
|
||||||
if (!(wi is null))
|
if (wi is not null)
|
||||||
{
|
{
|
||||||
// remove updates which have new or old as this waifu
|
// remove updates which have new or old as this waifu
|
||||||
await uow
|
await uow
|
||||||
|
@@ -145,7 +145,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
public async Task<bool> TryBlockLate(DiscordSocketClient client, ICommandContext context, string moduleName,
|
public async Task<bool> TryBlockLate(DiscordSocketClient client, ICommandContext context, string moduleName,
|
||||||
CommandInfo command)
|
CommandInfo command)
|
||||||
{
|
{
|
||||||
if (TryGetOverrides(context.Guild?.Id ?? 0, command.Name, out var perm) && !(perm is null))
|
if (TryGetOverrides(context.Guild?.Id ?? 0, command.Name, out var perm) && perm is not null)
|
||||||
{
|
{
|
||||||
var result = await new RequireUserPermissionAttribute((GuildPermission) perm)
|
var result = await new RequireUserPermissionAttribute((GuildPermission) perm)
|
||||||
.CheckPermissionsAsync(context, command, _services);
|
.CheckPermissionsAsync(context, command, _services);
|
||||||
|
@@ -38,7 +38,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
{
|
{
|
||||||
//if the user is in the voice channel and that voice channel is gvc
|
//if the user is in the voice channel and that voice channel is gvc
|
||||||
var vc = after.VoiceChannel;
|
var vc = after.VoiceChannel;
|
||||||
if (vc == null || !GameVoiceChannels.Contains(vc.Id))
|
if (vc is null || !GameVoiceChannels.Contains(vc.Id))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//if the activity has changed, and is a playing activity
|
//if the activity has changed, and is a playing activity
|
||||||
@@ -96,7 +96,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
var game = gUser.Activity?.Name;
|
var game = gUser.Activity?.Name;
|
||||||
|
|
||||||
if (oldState.VoiceChannel == newState.VoiceChannel ||
|
if (oldState.VoiceChannel == newState.VoiceChannel ||
|
||||||
newState.VoiceChannel == null)
|
newState.VoiceChannel is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!GameVoiceChannels.Contains(newState.VoiceChannel.Id) ||
|
if (!GameVoiceChannels.Contains(newState.VoiceChannel.Id) ||
|
||||||
@@ -123,7 +123,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
var vch = gUser.Guild.VoiceChannels
|
var vch = gUser.Guild.VoiceChannels
|
||||||
.FirstOrDefault(x => x.Name.ToLowerInvariant() == game);
|
.FirstOrDefault(x => x.Name.ToLowerInvariant() == game);
|
||||||
|
|
||||||
if (vch == null)
|
if (vch is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
await Task.Delay(1000).ConfigureAwait(false);
|
await Task.Delay(1000).ConfigureAwait(false);
|
||||||
|
@@ -45,7 +45,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
TimeZoneInfo tz;
|
TimeZoneInfo tz;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (x.TimeZoneId == null)
|
if (x.TimeZoneId is null)
|
||||||
tz = null;
|
tz = null;
|
||||||
else
|
else
|
||||||
tz = TimeZoneInfo.FindSystemTimeZoneById(x.TimeZoneId);
|
tz = TimeZoneInfo.FindSystemTimeZoneById(x.TimeZoneId);
|
||||||
@@ -73,7 +73,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
gc.TimeZoneId = tz?.Id;
|
gc.TimeZoneId = tz?.Id;
|
||||||
uow.SaveChanges();
|
uow.SaveChanges();
|
||||||
|
|
||||||
if (tz == null)
|
if (tz is null)
|
||||||
_timezones.TryRemove(guildId, out tz);
|
_timezones.TryRemove(guildId, out tz);
|
||||||
else
|
else
|
||||||
_timezones.AddOrUpdate(guildId, tz, (key, old) => tz);
|
_timezones.AddOrUpdate(guildId, tz, (key, old) => tz);
|
||||||
|
@@ -203,12 +203,12 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
var g = after.Guild;
|
var g = after.Guild;
|
||||||
|
|
||||||
if (!GuildLogSettings.TryGetValue(g.Id, out LogSetting logSetting)
|
if (!GuildLogSettings.TryGetValue(g.Id, out LogSetting logSetting)
|
||||||
|| (logSetting.UserUpdatedId == null))
|
|| (logSetting.UserUpdatedId is null))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ITextChannel logChannel;
|
ITextChannel logChannel;
|
||||||
if ((logChannel =
|
if ((logChannel =
|
||||||
await TryGetLogChannel(g, logSetting, LogType.UserUpdated).ConfigureAwait(false)) == null)
|
await TryGetLogChannel(g, logSetting, LogType.UserUpdated).ConfigureAwait(false)) is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var embed = new EmbedBuilder();
|
var embed = new EmbedBuilder();
|
||||||
@@ -262,54 +262,54 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case LogType.Other:
|
case LogType.Other:
|
||||||
channelId = logSetting.LogOtherId = (logSetting.LogOtherId == null ? cid : default);
|
channelId = logSetting.LogOtherId = (logSetting.LogOtherId is null ? cid : default);
|
||||||
break;
|
break;
|
||||||
case LogType.MessageUpdated:
|
case LogType.MessageUpdated:
|
||||||
channelId = logSetting.MessageUpdatedId = (logSetting.MessageUpdatedId == null ? cid : default);
|
channelId = logSetting.MessageUpdatedId = (logSetting.MessageUpdatedId is null ? cid : default);
|
||||||
break;
|
break;
|
||||||
case LogType.MessageDeleted:
|
case LogType.MessageDeleted:
|
||||||
channelId = logSetting.MessageDeletedId = (logSetting.MessageDeletedId == null ? cid : default);
|
channelId = logSetting.MessageDeletedId = (logSetting.MessageDeletedId is null ? cid : default);
|
||||||
//logSetting.DontLogBotMessageDeleted = (options == "nobot");
|
//logSetting.DontLogBotMessageDeleted = (options == "nobot");
|
||||||
break;
|
break;
|
||||||
case LogType.UserJoined:
|
case LogType.UserJoined:
|
||||||
channelId = logSetting.UserJoinedId = (logSetting.UserJoinedId == null ? cid : default);
|
channelId = logSetting.UserJoinedId = (logSetting.UserJoinedId is null ? cid : default);
|
||||||
break;
|
break;
|
||||||
case LogType.UserLeft:
|
case LogType.UserLeft:
|
||||||
channelId = logSetting.UserLeftId = (logSetting.UserLeftId == null ? cid : default);
|
channelId = logSetting.UserLeftId = (logSetting.UserLeftId is null ? cid : default);
|
||||||
break;
|
break;
|
||||||
case LogType.UserBanned:
|
case LogType.UserBanned:
|
||||||
channelId = logSetting.UserBannedId = (logSetting.UserBannedId == null ? cid : default);
|
channelId = logSetting.UserBannedId = (logSetting.UserBannedId is null ? cid : default);
|
||||||
break;
|
break;
|
||||||
case LogType.UserUnbanned:
|
case LogType.UserUnbanned:
|
||||||
channelId = logSetting.UserUnbannedId = (logSetting.UserUnbannedId == null ? cid : default);
|
channelId = logSetting.UserUnbannedId = (logSetting.UserUnbannedId is null ? cid : default);
|
||||||
break;
|
break;
|
||||||
case LogType.UserUpdated:
|
case LogType.UserUpdated:
|
||||||
channelId = logSetting.UserUpdatedId = (logSetting.UserUpdatedId == null ? cid : default);
|
channelId = logSetting.UserUpdatedId = (logSetting.UserUpdatedId is null ? cid : default);
|
||||||
break;
|
break;
|
||||||
case LogType.UserMuted:
|
case LogType.UserMuted:
|
||||||
channelId = logSetting.UserMutedId = (logSetting.UserMutedId == null ? cid : default);
|
channelId = logSetting.UserMutedId = (logSetting.UserMutedId is null ? cid : default);
|
||||||
break;
|
break;
|
||||||
case LogType.ChannelCreated:
|
case LogType.ChannelCreated:
|
||||||
channelId = logSetting.ChannelCreatedId = (logSetting.ChannelCreatedId == null ? cid : default);
|
channelId = logSetting.ChannelCreatedId = (logSetting.ChannelCreatedId is null ? cid : default);
|
||||||
break;
|
break;
|
||||||
case LogType.ChannelDestroyed:
|
case LogType.ChannelDestroyed:
|
||||||
channelId = logSetting.ChannelDestroyedId =
|
channelId = logSetting.ChannelDestroyedId =
|
||||||
(logSetting.ChannelDestroyedId == null ? cid : default);
|
(logSetting.ChannelDestroyedId is null ? cid : default);
|
||||||
break;
|
break;
|
||||||
case LogType.ChannelUpdated:
|
case LogType.ChannelUpdated:
|
||||||
channelId = logSetting.ChannelUpdatedId = (logSetting.ChannelUpdatedId == null ? cid : default);
|
channelId = logSetting.ChannelUpdatedId = (logSetting.ChannelUpdatedId is null ? cid : default);
|
||||||
break;
|
break;
|
||||||
case LogType.UserPresence:
|
case LogType.UserPresence:
|
||||||
channelId = logSetting.LogUserPresenceId =
|
channelId = logSetting.LogUserPresenceId =
|
||||||
(logSetting.LogUserPresenceId == null ? cid : default);
|
(logSetting.LogUserPresenceId is null ? cid : default);
|
||||||
break;
|
break;
|
||||||
case LogType.VoicePresence:
|
case LogType.VoicePresence:
|
||||||
channelId = logSetting.LogVoicePresenceId =
|
channelId = logSetting.LogVoicePresenceId =
|
||||||
(logSetting.LogVoicePresenceId == null ? cid : default);
|
(logSetting.LogVoicePresenceId is null ? cid : default);
|
||||||
break;
|
break;
|
||||||
case LogType.VoicePresenceTTS:
|
case LogType.VoicePresenceTTS:
|
||||||
channelId = logSetting.LogVoicePresenceTTSId =
|
channelId = logSetting.LogVoicePresenceTTSId =
|
||||||
(logSetting.LogVoicePresenceTTSId == null ? cid : default);
|
(logSetting.LogVoicePresenceTTSId is null ? cid : default);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -335,12 +335,12 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out LogSetting logSetting)
|
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out LogSetting logSetting)
|
||||||
|| (logSetting.LogVoicePresenceTTSId == null))
|
|| (logSetting.LogVoicePresenceTTSId is null))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ITextChannel logChannel;
|
ITextChannel logChannel;
|
||||||
if ((logChannel = await TryGetLogChannel(usr.Guild, logSetting, LogType.VoicePresenceTTS)
|
if ((logChannel = await TryGetLogChannel(usr.Guild, logSetting, LogType.VoicePresenceTTS)
|
||||||
.ConfigureAwait(false)) == null)
|
.ConfigureAwait(false)) is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var str = "";
|
var str = "";
|
||||||
@@ -348,11 +348,11 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
{
|
{
|
||||||
str = GetText(logChannel.Guild, "log_vc_moved", usr.Username, beforeVch?.Name, afterVch?.Name);
|
str = GetText(logChannel.Guild, "log_vc_moved", usr.Username, beforeVch?.Name, afterVch?.Name);
|
||||||
}
|
}
|
||||||
else if (beforeVch == null)
|
else if (beforeVch is null)
|
||||||
{
|
{
|
||||||
str = GetText(logChannel.Guild, "log_vc_joined", usr.Username, afterVch.Name);
|
str = GetText(logChannel.Guild, "log_vc_joined", usr.Username, afterVch.Name);
|
||||||
}
|
}
|
||||||
else if (afterVch == null)
|
else if (afterVch is null)
|
||||||
{
|
{
|
||||||
str = GetText(logChannel.Guild, "log_vc_left", usr.Username, beforeVch.Name);
|
str = GetText(logChannel.Guild, "log_vc_left", usr.Username, beforeVch.Name);
|
||||||
}
|
}
|
||||||
@@ -375,12 +375,12 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out LogSetting logSetting)
|
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out LogSetting logSetting)
|
||||||
|| (logSetting.UserMutedId == null))
|
|| (logSetting.UserMutedId is null))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ITextChannel logChannel;
|
ITextChannel logChannel;
|
||||||
if ((logChannel = await TryGetLogChannel(usr.Guild, logSetting, LogType.UserMuted)
|
if ((logChannel = await TryGetLogChannel(usr.Guild, logSetting, LogType.UserMuted)
|
||||||
.ConfigureAwait(false)) == null)
|
.ConfigureAwait(false)) is null)
|
||||||
return;
|
return;
|
||||||
var mutes = "";
|
var mutes = "";
|
||||||
var mutedLocalized = GetText(logChannel.Guild, "muted_sn");
|
var mutedLocalized = GetText(logChannel.Guild, "muted_sn");
|
||||||
@@ -419,12 +419,12 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out LogSetting logSetting)
|
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out LogSetting logSetting)
|
||||||
|| (logSetting.UserMutedId == null))
|
|| (logSetting.UserMutedId is null))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ITextChannel logChannel;
|
ITextChannel logChannel;
|
||||||
if ((logChannel = await TryGetLogChannel(usr.Guild, logSetting, LogType.UserMuted)
|
if ((logChannel = await TryGetLogChannel(usr.Guild, logSetting, LogType.UserMuted)
|
||||||
.ConfigureAwait(false)) == null)
|
.ConfigureAwait(false)) is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var mutes = "";
|
var mutes = "";
|
||||||
@@ -471,11 +471,11 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (!GuildLogSettings.TryGetValue(users.First().Guild.Id, out LogSetting logSetting)
|
if (!GuildLogSettings.TryGetValue(users.First().Guild.Id, out LogSetting logSetting)
|
||||||
|| (logSetting.LogOtherId == null))
|
|| (logSetting.LogOtherId is null))
|
||||||
return;
|
return;
|
||||||
ITextChannel logChannel;
|
ITextChannel logChannel;
|
||||||
if ((logChannel = await TryGetLogChannel(users.First().Guild, logSetting, LogType.Other)
|
if ((logChannel = await TryGetLogChannel(users.First().Guild, logSetting, LogType.Other)
|
||||||
.ConfigureAwait(false)) == null)
|
.ConfigureAwait(false)) is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var punishment = "";
|
var punishment = "";
|
||||||
@@ -642,13 +642,13 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
var after = (IGuildChannel) cafter;
|
var after = (IGuildChannel) cafter;
|
||||||
|
|
||||||
if (!GuildLogSettings.TryGetValue(before.Guild.Id, out LogSetting logSetting)
|
if (!GuildLogSettings.TryGetValue(before.Guild.Id, out LogSetting logSetting)
|
||||||
|| (logSetting.ChannelUpdatedId == null)
|
|| (logSetting.ChannelUpdatedId is null)
|
||||||
|| logSetting.IgnoredChannels.Any(ilc => ilc.ChannelId == after.Id))
|
|| logSetting.IgnoredChannels.Any(ilc => ilc.ChannelId == after.Id))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ITextChannel logChannel;
|
ITextChannel logChannel;
|
||||||
if ((logChannel = await TryGetLogChannel(before.Guild, logSetting, LogType.ChannelUpdated)
|
if ((logChannel = await TryGetLogChannel(before.Guild, logSetting, LogType.ChannelUpdated)
|
||||||
.ConfigureAwait(false)) == null)
|
.ConfigureAwait(false)) is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var embed = new EmbedBuilder().WithOkColor()
|
var embed = new EmbedBuilder().WithOkColor()
|
||||||
@@ -698,13 +698,13 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (!GuildLogSettings.TryGetValue(ch.Guild.Id, out LogSetting logSetting)
|
if (!GuildLogSettings.TryGetValue(ch.Guild.Id, out LogSetting logSetting)
|
||||||
|| (logSetting.ChannelDestroyedId == null)
|
|| (logSetting.ChannelDestroyedId is null)
|
||||||
|| logSetting.IgnoredChannels.Any(ilc => ilc.ChannelId == ch.Id))
|
|| logSetting.IgnoredChannels.Any(ilc => ilc.ChannelId == ch.Id))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ITextChannel logChannel;
|
ITextChannel logChannel;
|
||||||
if ((logChannel = await TryGetLogChannel(ch.Guild, logSetting, LogType.ChannelDestroyed)
|
if ((logChannel = await TryGetLogChannel(ch.Guild, logSetting, LogType.ChannelDestroyed)
|
||||||
.ConfigureAwait(false)) == null)
|
.ConfigureAwait(false)) is null)
|
||||||
return;
|
return;
|
||||||
string title;
|
string title;
|
||||||
if (ch is IVoiceChannel)
|
if (ch is IVoiceChannel)
|
||||||
@@ -738,12 +738,12 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (!GuildLogSettings.TryGetValue(ch.Guild.Id, out LogSetting logSetting)
|
if (!GuildLogSettings.TryGetValue(ch.Guild.Id, out LogSetting logSetting)
|
||||||
|| (logSetting.ChannelCreatedId == null))
|
|| (logSetting.ChannelCreatedId is null))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ITextChannel logChannel;
|
ITextChannel logChannel;
|
||||||
if ((logChannel = await TryGetLogChannel(ch.Guild, logSetting, LogType.ChannelCreated)
|
if ((logChannel = await TryGetLogChannel(ch.Guild, logSetting, LogType.ChannelCreated)
|
||||||
.ConfigureAwait(false)) == null)
|
.ConfigureAwait(false)) is null)
|
||||||
return;
|
return;
|
||||||
string title;
|
string title;
|
||||||
if (ch is IVoiceChannel)
|
if (ch is IVoiceChannel)
|
||||||
@@ -783,12 +783,12 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out LogSetting logSetting)
|
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out LogSetting logSetting)
|
||||||
|| (logSetting.LogVoicePresenceId == null))
|
|| (logSetting.LogVoicePresenceId is null))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ITextChannel logChannel;
|
ITextChannel logChannel;
|
||||||
if ((logChannel = await TryGetLogChannel(usr.Guild, logSetting, LogType.VoicePresence)
|
if ((logChannel = await TryGetLogChannel(usr.Guild, logSetting, LogType.VoicePresence)
|
||||||
.ConfigureAwait(false)) == null)
|
.ConfigureAwait(false)) is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string str = null;
|
string str = null;
|
||||||
@@ -799,14 +799,14 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
"👤" + Format.Bold(usr.Username + "#" + usr.Discriminator),
|
"👤" + Format.Bold(usr.Username + "#" + usr.Discriminator),
|
||||||
Format.Bold(beforeVch?.Name ?? ""), Format.Bold(afterVch?.Name ?? ""));
|
Format.Bold(beforeVch?.Name ?? ""), Format.Bold(afterVch?.Name ?? ""));
|
||||||
}
|
}
|
||||||
else if (beforeVch == null)
|
else if (beforeVch is null)
|
||||||
{
|
{
|
||||||
str = "🎙" + Format.Code(PrettyCurrentTime(usr.Guild)) + GetText(logChannel.Guild,
|
str = "🎙" + Format.Code(PrettyCurrentTime(usr.Guild)) + GetText(logChannel.Guild,
|
||||||
"user_vjoined",
|
"user_vjoined",
|
||||||
"👤" + Format.Bold(usr.Username + "#" + usr.Discriminator),
|
"👤" + Format.Bold(usr.Username + "#" + usr.Discriminator),
|
||||||
Format.Bold(afterVch.Name ?? ""));
|
Format.Bold(afterVch.Name ?? ""));
|
||||||
}
|
}
|
||||||
else if (afterVch == null)
|
else if (afterVch is null)
|
||||||
{
|
{
|
||||||
str = "🎙" + Format.Code(PrettyCurrentTime(usr.Guild)) + GetText(logChannel.Guild, "user_vleft",
|
str = "🎙" + Format.Code(PrettyCurrentTime(usr.Guild)) + GetText(logChannel.Guild, "user_vleft",
|
||||||
"👤" + Format.Bold(usr.Username + "#" + usr.Discriminator),
|
"👤" + Format.Bold(usr.Username + "#" + usr.Discriminator),
|
||||||
@@ -836,16 +836,16 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
// {
|
// {
|
||||||
// var guild = optGuild.GetValueOrDefault() ?? (usr as SocketGuildUser)?.Guild;
|
// var guild = optGuild.GetValueOrDefault() ?? (usr as SocketGuildUser)?.Guild;
|
||||||
|
|
||||||
// if (guild == null)
|
// if (guild is null)
|
||||||
// return;
|
// return;
|
||||||
|
|
||||||
// if (!GuildLogSettings.TryGetValue(guild.Id, out LogSetting logSetting)
|
// if (!GuildLogSettings.TryGetValue(guild.Id, out LogSetting logSetting)
|
||||||
// || (logSetting.LogUserPresenceId == null)
|
// || (logSetting.LogUserPresenceId is null)
|
||||||
// || before.Status == after.Status)
|
// || before.Status == after.Status)
|
||||||
// return;
|
// return;
|
||||||
|
|
||||||
// ITextChannel logChannel;
|
// ITextChannel logChannel;
|
||||||
// if ((logChannel = await TryGetLogChannel(guild, logSetting, LogType.UserPresence)) == null)
|
// if ((logChannel = await TryGetLogChannel(guild, logSetting, LogType.UserPresence)) is null)
|
||||||
// return;
|
// return;
|
||||||
// string str = "";
|
// string str = "";
|
||||||
// if (before.Status != after.Status)
|
// if (before.Status != after.Status)
|
||||||
@@ -878,12 +878,12 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out LogSetting logSetting)
|
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out LogSetting logSetting)
|
||||||
|| (logSetting.UserLeftId == null))
|
|| (logSetting.UserLeftId is null))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ITextChannel logChannel;
|
ITextChannel logChannel;
|
||||||
if ((logChannel = await TryGetLogChannel(usr.Guild, logSetting, LogType.UserLeft)
|
if ((logChannel = await TryGetLogChannel(usr.Guild, logSetting, LogType.UserLeft)
|
||||||
.ConfigureAwait(false)) == null)
|
.ConfigureAwait(false)) is null)
|
||||||
return;
|
return;
|
||||||
var embed = new EmbedBuilder()
|
var embed = new EmbedBuilder()
|
||||||
.WithOkColor()
|
.WithOkColor()
|
||||||
@@ -912,12 +912,12 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out LogSetting logSetting)
|
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out LogSetting logSetting)
|
||||||
|| (logSetting.UserJoinedId == null))
|
|| (logSetting.UserJoinedId is null))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ITextChannel logChannel;
|
ITextChannel logChannel;
|
||||||
if ((logChannel = await TryGetLogChannel(usr.Guild, logSetting, LogType.UserJoined)
|
if ((logChannel = await TryGetLogChannel(usr.Guild, logSetting, LogType.UserJoined)
|
||||||
.ConfigureAwait(false)) == null)
|
.ConfigureAwait(false)) is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var embed = new EmbedBuilder()
|
var embed = new EmbedBuilder()
|
||||||
@@ -953,12 +953,12 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!GuildLogSettings.TryGetValue(guild.Id, out LogSetting logSetting)
|
if (!GuildLogSettings.TryGetValue(guild.Id, out LogSetting logSetting)
|
||||||
|| (logSetting.UserUnbannedId == null))
|
|| (logSetting.UserUnbannedId is null))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ITextChannel logChannel;
|
ITextChannel logChannel;
|
||||||
if ((logChannel = await TryGetLogChannel(guild, logSetting, LogType.UserUnbanned)
|
if ((logChannel = await TryGetLogChannel(guild, logSetting, LogType.UserUnbanned)
|
||||||
.ConfigureAwait(false)) == null)
|
.ConfigureAwait(false)) is null)
|
||||||
return;
|
return;
|
||||||
var embed = new EmbedBuilder()
|
var embed = new EmbedBuilder()
|
||||||
.WithOkColor()
|
.WithOkColor()
|
||||||
@@ -987,7 +987,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!GuildLogSettings.TryGetValue(guild.Id, out LogSetting logSetting)
|
if (!GuildLogSettings.TryGetValue(guild.Id, out LogSetting logSetting)
|
||||||
|| (logSetting.UserBannedId == null))
|
|| (logSetting.UserBannedId is null))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ITextChannel logChannel;
|
ITextChannel logChannel;
|
||||||
@@ -1024,7 +1024,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var msg = (optMsg.HasValue ? optMsg.Value : null) as IUserMessage;
|
var msg = (optMsg.HasValue ? optMsg.Value : null) as IUserMessage;
|
||||||
if (msg == null || msg.IsAuthor(_client))
|
if (msg is null || msg.IsAuthor(_client))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_ignoreMessageIds.Contains(msg.Id))
|
if (_ignoreMessageIds.Contains(msg.Id))
|
||||||
@@ -1034,13 +1034,13 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (!GuildLogSettings.TryGetValue(channel.Guild.Id, out LogSetting logSetting)
|
if (!GuildLogSettings.TryGetValue(channel.Guild.Id, out LogSetting logSetting)
|
||||||
|| (logSetting.MessageDeletedId == null)
|
|| (logSetting.MessageDeletedId is null)
|
||||||
|| logSetting.IgnoredChannels.Any(ilc => ilc.ChannelId == channel.Id))
|
|| logSetting.IgnoredChannels.Any(ilc => ilc.ChannelId == channel.Id))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ITextChannel logChannel;
|
ITextChannel logChannel;
|
||||||
if ((logChannel = await TryGetLogChannel(channel.Guild, logSetting, LogType.MessageDeleted)
|
if ((logChannel = await TryGetLogChannel(channel.Guild, logSetting, LogType.MessageDeleted)
|
||||||
.ConfigureAwait(false)) == null || logChannel.Id == msg.Id)
|
.ConfigureAwait(false)) is null || logChannel.Id == msg.Id)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var resolvedMessage = msg.Resolve(userHandling: TagHandling.FullName);
|
var resolvedMessage = msg.Resolve(userHandling: TagHandling.FullName);
|
||||||
@@ -1080,7 +1080,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var before = (optmsg.HasValue ? optmsg.Value : null) as IUserMessage;
|
var before = (optmsg.HasValue ? optmsg.Value : null) as IUserMessage;
|
||||||
if (before == null)
|
if (before is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!(ch is ITextChannel channel))
|
if (!(ch is ITextChannel channel))
|
||||||
@@ -1093,13 +1093,13 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (!GuildLogSettings.TryGetValue(channel.Guild.Id, out LogSetting logSetting)
|
if (!GuildLogSettings.TryGetValue(channel.Guild.Id, out LogSetting logSetting)
|
||||||
|| (logSetting.MessageUpdatedId == null)
|
|| (logSetting.MessageUpdatedId is null)
|
||||||
|| logSetting.IgnoredChannels.Any(ilc => ilc.ChannelId == channel.Id))
|
|| logSetting.IgnoredChannels.Any(ilc => ilc.ChannelId == channel.Id))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ITextChannel logChannel;
|
ITextChannel logChannel;
|
||||||
if ((logChannel = await TryGetLogChannel(channel.Guild, logSetting, LogType.MessageUpdated)
|
if ((logChannel = await TryGetLogChannel(channel.Guild, logSetting, LogType.MessageUpdated)
|
||||||
.ConfigureAwait(false)) == null || logChannel.Id == after.Channel.Id)
|
.ConfigureAwait(false)) is null || logChannel.Id == after.Channel.Id)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var embed = new EmbedBuilder()
|
var embed = new EmbedBuilder()
|
||||||
@@ -1208,7 +1208,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
|
|
||||||
var channel = await guild.GetTextChannelAsync(id.Value).ConfigureAwait(false);
|
var channel = await guild.GetTextChannelAsync(id.Value).ConfigureAwait(false);
|
||||||
|
|
||||||
if (channel == null)
|
if (channel is null)
|
||||||
{
|
{
|
||||||
UnsetLogSetting(guild.Id, logChannelType);
|
UnsetLogSetting(guild.Id, logChannelType);
|
||||||
return null;
|
return null;
|
||||||
|
@@ -159,7 +159,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
{
|
{
|
||||||
MutedUsers.TryGetValue(usr.Guild.Id, out ConcurrentHashSet<ulong> muted);
|
MutedUsers.TryGetValue(usr.Guild.Id, out ConcurrentHashSet<ulong> muted);
|
||||||
|
|
||||||
if (muted == null || !muted.Contains(usr.Id))
|
if (muted is null || !muted.Contains(usr.Id))
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
var _ = Task.Run(() => MuteUser(usr, _client.CurrentUser, reason: "Sticky mute").ConfigureAwait(false));
|
var _ = Task.Run(() => MuteUser(usr, _client.CurrentUser, reason: "Sticky mute").ConfigureAwait(false));
|
||||||
}
|
}
|
||||||
@@ -259,7 +259,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
}
|
}
|
||||||
else if (type == MuteType.Voice)
|
else if (type == MuteType.Voice)
|
||||||
{
|
{
|
||||||
if (usr == null)
|
if (usr is null)
|
||||||
return;
|
return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -270,7 +270,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
}
|
}
|
||||||
else if (type == MuteType.Chat)
|
else if (type == MuteType.Chat)
|
||||||
{
|
{
|
||||||
if (usr == null)
|
if (usr is null)
|
||||||
return;
|
return;
|
||||||
await usr.RemoveRoleAsync(await GetMuteRole(usr.Guild).ConfigureAwait(false)).ConfigureAwait(false);
|
await usr.RemoveRoleAsync(await GetMuteRole(usr.Guild).ConfigureAwait(false)).ConfigureAwait(false);
|
||||||
UserUnmuted(usr, mod, MuteType.Chat, reason);
|
UserUnmuted(usr, mod, MuteType.Chat, reason);
|
||||||
@@ -279,7 +279,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
|
|
||||||
public async Task<IRole> GetMuteRole(IGuild guild)
|
public async Task<IRole> GetMuteRole(IGuild guild)
|
||||||
{
|
{
|
||||||
if (guild == null)
|
if (guild is null)
|
||||||
throw new ArgumentNullException(nameof(guild));
|
throw new ArgumentNullException(nameof(guild));
|
||||||
|
|
||||||
const string defaultMuteRoleName = "nadeko-mute";
|
const string defaultMuteRoleName = "nadeko-mute";
|
||||||
@@ -287,7 +287,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
var muteRoleName = GuildMuteRoles.GetOrAdd(guild.Id, defaultMuteRoleName);
|
var muteRoleName = GuildMuteRoles.GetOrAdd(guild.Id, defaultMuteRoleName);
|
||||||
|
|
||||||
var muteRole = guild.Roles.FirstOrDefault(r => r.Name == muteRoleName);
|
var muteRole = guild.Roles.FirstOrDefault(r => r.Name == muteRoleName);
|
||||||
if (muteRole == null)
|
if (muteRole is null)
|
||||||
{
|
{
|
||||||
|
|
||||||
//if it doesn't exist, create it
|
//if it doesn't exist, create it
|
||||||
|
@@ -141,7 +141,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
_antiSpamGuilds[gc.GuildId] = new AntiSpamStats() { AntiSpamSettings = spam };
|
_antiSpamGuilds[gc.GuildId] = new AntiSpamStats() { AntiSpamSettings = spam };
|
||||||
|
|
||||||
var alt = gc.AntiAltSetting;
|
var alt = gc.AntiAltSetting;
|
||||||
if (!(alt is null))
|
if (alt is not null)
|
||||||
_antiAltGuilds[gc.GuildId] = new AntiAltStats(alt);
|
_antiAltGuilds[gc.GuildId] = new AntiAltStats(alt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -53,7 +53,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
|
|
||||||
var conf = confs.FirstOrDefault(x => x.MessageId == msg.Id);
|
var conf = confs.FirstOrDefault(x => x.MessageId == msg.Id);
|
||||||
|
|
||||||
if (conf == null)
|
if (conf is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// compare emote names for backwards compatibility :facepalm:
|
// compare emote names for backwards compatibility :facepalm:
|
||||||
@@ -129,7 +129,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
|
|
||||||
var conf = confs.FirstOrDefault(x => x.MessageId == msg.Id);
|
var conf = confs.FirstOrDefault(x => x.MessageId == msg.Id);
|
||||||
|
|
||||||
if (conf == null)
|
if (conf is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var reactionRole = conf.ReactionRoles.FirstOrDefault(x => x.EmoteName == reaction.Emote.Name || x.EmoteName == reaction.Emote.ToString());
|
var reactionRole = conf.ReactionRoles.FirstOrDefault(x => x.EmoteName == reaction.Emote.Name || x.EmoteName == reaction.Emote.ToString());
|
||||||
@@ -137,7 +137,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
if (reactionRole != null)
|
if (reactionRole != null)
|
||||||
{
|
{
|
||||||
var role = gusr.Guild.GetRole(reactionRole.RoleId);
|
var role = gusr.Guild.GetRole(reactionRole.RoleId);
|
||||||
if (role == null)
|
if (role is null)
|
||||||
return;
|
return;
|
||||||
await gusr.RemoveRoleAsync(role).ConfigureAwait(false);
|
await gusr.RemoveRoleAsync(role).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
@@ -82,7 +82,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
var (autoDelete, exclusive, roles) = GetAdAndRoles(guildUser.Guild.Id);
|
var (autoDelete, exclusive, roles) = GetAdAndRoles(guildUser.Guild.Id);
|
||||||
|
|
||||||
var theRoleYouWant = roles.FirstOrDefault(r => r.RoleId == role.Id);
|
var theRoleYouWant = roles.FirstOrDefault(r => r.RoleId == role.Id);
|
||||||
if (theRoleYouWant == null)
|
if (theRoleYouWant is null)
|
||||||
{
|
{
|
||||||
return (AssignResult.Err_Not_Assignable, autoDelete, null);
|
return (AssignResult.Err_Not_Assignable, autoDelete, null);
|
||||||
}
|
}
|
||||||
@@ -145,7 +145,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
if (toUpdate != null)
|
if (toUpdate != null)
|
||||||
gc.SelfAssignableRoleGroupNames.Remove(toUpdate);
|
gc.SelfAssignableRoleGroupNames.Remove(toUpdate);
|
||||||
}
|
}
|
||||||
else if (toUpdate == null)
|
else if (toUpdate is null)
|
||||||
{
|
{
|
||||||
gc.SelfAssignableRoleGroupNames.Add(new GroupName
|
gc.SelfAssignableRoleGroupNames.Add(new GroupName
|
||||||
{
|
{
|
||||||
@@ -170,7 +170,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
{
|
{
|
||||||
var (autoDelete, _, roles) = GetAdAndRoles(guildUser.Guild.Id);
|
var (autoDelete, _, roles) = GetAdAndRoles(guildUser.Guild.Id);
|
||||||
|
|
||||||
if (roles.FirstOrDefault(r => r.RoleId == role.Id) == null)
|
if (roles.FirstOrDefault(r => r.RoleId == role.Id) is null)
|
||||||
{
|
{
|
||||||
return (RemoveResult.Err_Not_Assignable, autoDelete);
|
return (RemoveResult.Err_Not_Assignable, autoDelete);
|
||||||
}
|
}
|
||||||
@@ -261,7 +261,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
var roleModels = uow.SelfAssignableRoles.GetFromGuild(guild.Id);
|
var roleModels = uow.SelfAssignableRoles.GetFromGuild(guild.Id);
|
||||||
roles = roleModels
|
roles = roleModels
|
||||||
.Select(x => (Model: x, Role: guild.GetRole(x.RoleId)));
|
.Select(x => (Model: x, Role: guild.GetRole(x.RoleId)));
|
||||||
uow.SelfAssignableRoles.RemoveRange(roles.Where(x => x.Role == null).Select(x => x.Model).ToArray());
|
uow.SelfAssignableRoles.RemoveRange(roles.Where(x => x.Role is null).Select(x => x.Model).ToArray());
|
||||||
uow.SaveChanges();
|
uow.SaveChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -74,7 +74,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
var server = _client.Guilds.FirstOrDefault(g => g.Id.ToString() == guildStr) ??
|
var server = _client.Guilds.FirstOrDefault(g => g.Id.ToString() == guildStr) ??
|
||||||
_client.Guilds.FirstOrDefault(g => g.Name.Trim().ToUpperInvariant() == guildStr);
|
_client.Guilds.FirstOrDefault(g => g.Name.Trim().ToUpperInvariant() == guildStr);
|
||||||
|
|
||||||
if (server == null)
|
if (server is null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -205,7 +205,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
var channels = await Task.WhenAll(_creds.OwnerIds.Select(id =>
|
var channels = await Task.WhenAll(_creds.OwnerIds.Select(id =>
|
||||||
{
|
{
|
||||||
var user = _client.GetUser(id);
|
var user = _client.GetUser(id);
|
||||||
if (user == null)
|
if (user is null)
|
||||||
return Task.FromResult<IDMChannel>(null);
|
return Task.FromResult<IDMChannel>(null);
|
||||||
|
|
||||||
return user.GetOrCreateDMChannelAsync();
|
return user.GetOrCreateDMChannelAsync();
|
||||||
|
@@ -80,7 +80,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
if (p != null)
|
if (p != null)
|
||||||
{
|
{
|
||||||
var user = await guild.GetUserAsync(userId).ConfigureAwait(false);
|
var user = await guild.GetUserAsync(userId).ConfigureAwait(false);
|
||||||
if (user == null)
|
if (user is null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
await ApplyPunishment(guild, user, mod, p.Punishment, p.Time, p.RoleId, "Warned too many times.");
|
await ApplyPunishment(guild, user, mod, p.Punishment, p.Time, p.RoleId, "Warned too many times.");
|
||||||
@@ -146,7 +146,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
if (roleId is null)
|
if (roleId is null)
|
||||||
return;
|
return;
|
||||||
var role = guild.GetRole(roleId.Value);
|
var role = guild.GetRole(roleId.Value);
|
||||||
if (!(role is null))
|
if (role is not null)
|
||||||
{
|
{
|
||||||
if (minutes == 0)
|
if (minutes == 0)
|
||||||
await user.AddRoleAsync(role).ConfigureAwait(false);
|
await user.AddRoleAsync(role).ConfigureAwait(false);
|
||||||
@@ -389,14 +389,14 @@ WHERE GuildId={guildId}
|
|||||||
.AsQueryable()
|
.AsQueryable()
|
||||||
.FirstOrDefault(x => x.GuildId == guildId);
|
.FirstOrDefault(x => x.GuildId == guildId);
|
||||||
|
|
||||||
if (text == null)
|
if (text is null)
|
||||||
{
|
{
|
||||||
if (template is null)
|
if (template is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uow.Remove(template);
|
uow.Remove(template);
|
||||||
}
|
}
|
||||||
else if (template == null)
|
else if (template is null)
|
||||||
{
|
{
|
||||||
uow.BanTemplates.Add(new BanTemplate()
|
uow.BanTemplates.Add(new BanTemplate()
|
||||||
{
|
{
|
||||||
|
@@ -106,7 +106,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
{
|
{
|
||||||
await Task.Yield();
|
await Task.Yield();
|
||||||
var g = _client.GetGuild(gconf.GuildId);
|
var g = _client.GetGuild(gconf.GuildId);
|
||||||
if (g == null)
|
if (g is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var infos = new ConcurrentDictionary<ulong, IRole>();
|
var infos = new ConcurrentDictionary<ulong, IRole>();
|
||||||
@@ -115,7 +115,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
foreach (var ri in gconf.VcRoleInfos)
|
foreach (var ri in gconf.VcRoleInfos)
|
||||||
{
|
{
|
||||||
var role = g.GetRole(ri.RoleId);
|
var role = g.GetRole(ri.RoleId);
|
||||||
if (role == null)
|
if (role is null)
|
||||||
{
|
{
|
||||||
missingRoles.Add(ri);
|
missingRoles.Add(ri);
|
||||||
continue;
|
continue;
|
||||||
@@ -137,7 +137,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
|
|
||||||
public void AddVcRole(ulong guildId, IRole role, ulong vcId)
|
public void AddVcRole(ulong guildId, IRole role, ulong vcId)
|
||||||
{
|
{
|
||||||
if (role == null)
|
if (role is null)
|
||||||
throw new ArgumentNullException(nameof(role));
|
throw new ArgumentNullException(nameof(role));
|
||||||
|
|
||||||
var guildVcRoles = VcRoles.GetOrAdd(guildId, new ConcurrentDictionary<ulong, IRole>());
|
var guildVcRoles = VcRoles.GetOrAdd(guildId, new ConcurrentDictionary<ulong, IRole>());
|
||||||
@@ -184,7 +184,7 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
{
|
{
|
||||||
|
|
||||||
var gusr = usr as SocketGuildUser;
|
var gusr = usr as SocketGuildUser;
|
||||||
if (gusr == null)
|
if (gusr is null)
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
||||||
var oldVc = oldState.VoiceChannel;
|
var oldVc = oldState.VoiceChannel;
|
||||||
|
@@ -76,7 +76,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
try { tz = TimeZoneInfo.FindSystemTimeZoneById(id); } catch { tz = null; }
|
try { tz = TimeZoneInfo.FindSystemTimeZoneById(id); } catch { tz = null; }
|
||||||
|
|
||||||
|
|
||||||
if (tz == null)
|
if (tz is null)
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync("timezone_not_found").ConfigureAwait(false);
|
await ReplyErrorLocalizedAsync("timezone_not_found").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
|
@@ -94,7 +94,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
|
|
||||||
var embed = new EmbedBuilder()
|
var embed = new EmbedBuilder()
|
||||||
.WithOkColor();
|
.WithOkColor();
|
||||||
if (punishment == null)
|
if (punishment is null)
|
||||||
{
|
{
|
||||||
embed.WithDescription(GetText("user_warned",
|
embed.WithDescription(GetText("user_warned",
|
||||||
Format.Bold(user.ToString())));
|
Format.Bold(user.ToString())));
|
||||||
@@ -430,7 +430,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
var defaultMessage = GetText("bandm", Format.Bold(ctx.Guild.Name), msg);
|
var defaultMessage = GetText("bandm", Format.Bold(ctx.Guild.Name), msg);
|
||||||
var embed = _service.GetBanUserDmEmbed(Context, guildUser, defaultMessage, msg, time.Time);
|
var embed = _service.GetBanUserDmEmbed(Context, guildUser, defaultMessage, msg, time.Time);
|
||||||
if (!(embed is null))
|
if (embed is not null)
|
||||||
{
|
{
|
||||||
var userChannel = await guildUser.GetOrCreateDMChannelAsync();
|
var userChannel = await guildUser.GetOrCreateDMChannelAsync();
|
||||||
await userChannel.EmbedAsync(embed);
|
await userChannel.EmbedAsync(embed);
|
||||||
@@ -497,7 +497,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
var defaultMessage = GetText("bandm", Format.Bold(ctx.Guild.Name), msg);
|
var defaultMessage = GetText("bandm", Format.Bold(ctx.Guild.Name), msg);
|
||||||
var embed = _service.GetBanUserDmEmbed(Context, user, defaultMessage, msg, null);
|
var embed = _service.GetBanUserDmEmbed(Context, user, defaultMessage, msg, null);
|
||||||
if (!(embed is null))
|
if (embed is not null)
|
||||||
{
|
{
|
||||||
var userChannel = await user.GetOrCreateDMChannelAsync();
|
var userChannel = await user.GetOrCreateDMChannelAsync();
|
||||||
await userChannel.EmbedAsync(embed);
|
await userChannel.EmbedAsync(embed);
|
||||||
@@ -613,7 +613,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
|
|
||||||
var bun = bans.FirstOrDefault(x => x.User.ToString().ToLowerInvariant() == user.ToLowerInvariant());
|
var bun = bans.FirstOrDefault(x => x.User.ToString().ToLowerInvariant() == user.ToLowerInvariant());
|
||||||
|
|
||||||
if (bun == null)
|
if (bun is null)
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync("user_not_found").ConfigureAwait(false);
|
await ReplyErrorLocalizedAsync("user_not_found").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
@@ -632,7 +632,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
|
|
||||||
var bun = bans.FirstOrDefault(x => x.User.Id == userId);
|
var bun = bans.FirstOrDefault(x => x.User.Id == userId);
|
||||||
|
|
||||||
if (bun == null)
|
if (bun is null)
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync("user_not_found").ConfigureAwait(false);
|
await ReplyErrorLocalizedAsync("user_not_found").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
|
@@ -41,13 +41,13 @@ namespace NadekoBot.Modules.Administration
|
|||||||
|
|
||||||
var vc = user.VoiceChannel;
|
var vc = user.VoiceChannel;
|
||||||
|
|
||||||
if (vc == null || vc.GuildId != user.GuildId)
|
if (vc is null || vc.GuildId != user.GuildId)
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync("must_be_in_voice").ConfigureAwait(false);
|
await ReplyErrorLocalizedAsync("must_be_in_voice").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (role == null)
|
if (role is null)
|
||||||
{
|
{
|
||||||
if (_service.RemoveVcRole(ctx.Guild.Id, vc.Id))
|
if (_service.RemoveVcRole(ctx.Guild.Id, vc.Id))
|
||||||
{
|
{
|
||||||
|
@@ -23,7 +23,7 @@ namespace NadekoBot.Modules.CustomReactions
|
|||||||
_clientFactory = clientFactory;
|
_clientFactory = clientFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool AdminInGuildOrOwnerInDm() => (ctx.Guild == null && _creds.IsOwner(ctx.User))
|
private bool AdminInGuildOrOwnerInDm() => (ctx.Guild is null && _creds.IsOwner(ctx.User))
|
||||||
|| (ctx.Guild != null && ((IGuildUser)ctx.User).GuildPermissions.Administrator);
|
|| (ctx.Guild != null && ((IGuildUser)ctx.User).GuildPermissions.Administrator);
|
||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
@@ -56,7 +56,7 @@ namespace NadekoBot.Modules.CustomReactions
|
|||||||
if (string.IsNullOrWhiteSpace(message) || id < 0)
|
if (string.IsNullOrWhiteSpace(message) || id < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((channel == null && !_creds.IsOwner(ctx.User)) || (channel != null && !((IGuildUser)ctx.User).GuildPermissions.Administrator))
|
if ((channel is null && !_creds.IsOwner(ctx.User)) || (channel != null && !((IGuildUser)ctx.User).GuildPermissions.Administrator))
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync("insuff_perms").ConfigureAwait(false);
|
await ReplyErrorLocalizedAsync("insuff_perms").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
@@ -87,7 +87,7 @@ namespace NadekoBot.Modules.CustomReactions
|
|||||||
|
|
||||||
var customReactions = _service.GetCustomReactionsFor(ctx.Guild?.Id);
|
var customReactions = _service.GetCustomReactionsFor(ctx.Guild?.Id);
|
||||||
|
|
||||||
if (customReactions == null || !customReactions.Any())
|
if (customReactions is null || !customReactions.Any())
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync("no_found").ConfigureAwait(false);
|
await ReplyErrorLocalizedAsync("no_found").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
@@ -139,7 +139,7 @@ namespace NadekoBot.Modules.CustomReactions
|
|||||||
{
|
{
|
||||||
var found = _service.GetCustomReaction(ctx.Guild?.Id, (int)id);
|
var found = _service.GetCustomReaction(ctx.Guild?.Id, (int)id);
|
||||||
|
|
||||||
if (found == null)
|
if (found is null)
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync("no_found_id").ConfigureAwait(false);
|
await ReplyErrorLocalizedAsync("no_found_id").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
|
@@ -37,7 +37,7 @@ namespace NadekoBot.Modules.CustomReactions.Extensions
|
|||||||
|
|
||||||
var img = (elems.ElementAtOrDefault(new NadekoRandom().Next(0, elems.Length))?.Children?.FirstOrDefault() as IHtmlImageElement);
|
var img = (elems.ElementAtOrDefault(new NadekoRandom().Next(0, elems.Length))?.Children?.FirstOrDefault() as IHtmlImageElement);
|
||||||
|
|
||||||
if (img?.Source == null)
|
if (img?.Source is null)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
return " " + img.Source.Replace("b.", ".", StringComparison.InvariantCulture) + " ";
|
return " " + img.Source.Replace("b.", ".", StringComparison.InvariantCulture) + " ";
|
||||||
|
@@ -237,7 +237,7 @@ namespace NadekoBot.Modules.CustomReactions.Services
|
|||||||
using var uow = _db.GetDbContext();
|
using var uow = _db.GetDbContext();
|
||||||
var cr = uow.CustomReactions.GetById(id);
|
var cr = uow.CustomReactions.GetById(id);
|
||||||
|
|
||||||
if (cr == null || cr.GuildId != guildId)
|
if (cr is null || cr.GuildId != guildId)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
// disable allowtarget if message had target, but it was removed from it
|
// disable allowtarget if message had target, but it was removed from it
|
||||||
@@ -268,7 +268,7 @@ namespace NadekoBot.Modules.CustomReactions.Services
|
|||||||
if (toDelete is null)
|
if (toDelete is null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if ((toDelete.IsGlobal() && guildId == null) || (guildId == toDelete.GuildId))
|
if ((toDelete.IsGlobal() && guildId is null) || (guildId == toDelete.GuildId))
|
||||||
{
|
{
|
||||||
uow.CustomReactions.Remove(toDelete);
|
uow.CustomReactions.Remove(toDelete);
|
||||||
await uow.SaveChangesAsync();
|
await uow.SaveChangesAsync();
|
||||||
@@ -309,7 +309,7 @@ namespace NadekoBot.Modules.CustomReactions.Services
|
|||||||
if (_newGuildReactions.TryGetValue(channel.Guild.Id, out var reactions) && reactions.Length > 0)
|
if (_newGuildReactions.TryGetValue(channel.Guild.Id, out var reactions) && reactions.Length > 0)
|
||||||
{
|
{
|
||||||
var cr = MatchCustomReactions(content, reactions);
|
var cr = MatchCustomReactions(content, reactions);
|
||||||
if (!(cr is null))
|
if (cr is not null)
|
||||||
return cr;
|
return cr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,7 +375,7 @@ namespace NadekoBot.Modules.CustomReactions.Services
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
var cancelled = result.FirstOrDefault(x => x.Response == "-");
|
var cancelled = result.FirstOrDefault(x => x.Response == "-");
|
||||||
if (!(cancelled is null))
|
if (cancelled is not null)
|
||||||
return cancelled;
|
return cancelled;
|
||||||
|
|
||||||
return result[_rng.Next(0, result.Count)];
|
return result[_rng.Next(0, result.Count)];
|
||||||
@@ -551,7 +551,7 @@ namespace NadekoBot.Modules.CustomReactions.Services
|
|||||||
lock (_gcrWriteLock)
|
lock (_gcrWriteLock)
|
||||||
{
|
{
|
||||||
var cr = Array.Find(_globalReactions, item => item.Id == id);
|
var cr = Array.Find(_globalReactions, item => item.Id == id);
|
||||||
if (!(cr is null))
|
if (cr is not null)
|
||||||
{
|
{
|
||||||
return _pubSub.Pub(_gcrDeletedkey, cr.Id);
|
return _pubSub.Pub(_gcrDeletedkey, cr.Id);
|
||||||
}
|
}
|
||||||
@@ -629,7 +629,7 @@ namespace NadekoBot.Modules.CustomReactions.Services
|
|||||||
{
|
{
|
||||||
using var uow = _db.GetDbContext();
|
using var uow = _db.GetDbContext();
|
||||||
var cr = uow.CustomReactions.GetById(id);
|
var cr = uow.CustomReactions.GetById(id);
|
||||||
if (cr == null || cr.GuildId != guildId)
|
if (cr is null || cr.GuildId != guildId)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return cr;
|
return cr;
|
||||||
|
@@ -118,7 +118,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
|
|
||||||
var msg = raceMessage;
|
var msg = raceMessage;
|
||||||
|
|
||||||
if (msg == null)
|
if (msg is null)
|
||||||
raceMessage = await ctx.Channel.SendConfirmAsync(text)
|
raceMessage = await ctx.Channel.SendConfirmAsync(text)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
|
@@ -345,7 +345,7 @@ namespace NadekoBot.Modules.Gambling.Common.Blackjack
|
|||||||
|
|
||||||
public Task PrintState()
|
public Task PrintState()
|
||||||
{
|
{
|
||||||
if (StateUpdated == null)
|
if (StateUpdated is null)
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
return StateUpdated.Invoke(this);
|
return StateUpdated.Invoke(this);
|
||||||
}
|
}
|
||||||
|
@@ -300,7 +300,7 @@ namespace NadekoBot.Modules.Gambling.Common
|
|||||||
|
|
||||||
public static string GetHandValue(List<Card> cards)
|
public static string GetHandValue(List<Card> cards)
|
||||||
{
|
{
|
||||||
if (handValues == null)
|
if (handValues is null)
|
||||||
InitHandValues();
|
InitHandValues();
|
||||||
foreach (var kvp in handValues.Where(x => x.Value(cards)))
|
foreach (var kvp in handValues.Where(x => x.Value(cards)))
|
||||||
{
|
{
|
||||||
|
@@ -169,12 +169,12 @@ namespace NadekoBot.Modules.Gambling.Common.Events
|
|||||||
if (_emote.Name != r.Emote.Name)
|
if (_emote.Name != r.Emote.Name)
|
||||||
return;
|
return;
|
||||||
var gu = (r.User.IsSpecified ? r.User.Value : null) as IGuildUser;
|
var gu = (r.User.IsSpecified ? r.User.Value : null) as IGuildUser;
|
||||||
if (gu == null // no unknown users, as they could be bots, or alts
|
if (gu is null // no unknown users, as they could be bots, or alts
|
||||||
|| msg.Id != _msg.Id // same message
|
|| msg.Id != _msg.Id // same message
|
||||||
|| gu.IsBot // no bots
|
|| gu.IsBot // no bots
|
||||||
|| (DateTime.UtcNow - gu.CreatedAt).TotalDays <= 5 // no recently created accounts
|
|| (DateTime.UtcNow - gu.CreatedAt).TotalDays <= 5 // no recently created accounts
|
||||||
|| (_noRecentlyJoinedServer && // if specified, no users who joined the server in the last 24h
|
|| (_noRecentlyJoinedServer && // if specified, no users who joined the server in the last 24h
|
||||||
(gu.JoinedAt == null || (DateTime.UtcNow - gu.JoinedAt.Value).TotalDays < 1))) // and no users for who we don't know when they joined
|
(gu.JoinedAt is null || (DateTime.UtcNow - gu.JoinedAt.Value).TotalDays < 1))) // and no users for who we don't know when they joined
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -98,7 +98,7 @@ namespace NadekoBot.Modules.Gambling.Common.Connect4
|
|||||||
await _locker.WaitAsync().ConfigureAwait(false);
|
await _locker.WaitAsync().ConfigureAwait(false);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_players[1] == null)
|
if (_players[1] is null)
|
||||||
{
|
{
|
||||||
var __ = OnGameFailedToStart?.Invoke(this);
|
var __ = OnGameFailedToStart?.Invoke(this);
|
||||||
CurrentPhase = Phase.Ended;
|
CurrentPhase = Phase.Ended;
|
||||||
|
@@ -168,7 +168,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
.WithOkColor();
|
.WithOkColor();
|
||||||
|
|
||||||
|
|
||||||
if (msg == null)
|
if (msg is null)
|
||||||
msg = await ctx.Channel.EmbedAsync(embed).ConfigureAwait(false);
|
msg = await ctx.Channel.EmbedAsync(embed).ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
await msg.ModifyAsync(x => x.Embed = embed.Build()).ConfigureAwait(false);
|
await msg.ModifyAsync(x => x.Embed = embed.Build()).ConfigureAwait(false);
|
||||||
|
@@ -33,7 +33,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
if (num < 1 || num > 10)
|
if (num < 1 || num > 10)
|
||||||
throw new ArgumentOutOfRangeException(nameof(num));
|
throw new ArgumentOutOfRangeException(nameof(num));
|
||||||
|
|
||||||
Deck cards = guildId == null ? new Deck() : _allDecks.GetOrAdd(ctx.Guild, (s) => new Deck());
|
Deck cards = guildId is null ? new Deck() : _allDecks.GetOrAdd(ctx.Guild, (s) => new Deck());
|
||||||
var images = new List<Image<Rgba32>>();
|
var images = new List<Image<Rgba32>>();
|
||||||
var cardObjects = new List<Deck.Card>();
|
var cardObjects = new List<Deck.Card>();
|
||||||
for (var i = 0; i < num; i++)
|
for (var i = 0; i < num; i++)
|
||||||
|
@@ -413,7 +413,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
--
|
--
|
||||||
";
|
";
|
||||||
|
|
||||||
if (rdMsg == null)
|
if (rdMsg is null)
|
||||||
{
|
{
|
||||||
rdMsg = await ctx.Channel.EmbedAsync(embed)
|
rdMsg = await ctx.Channel.EmbedAsync(embed)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
@@ -92,7 +92,7 @@ namespace NadekoBot.Modules.Gambling.Services
|
|||||||
{
|
{
|
||||||
SocketGuild g = _client.GetGuild(guildId);
|
SocketGuild g = _client.GetGuild(guildId);
|
||||||
SocketTextChannel ch = g?.GetChannel(channelId) as SocketTextChannel;
|
SocketTextChannel ch = g?.GetChannel(channelId) as SocketTextChannel;
|
||||||
if (ch == null)
|
if (ch is null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ICurrencyEvent ce;
|
ICurrencyEvent ce;
|
||||||
|
@@ -182,7 +182,7 @@ namespace NadekoBot.Modules.Gambling.Services
|
|||||||
private Task PotentialFlowerGeneration(IUserMessage imsg)
|
private Task PotentialFlowerGeneration(IUserMessage imsg)
|
||||||
{
|
{
|
||||||
var msg = imsg as SocketUserMessage;
|
var msg = imsg as SocketUserMessage;
|
||||||
if (msg == null || msg.Author.IsBot)
|
if (msg is null || msg.Author.IsBot)
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
||||||
if (!(imsg.Channel is ITextChannel channel))
|
if (!(imsg.Channel is ITextChannel channel))
|
||||||
@@ -351,7 +351,7 @@ namespace NadekoBot.Modules.Gambling.Services
|
|||||||
{
|
{
|
||||||
// try to send the message with the currency image
|
// try to send the message with the currency image
|
||||||
var msgId = await SendPlantMessageAsync(gid, ch, user, amount, pass).ConfigureAwait(false);
|
var msgId = await SendPlantMessageAsync(gid, ch, user, amount, pass).ConfigureAwait(false);
|
||||||
if (msgId == null)
|
if (msgId is null)
|
||||||
{
|
{
|
||||||
// if it fails it will return null, if it returns null, refund
|
// if it fails it will return null, if it returns null, refund
|
||||||
await _cs.AddAsync(uid, "Planted currency refund", amount, gamble: false);
|
await _cs.AddAsync(uid, "Planted currency refund", amount, gamble: false);
|
||||||
|
@@ -49,7 +49,7 @@ namespace NadekoBot.Modules.Gambling.Services
|
|||||||
var ownerUser = uow.GetOrCreateUser(owner);
|
var ownerUser = uow.GetOrCreateUser(owner);
|
||||||
|
|
||||||
// owner has to be the owner of the waifu
|
// owner has to be the owner of the waifu
|
||||||
if (waifu == null || waifu.ClaimerId != ownerUser.Id)
|
if (waifu is null || waifu.ClaimerId != ownerUser.Id)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// if waifu likes the person, gotta pay the penalty
|
// if waifu likes the person, gotta pay the penalty
|
||||||
@@ -97,7 +97,7 @@ namespace NadekoBot.Modules.Gambling.Services
|
|||||||
{
|
{
|
||||||
var waifu = uow.WaifuInfo.ByWaifuUserId(user.Id);
|
var waifu = uow.WaifuInfo.ByWaifuUserId(user.Id);
|
||||||
|
|
||||||
if (waifu == null)
|
if (waifu is null)
|
||||||
return settings.Waifu.MinPrice;
|
return settings.Waifu.MinPrice;
|
||||||
|
|
||||||
var divorces = uow.WaifuUpdates.Count(x => x.Old != null &&
|
var divorces = uow.WaifuUpdates.Count(x => x.Old != null &&
|
||||||
@@ -168,7 +168,7 @@ namespace NadekoBot.Modules.Gambling.Services
|
|||||||
{
|
{
|
||||||
w = uow.WaifuInfo.ByWaifuUserId(target.Id);
|
w = uow.WaifuInfo.ByWaifuUserId(target.Id);
|
||||||
isAffinity = (w?.Affinity?.UserId == user.Id);
|
isAffinity = (w?.Affinity?.UserId == user.Id);
|
||||||
if (w == null)
|
if (w is null)
|
||||||
{
|
{
|
||||||
var claimer = uow.GetOrCreateUser(user);
|
var claimer = uow.GetOrCreateUser(user);
|
||||||
var waifu = uow.GetOrCreateUser(target);
|
var waifu = uow.GetOrCreateUser(target);
|
||||||
@@ -257,14 +257,14 @@ namespace NadekoBot.Modules.Gambling.Services
|
|||||||
using (var uow = _db.GetDbContext())
|
using (var uow = _db.GetDbContext())
|
||||||
{
|
{
|
||||||
var w = uow.WaifuInfo.ByWaifuUserId(user.Id);
|
var w = uow.WaifuInfo.ByWaifuUserId(user.Id);
|
||||||
var newAff = target == null ? null : uow.GetOrCreateUser(target);
|
var newAff = target is null ? null : uow.GetOrCreateUser(target);
|
||||||
if (w?.Affinity?.UserId == target?.Id)
|
if (w?.Affinity?.UserId == target?.Id)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
else if (!_cache.TryAddAffinityCooldown(user.Id, out remaining))
|
else if (!_cache.TryAddAffinityCooldown(user.Id, out remaining))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
else if (w == null)
|
else if (w is null)
|
||||||
{
|
{
|
||||||
var thisUser = uow.GetOrCreateUser(user);
|
var thisUser = uow.GetOrCreateUser(user);
|
||||||
uow.WaifuInfo.Add(new WaifuInfo()
|
uow.WaifuInfo.Add(new WaifuInfo()
|
||||||
@@ -330,7 +330,7 @@ namespace NadekoBot.Modules.Gambling.Services
|
|||||||
{
|
{
|
||||||
w = uow.WaifuInfo.ByWaifuUserId(targetId);
|
w = uow.WaifuInfo.ByWaifuUserId(targetId);
|
||||||
var now = DateTime.UtcNow;
|
var now = DateTime.UtcNow;
|
||||||
if (w?.Claimer == null || w.Claimer.UserId != user.Id)
|
if (w?.Claimer is null || w.Claimer.UserId != user.Id)
|
||||||
result = DivorceResult.NotYourWife;
|
result = DivorceResult.NotYourWife;
|
||||||
else if (!_cache.TryAddDivorceCooldown(user.Id, out remaining))
|
else if (!_cache.TryAddDivorceCooldown(user.Id, out remaining))
|
||||||
{
|
{
|
||||||
@@ -383,7 +383,7 @@ namespace NadekoBot.Modules.Gambling.Services
|
|||||||
var w = uow.WaifuInfo.ByWaifuUserId(giftedWaifu.Id,
|
var w = uow.WaifuInfo.ByWaifuUserId(giftedWaifu.Id,
|
||||||
set => set.Include(x => x.Items)
|
set => set.Include(x => x.Items)
|
||||||
.Include(x => x.Claimer));
|
.Include(x => x.Claimer));
|
||||||
if (w == null)
|
if (w is null)
|
||||||
{
|
{
|
||||||
uow.WaifuInfo.Add(w = new WaifuInfo()
|
uow.WaifuInfo.Add(w = new WaifuInfo()
|
||||||
{
|
{
|
||||||
|
@@ -104,7 +104,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
uow.SaveChanges();
|
uow.SaveChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry == null)
|
if (entry is null)
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync("shop_item_not_found").ConfigureAwait(false);
|
await ReplyErrorLocalizedAsync("shop_item_not_found").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
@@ -115,7 +115,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
var guser = (IGuildUser)ctx.User;
|
var guser = (IGuildUser)ctx.User;
|
||||||
var role = ctx.Guild.GetRole(entry.RoleId);
|
var role = ctx.Guild.GetRole(entry.RoleId);
|
||||||
|
|
||||||
if (role == null)
|
if (role is null)
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync("shop_role_not_found").ConfigureAwait(false);
|
await ReplyErrorLocalizedAsync("shop_role_not_found").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
@@ -306,7 +306,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (entry == null)
|
if (entry is null)
|
||||||
await ReplyErrorLocalizedAsync("shop_item_not_found").ConfigureAwait(false);
|
await ReplyErrorLocalizedAsync("shop_item_not_found").ConfigureAwait(false);
|
||||||
else if (!rightType)
|
else if (!rightType)
|
||||||
await ReplyErrorLocalizedAsync("shop_item_wrong_type").ConfigureAwait(false);
|
await ReplyErrorLocalizedAsync("shop_item_wrong_type").ConfigureAwait(false);
|
||||||
@@ -341,7 +341,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (removed == null)
|
if (removed is null)
|
||||||
await ReplyErrorLocalizedAsync("shop_item_not_found").ConfigureAwait(false);
|
await ReplyErrorLocalizedAsync("shop_item_not_found").ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
await ctx.Channel.EmbedAsync(EntryToEmbed(removed)
|
await ctx.Channel.EmbedAsync(EntryToEmbed(removed)
|
||||||
|
@@ -187,11 +187,11 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (u == null)
|
if (u is null)
|
||||||
{
|
{
|
||||||
await ReplyConfirmLocalizedAsync("waifu_affinity_reset");
|
await ReplyConfirmLocalizedAsync("waifu_affinity_reset");
|
||||||
}
|
}
|
||||||
else if (oldAff == null)
|
else if (oldAff is null)
|
||||||
{
|
{
|
||||||
await ReplyConfirmLocalizedAsync("waifu_affinity_set", Format.Bold(u.ToString()));
|
await ReplyConfirmLocalizedAsync("waifu_affinity_set", Format.Bold(u.ToString()));
|
||||||
}
|
}
|
||||||
@@ -240,7 +240,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
[Priority(1)]
|
[Priority(1)]
|
||||||
public Task WaifuInfo([Leftover]IUser target = null)
|
public Task WaifuInfo([Leftover]IUser target = null)
|
||||||
{
|
{
|
||||||
if (target == null)
|
if (target is null)
|
||||||
target = ctx.User;
|
target = ctx.User;
|
||||||
|
|
||||||
return InternalWaifuInfo(target.Id, target.ToString());
|
return InternalWaifuInfo(target.Id, target.ToString());
|
||||||
|
@@ -32,7 +32,7 @@ namespace NadekoBot.Modules.Games.Common
|
|||||||
{
|
{
|
||||||
// has to be a user message
|
// has to be a user message
|
||||||
// channel must be the same the poll started in
|
// channel must be the same the poll started in
|
||||||
if (msg == null || msg.Author.IsBot || msg.Channel.Id != Poll.ChannelId)
|
if (msg is null || msg.Author.IsBot || msg.Channel.Id != Poll.ChannelId)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// has to be an integer
|
// has to be an integer
|
||||||
@@ -43,7 +43,7 @@ namespace NadekoBot.Modules.Games.Common
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
var usr = msg.Author as IGuildUser;
|
var usr = msg.Author as IGuildUser;
|
||||||
if (usr == null)
|
if (usr is null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
voteObj = new PollVote()
|
voteObj = new PollVote()
|
||||||
|
@@ -81,7 +81,7 @@ namespace NadekoBot.Modules.Games.Common
|
|||||||
{
|
{
|
||||||
for (var j = 0; j < _state.GetLength(1); j++)
|
for (var j = 0; j < _state.GetLength(1); j++)
|
||||||
{
|
{
|
||||||
sb.Append(_state[i, j] == null ? _numbers[i * 3 + j] : GetIcon(_state[i, j]));
|
sb.Append(_state[i, j] is null ? _numbers[i * 3 + j] : GetIcon(_state[i, j]));
|
||||||
if (j < _state.GetLength(1) - 1)
|
if (j < _state.GetLength(1) - 1)
|
||||||
sb.Append("┃");
|
sb.Append("┃");
|
||||||
}
|
}
|
||||||
@@ -102,7 +102,7 @@ namespace NadekoBot.Modules.Games.Common
|
|||||||
if (!string.IsNullOrWhiteSpace(title))
|
if (!string.IsNullOrWhiteSpace(title))
|
||||||
embed.WithTitle(title);
|
embed.WithTitle(title);
|
||||||
|
|
||||||
if (_winner == null)
|
if (_winner is null)
|
||||||
{
|
{
|
||||||
if (_phase == Phase.Ended)
|
if (_phase == Phase.Ended)
|
||||||
embed.WithFooter(efb => efb.WithText(GetText("ttt_no_moves")));
|
embed.WithFooter(efb => efb.WithText(GetText("ttt_no_moves")));
|
||||||
@@ -192,7 +192,7 @@ namespace NadekoBot.Modules.Games.Common
|
|||||||
{
|
{
|
||||||
for (var j = 0; j < 3; j++)
|
for (var j = 0; j < 3; j++)
|
||||||
{
|
{
|
||||||
if (_state[i, j] == null)
|
if (_state[i, j] is null)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -213,7 +213,7 @@ namespace NadekoBot.Modules.Games.Common
|
|||||||
if (int.TryParse(msg.Content, out var index) &&
|
if (int.TryParse(msg.Content, out var index) &&
|
||||||
--index >= 0 &&
|
--index >= 0 &&
|
||||||
index <= 9 &&
|
index <= 9 &&
|
||||||
_state[index / 3, index % 3] == null)
|
_state[index / 3, index % 3] is null)
|
||||||
{
|
{
|
||||||
_state[index / 3, index % 3] = _curUserIndex;
|
_state[index / 3, index % 3] = _curUserIndex;
|
||||||
|
|
||||||
|
@@ -210,7 +210,7 @@ namespace NadekoBot.Modules.Games.Common.Trivia
|
|||||||
var umsg = imsg as SocketUserMessage;
|
var umsg = imsg as SocketUserMessage;
|
||||||
|
|
||||||
var textChannel = umsg?.Channel as ITextChannel;
|
var textChannel = umsg?.Channel as ITextChannel;
|
||||||
if (textChannel == null || textChannel.Guild != Guild)
|
if (textChannel is null || textChannel.Guild != Guild)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var guildUser = (IGuildUser)umsg.Author;
|
var guildUser = (IGuildUser)umsg.Author;
|
||||||
|
@@ -143,10 +143,10 @@ namespace NadekoBot.Modules.Games.Common
|
|||||||
if (imsg.Author.IsBot)
|
if (imsg.Author.IsBot)
|
||||||
return;
|
return;
|
||||||
var msg = imsg as SocketUserMessage;
|
var msg = imsg as SocketUserMessage;
|
||||||
if (msg == null)
|
if (msg is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (this.Channel == null || this.Channel.Id != msg.Channel.Id) return;
|
if (this.Channel is null || this.Channel.Id != msg.Channel.Id) return;
|
||||||
|
|
||||||
var guess = msg.Content;
|
var guess = msg.Content;
|
||||||
|
|
||||||
|
@@ -61,7 +61,7 @@ namespace NadekoBot.Modules.Games
|
|||||||
var gr = _service.GirlRatings.GetOrAdd(usr.Id, GetGirl);
|
var gr = _service.GirlRatings.GetOrAdd(usr.Id, GetGirl);
|
||||||
var originalStream = await gr.Stream;
|
var originalStream = await gr.Stream;
|
||||||
|
|
||||||
if (originalStream == null)
|
if (originalStream is null)
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync("something_went_wrong").ConfigureAwait(false);
|
await ReplyErrorLocalizedAsync("something_went_wrong").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
|
@@ -85,7 +85,7 @@ namespace NadekoBot.Modules.Games
|
|||||||
|
|
||||||
Task Hm_OnGameEnded(Hangman game, string winner)
|
Task Hm_OnGameEnded(Hangman game, string winner)
|
||||||
{
|
{
|
||||||
if (winner == null)
|
if (winner is null)
|
||||||
{
|
{
|
||||||
var loseEmbed = new EmbedBuilder().WithTitle($"Hangman Game ({game.TermType}) - Ended")
|
var loseEmbed = new EmbedBuilder().WithTitle($"Hangman Game ({game.TermType}) - Ended")
|
||||||
.WithDescription(Format.Bold("You lose."))
|
.WithDescription(Format.Bold("You lose."))
|
||||||
|
@@ -89,7 +89,7 @@ namespace NadekoBot.Modules.Games
|
|||||||
game.Dispose();
|
game.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg2 == null)
|
if (arg2 is null)
|
||||||
return ConfirmLocalizedAsync("nunchi_ended_no_winner", Format.Bold(arg2));
|
return ConfirmLocalizedAsync("nunchi_ended_no_winner", Format.Bold(arg2));
|
||||||
else
|
else
|
||||||
return ConfirmLocalizedAsync("nunchi_ended", Format.Bold(arg2));
|
return ConfirmLocalizedAsync("nunchi_ended", Format.Bold(arg2));
|
||||||
|
@@ -33,7 +33,7 @@ namespace NadekoBot.Modules.Games
|
|||||||
|
|
||||||
var poll = _service.CreatePoll(ctx.Guild.Id,
|
var poll = _service.CreatePoll(ctx.Guild.Id,
|
||||||
ctx.Channel.Id, arg);
|
ctx.Channel.Id, arg);
|
||||||
if(poll == null)
|
if(poll is null)
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync("poll_invalid_input").ConfigureAwait(false);
|
await ReplyErrorLocalizedAsync("poll_invalid_input").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
@@ -75,7 +75,7 @@ namespace NadekoBot.Modules.Games
|
|||||||
var channel = (ITextChannel)ctx.Channel;
|
var channel = (ITextChannel)ctx.Channel;
|
||||||
|
|
||||||
Poll p;
|
Poll p;
|
||||||
if ((p = _service.StopPoll(ctx.Guild.Id)) == null)
|
if ((p = _service.StopPoll(ctx.Guild.Id)) is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var embed = GetStats(p, GetText("poll_closed"));
|
var embed = GetStats(p, GetText("poll_closed"));
|
||||||
|
@@ -59,7 +59,7 @@ namespace NadekoBot.Modules.Games.Services
|
|||||||
var channel = msg.Channel as ITextChannel;
|
var channel = msg.Channel as ITextChannel;
|
||||||
cleverbot = null;
|
cleverbot = null;
|
||||||
|
|
||||||
if (channel == null)
|
if (channel is null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (!ChatterBotGuilds.TryGetValue(channel.Guild.Id, out Lazy<IChatterBotSession> lazyCleverbot))
|
if (!ChatterBotGuilds.TryGetValue(channel.Guild.Id, out Lazy<IChatterBotSession> lazyCleverbot))
|
||||||
@@ -110,7 +110,7 @@ namespace NadekoBot.Modules.Games.Services
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var message = PrepareMessage(usrMsg, out IChatterBotSession cbs);
|
var message = PrepareMessage(usrMsg, out IChatterBotSession cbs);
|
||||||
if (message == null || cbs == null)
|
if (message is null || cbs is null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var pc = _perms.GetCacheFor(guild.Id);
|
var pc = _perms.GetCacheFor(guild.Id);
|
||||||
|
@@ -108,7 +108,7 @@ namespace NadekoBot.Modules.Games.Services
|
|||||||
|
|
||||||
public async Task<bool> RunBehavior(DiscordSocketClient client, IGuild guild, IUserMessage msg)
|
public async Task<bool> RunBehavior(DiscordSocketClient client, IGuild guild, IUserMessage msg)
|
||||||
{
|
{
|
||||||
if (guild == null)
|
if (guild is null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!ActivePolls.TryGetValue(guild.Id, out var poll))
|
if (!ActivePolls.TryGetValue(guild.Id, out var poll))
|
||||||
|
@@ -268,7 +268,7 @@ namespace NadekoBot.Modules.Help
|
|||||||
{
|
{
|
||||||
var channel = ctx.Channel;
|
var channel = ctx.Channel;
|
||||||
|
|
||||||
if (com == null)
|
if (com is null)
|
||||||
{
|
{
|
||||||
IMessageChannel ch = channel is ITextChannel
|
IMessageChannel ch = channel is ITextChannel
|
||||||
? await ((IGuildUser)ctx.User).GetOrCreateDMChannelAsync().ConfigureAwait(false)
|
? await ((IGuildUser)ctx.User).GetOrCreateDMChannelAsync().ConfigureAwait(false)
|
||||||
|
@@ -43,7 +43,7 @@ namespace NadekoBot.Modules.Help.Services
|
|||||||
public Task LateExecute(DiscordSocketClient client, IGuild guild, IUserMessage msg)
|
public Task LateExecute(DiscordSocketClient client, IGuild guild, IUserMessage msg)
|
||||||
{
|
{
|
||||||
var settings = _bss.Data;
|
var settings = _bss.Data;
|
||||||
if (guild == null)
|
if (guild is null)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(settings.DmHelpText) || settings.DmHelpText == "-")
|
if (string.IsNullOrWhiteSpace(settings.DmHelpText) || settings.DmHelpText == "-")
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
@@ -136,7 +136,7 @@ namespace NadekoBot.Modules.Help.Services
|
|||||||
.FirstOrDefault(ca => ca is UserPermAttribute);
|
.FirstOrDefault(ca => ca is UserPermAttribute);
|
||||||
|
|
||||||
string userPermString = string.Empty;
|
string userPermString = string.Empty;
|
||||||
if (!(userPerm is null))
|
if (userPerm is not null)
|
||||||
{
|
{
|
||||||
if (userPerm.UserPermissionAttribute.ChannelPermission is ChannelPermission cPerm)
|
if (userPerm.UserPermissionAttribute.ChannelPermission is ChannelPermission cPerm)
|
||||||
userPermString = GetPreconditionString((ChannelPerm) cPerm);
|
userPermString = GetPreconditionString((ChannelPerm) cPerm);
|
||||||
|
@@ -64,7 +64,7 @@ namespace NadekoBot.Modules.Music.Resolvers
|
|||||||
yield break;
|
yield break;
|
||||||
|
|
||||||
var firstData = await ResolveByQueryAsync(firstFile);
|
var firstData = await ResolveByQueryAsync(firstFile);
|
||||||
if (!(firstData is null))
|
if (firstData is not null)
|
||||||
yield return firstData;
|
yield return firstData;
|
||||||
|
|
||||||
var fileChunks = files.Skip(1).Chunk(10);
|
var fileChunks = files.Skip(1).Chunk(10);
|
||||||
|
@@ -81,7 +81,7 @@ namespace NadekoBot.Modules.Music.Resolvers
|
|||||||
public async Task<ITrackInfo?> ResolveByQueryAsync(string query)
|
public async Task<ITrackInfo?> ResolveByQueryAsync(string query)
|
||||||
{
|
{
|
||||||
var cached = await _trackCacher.GetCachedDataByQueryAsync(query, MusicPlatform.SoundCloud);
|
var cached = await _trackCacher.GetCachedDataByQueryAsync(query, MusicPlatform.SoundCloud);
|
||||||
if (!(cached is null))
|
if (cached is not null)
|
||||||
return CachableDataToTrackInfo(cached);
|
return CachableDataToTrackInfo(cached);
|
||||||
|
|
||||||
var svideo = !IsSoundCloudLink(query)
|
var svideo = !IsSoundCloudLink(query)
|
||||||
|
@@ -199,7 +199,7 @@
|
|||||||
// //Log.Information("Buffered. Getting audio client...");
|
// //Log.Information("Buffered. Getting audio client...");
|
||||||
// var ac = await GetAudioClient().ConfigureAwait(false);
|
// var ac = await GetAudioClient().ConfigureAwait(false);
|
||||||
// Log.Information("Got Audio client");
|
// Log.Information("Got Audio client");
|
||||||
// if (ac == null)
|
// if (ac is null)
|
||||||
// {
|
// {
|
||||||
// Log.Information("Can't join");
|
// Log.Information("Can't join");
|
||||||
// await Task.Delay(900, cancelToken).ConfigureAwait(false);
|
// await Task.Delay(900, cancelToken).ConfigureAwait(false);
|
||||||
@@ -371,7 +371,7 @@
|
|||||||
//
|
//
|
||||||
// private async Task<IAudioClient> GetAudioClient(bool reconnect = false)
|
// private async Task<IAudioClient> GetAudioClient(bool reconnect = false)
|
||||||
// {
|
// {
|
||||||
// if (_audioClient == null ||
|
// if (_audioClient is null ||
|
||||||
// _audioClient.ConnectionState != ConnectionState.Connected ||
|
// _audioClient.ConnectionState != ConnectionState.Connected ||
|
||||||
// reconnect ||
|
// reconnect ||
|
||||||
// newVoiceChannel)
|
// newVoiceChannel)
|
||||||
@@ -529,7 +529,7 @@
|
|||||||
// {
|
// {
|
||||||
// lock (locker)
|
// lock (locker)
|
||||||
// {
|
// {
|
||||||
// if (PauseTaskSource == null)
|
// if (PauseTaskSource is null)
|
||||||
// PauseTaskSource = new TaskCompletionSource<bool>();
|
// PauseTaskSource = new TaskCompletionSource<bool>();
|
||||||
// else
|
// else
|
||||||
// {
|
// {
|
||||||
|
@@ -86,7 +86,7 @@
|
|||||||
// if (MaxQueueSize != 0 && Songs.Count >= MaxQueueSize)
|
// if (MaxQueueSize != 0 && Songs.Count >= MaxQueueSize)
|
||||||
// throw new QueueFullException();
|
// throw new QueueFullException();
|
||||||
// var curSong = Current.Song;
|
// var curSong = Current.Song;
|
||||||
// if (curSong == null)
|
// if (curSong is null)
|
||||||
// {
|
// {
|
||||||
// Songs.AddLast(song);
|
// Songs.AddLast(song);
|
||||||
// return Songs.Count;
|
// return Songs.Count;
|
||||||
|
@@ -285,7 +285,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
{
|
{
|
||||||
string desc = string.Empty;
|
string desc = string.Empty;
|
||||||
var current = mp.GetCurrentTrack(out var currentIndex);
|
var current = mp.GetCurrentTrack(out var currentIndex);
|
||||||
if (!(current is null))
|
if (current is not null)
|
||||||
{
|
{
|
||||||
desc = $"`🔊` {current.PrettyFullName()}\n\n" + desc;
|
desc = $"`🔊` {current.PrettyFullName()}\n\n" + desc;
|
||||||
}
|
}
|
||||||
@@ -371,7 +371,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var input = await GetUserInputAsync(ctx.User.Id, ctx.Channel.Id).ConfigureAwait(false);
|
var input = await GetUserInputAsync(ctx.User.Id, ctx.Channel.Id).ConfigureAwait(false);
|
||||||
if (input == null
|
if (input is null
|
||||||
|| !int.TryParse(input, out var index)
|
|| !int.TryParse(input, out var index)
|
||||||
|| (index -= 1) < 0
|
|| (index -= 1) < 0
|
||||||
|| index >= videos.Count)
|
|| index >= videos.Count)
|
||||||
@@ -699,7 +699,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
}
|
}
|
||||||
|
|
||||||
var currentTrack = mp.GetCurrentTrack(out _);
|
var currentTrack = mp.GetCurrentTrack(out _);
|
||||||
if (currentTrack == null)
|
if (currentTrack is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var embed = new EmbedBuilder().WithOkColor()
|
var embed = new EmbedBuilder().WithOkColor()
|
||||||
|
@@ -213,7 +213,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
mpl = uow.MusicPlaylists.GetWithSongs(id);
|
mpl = uow.MusicPlaylists.GetWithSongs(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mpl == null)
|
if (mpl is null)
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync("playlist_id_not_found").ConfigureAwait(false);
|
await ReplyErrorLocalizedAsync("playlist_id_not_found").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
|
@@ -313,7 +313,7 @@ namespace NadekoBot.Modules.Music.Services
|
|||||||
{
|
{
|
||||||
var randomPlayingTrack = _players
|
var randomPlayingTrack = _players
|
||||||
.Select(x => x.Value.GetCurrentTrack(out _))
|
.Select(x => x.Value.GetCurrentTrack(out _))
|
||||||
.Where(x => !(x is null))
|
.Where(x => x is not null)
|
||||||
.Shuffle()
|
.Shuffle()
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
|
|
||||||
@@ -328,7 +328,7 @@ namespace NadekoBot.Modules.Music.Services
|
|||||||
{
|
{
|
||||||
var count = _players
|
var count = _players
|
||||||
.Select(x => x.Value.GetCurrentTrack(out _))
|
.Select(x => x.Value.GetCurrentTrack(out _))
|
||||||
.Count(x => !(x is null));
|
.Count(x => x is not null);
|
||||||
|
|
||||||
return count.ToString();
|
return count.ToString();
|
||||||
});
|
});
|
||||||
|
@@ -100,7 +100,7 @@
|
|||||||
// string GetText(string text, params object[] replacements) =>
|
// string GetText(string text, params object[] replacements) =>
|
||||||
// _strings.GetText(text, textCh.Guild.Id, replacements);
|
// _strings.GetText(text, textCh.Guild.Id, replacements);
|
||||||
//
|
//
|
||||||
// if (voiceCh == null || voiceCh.Guild != textCh.Guild)
|
// if (voiceCh is null || voiceCh.Guild != textCh.Guild)
|
||||||
// {
|
// {
|
||||||
// if (textCh != null)
|
// if (textCh != null)
|
||||||
// {
|
// {
|
||||||
@@ -139,7 +139,7 @@
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// var (Index, Current) = mp.Current;
|
// var (Index, Current) = mp.Current;
|
||||||
// if (Current == null
|
// if (Current is null
|
||||||
// && !mp.RepeatCurrentSong
|
// && !mp.RepeatCurrentSong
|
||||||
// && !mp.RepeatPlaylist
|
// && !mp.RepeatPlaylist
|
||||||
// && !mp.FairPlay
|
// && !mp.FairPlay
|
||||||
@@ -161,7 +161,7 @@
|
|||||||
// // // ignored
|
// // // ignored
|
||||||
// //}
|
// //}
|
||||||
// var sender = player;
|
// var sender = player;
|
||||||
// if (sender == null)
|
// if (sender is null)
|
||||||
// return;
|
// return;
|
||||||
// try
|
// try
|
||||||
// {
|
// {
|
||||||
@@ -215,7 +215,7 @@
|
|||||||
// return;
|
// return;
|
||||||
//
|
//
|
||||||
// var si = await ResolveSong(related[new NadekoRandom().Next(related.Length)], _client.CurrentUser.ToString(), MusicType.YouTube).ConfigureAwait(false);
|
// var si = await ResolveSong(related[new NadekoRandom().Next(related.Length)], _client.CurrentUser.ToString(), MusicType.YouTube).ConfigureAwait(false);
|
||||||
// if (si == null)
|
// if (si is null)
|
||||||
// throw new SongNotFoundException();
|
// throw new SongNotFoundException();
|
||||||
// var mp = await GetOrCreatePlayer(txtCh.GuildId, vch, txtCh).ConfigureAwait(false);
|
// var mp = await GetOrCreatePlayer(txtCh.GuildId, vch, txtCh).ConfigureAwait(false);
|
||||||
// mp.Enqueue(si);
|
// mp.Enqueue(si);
|
||||||
@@ -229,7 +229,7 @@
|
|||||||
// var strategy = await resolverFactory.GetResolveStrategy(query, musicType).ConfigureAwait(false);
|
// var strategy = await resolverFactory.GetResolveStrategy(query, musicType).ConfigureAwait(false);
|
||||||
// var sinfo = await strategy.ResolveSong(query).ConfigureAwait(false);
|
// var sinfo = await strategy.ResolveSong(query).ConfigureAwait(false);
|
||||||
//
|
//
|
||||||
// if (sinfo == null)
|
// if (sinfo is null)
|
||||||
// return null;
|
// return null;
|
||||||
//
|
//
|
||||||
// sinfo.QueuerName = queuerName;
|
// sinfo.QueuerName = queuerName;
|
||||||
|
@@ -51,13 +51,13 @@
|
|||||||
// // var t = Task.Run(() =>
|
// // var t = Task.Run(() =>
|
||||||
// // {
|
// // {
|
||||||
// // var usr = iusr as SocketGuildUser;
|
// // var usr = iusr as SocketGuildUser;
|
||||||
// // if (usr == null ||
|
// // if (usr is null ||
|
||||||
// // oldState.VoiceChannel == newState.VoiceChannel)
|
// // oldState.VoiceChannel == newState.VoiceChannel)
|
||||||
// // return;
|
// // return;
|
||||||
//
|
//
|
||||||
// // var player = _music.GetPlayerOrDefault(usr.Guild.Id);
|
// // var player = _music.GetPlayerOrDefault(usr.Guild.Id);
|
||||||
//
|
//
|
||||||
// // if (player == null)
|
// // if (player is null)
|
||||||
// // return;
|
// // return;
|
||||||
//
|
//
|
||||||
// // try
|
// // try
|
||||||
@@ -97,7 +97,7 @@
|
|||||||
//
|
//
|
||||||
// private async Task InternalQueue(MusicPlayer mp, SongInfo songInfo, bool silent, bool queueFirst = false, bool forcePlay = false)
|
// private async Task InternalQueue(MusicPlayer mp, SongInfo songInfo, bool silent, bool queueFirst = false, bool forcePlay = false)
|
||||||
// {
|
// {
|
||||||
// if (songInfo == null)
|
// if (songInfo is null)
|
||||||
// {
|
// {
|
||||||
// if (!silent)
|
// if (!silent)
|
||||||
// await ReplyErrorLocalizedAsync("song_not_found").ConfigureAwait(false);
|
// await ReplyErrorLocalizedAsync("song_not_found").ConfigureAwait(false);
|
||||||
@@ -216,7 +216,7 @@
|
|||||||
// try
|
// try
|
||||||
// {
|
// {
|
||||||
// var input = await GetUserInputAsync(ctx.User.Id, ctx.Channel.Id).ConfigureAwait(false);
|
// var input = await GetUserInputAsync(ctx.User.Id, ctx.Channel.Id).ConfigureAwait(false);
|
||||||
// if (input == null
|
// if (input is null
|
||||||
// || !int.TryParse(input, out var index)
|
// || !int.TryParse(input, out var index)
|
||||||
// || (index -= 1) < 0
|
// || (index -= 1) < 0
|
||||||
// || index >= videos.Length)
|
// || index >= videos.Length)
|
||||||
@@ -436,7 +436,7 @@
|
|||||||
// public async Task SongRemove(All _)
|
// public async Task SongRemove(All _)
|
||||||
// {
|
// {
|
||||||
// var mp = _service.GetPlayerOrDefault(ctx.Guild.Id);
|
// var mp = _service.GetPlayerOrDefault(ctx.Guild.Id);
|
||||||
// if (mp == null)
|
// if (mp is null)
|
||||||
// return;
|
// return;
|
||||||
// mp.Stop(true);
|
// mp.Stop(true);
|
||||||
// await ReplyConfirmLocalizedAsync("queue_cleared").ConfigureAwait(false);
|
// await ReplyConfirmLocalizedAsync("queue_cleared").ConfigureAwait(false);
|
||||||
@@ -576,7 +576,7 @@
|
|||||||
// mpl = uow.MusicPlaylists.GetWithSongs(id);
|
// mpl = uow.MusicPlaylists.GetWithSongs(id);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// if (mpl == null)
|
// if (mpl is null)
|
||||||
// {
|
// {
|
||||||
// await ReplyErrorLocalizedAsync("playlist_id_not_found").ConfigureAwait(false);
|
// await ReplyErrorLocalizedAsync("playlist_id_not_found").ConfigureAwait(false);
|
||||||
// return;
|
// return;
|
||||||
@@ -700,7 +700,7 @@
|
|||||||
// {
|
// {
|
||||||
// var mp = await _service.GetOrCreatePlayer(Context).ConfigureAwait(false);
|
// var mp = await _service.GetOrCreatePlayer(Context).ConfigureAwait(false);
|
||||||
// var (_, currentSong) = mp.Current;
|
// var (_, currentSong) = mp.Current;
|
||||||
// if (currentSong == null)
|
// if (currentSong is null)
|
||||||
// return;
|
// return;
|
||||||
// try { await mp.UpdateSongDurationsAsync().ConfigureAwait(false); } catch { }
|
// try { await mp.UpdateSongDurationsAsync().ConfigureAwait(false); } catch { }
|
||||||
//
|
//
|
||||||
@@ -744,7 +744,7 @@
|
|||||||
// Log.Warning(ex.Message);
|
// Log.Warning(ex.Message);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// if (plId == null)
|
// if (plId is null)
|
||||||
// {
|
// {
|
||||||
// await ReplyErrorLocalizedAsync("no_search_results").ConfigureAwait(false);
|
// await ReplyErrorLocalizedAsync("no_search_results").ConfigureAwait(false);
|
||||||
// return;
|
// return;
|
||||||
@@ -834,12 +834,12 @@
|
|||||||
// {
|
// {
|
||||||
// var vch = ((IGuildUser)ctx.User).VoiceChannel;
|
// var vch = ((IGuildUser)ctx.User).VoiceChannel;
|
||||||
//
|
//
|
||||||
// if (vch == null)
|
// if (vch is null)
|
||||||
// return;
|
// return;
|
||||||
//
|
//
|
||||||
// var mp = _service.GetPlayerOrDefault(ctx.Guild.Id);
|
// var mp = _service.GetPlayerOrDefault(ctx.Guild.Id);
|
||||||
//
|
//
|
||||||
// if (mp == null)
|
// if (mp is null)
|
||||||
// return;
|
// return;
|
||||||
//
|
//
|
||||||
// await mp.SetVoiceChannel(vch).ConfigureAwait(false);
|
// await mp.SetVoiceChannel(vch).ConfigureAwait(false);
|
||||||
@@ -853,7 +853,7 @@
|
|||||||
// return;
|
// return;
|
||||||
//
|
//
|
||||||
// MusicPlayer mp = _service.GetPlayerOrDefault(ctx.Guild.Id);
|
// MusicPlayer mp = _service.GetPlayerOrDefault(ctx.Guild.Id);
|
||||||
// if (mp == null)
|
// if (mp is null)
|
||||||
// return;
|
// return;
|
||||||
//
|
//
|
||||||
// fromto = fromto?.Trim();
|
// fromto = fromto?.Trim();
|
||||||
@@ -862,7 +862,7 @@
|
|||||||
// SongInfo s;
|
// SongInfo s;
|
||||||
// if (fromtoArr.Length != 2 || !int.TryParse(fromtoArr[0], out var n1) ||
|
// if (fromtoArr.Length != 2 || !int.TryParse(fromtoArr[0], out var n1) ||
|
||||||
// !int.TryParse(fromtoArr[1], out var n2) || n1 < 1 || n2 < 1 || n1 == n2
|
// !int.TryParse(fromtoArr[1], out var n2) || n1 < 1 || n2 < 1 || n1 == n2
|
||||||
// || (s = mp.MoveSong(--n1, --n2)) == null)
|
// || (s = mp.MoveSong(--n1, --n2)) is null)
|
||||||
// {
|
// {
|
||||||
// await ReplyConfirmLocalizedAsync("invalid_input").ConfigureAwait(false);
|
// await ReplyConfirmLocalizedAsync("invalid_input").ConfigureAwait(false);
|
||||||
// return;
|
// return;
|
||||||
@@ -916,7 +916,7 @@
|
|||||||
// {
|
// {
|
||||||
// var mp = await _service.GetOrCreatePlayer(Context).ConfigureAwait(false);
|
// var mp = await _service.GetOrCreatePlayer(Context).ConfigureAwait(false);
|
||||||
// var (_, currentSong) = mp.Current;
|
// var (_, currentSong) = mp.Current;
|
||||||
// if (currentSong == null)
|
// if (currentSong is null)
|
||||||
// return;
|
// return;
|
||||||
// var currentValue = mp.ToggleRepeatSong();
|
// var currentValue = mp.ToggleRepeatSong();
|
||||||
//
|
//
|
||||||
|
@@ -55,13 +55,13 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
img = await _service.DapiSearch(tag, type, ctx.Guild?.Id, true).ConfigureAwait(false);
|
img = await _service.DapiSearch(tag, type, ctx.Guild?.Id, true).ConfigureAwait(false);
|
||||||
// if i can't find the image, ran out of providers, or tag is blacklisted
|
// if i can't find the image, ran out of providers, or tag is blacklisted
|
||||||
// return the error
|
// return the error
|
||||||
if (img == null && !listOfProviders.Any())
|
if (img is null && !listOfProviders.Any())
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync("no_results").ConfigureAwait(false);
|
await ReplyErrorLocalizedAsync("no_results").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (img == null);
|
} while (img is null);
|
||||||
|
|
||||||
await channel.EmbedAsync(new EmbedBuilder().WithOkColor()
|
await channel.EmbedAsync(new EmbedBuilder().WithOkColor()
|
||||||
.WithImageUrl(img.FileUrl)
|
.WithImageUrl(img.FileUrl)
|
||||||
@@ -129,7 +129,7 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (tagsArr == null || tagsArr.Length == 0)
|
if (tagsArr is null || tagsArr.Length == 0)
|
||||||
await InternalHentai(ctx.Channel, null).ConfigureAwait(false);
|
await InternalHentai(ctx.Channel, null).ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
await InternalHentai(ctx.Channel, tagsArr[new NadekoRandom().Next(0, tagsArr.Length)]).ConfigureAwait(false);
|
await InternalHentai(ctx.Channel, tagsArr[new NadekoRandom().Next(0, tagsArr.Length)]).ConfigureAwait(false);
|
||||||
@@ -252,7 +252,7 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
_service.DapiSearch(tag, DapiSearchType.Yandere, ctx.Guild?.Id, true)).ConfigureAwait(false);
|
_service.DapiSearch(tag, DapiSearchType.Yandere, ctx.Guild?.Id, true)).ConfigureAwait(false);
|
||||||
|
|
||||||
var linksEnum = images?.Where(l => l != null).ToArray();
|
var linksEnum = images?.Where(l => l != null).ToArray();
|
||||||
if (images == null || !linksEnum.Any())
|
if (images is null || !linksEnum.Any())
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync("no_results").ConfigureAwait(false);
|
await ReplyErrorLocalizedAsync("no_results").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
@@ -439,7 +439,7 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
|
|
||||||
imgObj = await _service.DapiSearch(tag, type, ctx.Guild?.Id, forceExplicit).ConfigureAwait(false);
|
imgObj = await _service.DapiSearch(tag, type, ctx.Guild?.Id, forceExplicit).ConfigureAwait(false);
|
||||||
|
|
||||||
if (imgObj == null)
|
if (imgObj is null)
|
||||||
await ReplyErrorLocalizedAsync("no_results").ConfigureAwait(false);
|
await ReplyErrorLocalizedAsync("no_results").ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -19,7 +19,7 @@ namespace NadekoBot.Modules.Permissions.Common
|
|||||||
|
|
||||||
var result = perm.CheckPermission(message, commandName, moduleName);
|
var result = perm.CheckPermission(message, commandName, moduleName);
|
||||||
|
|
||||||
if (result == null)
|
if (result is null)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -55,13 +55,13 @@ namespace NadekoBot.Modules.Permissions.Common
|
|||||||
return perm.State;
|
return perm.State;
|
||||||
break;
|
break;
|
||||||
case PrimaryPermissionType.Role:
|
case PrimaryPermissionType.Role:
|
||||||
if (guildUser == null)
|
if (guildUser is null)
|
||||||
break;
|
break;
|
||||||
if (guildUser.RoleIds.Contains(perm.PrimaryTargetId))
|
if (guildUser.RoleIds.Contains(perm.PrimaryTargetId))
|
||||||
return perm.State;
|
return perm.State;
|
||||||
break;
|
break;
|
||||||
case PrimaryPermissionType.Server:
|
case PrimaryPermissionType.Server:
|
||||||
if (guildUser == null)
|
if (guildUser is null)
|
||||||
break;
|
break;
|
||||||
return perm.State;
|
return perm.State;
|
||||||
}
|
}
|
||||||
|
@@ -77,7 +77,7 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
};
|
};
|
||||||
removed = config.FilterInvitesChannelIds.FirstOrDefault(fc => fc.Equals(match));
|
removed = config.FilterInvitesChannelIds.FirstOrDefault(fc => fc.Equals(match));
|
||||||
|
|
||||||
if (removed == null)
|
if (removed is null)
|
||||||
{
|
{
|
||||||
config.FilterInvitesChannelIds.Add(match);
|
config.FilterInvitesChannelIds.Add(match);
|
||||||
}
|
}
|
||||||
@@ -88,7 +88,7 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
await uow.SaveChangesAsync();
|
await uow.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (removed == null)
|
if (removed is null)
|
||||||
{
|
{
|
||||||
_service.InviteFilteringChannels.Add(channel.Id);
|
_service.InviteFilteringChannels.Add(channel.Id);
|
||||||
await ReplyConfirmLocalizedAsync("invite_filter_channel_on").ConfigureAwait(false);
|
await ReplyConfirmLocalizedAsync("invite_filter_channel_on").ConfigureAwait(false);
|
||||||
@@ -142,7 +142,7 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
};
|
};
|
||||||
removed = config.FilterLinksChannelIds.FirstOrDefault(fc => fc.Equals(match));
|
removed = config.FilterLinksChannelIds.FirstOrDefault(fc => fc.Equals(match));
|
||||||
|
|
||||||
if (removed == null)
|
if (removed is null)
|
||||||
{
|
{
|
||||||
config.FilterLinksChannelIds.Add(match);
|
config.FilterLinksChannelIds.Add(match);
|
||||||
}
|
}
|
||||||
@@ -153,7 +153,7 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
await uow.SaveChangesAsync();
|
await uow.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (removed == null)
|
if (removed is null)
|
||||||
{
|
{
|
||||||
_service.LinkFilteringChannels.Add(channel.Id);
|
_service.LinkFilteringChannels.Add(channel.Id);
|
||||||
await ReplyConfirmLocalizedAsync("link_filter_channel_on").ConfigureAwait(false);
|
await ReplyConfirmLocalizedAsync("link_filter_channel_on").ConfigureAwait(false);
|
||||||
@@ -207,7 +207,7 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
ChannelId = channel.Id
|
ChannelId = channel.Id
|
||||||
};
|
};
|
||||||
removed = config.FilterWordsChannelIds.FirstOrDefault(fc => fc.Equals(match));
|
removed = config.FilterWordsChannelIds.FirstOrDefault(fc => fc.Equals(match));
|
||||||
if (removed == null)
|
if (removed is null)
|
||||||
{
|
{
|
||||||
config.FilterWordsChannelIds.Add(match);
|
config.FilterWordsChannelIds.Add(match);
|
||||||
}
|
}
|
||||||
@@ -218,7 +218,7 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
await uow.SaveChangesAsync();
|
await uow.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (removed == null)
|
if (removed is null)
|
||||||
{
|
{
|
||||||
_service.WordFilteringChannels.Add(channel.Id);
|
_service.WordFilteringChannels.Add(channel.Id);
|
||||||
await ReplyConfirmLocalizedAsync("word_filter_channel_on").ConfigureAwait(false);
|
await ReplyConfirmLocalizedAsync("word_filter_channel_on").ConfigureAwait(false);
|
||||||
@@ -248,7 +248,7 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
|
|
||||||
removed = config.FilteredWords.FirstOrDefault(fw => fw.Word.Trim().ToLowerInvariant() == word);
|
removed = config.FilteredWords.FirstOrDefault(fw => fw.Word.Trim().ToLowerInvariant() == word);
|
||||||
|
|
||||||
if (removed == null)
|
if (removed is null)
|
||||||
config.FilteredWords.Add(new FilteredWord() { Word = word });
|
config.FilteredWords.Add(new FilteredWord() { Word = word });
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -260,7 +260,7 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
|
|
||||||
var filteredWords = _service.ServerFilteredWords.GetOrAdd(channel.Guild.Id, new ConcurrentHashSet<string>());
|
var filteredWords = _service.ServerFilteredWords.GetOrAdd(channel.Guild.Id, new ConcurrentHashSet<string>());
|
||||||
|
|
||||||
if (removed == null)
|
if (removed is null)
|
||||||
{
|
{
|
||||||
filteredWords.Add(word);
|
filteredWords.Add(word);
|
||||||
await ReplyConfirmLocalizedAsync("filter_word_add", Format.Code(word)).ConfigureAwait(false);
|
await ReplyConfirmLocalizedAsync("filter_word_add", Format.Code(word)).ConfigureAwait(false);
|
||||||
|
@@ -33,7 +33,7 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
using (var uow = _db.GetDbContext())
|
using (var uow = _db.GetDbContext())
|
||||||
{
|
{
|
||||||
var config = uow.GcWithPermissionsv2For(ctx.Guild.Id);
|
var config = uow.GcWithPermissionsv2For(ctx.Guild.Id);
|
||||||
if (action == null) action = new PermissionAction(!config.VerbosePermissions); // New behaviour, can toggle.
|
if (action is null) action = new PermissionAction(!config.VerbosePermissions); // New behaviour, can toggle.
|
||||||
config.VerbosePermissions = action.Value;
|
config.VerbosePermissions = action.Value;
|
||||||
await uow.SaveChangesAsync();
|
await uow.SaveChangesAsync();
|
||||||
_service.UpdateCache(config);
|
_service.UpdateCache(config);
|
||||||
@@ -57,11 +57,11 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
if (role != null && role == role.Guild.EveryoneRole)
|
if (role != null && role == role.Guild.EveryoneRole)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (role == null)
|
if (role is null)
|
||||||
{
|
{
|
||||||
var cache = _service.GetCacheFor(ctx.Guild.Id);
|
var cache = _service.GetCacheFor(ctx.Guild.Id);
|
||||||
if (!ulong.TryParse(cache.PermRole, out var roleId) ||
|
if (!ulong.TryParse(cache.PermRole, out var roleId) ||
|
||||||
(role = ((SocketGuild)ctx.Guild).GetRole(roleId)) == null)
|
(role = ((SocketGuild)ctx.Guild).GetRole(roleId)) is null)
|
||||||
{
|
{
|
||||||
await ReplyConfirmLocalizedAsync("permrole_not_set", Format.Bold(cache.PermRole)).ConfigureAwait(false);
|
await ReplyConfirmLocalizedAsync("permrole_not_set", Format.Bold(cache.PermRole)).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
@@ -89,7 +89,7 @@ namespace NadekoBot.Modules.Permissions.Services
|
|||||||
var toRemove = uow.Blacklist
|
var toRemove = uow.Blacklist
|
||||||
.FirstOrDefault(bi => bi.ItemId == id && bi.Type == type);
|
.FirstOrDefault(bi => bi.ItemId == id && bi.Type == type);
|
||||||
|
|
||||||
if (!(toRemove is null))
|
if (toRemove is not null)
|
||||||
uow.Blacklist.Remove(toRemove);
|
uow.Blacklist.Remove(toRemove);
|
||||||
|
|
||||||
uow.SaveChanges();
|
uow.SaveChanges();
|
||||||
|
@@ -114,7 +114,7 @@ namespace NadekoBot.Modules.Permissions.Services
|
|||||||
var guild = (channel as ITextChannel)?.Guild;
|
var guild = (channel as ITextChannel)?.Guild;
|
||||||
var usrMsg = newMsg as IUserMessage;
|
var usrMsg = newMsg as IUserMessage;
|
||||||
|
|
||||||
if (guild == null || usrMsg == null)
|
if (guild is null || usrMsg is null)
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
||||||
return RunBehavior(null, guild, usrMsg);
|
return RunBehavior(null, guild, usrMsg);
|
||||||
|
@@ -59,7 +59,7 @@ namespace NadekoBot.Modules.Permissions.Services
|
|||||||
UpdateCache(config);
|
UpdateCache(config);
|
||||||
}
|
}
|
||||||
Cache.TryGetValue(guildId, out pc);
|
Cache.TryGetValue(guildId, out pc);
|
||||||
if (pc == null)
|
if (pc is null)
|
||||||
throw new Exception("Cache is null.");
|
throw new Exception("Cache is null.");
|
||||||
}
|
}
|
||||||
return pc;
|
return pc;
|
||||||
@@ -108,7 +108,7 @@ namespace NadekoBot.Modules.Permissions.Services
|
|||||||
var commandName = command.Name.ToLowerInvariant();
|
var commandName = command.Name.ToLowerInvariant();
|
||||||
|
|
||||||
await Task.Yield();
|
await Task.Yield();
|
||||||
if (guild == null)
|
if (guild is null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -149,7 +149,7 @@ namespace NadekoBot.Modules.Permissions.Services
|
|||||||
rid = 0;
|
rid = 0;
|
||||||
string returnMsg;
|
string returnMsg;
|
||||||
IRole role;
|
IRole role;
|
||||||
if (string.IsNullOrWhiteSpace(permRole) || (role = guild.GetRole(rid)) == null)
|
if (string.IsNullOrWhiteSpace(permRole) || (role = guild.GetRole(rid)) is null)
|
||||||
{
|
{
|
||||||
returnMsg = $"You need Admin permissions in order to use permission commands.";
|
returnMsg = $"You need Admin permissions in order to use permission commands.";
|
||||||
if (pc.Verbose)
|
if (pc.Verbose)
|
||||||
|
@@ -24,7 +24,7 @@ namespace NadekoBot.Modules.Searches
|
|||||||
|
|
||||||
var novelData = await _service.GetNovelData(query).ConfigureAwait(false);
|
var novelData = await _service.GetNovelData(query).ConfigureAwait(false);
|
||||||
|
|
||||||
if (novelData == null)
|
if (novelData is null)
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync("failed_finding_novel").ConfigureAwait(false);
|
await ReplyErrorLocalizedAsync("failed_finding_novel").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
@@ -63,7 +63,7 @@ namespace NadekoBot.Modules.Searches
|
|||||||
var favorites = document.QuerySelectorAll("div.user-favorites > div.di-tc");
|
var favorites = document.QuerySelectorAll("div.user-favorites > div.di-tc");
|
||||||
|
|
||||||
var favAnime = GetText("anime_no_fav");
|
var favAnime = GetText("anime_no_fav");
|
||||||
if (favorites.Length > 0 && favorites[0].QuerySelector("p") == null)
|
if (favorites.Length > 0 && favorites[0].QuerySelector("p") is null)
|
||||||
favAnime = string.Join("\n", favorites[0].QuerySelectorAll("ul > li > div.di-tc.va-t > a")
|
favAnime = string.Join("\n", favorites[0].QuerySelectorAll("ul > li > div.di-tc.va-t > a")
|
||||||
.Shuffle()
|
.Shuffle()
|
||||||
.Take(3)
|
.Take(3)
|
||||||
@@ -144,7 +144,7 @@ namespace NadekoBot.Modules.Searches
|
|||||||
|
|
||||||
var animeData = await _service.GetAnimeData(query).ConfigureAwait(false);
|
var animeData = await _service.GetAnimeData(query).ConfigureAwait(false);
|
||||||
|
|
||||||
if (animeData == null)
|
if (animeData is null)
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync("failed_finding_anime").ConfigureAwait(false);
|
await ReplyErrorLocalizedAsync("failed_finding_anime").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
@@ -172,7 +172,7 @@ namespace NadekoBot.Modules.Searches
|
|||||||
|
|
||||||
var mangaData = await _service.GetMangaData(query).ConfigureAwait(false);
|
var mangaData = await _service.GetMangaData(query).ConfigureAwait(false);
|
||||||
|
|
||||||
if (mangaData == null)
|
if (mangaData is null)
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync("failed_finding_manga").ConfigureAwait(false);
|
await ReplyErrorLocalizedAsync("failed_finding_manga").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
|
@@ -32,7 +32,7 @@ namespace NadekoBot.Modules.Searches
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (crypto == null)
|
if (crypto is null)
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync("crypto_not_found").ConfigureAwait(false);
|
await ReplyErrorLocalizedAsync("crypto_not_found").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
|
@@ -51,7 +51,7 @@ namespace NadekoBot.Modules.Searches
|
|||||||
public async Task Rip([Leftover] IGuildUser usr)
|
public async Task Rip([Leftover] IGuildUser usr)
|
||||||
{
|
{
|
||||||
var av = usr.RealAvatarUrl(128);
|
var av = usr.RealAvatarUrl(128);
|
||||||
if (av == null)
|
if (av is null)
|
||||||
return;
|
return;
|
||||||
using (var picStream = await _service.GetRipPictureAsync(usr.Nickname ?? usr.Username, av).ConfigureAwait(false))
|
using (var picStream = await _service.GetRipPictureAsync(usr.Nickname ?? usr.Username, av).ConfigureAwait(false))
|
||||||
{
|
{
|
||||||
@@ -73,7 +73,7 @@ namespace NadekoBot.Modules.Searches
|
|||||||
var embed = new EmbedBuilder();
|
var embed = new EmbedBuilder();
|
||||||
var data = await _service.GetWeatherDataAsync(query).ConfigureAwait(false);
|
var data = await _service.GetWeatherDataAsync(query).ConfigureAwait(false);
|
||||||
|
|
||||||
if (data == null)
|
if (data is null)
|
||||||
{
|
{
|
||||||
embed.WithDescription(GetText("city_not_found"))
|
embed.WithDescription(GetText("city_not_found"))
|
||||||
.WithErrorColor();
|
.WithErrorColor();
|
||||||
@@ -115,7 +115,7 @@ namespace NadekoBot.Modules.Searches
|
|||||||
await ctx.Channel.TriggerTypingAsync().ConfigureAwait(false);
|
await ctx.Channel.TriggerTypingAsync().ConfigureAwait(false);
|
||||||
|
|
||||||
var (data, err) = await _service.GetTimeDataAsync(query).ConfigureAwait(false);
|
var (data, err) = await _service.GetTimeDataAsync(query).ConfigureAwait(false);
|
||||||
if (!(err is null))
|
if (err is not null)
|
||||||
{
|
{
|
||||||
string errorKey;
|
string errorKey;
|
||||||
switch (err)
|
switch (err)
|
||||||
@@ -177,7 +177,7 @@ namespace NadekoBot.Modules.Searches
|
|||||||
await ctx.Channel.TriggerTypingAsync().ConfigureAwait(false);
|
await ctx.Channel.TriggerTypingAsync().ConfigureAwait(false);
|
||||||
|
|
||||||
var movie = await _service.GetMovieDataAsync(query).ConfigureAwait(false);
|
var movie = await _service.GetMovieDataAsync(query).ConfigureAwait(false);
|
||||||
if (movie == null)
|
if (movie is null)
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync("imdb_fail").ConfigureAwait(false);
|
await ReplyErrorLocalizedAsync("imdb_fail").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
@@ -247,7 +247,7 @@ namespace NadekoBot.Modules.Searches
|
|||||||
|
|
||||||
var img = (elems.ElementAtOrDefault(new NadekoRandom().Next(0, elems.Count))?.Children?.FirstOrDefault() as IHtmlImageElement);
|
var img = (elems.ElementAtOrDefault(new NadekoRandom().Next(0, elems.Count))?.Children?.FirstOrDefault() as IHtmlImageElement);
|
||||||
|
|
||||||
if (img?.Source == null)
|
if (img?.Source is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var source = img.Source.Replace("b.", ".", StringComparison.InvariantCulture);
|
var source = img.Source.Replace("b.", ".", StringComparison.InvariantCulture);
|
||||||
@@ -406,7 +406,7 @@ namespace NadekoBot.Modules.Searches
|
|||||||
await ctx.Channel.TriggerTypingAsync().ConfigureAwait(false);
|
await ctx.Channel.TriggerTypingAsync().ConfigureAwait(false);
|
||||||
var card = await _service.GetMtgCardAsync(search).ConfigureAwait(false);
|
var card = await _service.GetMtgCardAsync(search).ConfigureAwait(false);
|
||||||
|
|
||||||
if (card == null)
|
if (card is null)
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync("card_not_found").ConfigureAwait(false);
|
await ReplyErrorLocalizedAsync("card_not_found").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
@@ -439,7 +439,7 @@ namespace NadekoBot.Modules.Searches
|
|||||||
await ctx.Channel.TriggerTypingAsync().ConfigureAwait(false);
|
await ctx.Channel.TriggerTypingAsync().ConfigureAwait(false);
|
||||||
var card = await _service.GetHearthstoneCardDataAsync(name).ConfigureAwait(false);
|
var card = await _service.GetHearthstoneCardDataAsync(name).ConfigureAwait(false);
|
||||||
|
|
||||||
if (card == null)
|
if (card is null)
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync("card_not_found").ConfigureAwait(false);
|
await ReplyErrorLocalizedAsync("card_not_found").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
@@ -560,7 +560,7 @@ namespace NadekoBot.Modules.Searches
|
|||||||
using (var http = _httpFactory.CreateClient())
|
using (var http = _httpFactory.CreateClient())
|
||||||
{
|
{
|
||||||
var response = await http.GetStringAsync("https://catfact.ninja/fact").ConfigureAwait(false);
|
var response = await http.GetStringAsync("https://catfact.ninja/fact").ConfigureAwait(false);
|
||||||
if (response == null)
|
if (response is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var fact = JObject.Parse(response)["fact"].ToString();
|
var fact = JObject.Parse(response)["fact"].ToString();
|
||||||
@@ -573,11 +573,11 @@ namespace NadekoBot.Modules.Searches
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Revav([Leftover] IGuildUser usr = null)
|
public async Task Revav([Leftover] IGuildUser usr = null)
|
||||||
{
|
{
|
||||||
if (usr == null)
|
if (usr is null)
|
||||||
usr = (IGuildUser)ctx.User;
|
usr = (IGuildUser)ctx.User;
|
||||||
|
|
||||||
var av = usr.RealAvatarUrl();
|
var av = usr.RealAvatarUrl();
|
||||||
if (av == null)
|
if (av is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
await ctx.Channel.SendConfirmAsync($"https://images.google.com/searchbyimage?image_url={av}").ConfigureAwait(false);
|
await ctx.Channel.SendConfirmAsync($"https://images.google.com/searchbyimage?image_url={av}").ConfigureAwait(false);
|
||||||
@@ -649,12 +649,12 @@ namespace NadekoBot.Modules.Searches
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Avatar([Leftover] IGuildUser usr = null)
|
public async Task Avatar([Leftover] IGuildUser usr = null)
|
||||||
{
|
{
|
||||||
if (usr == null)
|
if (usr is null)
|
||||||
usr = (IGuildUser)ctx.User;
|
usr = (IGuildUser)ctx.User;
|
||||||
|
|
||||||
var avatarUrl = usr.RealAvatarUrl(2048);
|
var avatarUrl = usr.RealAvatarUrl(2048);
|
||||||
|
|
||||||
if (avatarUrl == null)
|
if (avatarUrl is null)
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync("avatar_none", usr.ToString()).ConfigureAwait(false);
|
await ReplyErrorLocalizedAsync("avatar_none", usr.ToString()).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
@@ -725,7 +725,7 @@ namespace NadekoBot.Modules.Searches
|
|||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
if (obj.Error != null || obj.Verses == null || obj.Verses.Length == 0)
|
if (obj.Error != null || obj.Verses is null || obj.Verses.Length == 0)
|
||||||
await ctx.Channel.SendErrorAsync(obj.Error ?? "No verse found.").ConfigureAwait(false);
|
await ctx.Channel.SendErrorAsync(obj.Error ?? "No verse found.").ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -773,7 +773,7 @@ namespace NadekoBot.Modules.Searches
|
|||||||
|
|
||||||
var imgObj = await _service.DapiSearch(tag, type, ctx.Guild?.Id).ConfigureAwait(false);
|
var imgObj = await _service.DapiSearch(tag, type, ctx.Guild?.Id).ConfigureAwait(false);
|
||||||
|
|
||||||
if (imgObj == null)
|
if (imgObj is null)
|
||||||
await channel.SendErrorAsync(umsg.Author.Mention + " " + GetText("no_results")).ConfigureAwait(false);
|
await channel.SendErrorAsync(umsg.Author.Mention + " " + GetText("no_results")).ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
await channel.EmbedAsync(new EmbedBuilder().WithOkColor()
|
await channel.EmbedAsync(new EmbedBuilder().WithOkColor()
|
||||||
|
@@ -67,7 +67,7 @@ namespace NadekoBot.Modules.Searches.Services
|
|||||||
using (var document = await BrowsingContext.New(config).OpenAsync(link).ConfigureAwait(false))
|
using (var document = await BrowsingContext.New(config).OpenAsync(link).ConfigureAwait(false))
|
||||||
{
|
{
|
||||||
var imageElem = document.QuerySelector("div.seriesimg > img");
|
var imageElem = document.QuerySelector("div.seriesimg > img");
|
||||||
if (imageElem == null)
|
if (imageElem is null)
|
||||||
return null;
|
return null;
|
||||||
var imageUrl = ((IHtmlImageElement)imageElem).Source;
|
var imageUrl = ((IHtmlImageElement)imageElem).Source;
|
||||||
|
|
||||||
|
@@ -40,7 +40,7 @@ namespace NadekoBot.Modules.Searches.Services
|
|||||||
|| x.Symbol.ToUpperInvariant() == name);
|
|| x.Symbol.ToUpperInvariant() == name);
|
||||||
|
|
||||||
(CryptoResponseData Elem, int Distance)? nearest = null;
|
(CryptoResponseData Elem, int Distance)? nearest = null;
|
||||||
if (crypto == null)
|
if (crypto is null)
|
||||||
{
|
{
|
||||||
nearest = cryptos.Select(x => (x, Distance: x.Name.ToUpperInvariant().LevenshteinDistance(name)))
|
nearest = cryptos.Select(x => (x, Distance: x.Name.ToUpperInvariant().LevenshteinDistance(name)))
|
||||||
.OrderBy(x => x.Distance)
|
.OrderBy(x => x.Distance)
|
||||||
|
@@ -118,7 +118,7 @@ namespace NadekoBot.Modules.Searches.Services
|
|||||||
var previewElement = afi.Element.Elements()
|
var previewElement = afi.Element.Elements()
|
||||||
.FirstOrDefault(x => x.Name.LocalName == "preview");
|
.FirstOrDefault(x => x.Name.LocalName == "preview");
|
||||||
|
|
||||||
if (previewElement == null)
|
if (previewElement is null)
|
||||||
{
|
{
|
||||||
previewElement = afi.Element.Elements()
|
previewElement = afi.Element.Elements()
|
||||||
.FirstOrDefault(x => x.Name.LocalName == "thumbnail");
|
.FirstOrDefault(x => x.Name.LocalName == "thumbnail");
|
||||||
|
@@ -226,7 +226,7 @@ namespace NadekoBot.Modules.Searches.Services
|
|||||||
$"appid=42cd627dd60debf25a5739e50a217d74&" +
|
$"appid=42cd627dd60debf25a5739e50a217d74&" +
|
||||||
$"units=metric").ConfigureAwait(false);
|
$"units=metric").ConfigureAwait(false);
|
||||||
|
|
||||||
if (data == null)
|
if (data is null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return JsonConvert.DeserializeObject<WeatherData>(data);
|
return JsonConvert.DeserializeObject<WeatherData>(data);
|
||||||
@@ -504,7 +504,7 @@ namespace NadekoBot.Modules.Searches.Services
|
|||||||
search,
|
search,
|
||||||
TimeSpan.FromDays(1)).ConfigureAwait(false);
|
TimeSpan.FromDays(1)).ConfigureAwait(false);
|
||||||
|
|
||||||
if (data == null || data.Length == 0)
|
if (data is null || data.Length == 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return data[_rng.Next(0, data.Length)];
|
return data[_rng.Next(0, data.Length)];
|
||||||
@@ -543,7 +543,7 @@ namespace NadekoBot.Modules.Searches.Services
|
|||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
var responseObject = JsonConvert.DeserializeObject<MtgResponse>(response);
|
var responseObject = JsonConvert.DeserializeObject<MtgResponse>(response);
|
||||||
if (responseObject == null)
|
if (responseObject is null)
|
||||||
return new MtgData[0];
|
return new MtgData[0];
|
||||||
|
|
||||||
var cards = responseObject.Cards.Take(5).ToArray();
|
var cards = responseObject.Cards.Take(5).ToArray();
|
||||||
@@ -582,12 +582,12 @@ namespace NadekoBot.Modules.Searches.Services
|
|||||||
var response = await http.GetStringAsync($"https://omgvamp-hearthstone-v1.p.rapidapi.com/" +
|
var response = await http.GetStringAsync($"https://omgvamp-hearthstone-v1.p.rapidapi.com/" +
|
||||||
$"cards/search/{Uri.EscapeUriString(name)}").ConfigureAwait(false);
|
$"cards/search/{Uri.EscapeUriString(name)}").ConfigureAwait(false);
|
||||||
var objs = JsonConvert.DeserializeObject<HearthstoneCardData[]>(response);
|
var objs = JsonConvert.DeserializeObject<HearthstoneCardData[]>(response);
|
||||||
if (objs == null || objs.Length == 0)
|
if (objs is null || objs.Length == 0)
|
||||||
return null;
|
return null;
|
||||||
var data = objs.FirstOrDefault(x => x.Collectible)
|
var data = objs.FirstOrDefault(x => x.Collectible)
|
||||||
?? objs.FirstOrDefault(x => !string.IsNullOrEmpty(x.PlayerClass))
|
?? objs.FirstOrDefault(x => !string.IsNullOrEmpty(x.PlayerClass))
|
||||||
?? objs.FirstOrDefault();
|
?? objs.FirstOrDefault();
|
||||||
if (data == null)
|
if (data is null)
|
||||||
return null;
|
return null;
|
||||||
if (!string.IsNullOrWhiteSpace(data.Img))
|
if (!string.IsNullOrWhiteSpace(data.Img))
|
||||||
{
|
{
|
||||||
@@ -624,7 +624,7 @@ namespace NadekoBot.Modules.Searches.Services
|
|||||||
var res = await http.GetStringAsync(string.Format("https://omdbapi.nadeko.bot/?t={0}&y=&plot=full&r=json",
|
var res = await http.GetStringAsync(string.Format("https://omdbapi.nadeko.bot/?t={0}&y=&plot=full&r=json",
|
||||||
name.Trim().Replace(' ', '+'))).ConfigureAwait(false);
|
name.Trim().Replace(' ', '+'))).ConfigureAwait(false);
|
||||||
var movie = JsonConvert.DeserializeObject<OmdbMovie>(res);
|
var movie = JsonConvert.DeserializeObject<OmdbMovie>(res);
|
||||||
if (movie?.Title == null)
|
if (movie?.Title is null)
|
||||||
return null;
|
return null;
|
||||||
movie.Poster = await _google.ShortenUrl(movie.Poster).ConfigureAwait(false);
|
movie.Poster = await _google.ShortenUrl(movie.Poster).ConfigureAwait(false);
|
||||||
return movie;
|
return movie;
|
||||||
@@ -671,7 +671,7 @@ namespace NadekoBot.Modules.Searches.Services
|
|||||||
}
|
}
|
||||||
}, default(string), TimeSpan.FromHours(24));
|
}, default(string), TimeSpan.FromHours(24));
|
||||||
|
|
||||||
if (gamesMap == null)
|
if (gamesMap is null)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
||||||
@@ -780,7 +780,7 @@ namespace NadekoBot.Modules.Searches.Services
|
|||||||
var href = (children[0].QuerySelector("a") as IHtmlAnchorElement)?.Href;
|
var href = (children[0].QuerySelector("a") as IHtmlAnchorElement)?.Href;
|
||||||
var name = children[0].QuerySelector("h3")?.TextContent;
|
var name = children[0].QuerySelector("h3")?.TextContent;
|
||||||
|
|
||||||
if (href == null || name == null)
|
if (href is null || name is null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var txt = children[1].TextContent;
|
var txt = children[1].TextContent;
|
||||||
|
@@ -94,7 +94,7 @@ namespace NadekoBot.Modules.Searches.Services
|
|||||||
// var oldObj = gc.YtFollowedChannels
|
// var oldObj = gc.YtFollowedChannels
|
||||||
// .FirstOrDefault(x => x.ChannelId == channelId && x.YtChannelId == ytChannelId);
|
// .FirstOrDefault(x => x.ChannelId == channelId && x.YtChannelId == ytChannelId);
|
||||||
//
|
//
|
||||||
// if(!(oldObj is null))
|
// if(oldObj is not null)
|
||||||
// {
|
// {
|
||||||
// return false;
|
// return false;
|
||||||
// }
|
// }
|
||||||
|
@@ -36,7 +36,7 @@ namespace NadekoBot.Modules.Utility
|
|||||||
guild = (SocketGuild)channel.Guild;
|
guild = (SocketGuild)channel.Guild;
|
||||||
else
|
else
|
||||||
guild = _client.Guilds.FirstOrDefault(g => g.Name.ToUpperInvariant() == guildName.ToUpperInvariant());
|
guild = _client.Guilds.FirstOrDefault(g => g.Name.ToUpperInvariant() == guildName.ToUpperInvariant());
|
||||||
if (guild == null)
|
if (guild is null)
|
||||||
return;
|
return;
|
||||||
var ownername = guild.GetUser(guild.OwnerId);
|
var ownername = guild.GetUser(guild.OwnerId);
|
||||||
var textchn = guild.TextChannels.Count();
|
var textchn = guild.TextChannels.Count();
|
||||||
@@ -79,7 +79,7 @@ namespace NadekoBot.Modules.Utility
|
|||||||
public async Task ChannelInfo(ITextChannel channel = null)
|
public async Task ChannelInfo(ITextChannel channel = null)
|
||||||
{
|
{
|
||||||
var ch = channel ?? (ITextChannel)ctx.Channel;
|
var ch = channel ?? (ITextChannel)ctx.Channel;
|
||||||
if (ch == null)
|
if (ch is null)
|
||||||
return;
|
return;
|
||||||
var createdAt = new DateTime(2015, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(ch.Id >> 22);
|
var createdAt = new DateTime(2015, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(ch.Id >> 22);
|
||||||
var usercount = (await ch.GetUsersAsync().FlattenAsync().ConfigureAwait(false)).Count();
|
var usercount = (await ch.GetUsersAsync().FlattenAsync().ConfigureAwait(false)).Count();
|
||||||
@@ -99,7 +99,7 @@ namespace NadekoBot.Modules.Utility
|
|||||||
{
|
{
|
||||||
var user = usr ?? ctx.User as IGuildUser;
|
var user = usr ?? ctx.User as IGuildUser;
|
||||||
|
|
||||||
if (user == null)
|
if (user is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var embed = new EmbedBuilder()
|
var embed = new EmbedBuilder()
|
||||||
|
@@ -75,7 +75,7 @@ namespace NadekoBot.Modules.Utility
|
|||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (quote == null)
|
if (quote is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var rep = new ReplacementBuilder()
|
var rep = new ReplacementBuilder()
|
||||||
@@ -141,7 +141,7 @@ namespace NadekoBot.Modules.Utility
|
|||||||
keywordquote = await uow.Quotes.SearchQuoteKeywordTextAsync(ctx.Guild.Id, keyword, text);
|
keywordquote = await uow.Quotes.SearchQuoteKeywordTextAsync(ctx.Guild.Id, keyword, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keywordquote == null)
|
if (keywordquote is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
await ctx.Channel.SendMessageAsync($"`#{keywordquote.Id}` 💬 " + keyword.ToLowerInvariant() + ": " +
|
await ctx.Channel.SendMessageAsync($"`#{keywordquote.Id}` 💬 " + keyword.ToLowerInvariant() + ": " +
|
||||||
|
@@ -48,7 +48,7 @@ namespace NadekoBot.Modules.Utility
|
|||||||
|
|
||||||
ulong target;
|
ulong target;
|
||||||
target = meorhere == MeOrHere.Me ? ctx.User.Id : ctx.Channel.Id;
|
target = meorhere == MeOrHere.Me ? ctx.User.Id : ctx.Channel.Id;
|
||||||
if (!await RemindInternal(target, meorhere == MeOrHere.Me || ctx.Guild == null, remindData.Time, remindData.What)
|
if (!await RemindInternal(target, meorhere == MeOrHere.Me || ctx.Guild is null, remindData.Time, remindData.What)
|
||||||
.ConfigureAwait(false))
|
.ConfigureAwait(false))
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync("remind_too_long").ConfigureAwait(false);
|
await ReplyErrorLocalizedAsync("remind_too_long").ConfigureAwait(false);
|
||||||
@@ -144,7 +144,7 @@ namespace NadekoBot.Modules.Utility
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rem == null)
|
if (rem is null)
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync("reminder_not_exist").ConfigureAwait(false);
|
await ReplyErrorLocalizedAsync("reminder_not_exist").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
@@ -186,7 +186,7 @@ namespace NadekoBot.Modules.Utility
|
|||||||
await uow.SaveChangesAsync();
|
await uow.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
var gTime = ctx.Guild == null
|
var gTime = ctx.Guild is null
|
||||||
? time
|
? time
|
||||||
: TimeZoneInfo.ConvertTime(time, _tz.GetTimeZoneOrUtc(ctx.Guild.Id));
|
: TimeZoneInfo.ConvertTime(time, _tz.GetTimeZoneOrUtc(ctx.Guild.Id));
|
||||||
try
|
try
|
||||||
|
@@ -65,7 +65,7 @@ namespace NadekoBot.Modules.Utility.Services
|
|||||||
{
|
{
|
||||||
await Task.Yield();
|
await Task.Yield();
|
||||||
|
|
||||||
if (guild == null || string.IsNullOrWhiteSpace(input))
|
if (guild is null || string.IsNullOrWhiteSpace(input))
|
||||||
return input;
|
return input;
|
||||||
|
|
||||||
if (guild != null)
|
if (guild != null)
|
||||||
|
@@ -84,7 +84,7 @@ namespace NadekoBot.Modules.Utility.Services
|
|||||||
data = JsonConvert.DeserializeObject<PatreonData>(res);
|
data = JsonConvert.DeserializeObject<PatreonData>(res);
|
||||||
var pledgers = data.Data.Where(x => x["type"].ToString() == "pledge");
|
var pledgers = data.Data.Where(x => x["type"].ToString() == "pledge");
|
||||||
rewards.AddRange(pledgers.Select(x => JsonConvert.DeserializeObject<PatreonPledge>(x.ToString()))
|
rewards.AddRange(pledgers.Select(x => JsonConvert.DeserializeObject<PatreonPledge>(x.ToString()))
|
||||||
.Where(x => x.attributes.declined_since == null));
|
.Where(x => x.attributes.declined_since is null));
|
||||||
if (data.Included != null)
|
if (data.Included != null)
|
||||||
{
|
{
|
||||||
users.AddRange(data.Included
|
users.AddRange(data.Included
|
||||||
@@ -141,7 +141,7 @@ namespace NadekoBot.Modules.Utility.Services
|
|||||||
var users = uow.Set<RewardedUser>();
|
var users = uow.Set<RewardedUser>();
|
||||||
var usr = users.FirstOrDefault(x => x.PatreonUserId == data.User.id);
|
var usr = users.FirstOrDefault(x => x.PatreonUserId == data.User.id);
|
||||||
|
|
||||||
if (usr == null)
|
if (usr is null)
|
||||||
{
|
{
|
||||||
users.Add(new RewardedUser()
|
users.Add(new RewardedUser()
|
||||||
{
|
{
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user