From 34cacefdc75f54b8bbab7638575c0cafcd425ba7 Mon Sep 17 00:00:00 2001 From: Madpeter <57852827+Madpeterz@users.noreply.github.com> Date: Thu, 7 Dec 2023 10:30:43 +0000 Subject: [PATCH] set limits on reply length and use updated commandinterfacecaller --- SecondBotEvents/Services/DiscordService.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/SecondBotEvents/Services/DiscordService.cs b/SecondBotEvents/Services/DiscordService.cs index fffb755..a62eb57 100644 --- a/SecondBotEvents/Services/DiscordService.cs +++ b/SecondBotEvents/Services/DiscordService.cs @@ -164,6 +164,10 @@ namespace SecondBotEvents.Services protected void ReplyToMessage(IMessage message, string reply) { + if(reply.Length > 2000) + { + reply = reply.Substring(0, 1900)+"..."; + } message.Channel.SendMessageAsync(reply, false, null, null, null, new MessageReference(message.Id)); } @@ -278,6 +282,18 @@ namespace SecondBotEvents.Services _ = message.DeleteAsync(); } + protected void RunCommandFromChat(SocketMessage message) + { + KeyValuePair reply = master.CommandsService.CommandInterfaceCaller(message.Content, false, false, "DiscordAPI"); + string replyEmote = "✅"; + if (reply.Key == false) + { + replyEmote = "❌"; + } + _ = MarkMessage((IUserMessage)message, replyEmote); + ReplyToMessage(message, reply.Value); + } + protected void RunCommandFromMessage(SignedCommand C, SocketMessage message) { KeyValuePair reply = master.CommandsService.RunCommand(C); @@ -366,8 +382,7 @@ namespace SecondBotEvents.Services if (message.Author.Id != DiscordClient.CurrentUser.Id) { // do command - RunCommandFromMessage(new SignedCommand(master.CommandsService, - "discordapi", message.Content, false, false, 0, ""), message); + RunCommandFromChat(message); return; } }