This commit is contained in:
That-One-Nerd 2021-07-21 10:58:35 -04:00
parent 741a8bfc40
commit ae81c1fb89
7 changed files with 58 additions and 109 deletions

View File

@ -1,7 +1,10 @@
# Nerd's Teaser Bot - Changelog # Nerd's Teaser Bot - Changelog
## Version v3.05 ## Version v3.06
+ Added `n;level rank` command + Added `n;serverlist`. This command will show any and all servers the bot has joined.
+ Made a Github Repo for Nerd's Teaser Bot + Removed `n;leave`, as it was only required when the bot could not go into every server.
+ Newlines now are also interpreted by the changelog version detector as a version end + The Autopublish handler will now account for it's own messages as well
+ Setting a user's level or xp no longer looks weird + The ModMail handler will now account for the current bot prefix as an ignoreable message
+ The bot is now allowed to join any server, via anyone.
+ The bot will now DM the owner of it (me) with info about any server it joins.
+ The bot will now ping everyone avaliable when a new ModMail ticket is created.

View File

@ -78,7 +78,7 @@ namespace NerdsTeaserBot
client.InteractionCreated += ButtonModule.ButtonHandler; client.InteractionCreated += ButtonModule.ButtonHandler;
client.JoinedGuild += BotModule.PermittedServerHandler; client.JoinedGuild += BotModule.ServerJoinedDMHandler;
client.Log += LogHandler; client.Log += LogHandler;
@ -113,7 +113,8 @@ namespace NerdsTeaserBot
HandlesModule.OnUserMessageRecieved += LevelModule.LevelHandler; HandlesModule.OnUserMessageRecieved += LevelModule.LevelHandler;
HandlesModule.OnUserMessageRecieved += TagModule.TagHandler; HandlesModule.OnUserMessageRecieved += TagModule.TagHandler;
HandlesModule.OnUserMessageRecieved += VariableModule.AutopublishHandler;
HandlesModule.OnAnyUserMessageRecieved += VariableModule.AutopublishHandler;
} }
internal static void LoadBackground() internal static void LoadBackground()
@ -135,8 +136,7 @@ namespace NerdsTeaserBot
{ {
message = msg; message = msg;
context = new SocketCommandContext(client, message); context = new SocketCommandContext(client, message);
if (message.Channel.GetType() == typeof(SocketDMChannel)) return;
if (message.Author.Id == ID || message.Channel.GetType() == typeof(SocketDMChannel)) return;
Data.TryLoadAll(context.Guild.Id); Data.TryLoadAll(context.Guild.Id);
@ -144,6 +144,12 @@ namespace NerdsTeaserBot
int argPos = 0; int argPos = 0;
if (message.Author.Id == ID)
{
await HandlesModule.OnAnyUserMessageRecieved.Invoke(message);
return;
}
if (message.HasStringPrefix(Data.misc.Data.prefix, ref argPos) || message.HasMentionPrefix(client.CurrentUser, ref argPos)) if (message.HasStringPrefix(Data.misc.Data.prefix, ref argPos) || message.HasMentionPrefix(client.CurrentUser, ref argPos))
{ {
IResult result = await commands.ExecuteAsync(context, argPos, services); IResult result = await commands.ExecuteAsync(context, argPos, services);
@ -152,6 +158,7 @@ namespace NerdsTeaserBot
Log.Write(LogItem(context.User) + " has executed command: '" + message.Content + "'"); Log.Write(LogItem(context.User) + " has executed command: '" + message.Content + "'");
} }
await HandlesModule.OnAnyUserMessageRecieved.Invoke(message);
await HandlesModule.OnUserMessageRecieved.Invoke(message); await HandlesModule.OnUserMessageRecieved.Invoke(message);
Data.SaveAll(context.Guild.Id); Data.SaveAll(context.Guild.Id);

View File

@ -279,33 +279,6 @@ namespace NerdsTeaserBot.Modules.Commands
await ReplyAsync("", false, e.Build()); await ReplyAsync("", false, e.Build());
} }
[Command("leave")]
[RequireOwner]
[Summary("Runs through all servers the bot is in and checks them to the list of approved servers.")]
public async Task Leave()
{
List<SocketGuild> left = new();
foreach (SocketGuild g in Context.Client.Guilds) if (await PermittedServerHandler(g)) left.Add(g);
if (left.Length == 0)
{
LogModule.LogMessage(LogSeverity.Error, "No Servers Left");
return;
}
EmbedBuilder e = new()
{
Color = Colors.DefaultColor,
Description = "",
Timestamp = DateTime.Now,
Title = "Left " + left.Length + " Unapproved Servers",
};
foreach (SocketGuild g in left) e.Description += Code(g.Name) + " (Owner: <@" + g.Id + ">)";
await ReplyAsync("", false, e.Build());
}
[Command("ping")] [Command("ping")]
[Summary("Pings the bot, and returns helpful info about that ping")] [Summary("Pings the bot, and returns helpful info about that ping")]
public async Task Ping() public async Task Ping()
@ -328,6 +301,30 @@ namespace NerdsTeaserBot.Modules.Commands
await ReplyAsync("", false, e.Build()); await ReplyAsync("", false, e.Build());
} }
[Command("serverlist")]
[RequireOwner]
[Summary("Shows a list of all servers the bot is currently in")]
public async Task Serverlist()
{
List<SocketGuild> guilds = new(Context.Client.Guilds);
EmbedBuilder e = new()
{
Color = Colors.DefaultColor,
Description = "",
Timestamp = DateTime.Now,
Title = "This Bot is in " + guilds.Length + " Servers",
};
foreach (SocketGuild guild in guilds)
{
if (!guild.HasAllMembers) await guild.DownloadUsersAsync();
e.Description += Bold(Code(guild.Name)) + Italics(Code("(" + guild.Id + ")")) + " - Owned by " + guild.Owner.Mention + " and has " + Code(guild.MemberCount + " Member" + (guild.MemberCount == 1 ? "" : "s")) + "\n";
}
await ReplyAsync("", false, e.Build());
}
[Command("test")] [Command("test")]
[Summary("Does whatever is currently being tested")] [Summary("Does whatever is currently being tested")]
public async Task Test() public async Task Test()
@ -337,25 +334,22 @@ namespace NerdsTeaserBot.Modules.Commands
// end commands // end commands
public static async Task<bool> PermittedServerHandler(SocketGuild guild) public static async Task ServerJoinedDMHandler(SocketGuild guild)
{ {
bool not = !Data.misc.Data.allowedServers.Contains(guild.Id); if (!guild.HasAllMembers) await guild.DownloadUsersAsync();
if (not) EmbedBuilder e = new()
{ {
EmbedBuilder e = new() Color = Colors.DefaultColor,
{ Description = "<@" + ID + "> has joined " + Bold(Code(guild.Name)) + ". More info is below:\n\n" +
Color = Color.Red, "Member Count: " + Code(guild.MemberCount + " Member" + (guild.MemberCount == 1 ? "" : "s")) + "\n" +
Description = "This server is not a part of the list of approved servers. Please come into contact with <@478210457816006666> to add it", "Owner: " + guild.Owner.Mention + " " + Bold("(" + guild.Owner.Username + "#" + guild.Owner.Discriminator + ")") + "\n" +
Timestamp = DateTime.Now, "Server ID: " + Code(guild.Id.ToString()),
Title = "Server Cannot be Joined", Timestamp = DateTime.Now,
}; Title = "Joined New Server",
};
await guild.DefaultChannel.SendMessageAsync("", false, e.Build()); await (await Internals.client.GetApplicationInfoAsync()).Owner.SendMessageAsync("", false, e.Build());
await guild.LeaveAsync();
}
return not;
} }
} }
} }

View File

@ -403,7 +403,7 @@ namespace NerdsTeaserBot.Modules.Commands
if (message is SocketUserMessage msg) if (message is SocketUserMessage msg)
{ {
if (msg.Author.Id == ID) return; if (msg.Author.Id == ID) return;
if (msg.Content.Trim().StartsWith(";") || msg.Content.Trim().StartsWith("n;") || msg.Content.Trim().StartsWith("m;")) return; if (msg.Content.Trim().StartsWith(";") || msg.Content.Trim().StartsWith("n;") || msg.Content.Trim().StartsWith("m;") || msg.Content.Trim().StartsWith(Data.misc.Data.prefix)) return;
EmbedBuilder e; EmbedBuilder e;
@ -482,7 +482,7 @@ namespace NerdsTeaserBot.Modules.Commands
if (count != 1) s += "s"; if (count != 1) s += "s";
e.AddField("Warn Count", Code(count + " Warn" + s), true); e.AddField("Warn Count", Code(count + " Warn" + s), true);
await ch.SendMessageAsync("", false, e.Build()); await ch.SendMessageAsync(cat.Guild.EveryoneRole.Mention, false, e.Build());
await ch.SyncPermissionsAsync(); await ch.SyncPermissionsAsync();
await SuccessModMailMessage(await msg.Author.GetOrCreateDMChannelAsync(), true); await SuccessModMailMessage(await msg.Author.GetOrCreateDMChannelAsync(), true);
} }

View File

@ -232,61 +232,6 @@ namespace NerdsTeaserBot.Modules.Commands
await ReplyAsync("", false, e.Build()); await ReplyAsync("", false, e.Build());
} }
[Command("serverlist add")]
[RequireOwner]
[Summary("Adds a server to the list of approved servers to join")]
public async Task ServerlistAdd([Summary("The ID of the server you would like to add")] ulong id)
{
EmbedBuilder e = new()
{
Color = Colors.DefaultColor,
Description = "The bot is now allowed to enter the server with the ID of " + Italics(Code(id.ToString())),
Timestamp = DateTime.Now,
Title = "Approved Server",
};
Data.misc.Data.allowedServers.Add(id);
await ReplyAsync("", false, e.Build());
}
[Command("serverlist list")]
[Summary("Shows the list of approved servers to join")]
public async Task ServerlistList()
{
EmbedBuilder e = new()
{
Color = Colors.DefaultColor,
Description = "",
Timestamp = DateTime.Now,
Title = Data.misc.Data.allowedServers.Length + " Approved Server ID",
};
if (Data.misc.Data.allowedServers.Length != 1) e.Title += "s";
foreach (ulong u in Data.misc.Data.allowedServers) e.Description += Italics(Code(u.ToString())) + "\n";
await ReplyAsync("", false, e.Build());
}
[Command("serverlist remove")]
[RequireOwner]
[Summary("Removes a server from the list of approved servers to join")]
public async Task ServerlistRemove([Summary("The ID of the server you would like to remove")] ulong id)
{
EmbedBuilder e = new()
{
Color = Color.Red,
Description = "The bot will no longer be permitted to enter a server with the ID of " + Italics(Code(id.ToString())),
Timestamp = DateTime.Now,
Title = "Server Prohibited",
};
Data.misc.Data.allowedServers.Remove(id);
await ReplyAsync("", false, e.Build());
}
// handles // handles
public static async Task AutopublishHandler(SocketUserMessage msg) public static async Task AutopublishHandler(SocketUserMessage msg)

View File

@ -9,6 +9,7 @@ namespace NerdsTeaserBot.Modules
{ {
public static class HandlesModule public static class HandlesModule
{ {
internal static Func<SocketUserMessage, Task> OnAnyUserMessageRecieved;
internal static Func<SocketUserMessage, Task> OnUserMessageRecieved; internal static Func<SocketUserMessage, Task> OnUserMessageRecieved;
} }
} }

View File

@ -7,7 +7,6 @@ namespace NerdsTeaserBot.Modules.Models
public class MiscData public class MiscData
{ {
public List<ulong> announceChannels = new(); public List<ulong> announceChannels = new();
public List<ulong> allowedServers = new();
public ulong changelogChannel; public ulong changelogChannel;
public int levelCooldown = 60; public int levelCooldown = 60;
public bool levelMention; public bool levelMention;