2023-10-24 13:25:45 +00:00
|
|
|
|
using Discord.WebSocket;
|
|
|
|
|
|
|
|
|
|
namespace BiblioTech.Options
|
|
|
|
|
{
|
|
|
|
|
public class CommandContext
|
|
|
|
|
{
|
|
|
|
|
public CommandContext(SocketSlashCommand command, IReadOnlyCollection<SocketSlashCommandDataOption> options)
|
|
|
|
|
{
|
|
|
|
|
Command = command;
|
|
|
|
|
Options = options;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SocketSlashCommand Command { get; }
|
|
|
|
|
public IReadOnlyCollection<SocketSlashCommandDataOption> Options { get; }
|
2023-10-25 08:54:26 +00:00
|
|
|
|
|
|
|
|
|
public async Task Followup(string message)
|
|
|
|
|
{
|
2023-11-08 12:33:48 +00:00
|
|
|
|
if (message.Length > 1900)
|
|
|
|
|
{
|
|
|
|
|
await FollowupWithAttachement("codexdiscordbot_file.txt", message);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-02 14:04:53 +00:00
|
|
|
|
await Command.ModifyOriginalResponseAsync(m =>
|
|
|
|
|
{
|
|
|
|
|
m.Content = message;
|
|
|
|
|
});
|
2023-10-25 08:54:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-11-08 12:33:48 +00:00
|
|
|
|
private async Task FollowupWithAttachement(string filename, string content)
|
2023-10-25 08:54:26 +00:00
|
|
|
|
{
|
2023-11-02 14:04:53 +00:00
|
|
|
|
using var fileStream = new MemoryStream();
|
|
|
|
|
using var streamWriter = new StreamWriter(fileStream);
|
|
|
|
|
await streamWriter.WriteAsync(content);
|
|
|
|
|
|
|
|
|
|
await Command.FollowupWithFileAsync(fileStream, filename);
|
2023-10-25 08:54:26 +00:00
|
|
|
|
}
|
2023-10-24 13:25:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|