mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 17:28:27 -04:00
await usings and minor cleanup
This commit is contained in:
@@ -279,7 +279,7 @@ public sealed class Bot
|
||||
var _ = Task.Run(async () =>
|
||||
{
|
||||
GuildConfig gc;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
gc = uow.GuildConfigsForId(arg.Id);
|
||||
}
|
||||
|
@@ -155,7 +155,7 @@ public class ReplacementBuilder
|
||||
_reps.TryAdd("%users%", () => c.Guilds.Sum(g => g.MemberCount).ToString());
|
||||
|
||||
/*NEW*/
|
||||
_reps.TryAdd("%shard.servercount%", () => c.Guilds.Count.ToString());S
|
||||
_reps.TryAdd("%shard.servercount%", () => c.Guilds.Count.ToString());
|
||||
_reps.TryAdd("%shard.usercount%", () => c.Guilds.Sum(g => g.MemberCount).ToString());
|
||||
_reps.TryAdd("%shard.id%", () => c.ShardId.ToString());
|
||||
return this;
|
||||
|
@@ -135,19 +135,19 @@ public partial class Administration
|
||||
}
|
||||
|
||||
rolesStr.AppendLine("\t\t\t\t ⟪" + groupNameText + "⟫");
|
||||
foreach (var (Model, Role) in kvp.AsEnumerable())
|
||||
foreach (var (model, role) in kvp.AsEnumerable())
|
||||
{
|
||||
if (Role is null)
|
||||
if (role is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
// first character is invisible space
|
||||
if (Model.LevelRequirement == 0)
|
||||
rolesStr.AppendLine(" " + Role.Name);
|
||||
if (model.LevelRequirement == 0)
|
||||
rolesStr.AppendLine(" " + role.Name);
|
||||
else
|
||||
rolesStr.AppendLine(" " + Role.Name + $" (lvl {Model.LevelRequirement}+)");
|
||||
rolesStr.AppendLine(" " + role.Name + $" (lvl {model.LevelRequirement}+)");
|
||||
}
|
||||
}
|
||||
rolesStr.AppendLine();
|
||||
|
@@ -90,7 +90,7 @@ public class AdministrationService : INService
|
||||
|
||||
public async Task SetDelMsgOnCmdState(ulong guildId, ulong chId, Administration.State newState)
|
||||
{
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var conf = uow.GuildConfigsForId(guildId,
|
||||
set => set.Include(x => x.DelMsgOnCmdChannels));
|
||||
|
@@ -103,7 +103,7 @@ public sealed class AutoAssignRoleService : INService
|
||||
|
||||
public async Task<IReadOnlyList<ulong>> ToggleAarAsync(ulong guildId, ulong roleId)
|
||||
{
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
var gc = uow.GuildConfigsForId(guildId, set => set);
|
||||
var roles = gc.GetAutoAssignableRoles();
|
||||
if(!roles.Remove(roleId) && roles.Count < 3)
|
||||
@@ -122,7 +122,7 @@ public sealed class AutoAssignRoleService : INService
|
||||
|
||||
public async Task DisableAarAsync(ulong guildId)
|
||||
{
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
|
||||
await uow
|
||||
.GuildConfigs
|
||||
@@ -137,7 +137,7 @@ public sealed class AutoAssignRoleService : INService
|
||||
|
||||
public async Task SetAarRolesAsync(ulong guildId, IEnumerable<ulong> newRoles)
|
||||
{
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
|
||||
var gc = uow.GuildConfigsForId(guildId, set => set);
|
||||
gc.SetAutoAssignableRoles(newRoles);
|
||||
|
@@ -42,7 +42,7 @@ DELETE FROM Clubs;";
|
||||
public async Task<int> ExecuteSql(string sql)
|
||||
{
|
||||
int res;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
res = await uow.Database.ExecuteSqlRawAsync(sql);
|
||||
}
|
||||
@@ -92,7 +92,7 @@ DELETE FROM Clubs;";
|
||||
|
||||
public async Task PurgeUserAsync(ulong userId)
|
||||
{
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
|
||||
// get waifu info
|
||||
var wi = await uow.Set<WaifuInfo>()
|
||||
|
@@ -54,7 +54,7 @@ public class DiscordPermOverrideService : INService, ILateBlocker
|
||||
public async Task AddOverride(ulong guildId, string commandName, GuildPerm perm)
|
||||
{
|
||||
commandName = commandName.ToLowerInvariant();
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var over = await uow
|
||||
.Set<DiscordPermOverride>()
|
||||
@@ -84,7 +84,7 @@ public class DiscordPermOverrideService : INService, ILateBlocker
|
||||
|
||||
public async Task ClearAllOverrides(ulong guildId)
|
||||
{
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var overrides = await uow
|
||||
.Set<DiscordPermOverride>()
|
||||
@@ -107,7 +107,7 @@ public class DiscordPermOverrideService : INService, ILateBlocker
|
||||
{
|
||||
commandName = commandName.ToLowerInvariant();
|
||||
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var over = await uow
|
||||
.Set<DiscordPermOverride>()
|
||||
|
@@ -206,7 +206,7 @@ public sealed class LogCommandService : ILogCommandService
|
||||
|
||||
public async Task LogServer(ulong guildId, ulong channelId, bool value)
|
||||
{
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var logSetting = uow.LogSettingsFor(guildId);
|
||||
|
||||
|
@@ -171,7 +171,7 @@ public class MuteService : INService
|
||||
|
||||
public async Task SetMuteRoleAsync(ulong guildId, string name)
|
||||
{
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var config = uow.GuildConfigsForId(guildId, set => set);
|
||||
config.MuteRoleName = name;
|
||||
@@ -189,7 +189,7 @@ public class MuteService : INService
|
||||
if (!usr.RoleIds.Contains(muteRole.Id))
|
||||
await usr.AddRoleAsync(muteRole).ConfigureAwait(false);
|
||||
StopTimer(usr.GuildId, usr.Id, TimerType.Mute);
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var config = uow.GuildConfigsForId(usr.Guild.Id,
|
||||
set => set.Include(gc => gc.MutedUsers)
|
||||
@@ -229,7 +229,7 @@ public class MuteService : INService
|
||||
if (type == MuteType.All)
|
||||
{
|
||||
StopTimer(guildId, usrId, TimerType.Mute);
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var config = uow.GuildConfigsForId(guildId, set => set.Include(gc => gc.MutedUsers)
|
||||
.Include(gc => gc.UnmuteTimers));
|
||||
@@ -324,7 +324,7 @@ public class MuteService : INService
|
||||
public async Task TimedMute(IGuildUser user, IUser mod, TimeSpan after, MuteType muteType = MuteType.All, string reason = "")
|
||||
{
|
||||
await MuteUser(user, mod, muteType, reason).ConfigureAwait(false); // mute the user. This will also remove any previous unmute timers
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var config = uow.GuildConfigsForId(user.GuildId, set => set.Include(x => x.UnmuteTimers));
|
||||
config.UnmuteTimers.Add(new()
|
||||
@@ -341,7 +341,7 @@ public class MuteService : INService
|
||||
public async Task TimedBan(IGuild guild, IUser user, TimeSpan after, string reason)
|
||||
{
|
||||
await guild.AddBanAsync(user.Id, 0, reason).ConfigureAwait(false);
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var config = uow.GuildConfigsForId(guild.Id, set => set.Include(x => x.UnbanTimer));
|
||||
config.UnbanTimer.Add(new()
|
||||
@@ -358,7 +358,7 @@ public class MuteService : INService
|
||||
public async Task TimedRole(IGuildUser user, TimeSpan after, string reason, IRole role)
|
||||
{
|
||||
await user.AddRoleAsync(role).ConfigureAwait(false);
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var config = uow.GuildConfigsForId(user.GuildId, set => set.Include(x => x.UnroleTimer));
|
||||
config.UnroleTimer.Add(new()
|
||||
|
@@ -52,7 +52,7 @@ public sealed class PlayingRotateService : INService
|
||||
if (!_bss.Data.RotateStatuses) return;
|
||||
|
||||
IReadOnlyList<RotatingPlayingStatus> rotatingStatuses;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
rotatingStatuses = uow.RotatingStatus
|
||||
.AsNoTracking()
|
||||
@@ -81,7 +81,7 @@ public sealed class PlayingRotateService : INService
|
||||
if (index < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
var toRemove = await uow.RotatingStatus
|
||||
.AsQueryable()
|
||||
.AsNoTracking()
|
||||
@@ -98,7 +98,7 @@ public sealed class PlayingRotateService : INService
|
||||
|
||||
public async Task AddPlaying(ActivityType t, string status)
|
||||
{
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
var toAdd = new RotatingPlayingStatus {Status = status, Type = t};
|
||||
uow.Add(toAdd);
|
||||
await uow.SaveChangesAsync();
|
||||
|
@@ -299,7 +299,7 @@ public class ProtectionService : INService
|
||||
|
||||
_antiRaidGuilds.AddOrUpdate(guildId, stats, (key, old) => stats);
|
||||
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var gc = uow.GuildConfigsForId(guildId, set => set.Include(x => x.AntiRaidSetting));
|
||||
|
||||
@@ -370,7 +370,7 @@ public class ProtectionService : INService
|
||||
return stats;
|
||||
});
|
||||
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var gc = uow.GuildConfigsForId(guildId, set => set.Include(x => x.AntiSpamSetting));
|
||||
|
||||
@@ -397,7 +397,7 @@ public class ProtectionService : INService
|
||||
ChannelId = channelId
|
||||
};
|
||||
bool added;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var gc = uow.GuildConfigsForId(guildId, set => set.Include(x => x.AntiSpamSetting).ThenInclude(x => x.IgnoredChannels));
|
||||
var spam = gc.AntiSpamSetting;
|
||||
@@ -455,7 +455,7 @@ public class ProtectionService : INService
|
||||
public async Task StartAntiAltAsync(ulong guildId, int minAgeMinutes, PunishmentAction action,
|
||||
int actionDurationMinutes = 0, ulong? roleId = null)
|
||||
{
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
var gc = uow.GuildConfigsForId(guildId, set => set.Include(x => x.AntiAltSetting));
|
||||
gc.AntiAltSetting = new()
|
||||
{
|
||||
@@ -474,7 +474,7 @@ public class ProtectionService : INService
|
||||
if (!_antiAltGuilds.TryRemove(guildId, out _))
|
||||
return false;
|
||||
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
var gc = uow.GuildConfigsForId(guildId, set => set.Include(x => x.AntiAltSetting));
|
||||
gc.AntiAltSetting = null;
|
||||
await uow.SaveChangesAsync();
|
||||
|
@@ -70,7 +70,7 @@ public class SelfAssignedRolesService : INService
|
||||
public async Task<(AssignResult Result, bool AutoDelete, object extra)> Assign(IGuildUser guildUser, IRole role)
|
||||
{
|
||||
LevelStats userLevelData;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var stats = uow.GetOrCreateUserXpStats(guildUser.Guild.Id, guildUser.Id);
|
||||
userLevelData = new(stats.Xp + stats.AwardedXp);
|
||||
@@ -132,7 +132,7 @@ public class SelfAssignedRolesService : INService
|
||||
public async Task<bool> SetNameAsync(ulong guildId, int group, string name)
|
||||
{
|
||||
var set = false;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var gc = uow.GuildConfigsForId(guildId, y => y.Include(x => x.SelfAssignableRoleGroupNames));
|
||||
var toUpdate = gc.SelfAssignableRoleGroupNames.FirstOrDefault(x => x.Number == group);
|
||||
|
@@ -101,7 +101,7 @@ public sealed class SelfService : ILateExecutor, IReadyExecutor, INService
|
||||
|
||||
public async Task OnReadyAsync()
|
||||
{
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
|
||||
_autoCommands = uow
|
||||
.AutoCommands
|
||||
@@ -344,7 +344,7 @@ public sealed class SelfService : ILateExecutor, IReadyExecutor, INService
|
||||
|
||||
// i can't just do ReadAsStreamAsync because dicord.net's image poops itself
|
||||
var imgData = await sr.Content.ReadAsByteArrayAsync().ConfigureAwait(false);
|
||||
using (var imgStream = imgData.ToStream())
|
||||
await using (var imgStream = imgData.ToStream())
|
||||
{
|
||||
await _client.CurrentUser.ModifyAsync(u => u.Avatar = new Image(imgStream)).ConfigureAwait(false);
|
||||
}
|
||||
|
@@ -60,7 +60,7 @@ public class UserPunishService : INService
|
||||
|
||||
var warnings = 1;
|
||||
List<WarningPunishment> ps;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
ps = uow.GuildConfigsForId(guildId, set => set.Include(x => x.WarnPunishments))
|
||||
.WarnPunishments;
|
||||
@@ -206,7 +206,7 @@ public class UserPunishService : INService
|
||||
|
||||
public async Task CheckAllWarnExpiresAsync()
|
||||
{
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var cleared = await uow.Database.ExecuteSqlRawAsync($@"UPDATE Warnings
|
||||
SET Forgiven = 1,
|
||||
@@ -228,7 +228,7 @@ WHERE GuildId in (SELECT GuildId FROM GuildConfigs WHERE WarnExpireHours > 0 AND
|
||||
|
||||
public async Task CheckWarnExpiresAsync(ulong guildId)
|
||||
{
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var config = uow.GuildConfigsForId(guildId, inc => inc);
|
||||
|
||||
@@ -265,7 +265,7 @@ WHERE GuildId={guildId}
|
||||
|
||||
public async Task WarnExpireAsync(ulong guildId, int days, bool delete)
|
||||
{
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var config = uow.GuildConfigsForId(guildId, inc => inc);
|
||||
|
||||
@@ -300,7 +300,7 @@ WHERE GuildId={guildId}
|
||||
public async Task<bool> WarnClearAsync(ulong guildId, ulong userId, int index, string moderator)
|
||||
{
|
||||
var toReturn = true;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
if (index == 0)
|
||||
{
|
||||
|
@@ -122,7 +122,7 @@ public class VcRoleService : INService
|
||||
|
||||
if (missingRoles.Any())
|
||||
{
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
Log.Warning($"Removing {missingRoles.Count} missing roles from {nameof(VcRoleService)}");
|
||||
uow.RemoveRange(missingRoles);
|
||||
|
@@ -85,7 +85,7 @@ public sealed class CustomReactionsService : IEarlyBehavior, IReadyExecutor
|
||||
|
||||
private async Task ReloadInternal(IReadOnlyList<ulong> allGuildIds)
|
||||
{
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
var guildItems = await uow.CustomReactions
|
||||
.AsNoTracking()
|
||||
.Where(x => allGuildIds.Contains(x.GuildId.Value))
|
||||
@@ -190,7 +190,7 @@ public sealed class CustomReactionsService : IEarlyBehavior, IReadyExecutor
|
||||
|
||||
private async Task OnJoinedGuild(GuildConfig gc)
|
||||
{
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
var crs = await uow
|
||||
.CustomReactions
|
||||
.AsNoTracking()
|
||||
@@ -217,7 +217,7 @@ public sealed class CustomReactionsService : IEarlyBehavior, IReadyExecutor
|
||||
if (cr.Response.Contains("%target%", StringComparison.OrdinalIgnoreCase))
|
||||
cr.AllowTarget = true;
|
||||
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
uow.CustomReactions.Add(cr);
|
||||
await uow.SaveChangesAsync();
|
||||
@@ -230,7 +230,7 @@ public sealed class CustomReactionsService : IEarlyBehavior, IReadyExecutor
|
||||
|
||||
public async Task<CustomReaction> EditAsync(ulong? guildId, int id, string message)
|
||||
{
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
var cr = uow.CustomReactions.GetById(id);
|
||||
|
||||
if (cr is null || cr.GuildId != guildId)
|
||||
@@ -258,7 +258,7 @@ public sealed class CustomReactionsService : IEarlyBehavior, IReadyExecutor
|
||||
|
||||
public async Task<CustomReaction> DeleteAsync(ulong? guildId, int id)
|
||||
{
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
var toDelete = uow.CustomReactions.GetById(id);
|
||||
|
||||
if (toDelete is null)
|
||||
@@ -477,7 +477,7 @@ public sealed class CustomReactionsService : IEarlyBehavior, IReadyExecutor
|
||||
public async Task ResetCrReactions(ulong? maybeGuildId, int id)
|
||||
{
|
||||
CustomReaction cr;
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
cr = uow.CustomReactions.GetById(id);
|
||||
if (cr is null)
|
||||
return;
|
||||
@@ -594,7 +594,7 @@ public sealed class CustomReactionsService : IEarlyBehavior, IReadyExecutor
|
||||
public async Task SetCrReactions(ulong? guildId, int id, IEnumerable<string> emojis)
|
||||
{
|
||||
CustomReaction cr;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
cr = uow.CustomReactions.GetById(id);
|
||||
if (cr is null)
|
||||
@@ -612,7 +612,7 @@ public sealed class CustomReactionsService : IEarlyBehavior, IReadyExecutor
|
||||
{
|
||||
var newVal = false;
|
||||
CustomReaction cr;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
cr = uow.CustomReactions.GetById(id);
|
||||
if (cr is null)
|
||||
@@ -711,7 +711,7 @@ public sealed class CustomReactionsService : IEarlyBehavior, IReadyExecutor
|
||||
return false;
|
||||
}
|
||||
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
foreach (var entry in data)
|
||||
{
|
||||
var trigger = entry.Key;
|
||||
|
@@ -40,7 +40,7 @@ public partial class Gambling
|
||||
using (var img1 = GetDice(num1))
|
||||
using (var img2 = GetDice(num2))
|
||||
using (var img = new[] { img1, img2 }.Merge(out var format))
|
||||
using (var ms = img.ToStream(format))
|
||||
await using (var ms = img.ToStream(format))
|
||||
{
|
||||
await ctx.Channel.SendFileAsync(ms,
|
||||
$"dice.{format.FileExtensions.First()}",
|
||||
@@ -116,7 +116,7 @@ public partial class Gambling
|
||||
}
|
||||
|
||||
using (var bitmap = dice.Merge(out var format))
|
||||
using (var ms = bitmap.ToStream(format))
|
||||
await using (var ms = bitmap.ToStream(format))
|
||||
{
|
||||
foreach (var d in dice)
|
||||
{
|
||||
|
@@ -80,7 +80,7 @@ public partial class Gambling
|
||||
num = 10;
|
||||
|
||||
var (ImageStream, ToSend) = await InternalDraw(num, ctx.Guild.Id).ConfigureAwait(false);
|
||||
using (ImageStream)
|
||||
await using (ImageStream)
|
||||
{
|
||||
await ctx.Channel.SendFileAsync(ImageStream, num + " cards.jpg", ToSend).ConfigureAwait(false);
|
||||
}
|
||||
@@ -95,7 +95,7 @@ public partial class Gambling
|
||||
num = 10;
|
||||
|
||||
var (ImageStream, ToSend) = await InternalDraw(num).ConfigureAwait(false);
|
||||
using (ImageStream)
|
||||
await using (ImageStream)
|
||||
{
|
||||
await ctx.Channel.SendFileAsync(ImageStream, num + " cards.jpg", ToSend).ConfigureAwait(false);
|
||||
}
|
||||
|
@@ -55,7 +55,7 @@ public partial class Gambling
|
||||
}
|
||||
}
|
||||
using (var img = imgs.Merge(out var format))
|
||||
using (var stream = img.ToStream(format))
|
||||
await using (var stream = img.ToStream(format))
|
||||
{
|
||||
foreach (var i in imgs)
|
||||
{
|
||||
|
@@ -187,7 +187,7 @@ public partial class Gambling : GamblingModule<GamblingService>
|
||||
return;
|
||||
|
||||
var trs = new List<CurrencyTransaction>();
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
trs = uow.CurrencyTransactions.GetPageFor(userId, page);
|
||||
}
|
||||
@@ -528,7 +528,7 @@ public partial class Gambling : GamblingModule<GamblingService>
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
cleanRichest = uow.DiscordUser.GetTopRichest(_client.CurrentUser.Id, 10_000);
|
||||
}
|
||||
@@ -542,7 +542,7 @@ public partial class Gambling : GamblingModule<GamblingService>
|
||||
}
|
||||
else
|
||||
{
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
cleanRichest = uow.DiscordUser.GetTopRichest(_client.CurrentUser.Id, 9, page).ToList();
|
||||
}
|
||||
|
@@ -33,7 +33,7 @@ public class ShopService : IShopService, INService
|
||||
if (newPrice <= 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(newPrice));
|
||||
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
var entries = GetEntriesInternal(uow, guildId);
|
||||
|
||||
if (index >= entries.Count)
|
||||
@@ -51,7 +51,7 @@ public class ShopService : IShopService, INService
|
||||
if (string.IsNullOrWhiteSpace(newName))
|
||||
throw new ArgumentNullException(nameof(newName));
|
||||
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
var entries = GetEntriesInternal(uow, guildId);
|
||||
|
||||
if (index >= entries.Count)
|
||||
@@ -69,7 +69,7 @@ public class ShopService : IShopService, INService
|
||||
if (index2 < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(index2));
|
||||
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
var entries = GetEntriesInternal(uow, guildId);
|
||||
|
||||
if (index1 >= entries.Count || index2 >= entries.Count || index1 == index2)
|
||||
@@ -89,7 +89,7 @@ public class ShopService : IShopService, INService
|
||||
if (toIndex < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(toIndex));
|
||||
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
var entries = GetEntriesInternal(uow, guildId);
|
||||
|
||||
if (fromIndex >= entries.Count || toIndex >= entries.Count || fromIndex == toIndex)
|
||||
|
@@ -219,7 +219,7 @@ public class PlantPickService : INService
|
||||
var pw = config.Generation.HasPassword ? GenerateCurrencyPassword().ToUpperInvariant() : null;
|
||||
|
||||
IUserMessage sent;
|
||||
using (var stream = GetRandomCurrencyImage(pw, out var ext))
|
||||
await using (var stream = GetRandomCurrencyImage(pw, out var ext))
|
||||
{
|
||||
sent = await channel.SendFileAsync(stream, $"currency_image.{ext}", toSend).ConfigureAwait(false);
|
||||
}
|
||||
@@ -259,7 +259,7 @@ public class PlantPickService : INService
|
||||
{
|
||||
long amount;
|
||||
ulong[] ids;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
// this method will sum all plants with that password,
|
||||
// remove them, and get messageids of the removed plants
|
||||
@@ -318,7 +318,7 @@ public class PlantPickService : INService
|
||||
msgToSend += " " + GetText(gid, strs.pick_sn(prefix));
|
||||
|
||||
//get the image
|
||||
using (var stream = GetRandomCurrencyImage(pass, out var ext))
|
||||
await using (var stream = GetRandomCurrencyImage(pass, out var ext))
|
||||
{
|
||||
// send it
|
||||
var msg = await ch.SendFileAsync(stream, $"img.{ext}", msgToSend).ConfigureAwait(false);
|
||||
@@ -362,7 +362,7 @@ public class PlantPickService : INService
|
||||
|
||||
private async Task AddPlantToDatabase(ulong gid, ulong cid, ulong uid, ulong mid, long amount, string pass)
|
||||
{
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
uow.PlantedCurrency.Add(new()
|
||||
{
|
||||
|
@@ -40,7 +40,7 @@ public class WaifuService : INService
|
||||
|
||||
var settings = _gss.Data;
|
||||
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var waifu = uow.WaifuInfo.ByWaifuUserId(waifuId);
|
||||
var ownerUser = uow.GetOrCreateUser(owner);
|
||||
@@ -116,7 +116,7 @@ public class WaifuService : INService
|
||||
|
||||
public async Task<bool> TryReset(IUser user)
|
||||
{
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var price = GetResetPrice(user);
|
||||
if (!await _cs.RemoveAsync(user.Id, "Waifu Reset", price, gamble: true))
|
||||
@@ -161,7 +161,7 @@ public class WaifuService : INService
|
||||
WaifuClaimResult result;
|
||||
WaifuInfo w;
|
||||
bool isAffinity;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
w = uow.WaifuInfo.ByWaifuUserId(target.Id);
|
||||
isAffinity = (w?.Affinity?.UserId == user.Id);
|
||||
@@ -251,7 +251,7 @@ public class WaifuService : INService
|
||||
DiscordUser oldAff = null;
|
||||
var success = false;
|
||||
TimeSpan? remaining = null;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var w = uow.WaifuInfo.ByWaifuUserId(user.Id);
|
||||
var newAff = target is null ? null : uow.GetOrCreateUser(target);
|
||||
@@ -323,7 +323,7 @@ public class WaifuService : INService
|
||||
TimeSpan? remaining = null;
|
||||
long amount = 0;
|
||||
WaifuInfo w = null;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
w = uow.WaifuInfo.ByWaifuUserId(targetId);
|
||||
var now = DateTime.UtcNow;
|
||||
@@ -375,7 +375,7 @@ public class WaifuService : INService
|
||||
return false;
|
||||
}
|
||||
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var w = uow.WaifuInfo.ByWaifuUserId(giftedWaifu.Id,
|
||||
set => set.Include(x => x.Items)
|
||||
|
@@ -89,7 +89,7 @@ public partial class Gambling
|
||||
if (index < 0)
|
||||
return;
|
||||
ShopEntry entry;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var config = uow.GuildConfigsForId(ctx.Guild.Id, set => set
|
||||
.Include(x => x.ShopEntries)
|
||||
@@ -159,7 +159,7 @@ public partial class Gambling
|
||||
|
||||
if (await _cs.RemoveAsync(ctx.User.Id, $"Shop purchase - {entry.Type}", entry.Price).ConfigureAwait(false))
|
||||
{
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var x = uow.Set<ShopEntryItem>().Remove(item);
|
||||
uow.SaveChanges();
|
||||
@@ -183,7 +183,7 @@ public partial class Gambling
|
||||
await _cs.AddAsync(ctx.User.Id,
|
||||
$"Shop error refund - {entry.Name}",
|
||||
entry.Price).ConfigureAwait(false);
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var entries = new IndexedCollection<ShopEntry>(uow.GuildConfigsForId(ctx.Guild.Id,
|
||||
set => set.Include(x => x.ShopEntries)
|
||||
@@ -232,7 +232,7 @@ public partial class Gambling
|
||||
RoleId = role.Id,
|
||||
RoleName = role.Name
|
||||
};
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var entries = new IndexedCollection<ShopEntry>(uow.GuildConfigsForId(ctx.Guild.Id,
|
||||
set => set.Include(x => x.ShopEntries)
|
||||
@@ -263,7 +263,7 @@ public partial class Gambling
|
||||
AuthorId = ctx.User.Id,
|
||||
Items = new(),
|
||||
};
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var entries = new IndexedCollection<ShopEntry>(uow.GuildConfigsForId(ctx.Guild.Id,
|
||||
set => set.Include(x => x.ShopEntries)
|
||||
@@ -294,7 +294,7 @@ public partial class Gambling
|
||||
ShopEntry entry;
|
||||
var rightType = false;
|
||||
var added = false;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var entries = new IndexedCollection<ShopEntry>(uow.GuildConfigsForId(ctx.Guild.Id,
|
||||
set => set.Include(x => x.ShopEntries)
|
||||
@@ -327,7 +327,7 @@ public partial class Gambling
|
||||
if (index < 0)
|
||||
return;
|
||||
ShopEntry removed;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var config = uow.GuildConfigsForId(ctx.Guild.Id, set => set
|
||||
.Include(x => x.ShopEntries)
|
||||
|
@@ -172,7 +172,7 @@ public partial class Gambling
|
||||
Interlocked.Add(ref _totalPaidOut, result.Won);
|
||||
|
||||
long ownedAmount;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
ownedAmount = uow.Set<DiscordUser>()
|
||||
.FirstOrDefault(x => x.UserId == ctx.User.Id)
|
||||
@@ -243,7 +243,7 @@ public partial class Gambling
|
||||
msg = GetText(strs.slot_jackpot(30));
|
||||
}
|
||||
|
||||
using (var imgStream = bgImage.ToStream())
|
||||
await using (var imgStream = bgImage.ToStream())
|
||||
{
|
||||
await ctx.Channel.SendFileAsync(imgStream,
|
||||
filename: "result.png",
|
||||
|
@@ -32,7 +32,7 @@ public partial class Games
|
||||
|
||||
if (_service.ChatterBotGuilds.TryRemove(channel.Guild.Id, out _))
|
||||
{
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
uow.GuildConfigs.SetCleverbotEnabled(ctx.Guild.Id, false);
|
||||
await uow.SaveChangesAsync();
|
||||
@@ -43,7 +43,7 @@ public partial class Games
|
||||
|
||||
_service.ChatterBotGuilds.TryAdd(channel.Guild.Id, new(() => _service.CreateSession(), true));
|
||||
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
uow.GuildConfigs.SetCleverbotEnabled(ctx.Guild.Id, true);
|
||||
await uow.SaveChangesAsync();
|
||||
|
@@ -54,7 +54,8 @@ public class PollRunner
|
||||
var _ = OnVoted?.Invoke(msg, usr);
|
||||
}
|
||||
finally { _locker.Release(); }
|
||||
using (var uow = _db.GetDbContext())
|
||||
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var trackedPoll = uow.Poll.FirstOrDefault(x => x.Id == Poll.Id);
|
||||
trackedPoll.Votes.Add(voteObj);
|
||||
|
@@ -66,7 +66,7 @@ public partial class Games : NadekoModule<GamesService>
|
||||
return;
|
||||
}
|
||||
|
||||
using (var imgStream = new MemoryStream())
|
||||
await using (var imgStream = new MemoryStream())
|
||||
{
|
||||
lock (gr)
|
||||
{
|
||||
|
@@ -379,7 +379,7 @@ public class Help : NadekoModule<HelpService>
|
||||
});
|
||||
}
|
||||
|
||||
using var ms = new MemoryStream();
|
||||
await using var ms = new MemoryStream();
|
||||
await oldVersionObject.ResponseStream.CopyToAsync(ms);
|
||||
var versionListString = Encoding.UTF8.GetString(ms.ToArray());
|
||||
|
||||
@@ -415,7 +415,7 @@ public class Help : NadekoModule<HelpService>
|
||||
}
|
||||
|
||||
// also send the file, but indented one, to chat
|
||||
using var rDataStream = new MemoryStream(Encoding.ASCII.GetBytes(readableData));
|
||||
await using var rDataStream = new MemoryStream(Encoding.ASCII.GetBytes(readableData));
|
||||
await ctx.Channel.SendFileAsync(rDataStream, "cmds.json", GetText(strs.commandlist_regen)).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
|
@@ -49,7 +49,7 @@ public sealed partial class Music
|
||||
|
||||
List<MusicPlaylist> playlists;
|
||||
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
playlists = uow.MusicPlaylists.GetPlaylistsOnPage(num);
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public sealed partial class Music
|
||||
var success = false;
|
||||
try
|
||||
{
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var pl = uow.MusicPlaylists.FirstOrDefault(x => x.Id == id);
|
||||
|
||||
@@ -105,7 +105,7 @@ public sealed partial class Music
|
||||
return;
|
||||
|
||||
MusicPlaylist mpl;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
mpl = uow.MusicPlaylists.GetWithSongs(id);
|
||||
}
|
||||
@@ -144,7 +144,7 @@ public sealed partial class Music
|
||||
}).ToList();
|
||||
|
||||
MusicPlaylist playlist;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
playlist = new()
|
||||
{
|
||||
@@ -203,7 +203,7 @@ public sealed partial class Music
|
||||
}
|
||||
|
||||
MusicPlaylist mpl;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
mpl = uow.MusicPlaylists.GetWithSongs(id);
|
||||
}
|
||||
|
@@ -346,7 +346,7 @@ public sealed class MusicService : IMusicService
|
||||
if (_settings.TryGetValue(guildId, out var settings))
|
||||
return settings;
|
||||
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
var toReturn = _settings[guildId] = await uow.MusicPlayerSettings.ForGuildAsync(guildId);
|
||||
await uow.SaveChangesAsync();
|
||||
|
||||
@@ -358,7 +358,7 @@ public sealed class MusicService : IMusicService
|
||||
Action<MusicPlayerSettings, TState> action,
|
||||
TState state)
|
||||
{
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
var ms = await uow.MusicPlayerSettings.ForGuildAsync(guildId);
|
||||
action(ms, state);
|
||||
await uow.SaveChangesAsync();
|
||||
@@ -438,7 +438,7 @@ public sealed class MusicService : IMusicService
|
||||
|
||||
public async Task<QualityPreset> GetMusicQualityAsync(ulong guildId)
|
||||
{
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
var settings = await uow.MusicPlayerSettings.ForGuildAsync(guildId);
|
||||
return settings.QualityPreset;
|
||||
}
|
||||
|
@@ -45,7 +45,7 @@ public partial class Permissions
|
||||
}
|
||||
|
||||
var name = command.Name.ToLowerInvariant();
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var config = uow.GuildConfigsForId(channel.Guild.Id, set => set.Include(gc => gc.CommandCooldowns));
|
||||
var localSet = CommandCooldowns.GetOrAdd(channel.Guild.Id, new ConcurrentHashSet<CommandCooldown>());
|
||||
|
@@ -40,7 +40,7 @@ public partial class Permissions
|
||||
var channel = (ITextChannel)ctx.Channel;
|
||||
|
||||
bool enabled;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var config = uow.GuildConfigsForId(channel.Guild.Id, set => set);
|
||||
enabled = config.FilterInvites = !config.FilterInvites;
|
||||
@@ -66,7 +66,7 @@ public partial class Permissions
|
||||
var channel = (ITextChannel)ctx.Channel;
|
||||
|
||||
FilterChannelId removed;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var config = uow.GuildConfigsForId(channel.Guild.Id, set => set.Include(gc => gc.FilterInvitesChannelIds));
|
||||
var match = new FilterChannelId()
|
||||
@@ -105,7 +105,7 @@ public partial class Permissions
|
||||
var channel = (ITextChannel)ctx.Channel;
|
||||
|
||||
bool enabled;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var config = uow.GuildConfigsForId(channel.Guild.Id, set => set);
|
||||
enabled = config.FilterLinks = !config.FilterLinks;
|
||||
@@ -131,7 +131,7 @@ public partial class Permissions
|
||||
var channel = (ITextChannel)ctx.Channel;
|
||||
|
||||
FilterLinksChannelId removed;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var config = uow.GuildConfigsForId(channel.Guild.Id, set => set.Include(gc => gc.FilterLinksChannelIds));
|
||||
var match = new FilterLinksChannelId()
|
||||
@@ -170,7 +170,7 @@ public partial class Permissions
|
||||
var channel = (ITextChannel)ctx.Channel;
|
||||
|
||||
bool enabled;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var config = uow.GuildConfigsForId(channel.Guild.Id, set => set);
|
||||
enabled = config.FilterWords = !config.FilterWords;
|
||||
@@ -196,7 +196,7 @@ public partial class Permissions
|
||||
var channel = (ITextChannel)ctx.Channel;
|
||||
|
||||
FilterChannelId removed;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var config = uow.GuildConfigsForId(channel.Guild.Id, set => set.Include(gc => gc.FilterWordsChannelIds));
|
||||
|
||||
@@ -240,7 +240,7 @@ public partial class Permissions
|
||||
return;
|
||||
|
||||
FilteredWord removed;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var config = uow.GuildConfigsForId(channel.Guild.Id, set => set.Include(gc => gc.FilteredWords));
|
||||
|
||||
|
@@ -26,7 +26,7 @@ public partial class Permissions : NadekoModule<PermissionService>
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Verbose(PermissionAction action = null)
|
||||
{
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var config = uow.GcWithPermissionsv2For(ctx.Guild.Id);
|
||||
if (action is null) action = new(!config.VerbosePermissions); // New behaviour, can toggle.
|
||||
@@ -68,7 +68,7 @@ public partial class Permissions : NadekoModule<PermissionService>
|
||||
return;
|
||||
}
|
||||
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var config = uow.GcWithPermissionsv2For(ctx.Guild.Id);
|
||||
config.PermissionRole = role.Id.ToString();
|
||||
@@ -87,7 +87,7 @@ public partial class Permissions : NadekoModule<PermissionService>
|
||||
[Priority(1)]
|
||||
public async Task PermRole(Reset _)
|
||||
{
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var config = uow.GcWithPermissionsv2For(ctx.Guild.Id);
|
||||
config.PermissionRole = null;
|
||||
@@ -143,7 +143,7 @@ public partial class Permissions : NadekoModule<PermissionService>
|
||||
try
|
||||
{
|
||||
Permissionv2 p;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var config = uow.GcWithPermissionsv2For(ctx.Guild.Id);
|
||||
var permsCol = new PermissionsCollection<Permissionv2>(config.Permissions);
|
||||
@@ -175,7 +175,7 @@ public partial class Permissions : NadekoModule<PermissionService>
|
||||
try
|
||||
{
|
||||
Permissionv2 fromPerm;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var config = uow.GcWithPermissionsv2For(ctx.Guild.Id);
|
||||
var permsCol = new PermissionsCollection<Permissionv2>(config.Permissions);
|
||||
|
@@ -71,7 +71,7 @@ public class PermissionService : ILateBlocker, INService
|
||||
|
||||
public async Task AddPermissions(ulong guildId, params Permissionv2[] perms)
|
||||
{
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var config = uow.GcWithPermissionsv2For(guildId);
|
||||
//var orderedPerms = new PermissionsCollection<Permissionv2>(config.Permissions);
|
||||
@@ -178,7 +178,7 @@ public class PermissionService : ILateBlocker, INService
|
||||
|
||||
public async Task Reset(ulong guildId)
|
||||
{
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var config = uow.GcWithPermissionsv2For(guildId);
|
||||
config.Permissions = Permissionv2.GetDefaultPermlist;
|
||||
|
@@ -48,7 +48,7 @@ public partial class Searches : NadekoModule<SearchesService>
|
||||
var av = usr.RealAvatarUrl(128);
|
||||
if (av is null)
|
||||
return;
|
||||
using (var picStream = await _service.GetRipPictureAsync(usr.Nickname ?? usr.Username, av).ConfigureAwait(false))
|
||||
await using (var picStream = await _service.GetRipPictureAsync(usr.Nickname ?? usr.Username, av).ConfigureAwait(false))
|
||||
{
|
||||
await ctx.Channel.SendFileAsync(
|
||||
picStream,
|
||||
@@ -626,7 +626,8 @@ public partial class Searches : NadekoModule<SearchesService>
|
||||
new PointF(x, 50)
|
||||
}));
|
||||
}
|
||||
using (var ms = img.ToStream())
|
||||
|
||||
await using (var ms = img.ToStream())
|
||||
{
|
||||
await ctx.Channel.SendFileAsync(ms, $"colors.png").ConfigureAwait(false);
|
||||
}
|
||||
|
@@ -32,7 +32,6 @@ public class FeedsService : INService
|
||||
.AsQueryable()
|
||||
.Where(x => guildConfigIds.Contains(x.Id))
|
||||
.Include(x => x.FeedSubs)
|
||||
.ThenInclude(x => x.GuildConfig)
|
||||
.ToList()
|
||||
.SelectMany(x => x.FeedSubs)
|
||||
.GroupBy(x => x.Url.ToLower())
|
||||
|
@@ -339,7 +339,7 @@ public sealed class StreamNotificationService : INService
|
||||
|
||||
public async Task<int> ClearAllStreams(ulong guildId)
|
||||
{
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
var gc = uow.GuildConfigsForId(guildId, set => set.Include(x => x.FollowedStreams));
|
||||
uow.RemoveRange(gc.FollowedStreams);
|
||||
|
||||
@@ -354,7 +354,7 @@ public sealed class StreamNotificationService : INService
|
||||
public async Task<FollowedStream> UnfollowStreamAsync(ulong guildId, int index)
|
||||
{
|
||||
FollowedStream fs;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var fss = uow.Set<FollowedStream>()
|
||||
.AsQueryable()
|
||||
@@ -400,7 +400,7 @@ public sealed class StreamNotificationService : INService
|
||||
return null;
|
||||
|
||||
FollowedStream fs;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var gc = uow.GuildConfigsForId(guildId, set => set.Include(x => x.FollowedStreams));
|
||||
|
||||
|
@@ -84,7 +84,7 @@ public partial class Searches
|
||||
}
|
||||
|
||||
var streams = new List<FollowedStream>();
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var all = uow
|
||||
.GuildConfigsForId(ctx.Guild.Id, set => set.Include(gc => gc.FollowedStreams))
|
||||
|
@@ -57,7 +57,7 @@ public partial class Utility
|
||||
return;
|
||||
}
|
||||
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var config = uow.GuildConfigsForId(ctx.Guild.Id, set => set.Include(x => x.CommandAliases));
|
||||
var toAdd = new CommandAlias()
|
||||
|
@@ -44,7 +44,7 @@ public partial class Utility
|
||||
return;
|
||||
|
||||
IEnumerable<Quote> quotes;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
quotes = uow.Quotes.GetGroup(ctx.Guild.Id, page, order);
|
||||
}
|
||||
@@ -67,7 +67,7 @@ public partial class Utility
|
||||
keyword = keyword.ToUpperInvariant();
|
||||
|
||||
Quote quote;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
quote = await uow.Quotes.GetRandomQuoteByKeywordAsync(ctx.Guild.Id, keyword);
|
||||
//if (quote != null)
|
||||
@@ -95,7 +95,7 @@ public partial class Utility
|
||||
public async Task QuoteShow(int id)
|
||||
{
|
||||
Quote quote;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
quote = uow.Quotes.GetById(id);
|
||||
if (quote?.GuildId != ctx.Guild.Id)
|
||||
@@ -132,7 +132,7 @@ public partial class Utility
|
||||
keyword = keyword.ToUpperInvariant();
|
||||
|
||||
Quote keywordquote;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
keywordquote = await uow.Quotes.SearchQuoteKeywordTextAsync(ctx.Guild.Id, keyword, text);
|
||||
}
|
||||
@@ -157,7 +157,7 @@ public partial class Utility
|
||||
.WithDefault(Context)
|
||||
.Build();
|
||||
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
quote = uow.Quotes.GetById(id);
|
||||
}
|
||||
@@ -186,7 +186,7 @@ public partial class Utility
|
||||
keyword = keyword.ToUpperInvariant();
|
||||
|
||||
Quote q;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
uow.Quotes.Add(q = new()
|
||||
{
|
||||
@@ -209,7 +209,7 @@ public partial class Utility
|
||||
|
||||
var success = false;
|
||||
string response;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var q = uow.Quotes.GetById(id);
|
||||
|
||||
@@ -241,7 +241,7 @@ public partial class Utility
|
||||
|
||||
keyword = keyword.ToUpperInvariant();
|
||||
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
uow.Quotes.RemoveAllByKeyword(ctx.Guild.Id, keyword.ToUpperInvariant());
|
||||
|
||||
@@ -289,7 +289,7 @@ public partial class Utility
|
||||
public async Task QuotesExport()
|
||||
{
|
||||
IEnumerable<Quote> quotes;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
quotes = uow.Quotes
|
||||
.GetForGuild(ctx.Guild.Id)
|
||||
|
@@ -107,7 +107,7 @@ public partial class Utility
|
||||
.WithTitle(GetText(isServer ? strs.reminder_server_list : strs.reminder_list));
|
||||
|
||||
List<Reminder> rems;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
if (isServer)
|
||||
{
|
||||
@@ -164,7 +164,7 @@ public partial class Utility
|
||||
return;
|
||||
|
||||
Reminder rem = null;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var rems = isServer
|
||||
? uow.Reminders
|
||||
@@ -219,7 +219,7 @@ public partial class Utility
|
||||
ServerId = ctx.Guild?.Id ?? 0
|
||||
};
|
||||
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
uow.Reminders.Add(rem);
|
||||
await uow.SaveChangesAsync();
|
||||
|
@@ -231,7 +231,7 @@ public class PatreonRewardsService : INService
|
||||
{
|
||||
var eligibleFor = (int)(cents * settings.PatreonCurrencyPerCent);
|
||||
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var users = uow.Set<RewardedUser>();
|
||||
var usr = await users.FirstOrDefaultAsyncEF(x => x.PatreonUserId == patreonUserId);
|
||||
|
@@ -61,7 +61,7 @@ public class RemindService : INService
|
||||
|
||||
private async Task RemoveReminders(List<Reminder> reminders)
|
||||
{
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
uow.Set<Reminder>()
|
||||
.RemoveRange(reminders);
|
||||
|
@@ -138,7 +138,7 @@ where ((guildid >> 22) % {_creds.TotalShards}) == {_client.ShardId};")
|
||||
|
||||
public async Task<bool> TriggerExternal(ulong guildId, int index)
|
||||
{
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
|
||||
var toTrigger = await uow.Repeaters
|
||||
.AsNoTracking()
|
||||
@@ -291,7 +291,7 @@ where ((guildid >> 22) % {_creds.TotalShards}) == {_client.ShardId};")
|
||||
{
|
||||
_noRedundant.TryRemove(r.Id);
|
||||
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
await uow
|
||||
.Repeaters
|
||||
.DeleteAsync(x => x.Id == r.Id);
|
||||
@@ -314,7 +314,7 @@ where ((guildid >> 22) % {_creds.TotalShards}) == {_client.ShardId};")
|
||||
|
||||
private async Task SetRepeaterLastMessageInternal(int repeaterId, ulong lastMsgId)
|
||||
{
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
await uow.Repeaters
|
||||
.AsQueryable()
|
||||
.Where(x => x.Id == repeaterId)
|
||||
@@ -345,7 +345,7 @@ where ((guildid >> 22) % {_creds.TotalShards}) == {_client.ShardId};")
|
||||
DateAdded = DateTime.UtcNow
|
||||
};
|
||||
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
|
||||
if (await uow.Repeaters.CountAsyncEF(x => x.GuildId == guildId) < MAX_REPEATERS)
|
||||
uow.Repeaters.Add(rep);
|
||||
@@ -366,7 +366,7 @@ where ((guildid >> 22) % {_creds.TotalShards}) == {_client.ShardId};")
|
||||
if (index > MAX_REPEATERS * 2)
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
var toRemove = await uow.Repeaters
|
||||
.AsNoTracking()
|
||||
.Where(x => x.GuildId == guildId)
|
||||
@@ -398,7 +398,7 @@ where ((guildid >> 22) % {_creds.TotalShards}) == {_client.ShardId};")
|
||||
|
||||
public async Task<bool?> ToggleRedundantAsync(ulong guildId, int index)
|
||||
{
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
var toToggle = await uow
|
||||
.Repeaters
|
||||
.AsQueryable()
|
||||
|
@@ -70,7 +70,7 @@ public class StreamRoleService : INService
|
||||
userName.ThrowIfNull(nameof(userName));
|
||||
|
||||
var success = false;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var streamRoleSettings = uow.GetStreamRoleSettings(guild.Id);
|
||||
|
||||
@@ -135,7 +135,7 @@ public class StreamRoleService : INService
|
||||
{
|
||||
keyword = keyword?.Trim()?.ToLowerInvariant();
|
||||
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var streamRoleSettings = uow.GetStreamRoleSettings(guild.Id);
|
||||
|
||||
@@ -181,7 +181,7 @@ public class StreamRoleService : INService
|
||||
addRole.ThrowIfNull(nameof(addRole));
|
||||
|
||||
StreamRoleSettings setting;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var streamRoleSettings = uow.GetStreamRoleSettings(fromRole.Guild.Id);
|
||||
|
||||
@@ -208,7 +208,7 @@ public class StreamRoleService : INService
|
||||
/// <param name="guildId">Guild's Id</param>
|
||||
public async Task StopStreamRole(IGuild guild, bool cleanup = false)
|
||||
{
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var streamRoleSettings = uow.GetStreamRoleSettings(guild.Id);
|
||||
streamRoleSettings.Enabled = false;
|
||||
|
@@ -441,7 +441,7 @@ public partial class Utility : NadekoModule
|
||||
return msg;
|
||||
})
|
||||
});
|
||||
using (var stream = await JsonConvert.SerializeObject(grouping, Formatting.Indented).ToStream().ConfigureAwait(false))
|
||||
await using (var stream = await JsonConvert.SerializeObject(grouping, Formatting.Indented).ToStream().ConfigureAwait(false))
|
||||
{
|
||||
await ctx.User.SendFileAsync(stream, title, title, false).ConfigureAwait(false);
|
||||
}
|
||||
|
@@ -115,7 +115,7 @@ public class ClubService : INService
|
||||
}
|
||||
}
|
||||
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var club = uow.Clubs.GetByOwner(ownerUserId);
|
||||
|
||||
|
@@ -168,7 +168,7 @@ public class XpService : INService
|
||||
var group = toAddTo.GroupBy(x => (GuildId: x.Guild.Id, x.User));
|
||||
if (toAddTo.Count == 0) continue;
|
||||
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
foreach (var item in group)
|
||||
{
|
||||
@@ -450,7 +450,7 @@ public class XpService : INService
|
||||
|
||||
public async Task ChangeNotificationType(ulong userId, ulong guildId, XpNotificationLocation type)
|
||||
{
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var user = uow.GetOrCreateUserXpStats(guildId, userId);
|
||||
user.NotifyOnLevelUp = type;
|
||||
@@ -477,7 +477,7 @@ public class XpService : INService
|
||||
|
||||
public async Task ChangeNotificationType(IUser user, XpNotificationLocation type)
|
||||
{
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var du = uow.GetOrCreateUser(user);
|
||||
du.NotifyOnLevelUp = type;
|
||||
@@ -724,7 +724,7 @@ public class XpService : INService
|
||||
int totalXp;
|
||||
int globalRank;
|
||||
int guildRank;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
du = uow.GetOrCreateUser(user);
|
||||
totalXp = du.TotalXp;
|
||||
@@ -1044,7 +1044,7 @@ public class XpService : INService
|
||||
.Resize(_template.User.Icon.Size.X, _template.User.Icon.Size.Y)
|
||||
.ApplyRoundedCorners(
|
||||
Math.Max(_template.User.Icon.Size.X, _template.User.Icon.Size.Y) / 2));
|
||||
using (var stream = tempDraw.ToStream())
|
||||
await using (var stream = tempDraw.ToStream())
|
||||
{
|
||||
data = stream.ToArray();
|
||||
}
|
||||
@@ -1157,7 +1157,7 @@ public class XpService : INService
|
||||
.ApplyRoundedCorners(
|
||||
Math.Max(_template.Club.Icon.Size.X, _template.Club.Icon.Size.Y) / 2.0f));
|
||||
;
|
||||
using (var tds = tempDraw.ToStream())
|
||||
await using (var tds = tempDraw.ToStream())
|
||||
{
|
||||
data = tds.ToArray();
|
||||
}
|
||||
@@ -1207,7 +1207,7 @@ public class XpService : INService
|
||||
|
||||
public async Task ResetXpRewards(ulong guildId)
|
||||
{
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
var guildConfig = uow.GuildConfigsForId(guildId,
|
||||
set => set
|
||||
.Include(x => x.XpSettings)
|
||||
|
@@ -29,7 +29,7 @@ public partial class Xp : NadekoModule<XpService>
|
||||
user = user ?? ctx.User;
|
||||
await ctx.Channel.TriggerTypingAsync().ConfigureAwait(false);
|
||||
var (img, fmt) = await _service.GenerateXpImageAsync((IGuildUser)user).ConfigureAwait(false);
|
||||
using (img)
|
||||
await using (img)
|
||||
{
|
||||
await ctx.Channel.SendFileAsync(img, $"{ctx.Guild.Id}_{user.Id}_xp.{fmt.FileExtensions.FirstOrDefault()}")
|
||||
.ConfigureAwait(false);
|
||||
|
@@ -4,6 +4,7 @@
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>10.0</LangVersion>
|
||||
<EnablePreviewFeatures>True</EnablePreviewFeatures>
|
||||
<ImplicitUsings>true</ImplicitUsings>
|
||||
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
|
||||
<OutputType>exe</OutputType>
|
||||
<ApplicationIcon>nadeko_icon.ico</ApplicationIcon>
|
||||
|
@@ -345,7 +345,7 @@ public class GreetSettingsService : INService
|
||||
return false;
|
||||
}
|
||||
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var conf = uow.GuildConfigsForId(guildId, set => set);
|
||||
conf.DmGreetMessageText = settings.DmGreetMessageText?.SanitizeMentions();
|
||||
@@ -376,7 +376,7 @@ public class GreetSettingsService : INService
|
||||
public async Task<bool> SetGreet(ulong guildId, ulong channelId, bool? value = null)
|
||||
{
|
||||
bool enabled;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var conf = uow.GuildConfigsForId(guildId, set => set);
|
||||
enabled = conf.SendChannelGreetMessage = value ?? !conf.SendChannelGreetMessage;
|
||||
@@ -415,7 +415,7 @@ public class GreetSettingsService : INService
|
||||
public async Task<bool> SetGreetDm(ulong guildId, bool? value = null)
|
||||
{
|
||||
bool enabled;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var conf = uow.GuildConfigsForId(guildId, set => set);
|
||||
enabled = conf.SendDmGreetMessage = value ?? !conf.SendDmGreetMessage;
|
||||
@@ -503,7 +503,7 @@ public class GreetSettingsService : INService
|
||||
public async Task<bool> SetBye(ulong guildId, ulong channelId, bool? value = null)
|
||||
{
|
||||
bool enabled;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var conf = uow.GuildConfigsForId(guildId, set => set);
|
||||
enabled = conf.SendChannelByeMessage = value ?? !conf.SendChannelByeMessage;
|
||||
@@ -544,7 +544,7 @@ public class GreetSettingsService : INService
|
||||
if (timer < 0 || timer > 600)
|
||||
return;
|
||||
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var conf = uow.GuildConfigsForId(guildId, set => set);
|
||||
conf.AutoDeleteByeMessagesTimer = timer;
|
||||
@@ -561,7 +561,7 @@ public class GreetSettingsService : INService
|
||||
if (timer < 0 || timer > 600)
|
||||
return;
|
||||
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var conf = uow.GuildConfigsForId(id, set => set);
|
||||
conf.AutoDeleteGreetMessagesTimer = timer;
|
||||
@@ -593,7 +593,7 @@ public class GreetSettingsService : INService
|
||||
if (timer < 0 || timer > 600)
|
||||
throw new ArgumentOutOfRangeException(nameof(timer));
|
||||
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
var conf = uow.GuildConfigsForId(guildId, set => set);
|
||||
conf.BoostMessageDeleteAfter = timer;
|
||||
|
||||
@@ -605,7 +605,7 @@ public class GreetSettingsService : INService
|
||||
|
||||
public async Task<bool> ToggleBoost(ulong guildId, ulong channelId)
|
||||
{
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
var conf = uow.GuildConfigsForId(guildId, set => set);
|
||||
conf.SendBoostMessage = !conf.SendBoostMessage;
|
||||
conf.BoostMessageChannelId = channelId;
|
||||
|
@@ -58,7 +58,7 @@ public class CurrencyService : ICurrencyService, INService
|
||||
throw new ArgumentException("You can't add negative amounts. Use RemoveAsync method for that.", nameof(amount));
|
||||
}
|
||||
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
InternalChange(userId, userName, discrim, avatar, reason, amount, gamble, uow);
|
||||
await uow.SaveChangesAsync();
|
||||
@@ -102,7 +102,7 @@ public class CurrencyService : ICurrencyService, INService
|
||||
throw new ArgumentException("Cannot perform bulk operation. Arrays are not of equal length.");
|
||||
|
||||
var userIdHashSet = new HashSet<ulong>(idArray.Length);
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
for (var i = 0; i < idArray.Length; i++)
|
||||
{
|
||||
@@ -124,7 +124,7 @@ public class CurrencyService : ICurrencyService, INService
|
||||
throw new ArgumentException("Cannot perform bulk operation. Arrays are not of equal length.");
|
||||
|
||||
var userIdHashSet = new HashSet<ulong>(idArray.Length);
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
for (var i = 0; i < idArray.Length; i++)
|
||||
{
|
||||
@@ -144,7 +144,7 @@ public class CurrencyService : ICurrencyService, INService
|
||||
}
|
||||
|
||||
bool result;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
result = InternalChange(userId, userName, userDiscrim, avatar, reason, -amount, gamble, uow);
|
||||
await uow.SaveChangesAsync();
|
||||
|
@@ -16,7 +16,7 @@ public class StatsService : IStatsService, IReadyExecutor, INService, IDisposabl
|
||||
private readonly IBotCredentials _creds;
|
||||
private readonly DateTime _started;
|
||||
|
||||
public const string BotVersion = "3.0.11";
|
||||
public const string BotVersion = "4.0.0";
|
||||
public string Author => "Kwoth#2452";
|
||||
public string Library => "Discord.Net";
|
||||
public double MessagesPerSecond => MessageCounter / GetUptime().TotalSeconds;
|
||||
@@ -42,7 +42,7 @@ public class StatsService : IStatsService, IReadyExecutor, INService, IDisposabl
|
||||
|
||||
_started = DateTime.UtcNow;
|
||||
_client.MessageReceived += _ => Task.FromResult(Interlocked.Increment(ref _messageCounter));
|
||||
cmdHandler.CommandExecuted += (_, e) => Task.FromResult(Interlocked.Increment(ref _commandsRan));
|
||||
cmdHandler.CommandExecuted += (_, _) => Task.FromResult(Interlocked.Increment(ref _commandsRan));
|
||||
|
||||
_client.ChannelCreated += c =>
|
||||
{
|
||||
|
@@ -41,7 +41,7 @@ public static class IUserExtensions
|
||||
|
||||
public static async Task<IUserMessage> SendFileAsync(this IUser user, string filePath, string caption = null, string text = null, bool isTTS = false)
|
||||
{
|
||||
using (var file = File.Open(filePath, FileMode.Open))
|
||||
await using (var file = File.Open(filePath, FileMode.Open))
|
||||
{
|
||||
return await (await user.GetOrCreateDMChannelAsync().ConfigureAwait(false)).SendFileAsync(file, caption ?? "x", text, isTTS).ConfigureAwait(false);
|
||||
}
|
||||
|
Reference in New Issue
Block a user