Skip to content

Commit

Permalink
[release] 2.2.5 (#268)
Browse files Browse the repository at this point in the history
* [Backport] #264 to dev/2.2.x-staging (#265)

* Fix some null exceptions

* Fix null ref

---------

Co-authored-by: Sella-GH <147769367+Sella-GH@users.noreply.github.com>

* [Backport] #266 to dev/2.2.x-staging (#267)

* Add new embed and modify some strings

* Use the new embed

* Remove interpolation

---------

Co-authored-by: Sella-GH <147769367+Sella-GH@users.noreply.github.com>

* Update to 2.2.5

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
Sella-GH and github-actions[bot] authored Jan 25, 2025
1 parent 2783d90 commit a97165f
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 18 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 2.2.5 - 2025-01-25
### Dependencies
- Updated [NCronJob](https://github.com/NCronJob-Dev/NCronJob) to version 4.3.1

### Improvements
- The initial welcome message is now an embed with more info

### Fixes
- Null reference exception when the bot should join a voice channel but the requesting user isn't in one

## 2.2.4 - 2025-01-21
### Dependencies
- Updated [DSharpPlus](https://github.com/DSharpPlus/DSharpPlus) to version 5.0.0-nightly-02450
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<NeutralLanguage>en</NeutralLanguage>
<RepositoryType>Git</RepositoryType>
<RepositoryUrl>https://github.com/Sella-GH/AzzyBot</RepositoryUrl>
<Version>2.2.4</Version>
<Version>2.2.5</Version>
</PropertyGroup>

<!-- Runtimeconfig settings -->
Expand Down
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageVersion Include="Lavalink4NET.DSharpPlus.Nightly" Version="4.0.26-preview.4" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.1" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="9.0.1" />
<PackageVersion Include="NCronJob" Version="4.2.0" />
<PackageVersion Include="NCronJob" Version="4.3.1" />
<PackageVersion Include="Npgsql" Version="9.0.2" />
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.3" />
<PackageVersion Include="NReco.Logging.File" Version="1.2.2" />
Expand Down
10 changes: 6 additions & 4 deletions src/AzzyBot.Bot/Commands/AzuraCastCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1176,13 +1176,15 @@ public async ValueTask UploadFilesAsync
{
ArgumentNullException.ThrowIfNull(context);
ArgumentNullException.ThrowIfNull(context.Guild);
ArgumentNullException.ThrowIfNull(file);
ArgumentException.ThrowIfNullOrWhiteSpace(file.FileName);
ArgumentException.ThrowIfNullOrWhiteSpace(file.Url);

_logger.CommandRequested(nameof(UploadFilesAsync), context.User.GlobalName);

if (file.FileSize > FileSizes.AzuraFileSize)
if (file is null || string.IsNullOrWhiteSpace(file.FileName) || string.IsNullOrWhiteSpace(file.Url))
{
await context.EditResponseAsync(GeneralStrings.FileNotFound);
return;
}
else if (file.FileSize > FileSizes.AzuraFileSize)
{
await context.EditResponseAsync(GeneralStrings.FileTooBig);
return;
Expand Down
5 changes: 2 additions & 3 deletions src/AzzyBot.Bot/Commands/MusicStreamingCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,10 @@ public async ValueTask JoinAsync(SlashCommandContext context)
ArgumentNullException.ThrowIfNull(context);
ArgumentNullException.ThrowIfNull(context.Guild);
ArgumentNullException.ThrowIfNull(context.Member);
ArgumentNullException.ThrowIfNull(context.Member.VoiceState);

_logger.CommandRequested(nameof(JoinAsync), context.User.GlobalName);

if (context.Member.VoiceState.Channel is null)
if (context.Member.VoiceState?.Channel is null)
{
await context.EditResponseAsync(GeneralStrings.VoiceNoUser);
return;
Expand Down Expand Up @@ -177,7 +176,7 @@ public async ValueTask PlayAsync
SlashCommandContext context,
[Description("The provider you want to search for."), SlashChoiceProvider<MusicStreamingPlatformProvider>] string provider,
[Description("The url of the track you want to play.")] string track,
[Description("The volume which should be set. This is only respected when no music is being played.")] int volume = 100
[Description("The volume which should be set. This is only respected when no music is being played.")] int volume = 50
)
{
ArgumentNullException.ThrowIfNull(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private async Task GuildCreatedHelperAsync(IEnumerable<DiscordGuild> guilds)
foreach (DiscordGuild guild in guilds)
{
owner = await guild.GetGuildOwnerAsync();
await owner.SendMessageAsync(GeneralStrings.LegalsRequired.Replace("%GUILD%", guild.Name, StringComparison.OrdinalIgnoreCase));
await owner.SendMessageAsync(EmbedBuilder.BuildAzzyAddedEmbed());
embed = await EmbedBuilder.BuildGuildAddedEmbedAsync(guild);
await _botService.SendMessageAsync(_settings.NotificationChannelId, embeds: [embed]);
}
Expand Down
14 changes: 14 additions & 0 deletions src/AzzyBot.Bot/Utilities/EmbedBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text;
using System.Threading.Tasks;
using AzzyBot.Bot.Resources;
using AzzyBot.Bot.Utilities.Helpers;
using AzzyBot.Bot.Utilities.Records;
using AzzyBot.Bot.Utilities.Records.AzuraCast;
using AzzyBot.Core.Utilities;
Expand Down Expand Up @@ -314,6 +315,19 @@ public static DiscordEmbed BuildAzuraCastUploadFileEmbed(AzuraFilesDetailedRecor
return CreateBasicEmbed(title, description, DiscordColor.SpringGreen, new(stationArt), fields: fields);
}

public static DiscordEmbed BuildAzzyAddedEmbed()
{
const string title = "Thanks For Adding Me To Your Server!";
const string description = GeneralStrings.GuildJoinLegals;

Dictionary<string, AzzyDiscordEmbedRecord> fields = new(1)
{
["Setup Instructions"] = new($"[GitHub Wiki]({SetupInstructions})")
};

return CreateBasicEmbed(title, description, DiscordColor.SpringGreen, fields: fields);
}

public static async Task<DiscordEmbed> BuildAzzyHardwareStatsEmbedAsync(Uri avaUrl, int ping)
{
const string title = "AzzyBot Hardware Stats";
Expand Down
17 changes: 9 additions & 8 deletions src/AzzyBot.Bot/Utilities/Helpers/GeneralStrings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
public static class GeneralStrings
{
public const string AdminBotWideMessageEmpty = "You have to provide a message first!";
public const string BotStatusChanged = "Bot status has been updated!";
public const string BotStatusReset = "Bot status has been reset!";
public const string BotStatusChanged = "The bot status has been updated.";
public const string BotStatusReset = "The bot status has been reset.";
public const string CanNotLeaveServer = "You can't make me leave my own home server!";
public const string CoreSettingsMissing = "You have to set the core settings first!";
public const string CoreSettingsModified = "Core settings have been modified successfully.";
Expand All @@ -26,18 +26,19 @@ public static class GeneralStrings
public const string ConfigStationModifiedChecks = "Your station was modified successfully.";
public const string ConfigStationRequestChannelMissing = "You have to select a request channel first!";
public const string DateFormatInvalid = "The date format is invalid. Please use the format: YYYY-MM-DD.";
public const string FileNotFound = "Are you sure you uploaded a file with your command?";
public const string FileTooBig = "The file is too big. Please upload a file smaller than 50MB.";
public const string GuildIdInvalid = "This server ID is invalid.";
public const string GuildNotFound = "This server does not exist in the database.";
public const string GuildJoinLegals = "Before you're able to use me, you have to accept my legal conditions.\n\nPlease use the command `/legal accept-legals` for this.\nAfter this the whole functionality will be unlocked.\n\nIf you need more help about setting me up, please consult the following help page:";
public const string GuildNotFound = "This server does not exist in the database yet.";
public const string HlsNotAvailable = "This station does not support HLS streaming.";
public const string InstanceNotFound = "AzuraCast is not set up for this server.";
public const string InstanceUpdateError = "An error occurred while checking for AzuraCast updates.";
public const string InstanceUpToDate = "AzuraCast is already up to date.";
public const string LegalsAlreadyAccepted = "You already accepted the legals! No more action required.";
public const string LegalsAccepted = "Thank you for accepting the terms! Now you have to set my settings through `/config modify-core`.\nBe aware that only administrators are able to execute this command right now.";
public const string LegalsInformation = "Please accept the following three legal agreements to use me in your server:\n\n1. **[Privacy Policy](%PP%)**\n2. **[Terms Of Service](%TOS%)**";
public const string LegalsInformation = "Please accept the following two legal agreements to use me in your server:\n\n1. **[Privacy Policy](%PP%)**\n2. **[Terms Of Service](%TOS%)**";
public const string LegalsNotAccepted = "You have to accept the legal conditions first before you're able to use me!";
public const string LegalsRequired = "Thank you for adding me to your server **%GUILD%**! Before you're able to use me, you have to accept my legal conditions.\n\nPlease use the command `/legal accept-legals` for this.\nAfter the whole functionality will be unlocked.";
public const string LegalsReset = "Attention!\n\nThe associated legal agreements (Privacy Policy & Terms Of Service) have changed. Please accept them again if you wish to continue your usage of the bot. Use the command `/legal accept-legals` for this.\n\nIf you do not accept you're unable to use the bot in your server anymore.";
public const string MessageSentToAll = "Your message has been sent to all servers.";
public const string MountPointNotFound = "This mount point does not exist.";
Expand All @@ -59,13 +60,13 @@ public static class GeneralStrings
public const string VoiceJoined = "I'm here now.";
public const string VoiceLeft = "I'm gone now.";
public const string VoiceNotConnected = "You are not connected to a voice channel.";
public const string VoiceNoUser = "Discord didn't told me you're in a voice channel, please rejoin.";
public const string VoiceNoUser = "Discord didn't tell me you're in a voice channel, please rejoin.";
public const string VoiceNothingPlaying = "There is nothing playing right now.";
public const string VoicePlayingAzuraCast = "The current played song is from an AzuraCast station. Please use `music now-playing` to get the information.";
public const string VoicePlayMount = "I'm starting to play **%station%** now.";
public const string VoicePlaySong = "I'm starting to play **%track%** by **%artist%** now.";
public const string VoiceStationStopped = "The station has been stopped, I am stopping to play music.";
public const string VoiceStationStopped = "The station has been stopped, I'm stopping the music now.";
public const string VoiceStop = "I'm stopping the music now.";
public const string VoiceStopLeft = "I'm stopping the music and leaving now.";
public const string VoiceStopLeft = "I'm stopping the music and leave now.";
public const string VolumeInvalid = "Please use a value between 0 and 100.";
}

0 comments on commit a97165f

Please sign in to comment.