Fix DiscordBot
All checks were successful
Build App / Build (push) Successful in 1m41s

This commit is contained in:
2025-03-07 14:55:00 +01:00
parent e99479d8fb
commit 9d8a7b3100
5 changed files with 88 additions and 151 deletions

View File

@@ -1,58 +1,55 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using LaDOSE.DiscordBot.Service;
using LaDOSE.DTO;
namespace LaDOSE.DiscordBot.Command
{
public class BotEvent : BaseCommandModule
{
private WebService dep;
public BotEvent(WebService d)
{
dep = d;
}
[RequireRolesAttribute(RoleCheckMode.Any, "Staff")]
[Command("newevent")]
public async Task NewEventAsync(CommandContext ctx, string command)
{
await ctx.RespondAsync(dep.RestService.CreateBotEvent(command).ToString());
}
[RequireRolesAttribute(RoleCheckMode.Any,"Staff")]
[Command("staffs")]
public async Task StaffAsync(CommandContext ctx)
{
BotEventDTO currentEvent = dep.RestService.GetLastBotEvent();
StringBuilder stringBuilder = new StringBuilder();
var present = currentEvent.Results.Where(x => x.Result).ToList();
var absent = currentEvent.Results.Where(x => !x.Result).ToList();
stringBuilder.AppendLine($"Pour {currentEvent.Name} : ");
present.ForEach(x => stringBuilder.AppendLine($":white_check_mark: {x.Name}"));
absent.ForEach(x => stringBuilder.AppendLine($":x: {x.Name}"));
await ctx.RespondAsync(stringBuilder.ToString());
}
[RequireRolesAttribute(RoleCheckMode.Any, "Staff")]
[Command("present")]
public async Task PresentAsync(CommandContext ctx)
{
await ctx.RespondAsync(dep.RestService.ResultBotEvent(new DTO.BotEventSendDTO() { DiscordId = ctx.Member.Id.ToString(), DiscordName = ctx.Member.DisplayName, Present = true }).ToString());
}
[RequireRolesAttribute(RoleCheckMode.Any, "Staff")]
[Command("absent")]
public async Task AbsentAsync(CommandContext ctx)
{
await ctx.RespondAsync(dep.RestService.ResultBotEvent(new DTO.BotEventSendDTO() { DiscordId = ctx.Member.Id.ToString(), DiscordName = ctx.Member.DisplayName, Present = false }).ToString());
}
}
// public class BotEvent : BaseCommandModule
// {
// private WebService dep;
// public BotEvent(WebService d)
// {
// dep = d;
// }
//
// [Command("newevent")]
// public async Task NewEventAsync(CommandContext ctx, string command)
// {
//
// await ctx.RespondAsync(dep.RestService.CreateBotEvent(command).ToString());
// }
// [RequireRolesAttribute(RoleCheckMode.Any,"Staff")]
// [Command("staffs")]
// public async Task StaffAsync(CommandContext ctx)
// {
// BotEventDTO currentEvent = dep.RestService.GetLastBotEvent();
// StringBuilder stringBuilder = new StringBuilder();
//
// var present = currentEvent.Results.Where(x => x.Result).ToList();
// var absent = currentEvent.Results.Where(x => !x.Result).ToList();
//
// stringBuilder.AppendLine($"Pour {currentEvent.Name} : ");
// present.ForEach(x => stringBuilder.AppendLine($":white_check_mark: {x.Name}"));
// absent.ForEach(x => stringBuilder.AppendLine($":x: {x.Name}"));
//
// await ctx.RespondAsync(stringBuilder.ToString());
//
// }
// [RequireRolesAttribute(RoleCheckMode.Any, "Staff")]
// [Command("present")]
// public async Task PresentAsync(CommandContext ctx)
// {
// await ctx.RespondAsync(dep.RestService.ResultBotEvent(new DTO.BotEventSendDTO() { DiscordId = ctx.Member.Id.ToString(), DiscordName = ctx.Member.DisplayName, Present = true }).ToString());
//
//
// }
// [RequireRolesAttribute(RoleCheckMode.Any, "Staff")]
// [Command("absent")]
// public async Task AbsentAsync(CommandContext ctx)
// {
// await ctx.RespondAsync(dep.RestService.ResultBotEvent(new DTO.BotEventSendDTO() { DiscordId = ctx.Member.Id.ToString(), DiscordName = ctx.Member.DisplayName, Present = false }).ToString());
// }
// }
}