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")}**");
}
[Command("global")]
public async Task UseGlobalPrefixes(CommandContext ctx, [Description("0 is off, 1 is on.")] int isEnabled)
{
// 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)
public async Task UseGlobalPrefixes(CommandContext ctx, [Description("ON or OFF"),RemainingText] string isEnabled = null)
{
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.
if (isEnabled.ToLower() == "on")
if (turnOn.Contains(isEnabled))
{
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
{
// 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.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.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.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 DiscordClient Client { get; set; }
@@ -99,7 +99,7 @@ namespace StarsiegeBot
this.Client.UseInteractivity(new InteractivityConfiguration()
{
PollBehaviour = PollBehaviour.KeepEmojis,
Timeout = TimeSpan.FromSeconds(15)
Timeout = TimeSpan.FromSeconds(15)
});
// up next, let's set up our commands
@@ -202,7 +202,6 @@ namespace StarsiegeBot
this.Commands.CommandExecuted += Events.CommandExecuted;
this.Commands.CommandErrored += Events.CommandErrored;
// finally, let's connect and log in
await this.Client.ConnectAsync();
@@ -219,5 +218,10 @@ namespace StarsiegeBot
[JsonProperty("prefix")]
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")]
[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)
{
await ctx.TriggerTypingAsync();
+17 -38
View File
@@ -33,11 +33,7 @@ namespace StarsiegeBot
await ctx.TriggerTypingAsync();
string gId = ctx.Guild.Id.ToString();
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
{
Description = "Welcome Message Info",
Color = Program.colours[0]
};
DiscordEmbedBuilder embed = StartEmbed("Welcome Message Info");
if (GuildSettings[gId].WelcomeChannel is null)
embed.AddField("Channel", "*None*");
else
@@ -67,11 +63,7 @@ namespace StarsiegeBot
await ctx.TriggerTypingAsync();
string gId = ctx.Guild.Id.ToString();
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
{
Description = "Welcome Message Usage",
Color = Program.colours[0]
};
DiscordEmbedBuilder embed = StartEmbed("Welcome Message Status");
embed.AddField("Old", GuildSettings[gId].UseWelcome.ToString(), true);
GuildSettings[gId].UseWelcome = enable;
embed.AddField("New", GuildSettings[gId].UseWelcome.ToString(), true);
@@ -82,11 +74,7 @@ namespace StarsiegeBot
{
await ctx.TriggerTypingAsync();
string gId = ctx.Guild.Id.ToString();
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
{
Description = "Welcome Message Channel",
Color = Program.colours[0]
};
DiscordEmbedBuilder embed = StartEmbed("Welcome Message Channel");
if (GuildSettings[gId].WelcomeChannel != null)
{
embed.AddField("Old", GuildSettings[gId].WelcomeChannel.Mention, true);
@@ -105,11 +93,7 @@ namespace StarsiegeBot
{
await ctx.TriggerTypingAsync();
string gId = ctx.Guild.Id.ToString();
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
{
Description = "Welcome Message Channel",
Color = Program.colours[0]
};
DiscordEmbedBuilder embed = StartEmbed("Welcome Message Channel");
if (GuildSettings[gId].WelcomeChannel != null)
{
embed.AddField("Old", GuildSettings[gId].WelcomeChannel.Mention, true);
@@ -128,38 +112,23 @@ namespace StarsiegeBot
public async Task MessageOfWelcome(CommandContext ctx, [RemainingText]string msg)
{
await ctx.TriggerTypingAsync();
Console.WriteLine("1");
string gId = ctx.Guild.Id.ToString();
Console.WriteLine("2");
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
{
Description = "Welcome Message String",
Color = Program.colours[0]
};
Console.WriteLine("3");
DiscordEmbedBuilder embed = StartEmbed("Welcome Message String");
if (GuildSettings[gId].WelcomeMessage == "" || GuildSettings[gId].WelcomeMessage is null)
embed.AddField("Old", "*None*");
else
embed.AddField("Old", GuildSettings[gId].WelcomeMessage);
Console.WriteLine("4");
GuildSettings[gId].WelcomeMessage = msg;
Console.WriteLine("5");
embed.AddField("New", GuildSettings[gId].WelcomeMessage);
Console.WriteLine("6");
string example = WelcomeMessageProcessing(GuildSettings[gId].WelcomeMessage, ctx.Member, ctx.Guild);
Console.WriteLine("7");
await ctx.RespondAsync($"An example:\r\n> {example}", embed);
}
[Command("Help")]
public async Task WelcomeHelp(CommandContext ctx)
{
await ctx.TriggerTypingAsync();
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
{
Title = "Welcome Message Help",
Description = "List of placeholders and their intended replacement. Channel tags can be inserted without a placeholder.",
Color = Program.colours[0]
};
DiscordEmbedBuilder embed = StartEmbed("List of placeholders and their intended replacement. Channel tags can be inserted without a placeholder.");
embed.Title = "Welcome Message Help";
embed.AddField("[Discrim]", "Inserts the username of the member.");
embed.AddField("[UName]", "Inserts the username of the member.");
embed.AddField("[GName]", "Inserts your Guild/Server Name.");
@@ -175,5 +144,15 @@ namespace StarsiegeBot
.Replace("[mention]", member.Mention, StringComparison.OrdinalIgnoreCase);
return output;
}
private DiscordEmbedBuilder StartEmbed(string desc)
{
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
{
Description = desc,
Color = Program.colours[0]
};
return embed;
}
}
}