geekbot/Geekbot.net/Commands/Say.cs

66 lines
No EOL
2.1 KiB
C#

using System;
using System.Threading.Tasks;
using Discord;
using Discord.Commands;
using Geekbot.net.Lib;
namespace Geekbot.net.Commands
{
[Group("say")]
public class Say : ModuleBase
{
private readonly IErrorHandler _errorHandler;
private readonly IContextHandler _contextHandler;
public Say(IErrorHandler errorHandler, IContextHandler contextHandler)
{
_errorHandler = errorHandler;
_contextHandler = contextHandler;
}
[RequireUserPermission(GuildPermission.Administrator)]
[Command("record", RunMode = RunMode.Async)]
[Remarks(CommandCategories.Admin)]
[Summary("Say Something.")]
public async Task recordEcho()
{
try
{
_contextHandler.SaveContext(ContextReference.User, Context, "say");
await ReplyAsync("Recording...");
}
catch (Exception e)
{
_errorHandler.HandleCommandException(e, Context);
}
}
[RequireUserPermission(GuildPermission.Administrator)]
[Command("ctx", RunMode = RunMode.Async)]
[Remarks(CommandCategories.Admin)]
[Summary("Say Something.")]
public async Task recordEcho([Remainder] [Summary("What?")] string echo)
{
Console.WriteLine("actually got here...");
_contextHandler.ClearContext(Context.User.Id);
await Context.Channel.SendMessageAsync(echo);
}
[RequireUserPermission(GuildPermission.Administrator)]
[Command("ss", RunMode = RunMode.Async)]
[Remarks(CommandCategories.Admin)]
[Summary("Say Something.")]
public async Task Echo([Remainder] [Summary("What?")] string echo)
{
try
{
await Context.Message.DeleteAsync();
await ReplyAsync(echo);
}
catch (Exception e)
{
_errorHandler.HandleCommandException(e, Context);
}
}
}
}