Added general bot commands NewStatus, and NewName, both RequireOwner to evoke.

This commit is contained in:
Chris Darnell committed 2021-05-04 05:05:59 -07:00
1 parent 147c165e62
commit afca839596
7 files changed
+241 -110

No files matched your search

+88 -62
View File
@@ -1,6 +1,7 @@
#pragma warning disable IDE0060 // Remove unused parameter
using DSharpPlus;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Exceptions;
using DSharpPlus.Entities;
using DSharpPlus.EventArgs;
using Microsoft.Extensions.Logging;
@@ -15,20 +16,15 @@ namespace StarsiegeBot
{
public readonly EventId BotEventId;
public static DiscordMember notify;
protected string BotName { get; set; }
// protected string BotName { get; set; }
private readonly BotSettings Guilds = new BotSettings();
public Triggers(EventId botEventId)
{
BotEventId = botEventId;
}
public Triggers(EventId botEventId) => BotEventId = botEventId;
public Task CommandExecuted(CommandsNextExtension ext, CommandExecutionEventArgs e)
{
if (e.Context.Client.Guilds.Count > 75)
e.Context.Client.Logger.LogCritical(BotEventId, $"Client is in {e.Context.Client.Guilds.Count}");
// e.Context.Client.Logger.LogCritical(BotEventId, $"Client is in {e.Context.Client.Guilds.Count}");
// let's log the name of the command and user
e.Context.Client.Logger.LogInformation(BotEventId, $"{e.Context.User.Username} successfully executed '{e.Command.QualifiedName}'");
// e.Context.Client.Logger.LogInformation(BotEventId, $"{e.Context.User.Username} successfully executed '{e.Command.QualifiedName}'");
// since this method is not async, let's return
// a completed task, so that no additional work
@@ -37,7 +33,7 @@ namespace StarsiegeBot
}
public Task MessageCreated(DiscordClient d, MessageCreateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "MessageCreated.");
// d.Logger.LogDebug(BotEventId, "MessageCreated.");
// Ignore all bots. We don't care.
if (e.Author.IsBot)
@@ -97,47 +93,57 @@ namespace StarsiegeBot
public Task CommandErrored(CommandsNextExtension ext, CommandErrorEventArgs e)
{
e.Context.Client.Logger.LogError(BotEventId, $"{e.Context.User.Username} tried executing '{e.Command?.QualifiedName ?? "<unknown command>"}' but it errored: {e.Exception.GetType()}: {e.Exception.Message ?? "<no message>"}", DateTime.Now);
if (e.Exception is ChecksFailedException ex)
{
string output = "---\r\n";
foreach (var item in ex.FailedChecks)
{
output += item.ToString() + "\r\n";
}
Console.WriteLine(output);
}
return Task.CompletedTask;
}
public Task InteractionCreated(DiscordClient d, InteractionCreateEventArgs e)
{
d.Logger.LogDebug(BotEventId, $"{e.Interaction.User.Username} started an interaction. {e.Interaction.Data.Name}");
// d.Logger.LogDebug(BotEventId, $"{e.Interaction.User.Username} started an interaction. {e.Interaction.Data.Name}");
return Task.CompletedTask;
}
public Task ChannelCreated(DiscordClient d, ChannelCreateEventArgs e)
{
d.Logger.LogDebug(BotEventId, $"{e.Channel.Name} was created on {e.Guild.Name}. Type: {e.Channel.Type}");
// d.Logger.LogDebug(BotEventId, $"{e.Channel.Name} was created on {e.Guild.Name}. Type: {e.Channel.Type}");
return Task.CompletedTask;
}
public Task ChannelDeleted(DiscordClient d, ChannelDeleteEventArgs e)
{
d.Logger.LogDebug(BotEventId, "ChannelDeleted.");
// d.Logger.LogDebug(BotEventId, "ChannelDeleted.");
return Task.CompletedTask;
}
public Task ApplicationCommandCreated(DiscordClient d, ApplicationCommandEventArgs e)
{
d.Logger.LogDebug(BotEventId, "ApplicationCommandCreated.");
// d.Logger.LogDebug(BotEventId, "ApplicationCommandCreated.");
return Task.CompletedTask;
}
public Task ApplicationCommandDeleted(DiscordClient d, ApplicationCommandEventArgs e)
{
d.Logger.LogDebug(BotEventId, "ApplicationCommandDeleted.");
// d.Logger.LogDebug(BotEventId, "ApplicationCommandDeleted.");
return Task.CompletedTask;
}
public Task ApplicationCommandUpdated(DiscordClient d, ApplicationCommandEventArgs e)
{
d.Logger.LogDebug(BotEventId, "ApplicationCommandUpdated.");
// d.Logger.LogDebug(BotEventId, "ApplicationCommandUpdated.");
return Task.CompletedTask;
}
public Task ChannelPinsUpdated(DiscordClient d, ChannelPinsUpdateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "ChannelPinsUpdated.");
// d.Logger.LogDebug(BotEventId, "ChannelPinsUpdated.");
return Task.CompletedTask;
}
public Task ChannelUpdated(DiscordClient d, ChannelUpdateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "ChannelUpdated.");
// d.Logger.LogDebug(BotEventId, "ChannelUpdated.");
return Task.CompletedTask;
}
public Task ClientErrored(DiscordClient d, ClientErrorEventArgs e)
@@ -153,7 +159,7 @@ namespace StarsiegeBot
}
public Task DmChannelDeleted(DiscordClient d, DmChannelDeleteEventArgs e)
{
d.Logger.LogDebug(BotEventId, "ClientErrored.");
// d.Logger.LogDebug(BotEventId, "ClientErrored.");
return Task.CompletedTask;
}
public Task GuildAvailable(DiscordClient d, GuildCreateEventArgs e)
@@ -174,12 +180,14 @@ namespace StarsiegeBot
UseLevelRoles = false,
UseLevels = false,
UseSelfRoles = false,
AllowRolesPurchase = false
AllowRolesPurchase = false,
UseWelcome = false,
WelcomeChannel = null,
WelcomeMessage = "",
SelfRoles = new Dictionary<string, Dictionary<string, int>>(),
LevelRoles = new Dictionary<int, List<string>>(),
Prefixes = new List<string>()
};
item.UseAutoRoles = false;
item.LevelRoles = new Dictionary<int, List<DiscordRole>>();
item.Prefixes = new List<string>();
item.SelfRoles = new Dictionary<string, Dictionary<string, int>>();
// this line... is a test line.
BotSettings.GuildSettings.Add(gId, item);
}
@@ -188,6 +196,10 @@ namespace StarsiegeBot
// let's log the name of the guild that was just
// sent to our client
d.Logger.LogInformation(BotEventId, $"Guild available: {e.Guild.Name}");
if (!(notify is null))
// notify the *primary bot owner if the Guild count is above 75. So we can start bot verification process.
if (d.Guilds.Count > 75 && !(notify is null))
notify.SendMessageAsync("**__WARNING__: BOT IS IN OVER 75 SERVERS.");
// since this method is not async, let's return
// a completed task, so that no additional work
@@ -196,45 +208,59 @@ namespace StarsiegeBot
}
public Task GuildBanAdded(DiscordClient d, GuildBanAddEventArgs e)
{
d.Logger.LogDebug(BotEventId, "GuildBanAdded.");
// d.Logger.LogDebug(BotEventId, "GuildBanAdded.");
return Task.CompletedTask;
}
public Task GuildBanRemoved(DiscordClient d, GuildBanRemoveEventArgs e)
{
d.Logger.LogDebug(BotEventId, "GuildBanRemoved.");
// d.Logger.LogDebug(BotEventId, "GuildBanRemoved.");
return Task.CompletedTask;
}
public Task GuildCreated(DiscordClient d, GuildCreateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "GuildCreated.");
// d.Logger.LogDebug(BotEventId, "GuildCreated.");
return Task.CompletedTask;
}
public Task GuildDeleted(DiscordClient d, GuildDeleteEventArgs e)
{
d.Logger.LogDebug(BotEventId, "GuildDeleted.");
// d.Logger.LogDebug(BotEventId, "GuildDeleted.");
return Task.CompletedTask;
}
public Task GuildDownloadCompleted(DiscordClient d, GuildDownloadCompletedEventArgs e)
{
d.Logger.LogDebug(BotEventId, "GuildDownloadCompleted.");
// d.Logger.LogDebug(BotEventId, "GuildDownloadCompleted.");
//if(e.Guilds[376937422010974209].Members.ContainsKey(139548200099905536))
//notify = e.Guilds[376937422010974209].Members[139548200099905536];
ulong desiredKey = 139548200099905536;
foreach (KeyValuePair<ulong,DiscordGuild> item in e.Guilds)
{
DiscordGuild curr = item.Value;
if(curr.Members.ContainsKey(desiredKey))
{
notify = curr.Members[desiredKey];
break;
}
}
notify.SendMessageAsync("Bot has started up");
// notify the *primary bot owner if the Guild count is above 75. So we can start bot verification process.
if (e.Guilds.Count > 75)
notify.SendMessageAsync("**__WARNING__: BOT IS IN OVER 75 SERVERS.");
return Task.CompletedTask;
}
public Task GuildEmojisUpdated(DiscordClient d, GuildEmojisUpdateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "GuildEmojisUpdated.");
// d.Logger.LogDebug(BotEventId, "GuildEmojisUpdated.");
return Task.CompletedTask;
}
public Task GuildIntegrationsUpdated(DiscordClient d, GuildIntegrationsUpdateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "GuildIntegrationsUpdated.");
// d.Logger.LogDebug(BotEventId, "GuildIntegrationsUpdated.");
return Task.CompletedTask;
}
public Task GuildMemberAdded(DiscordClient d, GuildMemberAddEventArgs e)
{
d.Logger.LogDebug(BotEventId, $"GuildMemberAdded.");
// d.Logger.LogDebug(BotEventId, $"GuildMemberAdded.");
if (e.Member.IsBot)
{
return Task.CompletedTask;
@@ -253,102 +279,102 @@ namespace StarsiegeBot
}
public Task GuildMemberRemoved(DiscordClient d, GuildMemberRemoveEventArgs e)
{
d.Logger.LogDebug(BotEventId, "GuildMemberRemoved.");
// d.Logger.LogDebug(BotEventId, "GuildMemberRemoved.");
return Task.CompletedTask;
}
public Task GuildMembersChunked(DiscordClient d, GuildMembersChunkEventArgs e)
{
d.Logger.LogDebug(BotEventId, "GuildMembersChunked.");
// d.Logger.LogDebug(BotEventId, "GuildMembersChunked.");
return Task.CompletedTask;
}
public Task GuildMemberUpdated(DiscordClient d, GuildMemberUpdateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "GuildMemberUpdated.");
// d.Logger.LogDebug(BotEventId, "GuildMemberUpdated.");
return Task.CompletedTask;
}
public Task GuildRoleCreated(DiscordClient d, GuildRoleCreateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "GuildRoleCreated.");
// d.Logger.LogDebug(BotEventId, "GuildRoleCreated.");
return Task.CompletedTask;
}
public Task GuildRoleDeleted(DiscordClient d, GuildRoleDeleteEventArgs e)
{
d.Logger.LogDebug(BotEventId, "GuildRoleDeleted.");
// d.Logger.LogDebug(BotEventId, "GuildRoleDeleted.");
return Task.CompletedTask;
}
public Task GuildRoleUpdated(DiscordClient d, GuildRoleUpdateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "GuildRoleUpdated.");
// d.Logger.LogDebug(BotEventId, "GuildRoleUpdated.");
return Task.CompletedTask;
}
public Task GuildUnavailable(DiscordClient d, GuildDeleteEventArgs e)
{
d.Logger.LogDebug(BotEventId, "GuildUnavailable.");
// d.Logger.LogDebug(BotEventId, "GuildUnavailable.");
return Task.CompletedTask;
}
public Task GuildUpdated(DiscordClient d, GuildUpdateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "GuildUpdated.");
// d.Logger.LogDebug(BotEventId, "GuildUpdated.");
return Task.CompletedTask;
}
public Task Heartbeated(DiscordClient d, HeartbeatEventArgs e)
{
d.Logger.LogDebug(BotEventId, "Heartbeated.");
// d.Logger.LogDebug(BotEventId, "Heartbeated.");
return Task.CompletedTask;
}
public Task InviteCreated(DiscordClient d, InviteCreateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "InviteCreated.");
// d.Logger.LogDebug(BotEventId, "InviteCreated.");
return Task.CompletedTask;
}
public Task InviteDeleted(DiscordClient d, InviteDeleteEventArgs e)
{
d.Logger.LogDebug(BotEventId, "InviteDeleted.");
// d.Logger.LogDebug(BotEventId, "InviteDeleted.");
return Task.CompletedTask;
}
public Task MessageAcknowledged(DiscordClient d, MessageAcknowledgeEventArgs e)
{
d.Logger.LogDebug(BotEventId, "MessageAcknowledged.");
// d.Logger.LogDebug(BotEventId, "MessageAcknowledged.");
return Task.CompletedTask;
}
public Task MessageDeleted(DiscordClient d, MessageDeleteEventArgs e)
{
d.Logger.LogDebug(BotEventId, "MessageDeleted.");
// d.Logger.LogDebug(BotEventId, "MessageDeleted.");
return Task.CompletedTask;
}
public Task MessageReactionAdded(DiscordClient d, MessageReactionAddEventArgs e)
{
d.Logger.LogDebug(BotEventId, "MessageReactionAdded.");
// d.Logger.LogDebug(BotEventId, "MessageReactionAdded.");
return Task.CompletedTask;
}
public Task MessageReactionRemoved(DiscordClient d, MessageReactionRemoveEventArgs e)
{
d.Logger.LogDebug(BotEventId, "MessageReactionRemoved.");
// d.Logger.LogDebug(BotEventId, "MessageReactionRemoved.");
return Task.CompletedTask;
}
public Task MessageReactionRemovedEmoji(DiscordClient d, MessageReactionRemoveEmojiEventArgs e)
{
d.Logger.LogDebug(BotEventId, "MessageReactionRemovedEmoji.");
// d.Logger.LogDebug(BotEventId, "MessageReactionRemovedEmoji.");
return Task.CompletedTask;
}
public Task MessageReactionsCleared(DiscordClient d, MessageReactionsClearEventArgs e)
{
d.Logger.LogDebug(BotEventId, "MessageReactionsCleared.");
// d.Logger.LogDebug(BotEventId, "MessageReactionsCleared.");
return Task.CompletedTask;
}
public Task MessagesBulkDeleted(DiscordClient d, MessageBulkDeleteEventArgs e)
{
d.Logger.LogDebug(BotEventId, "MessagesBulkDeleted.");
// d.Logger.LogDebug(BotEventId, "MessagesBulkDeleted.");
return Task.CompletedTask;
}
public Task MessageUpdated(DiscordClient d, MessageUpdateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "MessageUpdated.");
// d.Logger.LogDebug(BotEventId, "MessageUpdated.");
return Task.CompletedTask;
}
public Task PresenceUpdated(DiscordClient d, PresenceUpdateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "PresenceUpdated.");
// d.Logger.LogDebug(BotEventId, "PresenceUpdated.");
return Task.CompletedTask;
}
public Task Ready(DiscordClient d, ReadyEventArgs e)
@@ -363,7 +389,7 @@ namespace StarsiegeBot
}
public Task Resumed(DiscordClient d, ReadyEventArgs e)
{
d.Logger.LogDebug(BotEventId, "Resumed.");
// d.Logger.LogDebug(BotEventId, "Resumed.");
return Task.CompletedTask;
}
public Task SocketClosed(DiscordClient d, SocketCloseEventArgs e)
@@ -378,42 +404,42 @@ namespace StarsiegeBot
}
public Task SocketOpened(DiscordClient d, SocketEventArgs e)
{
d.Logger.LogDebug(BotEventId, "SocketOpened.");
// d.Logger.LogDebug(BotEventId, "SocketOpened.");
return Task.CompletedTask;
}
public Task TypingStarted(DiscordClient d, TypingStartEventArgs e)
{
d.Logger.LogDebug(BotEventId, "TypingStarted.");
// d.Logger.LogDebug(BotEventId, "TypingStarted.");
return Task.CompletedTask;
}
public Task UnknownEvent(DiscordClient d, UnknownEventArgs e)
{
d.Logger.LogDebug(BotEventId, "UnknownEvent.");
// d.Logger.LogDebug(BotEventId, "UnknownEvent.");
return Task.CompletedTask;
}
public Task UserSettingsUpdated(DiscordClient d, UserSettingsUpdateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "UserSettingsUpdated.");
// d.Logger.LogDebug(BotEventId, "UserSettingsUpdated.");
return Task.CompletedTask;
}
public Task UserUpdated(DiscordClient d, UserUpdateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "UserUpdated.");
// d.Logger.LogDebug(BotEventId, "UserUpdated.");
return Task.CompletedTask;
}
public Task VoiceServerUpdated(DiscordClient d, VoiceServerUpdateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "VoiceServerUpdated.");
// d.Logger.LogDebug(BotEventId, "VoiceServerUpdated.");
return Task.CompletedTask;
}
public Task VoiceStateUpdated(DiscordClient d, VoiceStateUpdateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "VoiceStateUpdated.");
// d.Logger.LogDebug(BotEventId, "VoiceStateUpdated.");
return Task.CompletedTask;
}
public Task WebhooksUpdated(DiscordClient d, WebhooksUpdateEventArgs e)
{
d.Logger.LogDebug(BotEventId, "WebhooksUpdated.");
// d.Logger.LogDebug(BotEventId, "WebhooksUpdated.");
return Task.CompletedTask;
}
}