Completed welcome message functionality. Need to add notes and descriptions. Redid the SLAP command. Reformatted most of the general Commands output to be embeded instead. Moved a few class level fields to Program. Changed affected code accordingly.
This commit is contained in:
1 parent
08091e7456
commit
0479d443b8
7 files changed
+344
-209
No files matched your search
+217
-176
@@ -6,6 +6,7 @@ using DSharpPlus.CommandsNext.Attributes;
|
||||
using DSharpPlus.Entities;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace StarsiegeBot
|
||||
{
|
||||
@@ -14,35 +15,103 @@ namespace StarsiegeBot
|
||||
// this class depends a lot on the random stuff. so make it class level.
|
||||
private readonly Random rnd = new Random();
|
||||
|
||||
// start: neo wanted this shit....
|
||||
private readonly string[] insult = {
|
||||
"> {0} slaps {1} around a bit with a large trout.",
|
||||
"> {0} puts a jellyfish on {1}'s head.",
|
||||
"> {0} slaps {1} around a bit with the mustache of Caanon.",
|
||||
"> {0} slaps {1} around a bit with a questionable rubber object.",
|
||||
"> {0} slaps {1} around a bit with a rubber chicken."
|
||||
// Master insult list.
|
||||
private readonly string[] InsultMaster = {
|
||||
"{0} slaps {1} around a bit with a large trout.",
|
||||
"{0} puts a jellyfish on {1}'s head.",
|
||||
"{0} slaps {1} around a bit with the mustache of Caanon.",
|
||||
"{0} slaps {1} around a bit with a questionable rubber object.",
|
||||
"{0} slaps {1} around a bit with a rubber chicken."
|
||||
};
|
||||
private uint insultIndex;
|
||||
public string Insult {
|
||||
get {
|
||||
if (insultIndex >= insult.Length) {
|
||||
insultIndex = 0;
|
||||
}
|
||||
return insult[insultIndex++ % insult.Length];
|
||||
}
|
||||
}
|
||||
// end: neo's shit.
|
||||
private List<string> InsultCopy;
|
||||
|
||||
public Commands()
|
||||
{
|
||||
// Let the console know we've loaded basic commands.
|
||||
Console.WriteLine("Basic Commands Loaded");
|
||||
InsultCopy = InsultMaster.ToList<string>();
|
||||
}
|
||||
[Command("8ball"), Aliases(new String[] { "ball", "8" })]
|
||||
[Description("The Magic 8-Ball is a fortune-telling or seeking advice")]
|
||||
public async Task Eightball(CommandContext ctx, [RemainingText, Description("Your question to the 8 ball")] String remainingText = "")
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
// Load all the traditional 8-Ball answers into an array.
|
||||
string[] results = new string[] { "It is certain.", "It is decidedly so.", "Without a doubt.", "Yes - definitely.", "You may rely on it.", "As I see it, yes.", "Most likely.", "Outlook good.", "Yes.", "Signs point to yes.", "Reply hazy, try again", "Ask again later.", "Better not tell you now.", "Cannot predict now.", "Concentrate and ask again.", "Don't count on it.", "My reply is no.", "My sources say no", "Outlook not so good.", "Very doubtful." };
|
||||
// give the end user the randomly choosen result.
|
||||
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
|
||||
{
|
||||
Description = results[rnd.Next(0, results.Length)],
|
||||
Color = Program.colours[rnd.Next(0, Program.colours.Length)]
|
||||
};
|
||||
await ctx.RespondAsync(embed);
|
||||
}
|
||||
[Command("about")]
|
||||
[Description("Gives some basic info about the bot")]
|
||||
public async Task About(CommandContext ctx)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
// delcare an embed builder.
|
||||
DiscordEmbedBuilder embed = new DiscordEmbedBuilder();
|
||||
// Title the ebemd with the bot's name and discrim.
|
||||
embed.WithTitle("About " + ctx.Client.CurrentUser.Username + "#" + ctx.Client.CurrentUser.Discriminator);
|
||||
// add the bot's avatar as the Thumbnail.
|
||||
embed.WithThumbnail(ctx.Client.CurrentUser.GetAvatarUrl(DSharpPlus.ImageFormat.Png, 32));
|
||||
// Add a bit of color... the color from the member's top most role.
|
||||
embed.WithColor(ctx.Member.Color);
|
||||
// output various data abotu the bot.
|
||||
embed.AddField("D#+ Ver", ctx.Client.VersionString, true);
|
||||
embed.AddField("Guild Count", ctx.Client.Guilds.Count.ToString(), true);
|
||||
embed.AddField("Ping", ctx.Client.Ping.ToString(), true);
|
||||
embed.AddField("Shard Count", ctx.Client.ShardCount.ToString(), true);
|
||||
embed.AddField("Shard", ctx.Client.ShardId.ToString(), true);
|
||||
embed.Color = Program.colours[rnd.Next(0, Program.colours.Length)];
|
||||
// list all the owners of the bot.
|
||||
string owners = "";
|
||||
foreach (DiscordUser owner in ctx.Client.CurrentApplication.Owners)
|
||||
{
|
||||
owners += owner.Username + "#" + owner.Discriminator + "\r\n";
|
||||
}
|
||||
|
||||
embed.AddField("Owner(s)", owners, false);
|
||||
// send the data to the end user.
|
||||
await ctx.RespondAsync(embed);
|
||||
}
|
||||
[Command("coin")]
|
||||
[Description("Flips a coin for ya!")]
|
||||
public async Task Coinflip(CommandContext ctx)
|
||||
{
|
||||
// We're going to randomly select heads or tails and then give it to the user.
|
||||
await ctx.TriggerTypingAsync();
|
||||
string[] choices = { "heads", "tails" };
|
||||
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
|
||||
{
|
||||
Description = "The coin landed on... " + choices[rnd.Next(0, choices.Length)],
|
||||
Color = Program.colours[rnd.Next(0, Program.colours.Length)]
|
||||
};
|
||||
await ctx.RespondAsync(embed);
|
||||
}
|
||||
[Command("credits")]
|
||||
[Description("Shows all those that have helped with my bot(s) over the years!")]
|
||||
public async Task Credits(CommandContext ctx)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
// just some people that have helped me build the bot.
|
||||
string credits = "```asciidoc\r\n= CREDITS (Outdated) =\r\n" +
|
||||
"• UndeadShadow :: Flood Protection. Keepign teh bot from killing itself, and others.\r\n" +
|
||||
"• Da_D_Master :: For giving me my start in my first couple bots, and being a friendly rival.\r\n" +
|
||||
"• ThinkExist & Bored.com :: Quotes for the Quote Database\r\n" +
|
||||
"• Hanibal, TaMeD, Liquid- :: For awlays proving the points of others.\r\n" +
|
||||
"• Neo :: For all their hard work on all the things I've ever asked about.\r\n" +
|
||||
"• Alias :: For helping me learn how to make IRC bots back in the day.\r\n" +
|
||||
"• Drake, Eledore :: Supporting the development of the bot and supplying code for it.\r\n" +
|
||||
"\r\n```";
|
||||
await ctx.RespondAsync(credits);
|
||||
}
|
||||
[Command("dice"), Aliases("r", "d", "roll")]
|
||||
[Description("A classic dice throwing command. Limited to 1 use per 2 seconds. Format: <NumberOfDice>d<SidesOnDie> ")]
|
||||
[Cooldown(1, 2, CooldownBucketType.Guild)]
|
||||
public async Task Dice(CommandContext ctx, [RemainingText,Description("XdY")] String throwing = "d")
|
||||
public async Task Dice(CommandContext ctx, [RemainingText, Description("XdY")] String throwing = "d")
|
||||
{
|
||||
// let the end user know the bot is doing something...
|
||||
await ctx.TriggerTypingAsync();
|
||||
@@ -95,7 +164,7 @@ namespace StarsiegeBot
|
||||
dieResult += roll;
|
||||
}
|
||||
// If the end user is rolling more than 10 of any kind of die, dont show the results of the rolls. Just
|
||||
if(volume < 11)
|
||||
if (volume < 11)
|
||||
dieResults = $"{volume}d{sides}: Total: " + dieResult + " Avg: " + Math.Round(dieResult * 1.0 / volume, 2) + " Results: " + dieResults;
|
||||
else
|
||||
dieResults = $"{volume}d{sides}: Total: " + dieResult + " Avg: " + Math.Round(dieResult * 1.0 / volume, 2);
|
||||
@@ -108,7 +177,6 @@ namespace StarsiegeBot
|
||||
else
|
||||
await ctx.RespondAsync(overallResults);
|
||||
}
|
||||
|
||||
[Command("random")]
|
||||
[Description("Random number generator.")]
|
||||
public async Task Random(CommandContext ctx, [Description("Lowest number choice. (Inclusive)")] int min, [Description("Highest Number Choice. (Inclusive)")] int max)
|
||||
@@ -119,53 +187,91 @@ namespace StarsiegeBot
|
||||
int i = Math.Min(min, max);
|
||||
int a = Math.Max(min, max) + 1;
|
||||
// output the results
|
||||
await ctx.RespondAsync($"🎲 Your random number is: {rnd.Next(i, a)}");
|
||||
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
|
||||
{
|
||||
Description = $"🎲 Your random number is: {rnd.Next(i, a)}",
|
||||
Color = Program.colours[rnd.Next(0, Program.colours.Length)]
|
||||
};
|
||||
await ctx.RespondAsync(embed);
|
||||
}
|
||||
|
||||
[Command("random")]
|
||||
public async Task Random(CommandContext ctx)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
// some one didn't read the HELP file on Random. Explain it to them.
|
||||
await ctx.RespondAsync($"Gives you a random number between <Option 1> and <Option 2> Try someething like `random 3 30`!");
|
||||
}
|
||||
|
||||
[Command("8ball"), Aliases(new String[] { "ball", "8" })]
|
||||
[Description("The Magic 8-Ball is a fortune-telling or seeking advice")]
|
||||
public async Task Eightball(CommandContext ctx, [RemainingText, Description("Your question to the 8 ball")] String remainingText = "")
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
// Load all the traditional 8-Ball answers into an array.
|
||||
string[] results = new string[] { "It is certain.", "It is decidedly so.", "Without a doubt.", "Yes - definitely.", "You may rely on it.", "As I see it, yes.", "Most likely.", "Outlook good.", "Yes.", "Signs point to yes.", "Reply hazy, try again", "Ask again later.", "Better not tell you now.", "Cannot predict now.", "Concentrate and ask again.", "Don't count on it.", "My reply is no.", "My sources say no", "Outlook not so good.", "Very doubtful." };
|
||||
// give the end user the randomly choosen result.
|
||||
await ctx.RespondAsync(results[rnd.Next(0, results.Length)]);
|
||||
}
|
||||
|
||||
[Command("slap")]
|
||||
public async Task Slap(CommandContext ctx, DiscordMember user = null)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
// we're going to find out who we're slapping. Declare their place holders now.
|
||||
string user1;
|
||||
string user2;
|
||||
|
||||
// If we have some one not slapping some one, or they're trying to slap themself, the one getting slapped is the
|
||||
// author, the one doing the slapping is the bot.
|
||||
if (user == null || user.Mention == ctx.Message.Author.Mention)
|
||||
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
|
||||
{
|
||||
user1 = ctx.Client.CurrentUser.Mention;
|
||||
user2 = ctx.Message.Author.Mention;
|
||||
Description = $"Gives you a random number between <Option 1> and <Option 2> Try someething like `random 3 30`!",
|
||||
Color = Program.colours[rnd.Next(0, Program.colours.Length)]
|
||||
};
|
||||
await ctx.RespondAsync(embed);
|
||||
}
|
||||
[Command("rps")]
|
||||
[Description("Rock Paper Scissors")]
|
||||
public async Task Rps(CommandContext ctx, [RemainingText, Description("Your choice of hand sign to use.")] string text = "")
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
/* --- THIS FUNCTION IS A COPY AND PASTE OF RPSLS. AND ALL LOGIC IS IDENTICAL TO IT. PLEASE REFER TO THAT METHOD. ---
|
||||
// --- THIS FUNCTION IS A COPY AND PASTE OF RPSLS. AND ALL LOGIC IS IDENTICAL TO IT. PLEASE REFER TO THAT METHOD. ---
|
||||
// --- THIS FUNCTION IS A COPY AND PASTE OF RPSLS. AND ALL LOGIC IS IDENTICAL TO IT. PLEASE REFER TO THAT METHOD. --- */
|
||||
string[] choices = new string[] { "rock", "paper", "scissors" };
|
||||
text = text.ToLower();
|
||||
string botChoice = choices[rnd.Next(0, choices.Length)];
|
||||
string result;
|
||||
|
||||
if (text.Equals(""))
|
||||
{
|
||||
result = "I'm handing you a";
|
||||
switch (botChoice)
|
||||
{
|
||||
case "rock":
|
||||
result += " shiny rock.";
|
||||
break;
|
||||
case "paper":
|
||||
result += " crumpled paper.";
|
||||
break;
|
||||
case "scissors":
|
||||
result += " set of child proof scissors.";
|
||||
break;
|
||||
}
|
||||
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
|
||||
{
|
||||
Description = result,
|
||||
Color = Program.colours[rnd.Next(0, Program.colours.Length)]
|
||||
};
|
||||
await ctx.RespondAsync(embed);
|
||||
}
|
||||
// We're attempting to slap user that isn't the author... Lets do it!
|
||||
else
|
||||
{
|
||||
user1 = ctx.Message.Author.Mention;
|
||||
user2 = user.Mention;
|
||||
if (choices.Contains(text))
|
||||
{
|
||||
if (((botChoice == "scissors") && (text == "paper")) ||
|
||||
((botChoice == "paper") && (text == "rock")) ||
|
||||
((botChoice == "rock") && (text == "scissors")))
|
||||
{
|
||||
result = $"{botChoice} beats {text}. I'm sorry about this.";
|
||||
}
|
||||
else if (text.Equals(botChoice))
|
||||
{
|
||||
result = $"We both picked {text}, looks like we drew, go again?";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = $"{text} beats {botChoice}. **YOU WIN!!**";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = "Please pick a valid option! Options: " + String.Join(", ", choices);
|
||||
}
|
||||
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
|
||||
{
|
||||
Description = result,
|
||||
Color = Program.colours[rnd.Next(0, Program.colours.Length)]
|
||||
};
|
||||
await ctx.RespondAsync(embed);
|
||||
}
|
||||
// pick a random insult, and populate the names correctly.
|
||||
await ctx.RespondAsync(string.Format(Insult, user1, user2));
|
||||
}
|
||||
|
||||
[Command("rpsls")]
|
||||
[Description("Rock Paper Scissors Lizard Spock")]
|
||||
public async Task Rpsls(CommandContext ctx, [RemainingText, Description("Your choice of hand sign to use.")] string text = "")
|
||||
@@ -203,7 +309,12 @@ namespace StarsiegeBot
|
||||
break;
|
||||
}
|
||||
// tell the user we're giving them a thing.
|
||||
await ctx.RespondAsync(result);
|
||||
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
|
||||
{
|
||||
Description = result,
|
||||
Color = Program.colours[rnd.Next(0, Program.colours.Length)]
|
||||
};
|
||||
await ctx.RespondAsync(embed);
|
||||
}
|
||||
// the end user actually wants to throw down... Lets go!
|
||||
else
|
||||
@@ -241,127 +352,14 @@ namespace StarsiegeBot
|
||||
result = "Please pick a valid option! Options: " + String.Join(", ", choices);
|
||||
}
|
||||
// Actually send out all our info now.
|
||||
await ctx.RespondAsync(result);
|
||||
}
|
||||
}
|
||||
|
||||
[Command("rps")]
|
||||
[Description("Rock Paper Scissors")]
|
||||
public async Task Rps(CommandContext ctx, [RemainingText, Description("Your choice of hand sign to use.")] string text = "")
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
/* --- THIS FUNCTION IS A COPY AND PASTE OF RPSLS. AND ALL LOGIC IS IDENTICAL TO IT. PLEASE REFER TO THAT METHOD. ---
|
||||
// --- THIS FUNCTION IS A COPY AND PASTE OF RPSLS. AND ALL LOGIC IS IDENTICAL TO IT. PLEASE REFER TO THAT METHOD. ---
|
||||
// --- THIS FUNCTION IS A COPY AND PASTE OF RPSLS. AND ALL LOGIC IS IDENTICAL TO IT. PLEASE REFER TO THAT METHOD. --- */
|
||||
string[] choices = new string[] { "rock", "paper", "scissors" };
|
||||
text = text.ToLower();
|
||||
string botChoice = choices[rnd.Next(0, choices.Length)];
|
||||
string result;
|
||||
|
||||
if (text.Equals(""))
|
||||
{
|
||||
result = "I'm handing you a";
|
||||
switch (botChoice)
|
||||
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
|
||||
{
|
||||
case "rock":
|
||||
result += " shiny rock.";
|
||||
break;
|
||||
case "paper":
|
||||
result += " crumpled paper.";
|
||||
break;
|
||||
case "scissors":
|
||||
result += " set of child proof scissors.";
|
||||
break;
|
||||
}
|
||||
await ctx.RespondAsync(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (choices.Contains(text))
|
||||
{
|
||||
if (((botChoice == "scissors") && (text == "paper")) ||
|
||||
((botChoice == "paper") && (text == "rock")) ||
|
||||
((botChoice == "rock") && (text == "scissors")))
|
||||
{
|
||||
result = $"{botChoice} beats {text}. I'm sorry about this.";
|
||||
}
|
||||
else if (text.Equals(botChoice))
|
||||
{
|
||||
result = $"We both picked {text}, looks like we drew, go again?";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = $"{text} beats {botChoice}. **YOU WIN!!**";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = "Please pick a valid option! Options: " + String.Join(", ", choices);
|
||||
}
|
||||
await ctx.RespondAsync(result);
|
||||
Description = result,
|
||||
Color = Program.colours[rnd.Next(0, Program.colours.Length)]
|
||||
};
|
||||
await ctx.RespondAsync(embed);
|
||||
}
|
||||
}
|
||||
|
||||
[Command("about")]
|
||||
[Description("Gives some basic info about the bot")]
|
||||
public async Task About(CommandContext ctx)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
// delcare an embed builder.
|
||||
DiscordEmbedBuilder embed = new DiscordEmbedBuilder();
|
||||
// Title the ebemd with the bot's name and discrim.
|
||||
embed.WithTitle("About " + ctx.Client.CurrentUser.Username + "#" + ctx.Client.CurrentUser.Discriminator);
|
||||
// add the bot's avatar as the Thumbnail.
|
||||
embed.WithThumbnail(ctx.Client.CurrentUser.GetAvatarUrl(DSharpPlus.ImageFormat.Png, 32));
|
||||
// Add a bit of color... the color from the member's top most role.
|
||||
embed.WithColor(ctx.Member.Color);
|
||||
// output various data abotu the bot.
|
||||
embed.AddField("D#+ Ver", ctx.Client.VersionString, true);
|
||||
embed.AddField("Guild Count", ctx.Client.Guilds.Count.ToString(), true);
|
||||
embed.AddField("Ping", ctx.Client.Ping.ToString(), true);
|
||||
embed.AddField("Shard Count", ctx.Client.ShardCount.ToString(), true);
|
||||
embed.AddField("Shard", ctx.Client.ShardId.ToString(), true);
|
||||
|
||||
// list all the owners of the bot.
|
||||
string owners = "";
|
||||
foreach (DiscordUser owner in ctx.Client.CurrentApplication.Owners)
|
||||
{
|
||||
owners += owner.Username + "#" + owner.Discriminator+"\r\n";
|
||||
}
|
||||
|
||||
embed.AddField("Owner(s)", owners, false);
|
||||
// send the data to the end user.
|
||||
await ctx.RespondAsync(embed);
|
||||
}
|
||||
|
||||
[Command("credits")]
|
||||
[Description("Shows all those that have helped with my bot(s) over the years!")]
|
||||
public async Task Credits(CommandContext ctx)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
// just some people that have helped me build the bot.
|
||||
string credits = "```asciidoc\r\n= CREDITS (Outdated) =\r\n" +
|
||||
"• UndeadShadow :: Flood Protection. Keepign teh bot from killing itself, and others.\r\n" +
|
||||
"• Da_D_Master :: For giving me my start in my first couple bots, and being a friendly rival.\r\n" +
|
||||
"• ThinkExist & Bored.com :: Quotes for the Quote Database\r\n" +
|
||||
"• Hanibal, TaMeD, Liquid- :: For awlays proving the points of others.\r\n" +
|
||||
"• Neo :: For all their hard work on all the things I've ever asked about.\r\n" +
|
||||
"• Alias :: For helping me learn how to make IRC bots back in the day.\r\n" +
|
||||
"• Drake, Eledore :: Supporting the development of the bot and supplying code for it.\r\n" +
|
||||
"\r\n```";
|
||||
await ctx.RespondAsync(credits);
|
||||
}
|
||||
|
||||
[Command("coin")]
|
||||
[Description("Flips a coin for ya!")]
|
||||
public async Task Coinflip(CommandContext ctx)
|
||||
{
|
||||
// We're going to randomly select heads or tails and then give it to the user.
|
||||
await ctx.TriggerTypingAsync();
|
||||
string[] choices = { "heads", "tails" };
|
||||
await ctx.RespondAsync("The coin landed on... " + choices[rnd.Next(0, choices.Length)]);
|
||||
}
|
||||
|
||||
[Command("say")]
|
||||
[Description("Make the bot say something, perhaps silly?!")]
|
||||
public async Task MsgSay(CommandContext ctx, [RemainingText, Description("The stuff you want the bot to say.")] string msg = "")
|
||||
@@ -371,10 +369,53 @@ namespace StarsiegeBot
|
||||
return;
|
||||
await ctx.TriggerTypingAsync();
|
||||
// did the end user supply us something to say? no whine about it.
|
||||
string result;
|
||||
if (msg != "")
|
||||
await ctx.RespondAsync(msg);
|
||||
result = msg;
|
||||
else
|
||||
await ctx.RespondAsync("I need something to say...");
|
||||
result ="I need something to say...";
|
||||
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
|
||||
{
|
||||
Description = result,
|
||||
Color = Program.colours[rnd.Next(0, Program.colours.Length)]
|
||||
};
|
||||
await ctx.RespondAsync(embed);
|
||||
}
|
||||
[Command("slap")]
|
||||
public async Task Slap(CommandContext ctx, DiscordMember user = null)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
// we're going to find out who we're slapping. Declare their place holders now.
|
||||
string user1;
|
||||
string user2;
|
||||
|
||||
// If we have some one not slapping some one, or they're trying to slap themself, the one getting slapped is the
|
||||
// author, the one doing the slapping is the bot.
|
||||
if (user == null || user.Mention == ctx.Message.Author.Mention)
|
||||
{
|
||||
user1 = ctx.Client.CurrentUser.Mention;
|
||||
user2 = ctx.Message.Author.Mention;
|
||||
}
|
||||
// We're attempting to slap user that isn't the author... Lets do it!
|
||||
else
|
||||
{
|
||||
user1 = ctx.Message.Author.Mention;
|
||||
user2 = user.Mention;
|
||||
}
|
||||
// pick a random insult, and populate the names correctly.
|
||||
int randInt = rnd.Next(0, InsultCopy.Count);
|
||||
|
||||
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
|
||||
{
|
||||
Description = string.Format(InsultCopy[randInt], user1, user2),
|
||||
Color = Program.colours[rnd.Next(0, Program.colours.Length)]
|
||||
};
|
||||
await ctx.RespondAsync(embed);
|
||||
InsultCopy.RemoveAt(randInt);
|
||||
if (InsultCopy.Count == 0)
|
||||
{
|
||||
InsultCopy = InsultMaster.ToList<string>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -246,7 +246,7 @@ namespace StarsiegeBot
|
||||
}
|
||||
public Task GuildMemberAdded(DiscordClient d, GuildMemberAddEventArgs e)
|
||||
{
|
||||
d.Logger.LogDebug(BotEventId, $"GuildMemberAdded.{e.Guild.Name}");
|
||||
d.Logger.LogDebug(BotEventId, $"GuildMemberAdded.");
|
||||
if (e.Member.IsBot)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
@@ -255,15 +255,12 @@ namespace StarsiegeBot
|
||||
string gId = e.Guild.Id.ToString();
|
||||
if (BotSettings.GuildSettings[gId].UseWelcome)
|
||||
{
|
||||
if (BotSettings.GuildSettings[gId].WelcomeChannel is null)
|
||||
{ }
|
||||
else
|
||||
if (!(BotSettings.GuildSettings[gId].WelcomeChannel is null))
|
||||
{
|
||||
if (BotSettings.GuildSettings[gId].WelcomeMessage is null)
|
||||
{ }
|
||||
else
|
||||
if (!(BotSettings.GuildSettings[gId].WelcomeMessage is null))
|
||||
{
|
||||
BotSettings.GuildSettings[gId].WelcomeChannel.SendMessageAsync(BotSettings.GuildSettings[gId].WelcomeMessage);
|
||||
string msg = WelcomeMessage.WelcomeMessageProcessing(BotSettings.GuildSettings[gId].WelcomeMessage, e.Member, e.Guild);
|
||||
BotSettings.GuildSettings[gId].WelcomeChannel.SendMessageAsync(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+20
-13
@@ -20,12 +20,19 @@ namespace StarsiegeBot
|
||||
class Program
|
||||
{
|
||||
public readonly EventId BotEventId;
|
||||
public static Triggers Events;
|
||||
|
||||
public static Triggers Events;
|
||||
public static readonly DiscordColor[] colours = { DiscordColor.Aquamarine, DiscordColor.Azure, DiscordColor.Black, DiscordColor.Blue, DiscordColor.Blurple,
|
||||
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.Rose, DiscordColor.SapGreen, DiscordColor.Sienna, DiscordColor.SpringGreen, DiscordColor.Teal, DiscordColor.Turquoise, DiscordColor.VeryDarkGray,
|
||||
DiscordColor.Violet, DiscordColor.Wheat, DiscordColor.White, DiscordColor.Yellow };
|
||||
public static readonly Random rnd = new Random();
|
||||
|
||||
public DiscordClient Client { get; set; }
|
||||
public CommandsNextExtension Commands { get; set; }
|
||||
public VoiceNextExtension Voice { get; set; }
|
||||
|
||||
protected string BotName { get; set; }
|
||||
|
||||
private async Task StartTimer(CancellationToken cancellationToken)
|
||||
@@ -62,7 +69,7 @@ namespace StarsiegeBot
|
||||
if (args.Length > 0)
|
||||
BotName = args[0].ToLower();
|
||||
else
|
||||
BotName = "ssp";
|
||||
BotName = "raven";
|
||||
|
||||
BotEventId = new EventId(276, BotName);
|
||||
Events = new Triggers(BotEventId);
|
||||
@@ -114,17 +121,17 @@ namespace StarsiegeBot
|
||||
this.Commands = this.Client.UseCommandsNext(ccfg);
|
||||
|
||||
// up next, let's register our commands
|
||||
this.Commands.RegisterCommands<Commands>();
|
||||
this.Commands.RegisterCommands<BotSettings>(); // Main Folder. Test Items.
|
||||
this.Commands.RegisterCommands<WelcomeMessage>(); // Main Folder. Test Items.
|
||||
this.Commands.RegisterCommands<Commands>();
|
||||
this.Commands.RegisterCommands<GroupManagement>(); // Main Folder. Test Items.
|
||||
this.Commands.RegisterCommands<GroupRoleManagement>(); // Main Folder. Test Items.
|
||||
this.Commands.RegisterCommands<LevelManagement>(); // Main Folder. Test Items.
|
||||
this.Commands.RegisterCommands<LevelRoleManagement>(); // Main Folder. Test Items.
|
||||
this.Commands.RegisterCommands<PrefixManagement>();
|
||||
// this.Commands.RegisterCommands<SnappleFacts>();
|
||||
// this.Commands.RegisterCommands<RoleManagement>(); // Main Folder. Test Items.
|
||||
// this.Commands.RegisterCommands<LevelRoleManagement>(); // Main Folder. Test Items.
|
||||
// this.Commands.RegisterCommands<GroupRoleManagement>(); // Main Folder. Test Items.
|
||||
// this.Commands.RegisterCommands<LevelManagement>(); // Main Folder. Test Items.
|
||||
// this.Commands.RegisterCommands<GroupManagement>(); // Main Folder. Test Items.
|
||||
// this.Commands.RegisterCommands<StarsiegeCommands>();
|
||||
this.Commands.RegisterCommands<RoleManagement>(); // Main Folder. Test Items.
|
||||
this.Commands.RegisterCommands<SnappleFacts>();
|
||||
this.Commands.RegisterCommands<StarsiegeCommands>();
|
||||
this.Commands.RegisterCommands<WelcomeMessage>(); // Main Folder. Test Items.
|
||||
|
||||
// All these commands are in the STARSIEGE folder.
|
||||
//if (BotName.Contains("ssp"))
|
||||
|
||||
@@ -22,13 +22,6 @@ namespace StarsiegeBot
|
||||
[Group("functions"), Aliases("func")]
|
||||
class Functions : BaseCommandModule
|
||||
{
|
||||
private readonly DiscordColor[] colours = { DiscordColor.Aquamarine, DiscordColor.Azure, DiscordColor.Black, DiscordColor.Blue, DiscordColor.Blurple,
|
||||
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.Rose, DiscordColor.SapGreen, DiscordColor.Sienna, DiscordColor.SpringGreen, DiscordColor.Teal, DiscordColor.Turquoise, DiscordColor.VeryDarkGray,
|
||||
DiscordColor.Violet, DiscordColor.Wheat, DiscordColor.White, DiscordColor.Yellow };
|
||||
private readonly Random rnd = new Random();
|
||||
private Dictionary<string, SSFunction> ssFunctions;
|
||||
private bool FunctionsEnabled;
|
||||
@@ -101,7 +94,7 @@ namespace StarsiegeBot
|
||||
// set the timestamp to now... why, idk, its not really needed actually.
|
||||
embed.WithTimestamp(DateTime.Now);
|
||||
// add a random color to the left side bar of the embed.
|
||||
embed.WithColor(colours[rnd.Next(0, colours.Length)]);
|
||||
embed.WithColor(Program.colours[rnd.Next(0, Program.colours.Length)]);
|
||||
// Message Description, I dont remember what it is any more, sorry!
|
||||
embed.WithDescription(outItem.description);
|
||||
// iterate over each field item, and add them to the embed.
|
||||
|
||||
@@ -186,6 +186,7 @@ namespace StarsiegeBot
|
||||
}
|
||||
|
||||
[Command("search"), Aliases("s")]
|
||||
[Cooldown(1,5,CooldownBucketType.Global)]
|
||||
[Description("Searches all the [T]ext and [S]ound file names for the Search input.")]
|
||||
public async Task SearchQuickChats(CommandContext ctx, [RemainingText,Description("What to search for.")] string toSearch)
|
||||
{
|
||||
|
||||
@@ -33,9 +33,39 @@ namespace StarsiegeBot
|
||||
await ctx.TriggerTypingAsync();
|
||||
string gId = ctx.Guild.Id.ToString();
|
||||
|
||||
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
|
||||
{
|
||||
Description = "Welcome Message Usage",
|
||||
Color = Program.colours[0]
|
||||
};
|
||||
embed.AddField("Old", GuildSettings[gId].UseWelcome.ToString(), true);
|
||||
GuildSettings[gId].UseWelcome = enable;
|
||||
embed.AddField("New", GuildSettings[gId].UseWelcome.ToString(), true);
|
||||
await ctx.RespondAsync(embed);
|
||||
}
|
||||
|
||||
await ctx.RespondAsync($"Use welcome message? {enable}");
|
||||
[Command("Channel")]
|
||||
public async Task WelcomeChannel(CommandContext ctx, DiscordChannel channel)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
string gId = ctx.Guild.Id.ToString();
|
||||
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
|
||||
{
|
||||
Description = "Welcome Message Channel",
|
||||
Color = Program.colours[0]
|
||||
};
|
||||
if (GuildSettings[gId].WelcomeChannel != null)
|
||||
{
|
||||
embed.AddField("Old", GuildSettings[gId].WelcomeChannel.Mention, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
embed.AddField("Old", "*None*");
|
||||
}
|
||||
|
||||
GuildSettings[gId].WelcomeChannel = channel;
|
||||
embed.AddField("New", GuildSettings[gId].WelcomeChannel.Mention, true);
|
||||
await ctx.RespondAsync(embed);
|
||||
}
|
||||
|
||||
[Command("Channel")]
|
||||
@@ -43,17 +73,78 @@ namespace StarsiegeBot
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
string gId = ctx.Guild.Id.ToString();
|
||||
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
|
||||
{
|
||||
Description = "Welcome Message Channel",
|
||||
Color = Program.colours[0]
|
||||
};
|
||||
if (GuildSettings[gId].WelcomeChannel != null)
|
||||
{
|
||||
embed.AddField("Old", GuildSettings[gId].WelcomeChannel.Mention, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
embed.AddField("Old", "*None*");
|
||||
}
|
||||
|
||||
GuildSettings[gId].WelcomeChannel = ctx.Channel;
|
||||
await ctx.RespondAsync("This channel is the welcome channel now!");
|
||||
embed.AddField("New", GuildSettings[gId].WelcomeChannel.Mention, true);
|
||||
await ctx.RespondAsync(embed);
|
||||
}
|
||||
|
||||
|
||||
[Command("Message")]
|
||||
[Description("Hello. Run `>welcome help` for more info.")]
|
||||
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");
|
||||
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;
|
||||
await ctx.RespondAsync("welcome message set.");
|
||||
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]
|
||||
};
|
||||
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.");
|
||||
embed.AddField("[Mention]", "Inserts your Guild/Server Name.");
|
||||
await ctx.RespondAsync(embed);
|
||||
}
|
||||
public static string WelcomeMessageProcessing(string msg, DiscordMember member, DiscordGuild guild)
|
||||
{
|
||||
string output = msg
|
||||
.Replace("[discrim]", member.Discriminator, StringComparison.OrdinalIgnoreCase)
|
||||
.Replace("[gname]", guild.Name, StringComparison.OrdinalIgnoreCase)
|
||||
.Replace("[uname]", member.Username, StringComparison.OrdinalIgnoreCase)
|
||||
.Replace("[mention]", member.Mention, StringComparison.OrdinalIgnoreCase);
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user