geekbot/Geekbot.net/Commands/Say.cs

66 lines
2.1 KiB
C#
Raw Permalink Normal View History

using System;
using System.Threading.Tasks;
2017-09-15 22:56:03 +02:00
using Discord;
2017-04-17 16:58:48 +02:00
using Discord.Commands;
2017-10-12 16:34:10 +02:00
using Geekbot.net.Lib;
2017-04-17 16:58:48 +02:00
namespace Geekbot.net.Commands
2017-04-17 16:58:48 +02:00
{
2018-01-21 23:42:27 +01:00
[Group("say")]
2017-04-17 16:58:48 +02:00
public class Say : ModuleBase
{
private readonly IErrorHandler _errorHandler;
2018-01-21 23:42:27 +01:00
private readonly IContextHandler _contextHandler;
public Say(IErrorHandler errorHandler, IContextHandler contextHandler)
{
_errorHandler = errorHandler;
2018-01-21 23:42:27 +01:00
_contextHandler = contextHandler;
}
2017-12-29 01:53:50 +01:00
2017-09-15 22:56:03 +02:00
[RequireUserPermission(GuildPermission.Administrator)]
2018-01-21 23:42:27 +01:00
[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)]
2017-10-12 16:34:10 +02:00
[Remarks(CommandCategories.Admin)]
2017-09-15 22:56:03 +02:00
[Summary("Say Something.")]
public async Task Echo([Remainder] [Summary("What?")] string echo)
2017-04-17 16:58:48 +02:00
{
try
{
await Context.Message.DeleteAsync();
await ReplyAsync(echo);
}
catch (Exception e)
{
_errorHandler.HandleCommandException(e, Context);
}
2017-04-17 16:58:48 +02:00
}
}
}