-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathGuildEventLoggerCommands.cs
72 lines (57 loc) · 2.62 KB
/
GuildEventLoggerCommands.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using System.Threading.Tasks;
using DSharpPlus;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
namespace RoboBot
{
public class GuildEventLoggerCommands : BaseCommandModule
{
private static class CommandNames
{
public const string SetLoggingChannel = "logsetchan";
public const string UnsetLoggingChannel = "logunsetchan";
public const string TestLogging = "logtest";
public const string LoggingInfo = "loginfo";
}
private const Permissions RequiredPermissions = Permissions.Administrator;
[RequireGuild]
[Command(CommandNames.SetLoggingChannel)]
public async Task SetLoggingChannel(CommandContext ctx)
{
if (!await CommandHelpers.CheckPermissions(ctx, RequiredPermissions))
return;
GuildEventLogger.Instance.SetLogChannel(ctx.Guild, ctx.Channel);
await ctx.RespondAsync("Set this channel as the bot log channel");
}
[RequireGuild]
[Command(CommandNames.UnsetLoggingChannel)]
public async Task UnsetLoggingChannel(CommandContext ctx)
{
if (!await CommandHelpers.CheckPermissions(ctx, RequiredPermissions))
return;
GuildEventLogger.Instance.UnsetLogChannel(ctx.Guild);
await ctx.RespondAsync("Unset this channel as the bot log channel");
}
[RequireGuild]
[Command(CommandNames.TestLogging)]
public async Task TestLogging(CommandContext ctx)
{
if (!await CommandHelpers.CheckPermissions(ctx, RequiredPermissions))
return;
await ctx.RespondAsync($"Running test... if nothing happens try setting the log channel again with {ctx.Prefix}{CommandNames.SetLoggingChannel}");
await GuildEventLogger.Instance.LogInfo(ctx.Guild, $"This is the test of the event logger as requested per [this message]({ctx.Message.JumpLink})");
}
[RequireGuild]
[Command(CommandNames.LoggingInfo)]
public async Task LoggingInfo(CommandContext ctx)
{
if (!await CommandHelpers.CheckPermissions(ctx, RequiredPermissions))
return;
GuildEventLogger.GuildLogInfoResult result = GuildEventLogger.Instance.GetGuildLogInfo(ctx.Guild);
string response = $"Is event logging set : {result.IsSet}";
if(result.IsSet)
response += $"\nChannel where events are logged : {result.LogChannel.Mention}";
await ctx.RespondAsync(response);
}
}
}