Files
archived-discord-bot/CompatBot/Commands/Sudo.cs
13xforever 7fd7d09973 RPCS3 Compatibility Bot reimplemented in C# for .NET Core
RPCS3 Compatibility Bot reimplemented in C# for .NET Core

Current status of this PR:
* tested and targeted for .NET Core 2.1
* all functionality is either on par or improved compared to the python version
* compatibility with current bot.db should be preserved in all upgrade scenarios
* some bot management commands were changed (now under !sudo bot)
* standard help generator for the new discord client is ... different;
  compatibility with old format could be restored through custom formatter if needed
* everything has been split in more loosely tied components for easier extensibility and maintenance
* log parsing has been rewritten and should work ~2x as fast
2018-07-20 09:22:28 +02:00

34 lines
1.4 KiB
C#

using System.Threading.Tasks;
using CompatBot.Attributes;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
namespace CompatBot.Commands
{
[Group("sudo"), RequiresBotSudoerRole]
[Description("Used to manage bot moderators and sudoers")]
internal sealed partial class Sudo : BaseCommandModule
{
private static readonly object updateObj = new object();
[Command("say"), Priority(10)]
[Description("Make bot say things, optionally in a specific channel")]
public async Task Say(CommandContext ctx, [Description("Discord channel (can use just #name in DM)")] DiscordChannel channel, [RemainingText, Description("Message text to send")] string message)
{
var typingTask = channel.TriggerTypingAsync();
// simulate bot typing the message at 300 cps
await Task.Delay(message.Length * 10 / 3).ConfigureAwait(false);
await channel.SendMessageAsync(message).ConfigureAwait(false);
await typingTask.ConfigureAwait(false);
}
[Command("say"), Priority(10)]
[Description("Make bot say things, optionally in a specific channel")]
public Task Say(CommandContext ctx, [RemainingText, Description("Message text to send")] string message)
{
return Say(ctx, ctx.Channel, message);
}
}
}