Added raffle clear command and permission node.
This commit is contained in:
parent
59b6ff0569
commit
f9b5531b47
@ -71,6 +71,10 @@ namespace ChaosBot.Discord.Modules.User
|
||||
{
|
||||
await TotalRaffle();
|
||||
}
|
||||
else if ((cmd.ToLower() == "clear") && (await CheckPermissions.CheckPerms(Context, "points.clear", "Admin")))
|
||||
{
|
||||
await ClearRaffle(userMention);
|
||||
}
|
||||
else
|
||||
{
|
||||
await RaffleHelp();
|
||||
@ -264,6 +268,46 @@ namespace ChaosBot.Discord.Modules.User
|
||||
false);
|
||||
}
|
||||
|
||||
public async Task ClearRaffle(string confirm = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(confirm == "confirm")
|
||||
{
|
||||
using (ChaosbotContext dbContext = new ChaosbotContext())
|
||||
{
|
||||
IQueryable<Raffle> ctxRaffles = dbContext.Raffles;
|
||||
|
||||
IQueryable<Raffle> ctxRaffleDetail = ctxRaffles
|
||||
.Where(p => p.DiscordGuildId.Equals(Context.Guild.Id));
|
||||
|
||||
int cur = ctxRaffleDetail.Count();
|
||||
|
||||
if (cur != 0)
|
||||
{
|
||||
dbContext.Raffles.RemoveRange(ctxRaffleDetail);
|
||||
await dbContext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
await ReplyAsync(
|
||||
$"{Context.User.Mention} has removed all tickets.",
|
||||
false);
|
||||
}
|
||||
else
|
||||
{
|
||||
await ReplyAsync(
|
||||
$"{Context.User.Mention}, if you wish to clear ALL tickets, please send the below command.```{ConfigurationRepository.GetValue<string>("Discord:Prefix", Context.Guild.Id, "!")}raffle clear confirm```",
|
||||
false);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error(
|
||||
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task PickRaffle()
|
||||
{
|
||||
try
|
||||
|
||||
Loading…
Reference in New Issue
Block a user