public async Task ResetCooldowns([Remainder] string name) { var user = await UserRepository.FetchUserAsync(Context); if (user.Cash < Config.GANG_CREATION_COST) { throw new Exception($"You do not have {Config.GANG_CREATION_COST.ToString("C", Config.CI)}. Balance: {user.Cash.ToString("C", Config.CI)}."); } var gang = await GangRepository.CreateGangAsync(Context.User.Id, Context.Guild.Id, name); await UserRepository.EditCashAsync(Context, -Config.GANG_CREATION_COST); await ReplyAsync($"{Context.User.Mention}, You have successfully created the {gang.Name} gang!"); }
public async Task CreateGang([Summary("SLAM EM BOYS")][Remainder] string name) { if (Context.Cash < Config.GANG_CREATION_COST) { ReplyError($"You do not have {Config.GANG_CREATION_COST.USD()}. Balance: {Context.Cash.USD()}."); } else if (!Config.ALPHANUMERICAL.IsMatch(name)) { ReplyError("Gang names may not contain any non alphanumeric characters."); } var gang = await _gangRepo.CreateGangAsync(Context, name); await _userRepo.EditCashAsync(Context, -Config.GANG_CREATION_COST); await ReplyAsync($"You have successfully created the {gang.Name} gang."); }
public async Task ResetCooldowns([Remainder] string name) { using (var db = new SQLite.Models.DbContext()) { var userRepo = new UserRepository(db); var gangRepo = new GangRepository(db); var user = await userRepo.FetchUserAsync(Context.User.Id); if (user.Cash < Config.GANG_CREATION_COST) { throw new Exception($"You do not have {Config.GANG_CREATION_COST.ToString("C2")}. Balance: {user.Cash.ToString("C2")}."); } await userRepo.EditCashAsync(Context, -Config.GANG_CREATION_COST); var gang = await gangRepo.CreateGangAsync(Context.User.Id, Context.Guild.Id, name); await ReplyAsync($"{Context.User.Mention}, You have successfully created the {gang.Name} gang!"); } }