mirror of
https://github.com/Stone-Red-Code/Discord_Simple-Embed-Bot.git
synced 2026-09-04 09:06:05 +02:00
made GetPreifx call async
This commit is contained in:
Binary file not shown.
@@ -45,7 +45,7 @@ namespace Discord_Simple_Embed_Bot
|
||||
if (message is null) return;
|
||||
|
||||
int argPos = 0;
|
||||
string prefix = PrefixFromMessage(message);
|
||||
string prefix = await PrefixFromMessageAsync(message);
|
||||
if (message.MentionedUsers.Any(x => x.Discriminator == Client.CurrentUser.Discriminator))
|
||||
{
|
||||
EmbedBuilder eb = new EmbedBuilder
|
||||
@@ -77,13 +77,13 @@ namespace Discord_Simple_Embed_Bot
|
||||
}
|
||||
else
|
||||
{
|
||||
await message.Channel.SendMessageAsync($"Command not found! Use `{PrefixFromMessage(message)} help` to list all commands.");
|
||||
await message.Channel.SendMessageAsync($"Command not found! Use `{await PrefixFromMessageAsync(message)} help` to list all commands.");
|
||||
}
|
||||
}
|
||||
|
||||
public static string PrefixFromMessage(SocketUserMessage message)
|
||||
public static async Task<string> PrefixFromMessageAsync(SocketUserMessage message)
|
||||
{
|
||||
string prefix = SqlManager.GetData((message.Channel as SocketGuildChannel).Guild.Id, 'p').Result;
|
||||
string prefix = await SqlManager.GetData((message.Channel as SocketGuildChannel).Guild.Id, 'p');
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
return prefix;
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Discord_Simple_Embed_Bot
|
||||
{
|
||||
EmbedBuilder eb = new EmbedBuilder();
|
||||
eb.Color = Color.Blue;
|
||||
string[] args = CommandHandler.CheckCommandArgs(message.Content, 0, 1, CommandHandler.PrefixFromMessage(message));
|
||||
string[] args = CommandHandler.CheckCommandArgs(message.Content, 0, 1, await CommandHandler.PrefixFromMessageAsync(message));
|
||||
if (args == null)
|
||||
{
|
||||
eb.Title = "Commands:";
|
||||
@@ -33,7 +33,7 @@ namespace Discord_Simple_Embed_Bot
|
||||
eb.AddField("Parameters", CommandHandler.CommandList[args[0].ToLower()].Usage);
|
||||
if (!string.IsNullOrWhiteSpace(CommandHandler.CommandList[args[0].ToLower()].Example))
|
||||
{
|
||||
eb.AddField("Example", $"```{CommandHandler.PrefixFromMessage(message)} {args[0].ToLower()} {CommandHandler.CommandList[args[0].ToLower()].Example}```");
|
||||
eb.AddField("Example", $"```{await CommandHandler.PrefixFromMessageAsync(message)} {args[0].ToLower()} {CommandHandler.CommandList[args[0].ToLower()].Example}```");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -61,7 +61,7 @@ namespace Discord_Simple_Embed_Bot
|
||||
|
||||
static public async Task CreateEmbed(SocketUserMessage message)
|
||||
{
|
||||
string prefix = CommandHandler.PrefixFromMessage(message);
|
||||
string prefix = await CommandHandler.PrefixFromMessageAsync(message);
|
||||
string content = message.Content[prefix.Length..].Trim()[3..];
|
||||
string[] lines = content.Split("\n");
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user