Skip to content

Commit

Permalink
Upgraded borders on bot respond messages, added basic emojis on respo…
Browse files Browse the repository at this point in the history
…nding
  • Loading branch information
radoslavchobanov committed May 4, 2022
1 parent ad600ec commit 87be99e
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 18 deletions.
8 changes: 6 additions & 2 deletions qguaratBot/Scripts/Bot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@ public static async void SkipTrack()

public static DiscordEmbedBuilder CreateEmbed(string text, string emojiName = null)
{
// text.Insert(0, emojiName);
text += " | " + ConnectionManager.commandContext.Member?.Mention;
if (emojiName != null)
{
var emoji = DiscordEmoji.FromName(ConnectionManager.discordClient, emojiName);
text = text.Insert(0, emoji);
}
text += " | " + ConnectionManager.commandContext?.Member?.Mention;

DiscordEmbedBuilder embed = new DiscordEmbedBuilder()
{
Expand Down
8 changes: 4 additions & 4 deletions qguaratBot/Scripts/EventManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private static async void OnTrackAddedToQueue(object? sender, TrackEventArgs e)
else
{
Console.Log(Console.LogLevel.INFO, $"Queued [{e.Track.Title}]");
await ConnectionManager.commandContext.RespondAsync(Bot.CreateEmbed($"Queued [{e.Track.Title}]"));
await ConnectionManager.commandContext.RespondAsync(Bot.CreateEmbed($"Queued [{e.Track.Title}]", ":white_check_mark:"));
}
}

Expand All @@ -52,7 +52,7 @@ private static Task OnTrackStarted(LavalinkGuildConnection sender, TrackStartEve
Bot.isPlaying = true;

Console.Log(Console.LogLevel.INFO, $"Now playing [{e.Track.Title}]");
ConnectionManager.commandContext.RespondAsync(Bot.CreateEmbed($"Now playing [{e.Track.Title}]"));
ConnectionManager.commandContext.RespondAsync(Bot.CreateEmbed($"Now playing [{e.Track.Title}]", ":notes:"));

return Task.CompletedTask;
}
Expand All @@ -64,12 +64,12 @@ public static async Task OnTrackFinished(LavalinkGuildConnection sender, TrackFi
if (e.Reason is TrackEndReason.Replaced)
{
Console.Log(Console.LogLevel.INFO, $"Track [{e.Track.Title}] is skipped!");
await ConnectionManager.commandContext.RespondAsync(Bot.CreateEmbed($"Skipped [{e.Track.Title}]"));
await ConnectionManager.commandContext.RespondAsync(Bot.CreateEmbed($"Skipped [{e.Track.Title}]", ":track_next:"));
}
else if (e.Reason is TrackEndReason.Finished)
{
Console.Log(Console.LogLevel.INFO, $"Track [{e.Track.Title}] has finished!");
await ConnectionManager.commandContext.RespondAsync(Bot.CreateEmbed($"Finished [{e.Track.Title}]"));
await ConnectionManager.commandContext.RespondAsync(Bot.CreateEmbed($"Finished [{e.Track.Title}]", ":checkered_flag:"));
await Bot.PlayNextTrack();
}
}
Expand Down
20 changes: 10 additions & 10 deletions qguaratBot/Scripts/MusicCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public async Task JoinCommand(CommandContext ctx)
{
if (ctx.Member.VoiceState == null || ctx.Member.VoiceState.Channel == null)
{
await ctx.RespondAsync(Bot.CreateEmbed("You are not in a voice channel."));
await ctx.RespondAsync(Bot.CreateEmbed("You are not in a voice channel.", ":no_entry_sign:"));
return;
}

Expand All @@ -33,13 +33,13 @@ public async Task JoinCommand(CommandContext ctx)
if (channel.Type != ChannelType.Voice)
{
Console.Log(Console.LogLevel.ERROR, $"Not a valid voice channel {channel.Type}");
await ctx.RespondAsync(Bot.CreateEmbed("Not a valid voice channel."));
await ctx.RespondAsync(Bot.CreateEmbed("Not a valid voice channel.", ":no_entry_sign:"));
return;
}

await node.ConnectAsync(channel);
Console.Log(Console.LogLevel.INFO, $"Bot Joined {channel.Name}");
await ctx.RespondAsync(Bot.CreateEmbed($"Joined {channel.Name}!"));
await ctx.RespondAsync(Bot.CreateEmbed($"Joined {channel.Name}!", ":white_check_mark:"));
}

[Command("leave")]
Expand All @@ -48,7 +48,7 @@ public async Task LeaveCommand(CommandContext ctx)
{
if (ctx.Member.VoiceState == null || ctx.Member.VoiceState.Channel == null)
{
await ctx.RespondAsync(Bot.CreateEmbed("You are not in a voice channel."));
await ctx.RespondAsync(Bot.CreateEmbed("You are not in a voice channel.", ":no_entry_sign:"));
return;
}

Expand All @@ -61,15 +61,15 @@ public async Task LeaveCommand(CommandContext ctx)
if (conn == null)
{
Console.Log(Console.LogLevel.ERROR, $"Bot is not in a voice channel!");
await ctx.RespondAsync(Bot.CreateEmbed("Bot is not in a voice channel!"));
await ctx.RespondAsync(Bot.CreateEmbed("Bot is not in a voice channel!", ":no_entry_sign:"));
return;
}

// when leaving, it should trigger the OnTrackFinished event

await conn.DisconnectAsync();
Console.Log(Console.LogLevel.INFO, $"Bot left {channel.Name}");
await ctx.RespondAsync(Bot.CreateEmbed($"Left {channel.Name}!"));
await ctx.RespondAsync(Bot.CreateEmbed($"Left {channel.Name}!", ":exclamation:"));
}

[Command("play")]
Expand All @@ -79,7 +79,7 @@ public async Task Play(CommandContext ctx, [RemainingText] string search)
if (ctx.Member.VoiceState == null || ctx.Member.VoiceState.Channel == null)
{
Console.Log(Console.LogLevel.ERROR, $"You are not in a voice channel!");
await ctx.RespondAsync(Bot.CreateEmbed("You are not in a voice channel."));
await ctx.RespondAsync(Bot.CreateEmbed("You are not in a voice channel.", ":no_entry_sign:"));
return;
}

Expand All @@ -98,7 +98,7 @@ public async Task Play(CommandContext ctx, [RemainingText] string search)
|| loadResult.LoadResultType == LavalinkLoadResultType.NoMatches)
{
Console.Log(Console.LogLevel.ERROR, $"Track search failed for [{search}]");
await ctx.RespondAsync(Bot.CreateEmbed($"Track search failed for [{search}]"));
await ctx.RespondAsync(Bot.CreateEmbed($"Track search failed for [{search}]", ":exclamation:"));
return;
}

Expand All @@ -114,7 +114,7 @@ public async Task Skip(CommandContext ctx)
if (ctx.Member.VoiceState == null || ctx.Member.VoiceState.Channel == null)
{
Console.Log(Console.LogLevel.ERROR, $"You are not in a voice channel!");
await ctx.RespondAsync(Bot.CreateEmbed("You are not in a voice channel!"));
await ctx.RespondAsync(Bot.CreateEmbed("You are not in a voice channel!", ":no_entry_sign:"));
return;
}

Expand All @@ -125,7 +125,7 @@ public async Task Skip(CommandContext ctx)
if (conn == null)
{
Console.Log(Console.LogLevel.ERROR, $"Bot is not in a voice channel!");
await ctx.RespondAsync(Bot.CreateEmbed("Bot is not in a voice channel!"));
await ctx.RespondAsync(Bot.CreateEmbed("Bot is not in a voice channel!", ":no_entry_sign:"));
return;
}

Expand Down
4 changes: 2 additions & 2 deletions qguaratBot/Scripts/RandomCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ public class RandomCommands : BaseCommandModule
[Description("Greet you")]
public async Task GreetCommand(CommandContext ctx)
{
await ctx.RespondAsync(Bot.CreateEmbed("GREETINGS"));
await ctx.RespondAsync(Bot.CreateEmbed("GREETINGS", ":wave:"));
}

[Command("roll")]
[Description("Return a number from 0 to 100")]
public async Task Roll(CommandContext ctx)
{
await ctx.RespondAsync(Bot.CreateEmbed("rolled: " + GetRandom()));
await ctx.RespondAsync(Bot.CreateEmbed("rolled: " + GetRandom(), ":game_die:"));
}

// get random number from 0 to 100
Expand Down
Binary file modified qguaratBot/bin/Debug/net6.0/qguaratBot.dll
Binary file not shown.
Binary file modified qguaratBot/bin/Debug/net6.0/qguaratBot.pdb
Binary file not shown.
Binary file modified qguaratBot/obj/Debug/net6.0/qguaratBot.dll
Binary file not shown.
Binary file modified qguaratBot/obj/Debug/net6.0/qguaratBot.pdb
Binary file not shown.

0 comments on commit 87be99e

Please sign in to comment.