Add message lookup and log channel setting commands

This commit is contained in:
Ske
2019-06-21 13:49:58 +02:00
parent 06edc9d61e
commit 2c3c46002a
6 changed files with 92 additions and 19 deletions

View File

@@ -0,0 +1,42 @@
using System.Threading.Tasks;
using Discord;
using Discord.Commands;
namespace PluralKit.Bot.Commands
{
public class ModCommands: ModuleBase<PKCommandContext>
{
public LogChannelService LogChannels { get; set; }
public MessageStore Messages { get; set; }
public EmbedService Embeds { get; set; }
[Command("log")]
[Remarks("log <channel>")]
[RequireUserPermission(GuildPermission.ManageGuild, ErrorMessage = "You must have the Manage Server permission to use this command.")]
[RequireContext(ContextType.Guild, ErrorMessage = "This command can not be run in a DM.")]
public async Task SetLogChannel(ITextChannel channel = null)
{
await LogChannels.SetLogChannel(Context.Guild, channel);
if (channel != null)
await Context.Channel.SendMessageAsync($"{Emojis.Success} Proxy logging channel set to #{channel.Name}.");
else
await Context.Channel.SendMessageAsync($"{Emojis.Success} Proxy logging channel cleared.");
}
[Command("message")]
[Remarks("message <messageid>")]
public async Task GetMessage(ulong messageId)
{
var message = await Messages.Get(messageId);
if (message == null) throw Errors.MessageNotFound(messageId);
await Context.Channel.SendMessageAsync(embed: await Embeds.CreateMessageInfoEmbed(messageId));
}
[Command("message")]
[Remarks("message <messageid>")]
public async Task GetMessage(IMessage msg) => await GetMessage(msg.Id);
}
}