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());
// }
// }
}

View File

@@ -2,14 +2,15 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Commands;
using DSharpPlus.Commands.ArgumentModifiers;
using DSharpPlus.Commands.Processors.TextCommands;
using DSharpPlus.Entities;
namespace LaDOSE.DiscordBot.Command
{
public class Hokuto : BaseCommandModule
public class Hokuto
{
private static List<string> Games = new List<string> { "2X", "3.3", "Karnov" };
@@ -21,14 +22,21 @@ namespace LaDOSE.DiscordBot.Command
[Command("hokuto")]
public async Task HokutoUserAsync(CommandContext ctx, params DiscordMember[] user)
public async ValueTask HokutoUserAsync(TextCommandContext ctx)
{
var i = r.Next(0, 3);
if (user!=null && user.Length>0)
if (ctx.Message.MentionedUsers is { Count: 1 } )
{
await ctx.RespondAsync(ctx.User?.Mention + " vs " + user[0].Mention + " : " + Games[i].ToString());
foreach (var arg in ctx.Message.MentionedUsers)
{
if (arg is DiscordUser member)
{
await ctx.RespondAsync(ctx.User?.Mention + " vs " + member.Mention + " : " + Games[i].ToString());
return;
}
}
}
else
{

View File

@@ -4,12 +4,11 @@ using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Commands;
namespace LaDOSE.DiscordBot.Command
{
public class Public : BaseCommandModule
public class Public
{
private static List<string> Quotes { get; set; }