public async Task SetStrikeAction(ulong guildId, int amount, StrikeAction action) { var config = await GetServerConfig(guildId); config.StrikeActions[amount] = action; await cosmos.Upsert(config); }
public async Task SetStrike(int amount, string action, string length = null) { if (amount <= 0) { await ReplyAsync("Amount of strikes must be greater than 0."); return; } if (!Enum.TryParse(action, true, out BotAction botAction)) { await ReplyAsync($"Unable to determine action from '{action}'"); return; } if (!Parser.TryParseToSpan(length, out var span)) { await ReplyAsync($"Unable to determine length of action from '{length}'"); return; } var strikeAction = new StrikeAction { Action = botAction, Length = span }; await repo.SetStrikeAction(Context.Guild.Id, amount, strikeAction); await ReplyAsync($"Strike action set for {amount} strike(s)"); }
public async Task <string> HandleStrike(SocketGuild guild, SocketGuildUser user, StrikeAction action) { switch (action.Action) { case BotAction.Mute: return(await muteHandler.Mute(guild, user, action.Length)); case BotAction.Kick: await user.KickAsync(); return($"Kicking {Formatter.FullName(user, true)}."); case BotAction.Ban: return(await banHandler.Ban(guild, user.Id, action.Length)); case BotAction.Nothing: default: return(string.Empty); } }