mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 17:58:26 -04:00
vars and target-typed new
This commit is contained in:
@@ -73,7 +73,7 @@ DELETE FROM Clubs;";
|
||||
{
|
||||
if (reader.HasRows)
|
||||
{
|
||||
for (int i = 0; i < reader.FieldCount; i++)
|
||||
for (var i = 0; i < reader.FieldCount; i++)
|
||||
{
|
||||
result.ColumnNames.Add(reader.GetName(i));
|
||||
}
|
||||
|
@@ -153,7 +153,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
|
||||
public LogSetting GetGuildLogSettings(ulong guildId)
|
||||
{
|
||||
GuildLogSettings.TryGetValue(guildId, out LogSetting logSetting);
|
||||
GuildLogSettings.TryGetValue(guildId, out var logSetting);
|
||||
return logSetting;
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
|
||||
public bool LogIgnore(ulong gid, ulong itemId, IgnoredItemType itemType)
|
||||
{
|
||||
int removed = 0;
|
||||
var removed = 0;
|
||||
using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var logSetting = uow.LogSettingsFor(gid);
|
||||
@@ -197,7 +197,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
|
||||
private string CurrentTime(IGuild g)
|
||||
{
|
||||
DateTime time = DateTime.UtcNow;
|
||||
var time = DateTime.UtcNow;
|
||||
if (g != null)
|
||||
time = TimeZoneInfo.ConvertTime(time, _tz.GetTimeZoneOrUtc(g.Id));
|
||||
|
||||
@@ -243,7 +243,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
|
||||
var g = after.Guild;
|
||||
|
||||
if (!GuildLogSettings.TryGetValue(g.Id, out LogSetting logSetting)
|
||||
if (!GuildLogSettings.TryGetValue(g.Id, out var logSetting)
|
||||
|| (logSetting.UserUpdatedId is null))
|
||||
return;
|
||||
|
||||
@@ -375,7 +375,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
if (beforeVch == afterVch)
|
||||
return;
|
||||
|
||||
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out LogSetting logSetting)
|
||||
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out var logSetting)
|
||||
|| (logSetting.LogVoicePresenceTTSId is null))
|
||||
return;
|
||||
|
||||
@@ -384,7 +384,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
.ConfigureAwait(false)) is null)
|
||||
return;
|
||||
|
||||
var str = "";
|
||||
var str = string.Empty;
|
||||
if (beforeVch?.Guild == afterVch?.Guild)
|
||||
{
|
||||
str = GetText(logChannel.Guild, strs.log_vc_moved(usr.Username, beforeVch?.Name, afterVch?.Name));
|
||||
@@ -415,7 +415,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out LogSetting logSetting)
|
||||
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out var logSetting)
|
||||
|| (logSetting.UserMutedId is null))
|
||||
return;
|
||||
|
||||
@@ -423,7 +423,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
if ((logChannel = await TryGetLogChannel(usr.Guild, logSetting, LogType.UserMuted)
|
||||
.ConfigureAwait(false)) is null)
|
||||
return;
|
||||
var mutes = "";
|
||||
var mutes = string.Empty;
|
||||
var mutedLocalized = GetText(logChannel.Guild, strs.muted_sn);
|
||||
switch (muteType)
|
||||
{
|
||||
@@ -459,7 +459,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out LogSetting logSetting)
|
||||
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out var logSetting)
|
||||
|| (logSetting.UserMutedId is null))
|
||||
return;
|
||||
|
||||
@@ -468,7 +468,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
.ConfigureAwait(false)) is null)
|
||||
return;
|
||||
|
||||
var mutes = "";
|
||||
var mutes = string.Empty;
|
||||
var unmutedLocalized = GetText(logChannel.Guild, strs.unmuted_sn);
|
||||
switch (muteType)
|
||||
{
|
||||
@@ -511,7 +511,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
if (users.Length == 0)
|
||||
return;
|
||||
|
||||
if (!GuildLogSettings.TryGetValue(users.First().Guild.Id, out LogSetting logSetting)
|
||||
if (!GuildLogSettings.TryGetValue(users.First().Guild.Id, out var logSetting)
|
||||
|| (logSetting.LogOtherId is null))
|
||||
return;
|
||||
ITextChannel logChannel;
|
||||
@@ -519,7 +519,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
.ConfigureAwait(false)) is null)
|
||||
return;
|
||||
|
||||
var punishment = "";
|
||||
var punishment = string.Empty;
|
||||
switch (action)
|
||||
{
|
||||
case PunishmentAction.Mute:
|
||||
@@ -579,7 +579,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!GuildLogSettings.TryGetValue(before.Guild.Id, out LogSetting logSetting)
|
||||
if (!GuildLogSettings.TryGetValue(before.Guild.Id, out var logSetting)
|
||||
|| logSetting.LogIgnores.Any(ilc => ilc.LogItemId == after.Id && ilc.ItemType == IgnoredItemType.User))
|
||||
return;
|
||||
|
||||
@@ -680,7 +680,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
|
||||
var after = (IGuildChannel) cafter;
|
||||
|
||||
if (!GuildLogSettings.TryGetValue(before.Guild.Id, out LogSetting logSetting)
|
||||
if (!GuildLogSettings.TryGetValue(before.Guild.Id, out var logSetting)
|
||||
|| (logSetting.ChannelUpdatedId is null)
|
||||
|| logSetting.LogIgnores.Any(ilc => ilc.LogItemId == after.Id && ilc.ItemType == IgnoredItemType.Channel))
|
||||
return;
|
||||
@@ -731,7 +731,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
if (!(ich is IGuildChannel ch))
|
||||
return;
|
||||
|
||||
if (!GuildLogSettings.TryGetValue(ch.Guild.Id, out LogSetting logSetting)
|
||||
if (!GuildLogSettings.TryGetValue(ch.Guild.Id, out var logSetting)
|
||||
|| (logSetting.ChannelDestroyedId is null)
|
||||
|| logSetting.LogIgnores.Any(ilc => ilc.LogItemId == ch.Id && ilc.ItemType == IgnoredItemType.Channel))
|
||||
return;
|
||||
@@ -771,7 +771,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
if (!(ich is IGuildChannel ch))
|
||||
return;
|
||||
|
||||
if (!GuildLogSettings.TryGetValue(ch.Guild.Id, out LogSetting logSetting)
|
||||
if (!GuildLogSettings.TryGetValue(ch.Guild.Id, out var logSetting)
|
||||
|| logSetting.ChannelCreatedId is null)
|
||||
return;
|
||||
|
||||
@@ -816,7 +816,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
if (beforeVch == afterVch)
|
||||
return;
|
||||
|
||||
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out LogSetting logSetting)
|
||||
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out var logSetting)
|
||||
|| (logSetting.LogVoicePresenceId is null)
|
||||
|| logSetting.LogIgnores.Any(ilc => ilc.LogItemId == iusr.Id && ilc.ItemType == IgnoredItemType.User))
|
||||
return;
|
||||
@@ -869,7 +869,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out LogSetting logSetting)
|
||||
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out var logSetting)
|
||||
|| (logSetting.UserLeftId is null)
|
||||
|| logSetting.LogIgnores.Any(ilc => ilc.LogItemId == usr.Id && ilc.ItemType == IgnoredItemType.User))
|
||||
return;
|
||||
@@ -904,7 +904,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out LogSetting logSetting)
|
||||
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out var logSetting)
|
||||
|| (logSetting.UserJoinedId is null))
|
||||
return;
|
||||
|
||||
@@ -945,7 +945,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!GuildLogSettings.TryGetValue(guild.Id, out LogSetting logSetting)
|
||||
if (!GuildLogSettings.TryGetValue(guild.Id, out var logSetting)
|
||||
|| (logSetting.UserUnbannedId is null)
|
||||
|| logSetting.LogIgnores.Any(ilc => ilc.LogItemId == usr.Id && ilc.ItemType == IgnoredItemType.User))
|
||||
return;
|
||||
@@ -980,7 +980,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!GuildLogSettings.TryGetValue(guild.Id, out LogSetting logSetting)
|
||||
if (!GuildLogSettings.TryGetValue(guild.Id, out var logSetting)
|
||||
|| (logSetting.UserBannedId is null)
|
||||
|| logSetting.LogIgnores.Any(ilc => ilc.LogItemId == usr.Id && ilc.ItemType == IgnoredItemType.User))
|
||||
return;
|
||||
@@ -1028,7 +1028,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
if (!(ch is ITextChannel channel))
|
||||
return;
|
||||
|
||||
if (!GuildLogSettings.TryGetValue(channel.Guild.Id, out LogSetting logSetting)
|
||||
if (!GuildLogSettings.TryGetValue(channel.Guild.Id, out var logSetting)
|
||||
|| (logSetting.MessageDeletedId is null)
|
||||
|| logSetting.LogIgnores.Any(ilc => ilc.LogItemId == channel.Id && ilc.ItemType == IgnoredItemType.Channel))
|
||||
return;
|
||||
@@ -1086,7 +1086,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
if (before.Author.IsBot)
|
||||
return;
|
||||
|
||||
if (!GuildLogSettings.TryGetValue(channel.Guild.Id, out LogSetting logSetting)
|
||||
if (!GuildLogSettings.TryGetValue(channel.Guild.Id, out var logSetting)
|
||||
|| (logSetting.MessageUpdatedId is null)
|
||||
|| logSetting.LogIgnores.Any(ilc => ilc.LogItemId == channel.Id && ilc.ItemType == IgnoredItemType.Channel))
|
||||
return;
|
||||
|
@@ -156,7 +156,7 @@ public class MuteService : INService
|
||||
{
|
||||
try
|
||||
{
|
||||
MutedUsers.TryGetValue(usr.Guild.Id, out ConcurrentHashSet<ulong> muted);
|
||||
MutedUsers.TryGetValue(usr.Guild.Id, out var muted);
|
||||
|
||||
if (muted is null || !muted.Contains(usr.Id))
|
||||
return Task.CompletedTask;
|
||||
@@ -198,7 +198,7 @@ public class MuteService : INService
|
||||
{
|
||||
UserId = usr.Id
|
||||
});
|
||||
if (MutedUsers.TryGetValue(usr.Guild.Id, out ConcurrentHashSet<ulong> muted))
|
||||
if (MutedUsers.TryGetValue(usr.Guild.Id, out var muted))
|
||||
muted.Add(usr.Id);
|
||||
|
||||
config.UnmuteTimers.RemoveWhere(x => x.UserId == usr.Id);
|
||||
@@ -242,7 +242,7 @@ public class MuteService : INService
|
||||
{
|
||||
uow.Remove(toRemove);
|
||||
}
|
||||
if (MutedUsers.TryGetValue(guildId, out ConcurrentHashSet<ulong> muted))
|
||||
if (MutedUsers.TryGetValue(guildId, out var muted))
|
||||
muted.TryRemove(usrId);
|
||||
|
||||
config.UnmuteTimers.RemoveWhere(x => x.UserId == usrId);
|
||||
@@ -442,10 +442,10 @@ public class MuteService : INService
|
||||
|
||||
public void StopTimer(ulong guildId, ulong userId, TimerType type)
|
||||
{
|
||||
if (!Un_Timers.TryGetValue(guildId, out ConcurrentDictionary<(ulong, TimerType), Timer> userTimer))
|
||||
if (!Un_Timers.TryGetValue(guildId, out var userTimer))
|
||||
return;
|
||||
|
||||
if (userTimer.TryRemove((userId, type), out Timer removed))
|
||||
if (userTimer.TryRemove((userId, type), out var removed))
|
||||
{
|
||||
removed.Change(Timeout.Infinite, Timeout.Infinite);
|
||||
}
|
||||
|
@@ -131,7 +131,7 @@ public class SelfAssignedRolesService : INService
|
||||
|
||||
public async Task<bool> SetNameAsync(ulong guildId, int group, string name)
|
||||
{
|
||||
bool set = false;
|
||||
var set = false;
|
||||
using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var gc = uow.GuildConfigsForId(guildId, y => y.Include(x => x.SelfAssignableRoleGroupNames));
|
||||
|
@@ -58,7 +58,7 @@ public class UserPunishService : INService
|
||||
Weight = weight,
|
||||
};
|
||||
|
||||
int warnings = 1;
|
||||
var warnings = 1;
|
||||
List<WarningPunishment> ps;
|
||||
using (var uow = _db.GetDbContext())
|
||||
{
|
||||
@@ -299,7 +299,7 @@ WHERE GuildId={guildId}
|
||||
|
||||
public async Task<bool> WarnClearAsync(ulong guildId, ulong userId, int index, string moderator)
|
||||
{
|
||||
bool toReturn = true;
|
||||
var toReturn = true;
|
||||
using (var uow = _db.GetDbContext())
|
||||
{
|
||||
if (index == 0)
|
||||
|
@@ -194,10 +194,10 @@ public class VcRoleService : INService
|
||||
ulong guildId;
|
||||
guildId = newVc?.Guild.Id ?? oldVc.Guild.Id;
|
||||
|
||||
if (VcRoles.TryGetValue(guildId, out ConcurrentDictionary<ulong, IRole> guildVcRoles))
|
||||
if (VcRoles.TryGetValue(guildId, out var guildVcRoles))
|
||||
{
|
||||
//remove old
|
||||
if (oldVc != null && guildVcRoles.TryGetValue(oldVc.Id, out IRole role))
|
||||
if (oldVc != null && guildVcRoles.TryGetValue(oldVc.Id, out var role))
|
||||
{
|
||||
Assign(false, gusr, role);
|
||||
}
|
||||
|
Reference in New Issue
Block a user