Minor changes, added Code Oganization file.

This commit is contained in:
Chris Darnell committed 2021-04-30 18:12:29 -07:00
1 parent 45dd598882
commit 58333dbe41
5 files changed
+90 -62

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
Public const fields.
Non-public const fields.
Public static properties.
Public static fields.
Non-public static properties.
Non-public static fields.
Public properties.
Public fields.
Private properties.
Private fields.
Static constructor.
Public constructors.
Non-public constructors.
Public methods (with the exception of methods overriden from System.Object).
Non-public methods.
Methods overriden from System.Object.
Public static methods.
Non-public static methods.
Operator overloads.
Public events.
Non-public events.
+43 -19
View File
@@ -120,35 +120,59 @@ namespace StarsiegeBot
await ctx.RespondAsync($"Global Prefix usage has been turned **{(isEnabled ? "on" : "off")}**"); await ctx.RespondAsync($"Global Prefix usage has been turned **{(isEnabled ? "on" : "off")}**");
} }
[Command("global")] [Command("global")]
public async Task UseGlobalPrefixes(CommandContext ctx, [Description("0 is off, 1 is on.")] int isEnabled) public async Task UseGlobalPrefixes(CommandContext ctx, [Description("ON or OFF"),RemainingText] string isEnabled = null)
{
// since we're just allowing the user to use different ways to turn this function on and off... Redirect the work load there.
if (isEnabled >= 1)
{
await UseGlobalPrefixes(ctx, true);
}
else
{
await UseGlobalPrefixes(ctx, false);
}
}
[Command("global")]
public async Task UseGlobalPrefixes(CommandContext ctx, [Description("ON or OFF")] string isEnabled)
{ {
await ctx.TriggerTypingAsync();
isEnabled = isEnabled.ToLower();
string gId = ctx.Guild.Id.ToString();
int prefixCount = GuildSettings[gId].Prefixes.Count;
string[] turnOn = { "on", "true", "1" };
string[] turnOff = { "off", "false", "0" };
DiscordEmbedBuilder embed = StartEmbed("Global Prefix Usage");
embed.AddField("Old", Program.YesNo(GuildSettings[gId].UseGlobalPrefix));
// since we're just trying to make the end user's life easier by different means of turning this on/off. redirect work load that way. // since we're just trying to make the end user's life easier by different means of turning this on/off. redirect work load that way.
if (isEnabled.ToLower() == "on") if (turnOn.Contains(isEnabled))
{ {
await UseGlobalPrefixes(ctx, true); await UseGlobalPrefixes(ctx, true);
GuildSettings[gId].UseGlobalPrefix = true;
embed.AddField("New", Program.YesNo(GuildSettings[gId].UseGlobalPrefix));
} }
else if (isEnabled.ToLower() == "off") else if (turnOff.Contains(isEnabled))
{ {
await UseGlobalPrefixes(ctx, false); if (prefixCount > 0)
{
GuildSettings[gId].UseGlobalPrefix = false;
embed.AddField("New", Program.YesNo(GuildSettings[gId].UseGlobalPrefix));
}
else
{
embed = EmbedError("Could not turn off Global Prefix Usage. (Are you missing a server prefix?)");
}
} }
else else
{ {
// they wanna be smart, and we don't wanna, tell them that.
await ctx.RespondAsync("Please specify ON or OFF");
} }
await ctx.RespondAsync(embed);
}
private DiscordEmbedBuilder StartEmbed(string desc)
{
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
{
Description = desc,
Color = Program.colours[1]
};
return embed;
}
private DiscordEmbedBuilder EmbedError(string desc)
{
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
{
Description = desc,
Color = Program.colours[^1]
};
return embed;
} }
} }
} }
+8 -4
View File
@@ -25,9 +25,9 @@ namespace StarsiegeBot
DiscordColor.Brown, DiscordColor.Chartreuse, DiscordColor.CornflowerBlue, DiscordColor.Cyan, DiscordColor.DarkBlue, DiscordColor.DarkButNotBlack, DiscordColor.Brown, DiscordColor.Chartreuse, DiscordColor.CornflowerBlue, DiscordColor.Cyan, DiscordColor.DarkBlue, DiscordColor.DarkButNotBlack,
DiscordColor.DarkGray, DiscordColor.DarkGreen, DiscordColor.DarkRed, DiscordColor.Gold, DiscordColor.Goldenrod, DiscordColor.Gray, DiscordColor.Grayple, DiscordColor.DarkGray, DiscordColor.DarkGreen, DiscordColor.DarkRed, DiscordColor.Gold, DiscordColor.Goldenrod, DiscordColor.Gray, DiscordColor.Grayple,
DiscordColor.Green, DiscordColor.HotPink, DiscordColor.IndianRed, DiscordColor.LightGray, DiscordColor.Lilac, DiscordColor.Magenta, DiscordColor.MidnightBlue, DiscordColor.Green, DiscordColor.HotPink, DiscordColor.IndianRed, DiscordColor.LightGray, DiscordColor.Lilac, DiscordColor.Magenta, DiscordColor.MidnightBlue,
DiscordColor.None, DiscordColor.NotQuiteBlack, DiscordColor.Orange, DiscordColor.PhthaloBlue, DiscordColor.PhthaloGreen, DiscordColor.Purple, DiscordColor.Red, DiscordColor.None, DiscordColor.NotQuiteBlack, DiscordColor.Orange, DiscordColor.PhthaloBlue, DiscordColor.PhthaloGreen, DiscordColor.Purple,
DiscordColor.Rose, DiscordColor.SapGreen, DiscordColor.Sienna, DiscordColor.SpringGreen, DiscordColor.Teal, DiscordColor.Turquoise, DiscordColor.VeryDarkGray, DiscordColor.Rose, DiscordColor.SapGreen, DiscordColor.Sienna, DiscordColor.SpringGreen, DiscordColor.Teal, DiscordColor.Turquoise, DiscordColor.VeryDarkGray,
DiscordColor.Violet, DiscordColor.Wheat, DiscordColor.White, DiscordColor.Yellow }; DiscordColor.Violet, DiscordColor.Wheat, DiscordColor.White, DiscordColor.Yellow, DiscordColor.Red };
public static readonly Random rnd = new Random(); public static readonly Random rnd = new Random();
public DiscordClient Client { get; set; } public DiscordClient Client { get; set; }
@@ -99,7 +99,7 @@ namespace StarsiegeBot
this.Client.UseInteractivity(new InteractivityConfiguration() this.Client.UseInteractivity(new InteractivityConfiguration()
{ {
PollBehaviour = PollBehaviour.KeepEmojis, PollBehaviour = PollBehaviour.KeepEmojis,
Timeout = TimeSpan.FromSeconds(15) Timeout = TimeSpan.FromSeconds(15)
}); });
// up next, let's set up our commands // up next, let's set up our commands
@@ -202,7 +202,6 @@ namespace StarsiegeBot
this.Commands.CommandExecuted += Events.CommandExecuted; this.Commands.CommandExecuted += Events.CommandExecuted;
this.Commands.CommandErrored += Events.CommandErrored; this.Commands.CommandErrored += Events.CommandErrored;
// finally, let's connect and log in // finally, let's connect and log in
await this.Client.ConnectAsync(); await this.Client.ConnectAsync();
@@ -219,5 +218,10 @@ namespace StarsiegeBot
[JsonProperty("prefix")] [JsonProperty("prefix")]
public string CommandPrefix { get; private set; } public string CommandPrefix { get; private set; }
} }
public static string YesNo(bool test)
{
return (test ? "Enabled" : "Disabled");
}
} }
} }
+1 -1
View File
@@ -261,7 +261,7 @@ namespace StarsiegeBot
[Command("toggle"), Aliases("t")] [Command("toggle"), Aliases("t")]
[RequireOwner] [RequireOwner]
[Description("[Owner only] Enables or disables, or checks status of QuickChats.")] [Description("[Owner only] Enables or disables, or checks status of QuickChats.\r\nTo turn the feature on, use `TRUE`, `ON`, or `1`\r\nTo turn off, use `FALSE`, `OFF`, or `0`")]
public async Task ToggleQC (CommandContext ctx, [RemainingText] string isEnabled = null) public async Task ToggleQC (CommandContext ctx, [RemainingText] string isEnabled = null)
{ {
await ctx.TriggerTypingAsync(); await ctx.TriggerTypingAsync();
+17 -38
View File
@@ -33,11 +33,7 @@ namespace StarsiegeBot
await ctx.TriggerTypingAsync(); await ctx.TriggerTypingAsync();
string gId = ctx.Guild.Id.ToString(); string gId = ctx.Guild.Id.ToString();
DiscordEmbedBuilder embed = new DiscordEmbedBuilder DiscordEmbedBuilder embed = StartEmbed("Welcome Message Info");
{
Description = "Welcome Message Info",
Color = Program.colours[0]
};
if (GuildSettings[gId].WelcomeChannel is null) if (GuildSettings[gId].WelcomeChannel is null)
embed.AddField("Channel", "*None*"); embed.AddField("Channel", "*None*");
else else
@@ -67,11 +63,7 @@ namespace StarsiegeBot
await ctx.TriggerTypingAsync(); await ctx.TriggerTypingAsync();
string gId = ctx.Guild.Id.ToString(); string gId = ctx.Guild.Id.ToString();
DiscordEmbedBuilder embed = new DiscordEmbedBuilder DiscordEmbedBuilder embed = StartEmbed("Welcome Message Status");
{
Description = "Welcome Message Usage",
Color = Program.colours[0]
};
embed.AddField("Old", GuildSettings[gId].UseWelcome.ToString(), true); embed.AddField("Old", GuildSettings[gId].UseWelcome.ToString(), true);
GuildSettings[gId].UseWelcome = enable; GuildSettings[gId].UseWelcome = enable;
embed.AddField("New", GuildSettings[gId].UseWelcome.ToString(), true); embed.AddField("New", GuildSettings[gId].UseWelcome.ToString(), true);
@@ -82,11 +74,7 @@ namespace StarsiegeBot
{ {
await ctx.TriggerTypingAsync(); await ctx.TriggerTypingAsync();
string gId = ctx.Guild.Id.ToString(); string gId = ctx.Guild.Id.ToString();
DiscordEmbedBuilder embed = new DiscordEmbedBuilder DiscordEmbedBuilder embed = StartEmbed("Welcome Message Channel");
{
Description = "Welcome Message Channel",
Color = Program.colours[0]
};
if (GuildSettings[gId].WelcomeChannel != null) if (GuildSettings[gId].WelcomeChannel != null)
{ {
embed.AddField("Old", GuildSettings[gId].WelcomeChannel.Mention, true); embed.AddField("Old", GuildSettings[gId].WelcomeChannel.Mention, true);
@@ -105,11 +93,7 @@ namespace StarsiegeBot
{ {
await ctx.TriggerTypingAsync(); await ctx.TriggerTypingAsync();
string gId = ctx.Guild.Id.ToString(); string gId = ctx.Guild.Id.ToString();
DiscordEmbedBuilder embed = new DiscordEmbedBuilder DiscordEmbedBuilder embed = StartEmbed("Welcome Message Channel");
{
Description = "Welcome Message Channel",
Color = Program.colours[0]
};
if (GuildSettings[gId].WelcomeChannel != null) if (GuildSettings[gId].WelcomeChannel != null)
{ {
embed.AddField("Old", GuildSettings[gId].WelcomeChannel.Mention, true); embed.AddField("Old", GuildSettings[gId].WelcomeChannel.Mention, true);
@@ -128,38 +112,23 @@ namespace StarsiegeBot
public async Task MessageOfWelcome(CommandContext ctx, [RemainingText]string msg) public async Task MessageOfWelcome(CommandContext ctx, [RemainingText]string msg)
{ {
await ctx.TriggerTypingAsync(); await ctx.TriggerTypingAsync();
Console.WriteLine("1");
string gId = ctx.Guild.Id.ToString(); string gId = ctx.Guild.Id.ToString();
Console.WriteLine("2"); DiscordEmbedBuilder embed = StartEmbed("Welcome Message String");
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
{
Description = "Welcome Message String",
Color = Program.colours[0]
};
Console.WriteLine("3");
if (GuildSettings[gId].WelcomeMessage == "" || GuildSettings[gId].WelcomeMessage is null) if (GuildSettings[gId].WelcomeMessage == "" || GuildSettings[gId].WelcomeMessage is null)
embed.AddField("Old", "*None*"); embed.AddField("Old", "*None*");
else else
embed.AddField("Old", GuildSettings[gId].WelcomeMessage); embed.AddField("Old", GuildSettings[gId].WelcomeMessage);
Console.WriteLine("4");
GuildSettings[gId].WelcomeMessage = msg; GuildSettings[gId].WelcomeMessage = msg;
Console.WriteLine("5");
embed.AddField("New", GuildSettings[gId].WelcomeMessage); embed.AddField("New", GuildSettings[gId].WelcomeMessage);
Console.WriteLine("6");
string example = WelcomeMessageProcessing(GuildSettings[gId].WelcomeMessage, ctx.Member, ctx.Guild); string example = WelcomeMessageProcessing(GuildSettings[gId].WelcomeMessage, ctx.Member, ctx.Guild);
Console.WriteLine("7");
await ctx.RespondAsync($"An example:\r\n> {example}", embed); await ctx.RespondAsync($"An example:\r\n> {example}", embed);
} }
[Command("Help")] [Command("Help")]
public async Task WelcomeHelp(CommandContext ctx) public async Task WelcomeHelp(CommandContext ctx)
{ {
await ctx.TriggerTypingAsync(); await ctx.TriggerTypingAsync();
DiscordEmbedBuilder embed = new DiscordEmbedBuilder DiscordEmbedBuilder embed = StartEmbed("List of placeholders and their intended replacement. Channel tags can be inserted without a placeholder.");
{ embed.Title = "Welcome Message Help";
Title = "Welcome Message Help",
Description = "List of placeholders and their intended replacement. Channel tags can be inserted without a placeholder.",
Color = Program.colours[0]
};
embed.AddField("[Discrim]", "Inserts the username of the member."); embed.AddField("[Discrim]", "Inserts the username of the member.");
embed.AddField("[UName]", "Inserts the username of the member."); embed.AddField("[UName]", "Inserts the username of the member.");
embed.AddField("[GName]", "Inserts your Guild/Server Name."); embed.AddField("[GName]", "Inserts your Guild/Server Name.");
@@ -175,5 +144,15 @@ namespace StarsiegeBot
.Replace("[mention]", member.Mention, StringComparison.OrdinalIgnoreCase); .Replace("[mention]", member.Mention, StringComparison.OrdinalIgnoreCase);
return output; return output;
} }
private DiscordEmbedBuilder StartEmbed(string desc)
{
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
{
Description = desc,
Color = Program.colours[0]
};
return embed;
}
} }
} }