Skip to content

Commit

Permalink
Merge pull request #39 from CriticalFlaw/dev
Browse files Browse the repository at this point in the history
Version 4.0
  • Loading branch information
CriticalFlaw authored Jul 13, 2023
2 parents 9826329 + a06de09 commit 8fa10b3
Show file tree
Hide file tree
Showing 31 changed files with 186 additions and 551 deletions.
2 changes: 1 addition & 1 deletion src/FlawBOT.Models/FlawBOT.Models.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DSharpPlus.Lavalink" Version="4.4.1" />
<PackageReference Include="DSharpPlus.Lavalink" Version="4.4.2" />
</ItemGroup>

</Project>
10 changes: 5 additions & 5 deletions src/FlawBOT.Test/FlawBOT.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<IsPackable>false</IsPackable>
<AssemblyVersion>3.1.0.0</AssemblyVersion>
<FileVersion>3.1.0.0</FileVersion>
<Version>3.1.0</Version>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<FileVersion>4.0.0.0</FileVersion>
<Version>4.0.0</Version>
<Authors>Igor Nikitin</Authors>
<Company>CriticalFlaw</Company>
<Product>FlawBOT</Product>
Expand All @@ -20,11 +20,11 @@

<ItemGroup>
<PackageReference Include="nunit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2">
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion src/FlawBOT/FlawBOT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ public FlawBot(int shardId = 0)
Slash.RegisterCommands<BotModule>();
Slash.RegisterCommands<ChannelModule>();
Slash.RegisterCommands<DictionaryModule>();
//Slash.RegisterCommands<EmojiModule>();
Slash.RegisterCommands<ImgurModule>();
Slash.RegisterCommands<MiscModule>();
Slash.RegisterCommands<MusicModule>();
Expand Down
24 changes: 12 additions & 12 deletions src/FlawBOT/FlawBOT.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<ApplicationIcon>Resources/favicon.ico</ApplicationIcon>
<StartupObject>FlawBOT.Program</StartupObject>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<Version>3.1.0</Version>
<Version>4.0</Version>
<Win32Resource />
<LangVersion>9.0</LangVersion>
<AssemblyVersion>3.1.0.0</AssemblyVersion>
<FileVersion>3.1.0.0</FileVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<FileVersion>4.0.0.0</FileVersion>
<AssemblyName>FlawBOT</AssemblyName>
<RootNamespace>FlawBOT</RootNamespace>
<PackageTags />
Expand Down Expand Up @@ -53,27 +53,27 @@

<ItemGroup>
<PackageReference Include="AutoMapper" Version="12.0.1" />
<PackageReference Include="DSharpPlus" Version="4.4.1">
<PackageReference Include="DSharpPlus" Version="4.4.2">
<TreatAsUsed>true</TreatAsUsed>
</PackageReference>
<PackageReference Include="DSharpPlus.CommandsNext" Version="4.4.1" />
<PackageReference Include="DSharpPlus.Interactivity" Version="4.4.1" />
<PackageReference Include="DSharpPlus.Lavalink" Version="4.4.1">
<PackageReference Include="DSharpPlus.CommandsNext" Version="4.4.2" />
<PackageReference Include="DSharpPlus.Interactivity" Version="4.4.2" />
<PackageReference Include="DSharpPlus.Lavalink" Version="4.4.2">
<TreatAsUsed>true</TreatAsUsed>
</PackageReference>
<PackageReference Include="DSharpPlus.SlashCommands" Version="4.4.1" />
<PackageReference Include="DSharpPlus.VoiceNext" Version="4.4.1" />
<PackageReference Include="DSharpPlus.SlashCommands" Version="4.4.2" />
<PackageReference Include="DSharpPlus.VoiceNext" Version="4.4.2" />
<PackageReference Include="Genbox.Wikipedia" Version="4.0.0" />
<PackageReference Include="Google.Apis.YouTube.v3" Version="1.60.0.3064" />
<PackageReference Include="Google.Apis.YouTube.v3" Version="1.61.0.3106" />
<PackageReference Include="Imgur.API" Version="4.0.1" />
<PackageReference Include="Microsoft.Extensions.Options" Version="7.0.1" />
<PackageReference Include="OMDbSharp" Version="0.3.0" />
<PackageReference Include="PokemonTcgSdk" Version="2.4.1" />
<PackageReference Include="StackExchange.Redis" Version="2.6.111" />
<PackageReference Include="StackExchange.Redis" Version="2.6.122" />
<PackageReference Include="System.ServiceModel.Syndication" Version="7.0.0" />
<PackageReference Include="TeamworkTF.Sharp" Version="1.5.0" />
<PackageReference Include="TwitchLib.Api" Version="3.9.0" />
<PackageReference Include="YoutubeExplode" Version="6.2.15" />
<PackageReference Include="YoutubeExplode" Version="6.2.16" />
</ItemGroup>

<ItemGroup>
Expand Down
36 changes: 8 additions & 28 deletions src/FlawBOT/Modules/BotModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ namespace FlawBOT.Modules
[SlashCommandGroup("bot", "Slash command group for bot commands.")]
public class BotModule : ApplicationCommandModule
{
/// <summary>
/// Returns basic information about FlawBOT.
/// </summary>
[SlashCommand("info", "Returns basic information about FlawBOT.")]
public async Task GetBotInfo(InteractionContext ctx)
{
Expand All @@ -21,34 +18,27 @@ public async Task GetBotInfo(InteractionContext ctx)
.WithTitle(settings.Name)
.WithDescription($"Multipurpose Discord bot written in C# with DSharpPlus.")
.AddField(":clock1: Uptime", BotServices.GetCurrentUptime(), true)
.AddField(":link: Links", $"[Commands]({settings.DocsLink}) **|** [Commands]({settings.DocsLink}) **|** [GitHub]({settings.GitHubLink})", true)
.AddField(":link: Links", $"[Documentation]({settings.DocsLink}) **|** [GitHub]({settings.GitHubLink})", true)
.WithFooter($"Version {settings.Version}")
.WithUrl(settings.GitHubLink)
.WithColor(settings.DefaultColor).Build();
await ctx.CreateResponseAsync(output).ConfigureAwait(false);
}

/// <summary>
/// Ping the active FlawBOT instance.
/// </summary>
[SlashCommand("ping", "Ping the active FlawBOT instance.")]
[SlashCommand("ping", "Pings the active FlawBOT instance.")]
public async Task GetBotPing(InteractionContext ctx)
{
await BotServices.SendResponseAsync(ctx, $":ping_pong: Pong! Ping: {Formatter.Bold(ctx.Client.Ping.ToString())}ms").ConfigureAwait(false);
}

/// <summary>
/// Returns the uptime of the active FlawBOT instance.
/// </summary>
[SlashCommand("uptime", "Returns the uptime of the active FlawBOT instance.")]
public async Task GetBotUptime(InteractionContext ctx)
{
await BotServices.SendResponseAsync(ctx, $":clock1: {BotServices.GetCurrentUptime()}").ConfigureAwait(false);
}

/// <summary>
/// Changes FlawBOT's activity.
/// </summary>
#region OWNER-ONLY

[RequireOwner]
[SlashCommand("activity", "Changes FlawBOT's activity.")]
public async Task SetBotActivity(InteractionContext ctx, [Option("activity", "Activity name.")] string activity)
Expand All @@ -57,9 +47,6 @@ public async Task SetBotActivity(InteractionContext ctx, [Option("activity", "Ac
await ctx.CreateResponseAsync($"{Program.Settings.Name} activity has been changed to {Formatter.Bold(activity)}.").ConfigureAwait(false);
}

/// <summary>
/// Changes FlawBOT's avatar.
/// </summary>
[RequireOwner]
[SlashCommand("avatar", "Changes FlawBOT's avatar.")]
public async Task SetBotAvatar(InteractionContext ctx, [Option("url", "Image URL in JPG, PNG or IMG format.")] string url)
Expand All @@ -74,9 +61,6 @@ public async Task SetBotAvatar(InteractionContext ctx, [Option("url", "Image URL
await ctx.CreateResponseAsync($"{Program.Settings.Name} avatar has been updated.").ConfigureAwait(false);
}

/// <summary>
/// Changes FlawBOT's status.
/// </summary>
[RequireOwner]
[SlashCommand("status", "Changes FlawBOT's status.")]
public async Task SetBotStatus(InteractionContext ctx, [Choice("Online", "Online")][Choice("Idle", "Idle")][Choice("Invisible", "Invisible")][Choice("Do Not Disturb", "Do Not Disturb")][Option("status", "New FlawBOT status.")] string status)
Expand All @@ -92,23 +76,19 @@ public async Task SetBotStatus(InteractionContext ctx, [Choice("Online", "Online
await ctx.CreateResponseAsync($"{Program.Settings.Name} status has been changed to {status}.").ConfigureAwait(false);
}

/// <summary>
/// Changes FlawBOT's nickname.
/// </summary>
[RequireOwner]
[SlashCommand("nickname", "Changes FlawBOT's nickname.")]
public async Task SetBotUsername(InteractionContext ctx, [Option("nickname", "New nickname for FlawBOT.")] string nickname)
{
var oldName = ctx.Client.CurrentUser.Username;
var newName = string.IsNullOrWhiteSpace(nickname) ? Program.Settings.Name : nickname;
await ctx.Client.UpdateCurrentUserAsync(username: newName).ConfigureAwait(false);
await ctx.CreateResponseAsync($"{oldName}'s username has been changed to {newName}.").ConfigureAwait(false);
await ctx.CreateResponseAsync($"{oldName}'s username has been changed to {Formatter.Bold(newName)}.").ConfigureAwait(false);
}

/// <summary>
/// Makes FlawBOT leave the current server.
/// </summary>
[SlashCommand("leave", "Makes FlawBOT leave the current server.")]
#endregion

[SlashCommand("leave", "Removes FlawBOT from the server.")]
[RequireUserPermissions(Permissions.Administrator)]
public async Task LeaveServer(InteractionContext ctx)
{
Expand Down
31 changes: 3 additions & 28 deletions src/FlawBOT/Modules/ChannelModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ namespace FlawBOT.Modules
[SlashCommandGroup("channel", "Slash command group for channel commands.")]
public class ChannelModule : ApplicationCommandModule
{
/// <summary>
/// Creates a new channel category.
/// </summary>
[SlashCommand("new-category", "Creates a new channel category.")]
[SlashRequirePermissions(Permissions.ManageChannels)]
public async Task CreateCategory(InteractionContext ctx, [Option("name", "New category name.")] string name)
Expand All @@ -32,9 +29,6 @@ public async Task CreateCategory(InteractionContext ctx, [Option("name", "New ca
await ctx.CreateResponseAsync($"Created channel category {Formatter.Bold(name)}.").ConfigureAwait(false);
}

/// <summary>
/// Creates a new text channel.
/// </summary>
[SlashCommand("new-text", "Creates a new text channel.")]
[SlashRequirePermissions(Permissions.ManageChannels)]
public async Task CreateText(InteractionContext ctx, [Option("name", "New text channel name.")] string name)
Expand All @@ -55,9 +49,6 @@ public async Task CreateText(InteractionContext ctx, [Option("name", "New text c
await ctx.CreateResponseAsync($"Created text channel #{Formatter.Bold(channel.Name)}.").ConfigureAwait(false);
}

/// <summary>
/// Creates a new voice channel.
/// </summary>
[SlashCommand("new-voice", "Creates a new voice channel.")]
[SlashRequirePermissions(Permissions.ManageChannels)]
public async Task CreateVoice(InteractionContext ctx, [Option("name", "New voice channel name.")] string name)
Expand All @@ -78,20 +69,14 @@ public async Task CreateVoice(InteractionContext ctx, [Option("name", "New voice
await ctx.CreateResponseAsync($"Created voice channel #{Formatter.Bold(channel.Name)}.").ConfigureAwait(false);
}

/// <summary>
/// Deletes server channel.
/// </summary>
[SlashCommand("delete", "Delete server channel.")]
[SlashCommand("delete", "Deletes a server channel.")]
[SlashRequirePermissions(Permissions.ManageChannels)]
public async Task DeleteChannel(InteractionContext ctx, [Option("channel", "Channel to delete.")] DiscordChannel channel)
{
await channel.DeleteAsync().ConfigureAwait(false);
await ctx.CreateResponseAsync($"Deleted channel #{Formatter.Bold(channel.Name)}.").ConfigureAwait(false);
}

/// <summary>
/// Returns information about a server channel.
/// </summary>
[SlashCommand("info", "Returns information about a server channel.")]
public Task GetChannelInfo(InteractionContext ctx, [Option("channel", "Channel to retrieve information from.")] DiscordChannel channel)
{
Expand All @@ -108,7 +93,6 @@ public Task GetChannelInfo(InteractionContext ctx, [Option("channel", "Channel t
.WithColor(Program.Settings.DefaultColor);

// Add topic if it exists and target is not a category.
// BUG - DSharpPlus returns null even though a channel has a topic.
if (!channel.IsCategory && channel.Topic is not null)
output.WithDescription($"Topic: {channel.Topic}");

Expand All @@ -131,10 +115,7 @@ public Task GetChannelInfo(InteractionContext ctx, [Option("channel", "Channel t
return ctx.CreateResponseAsync(output.Build());
}

/// <summary>
/// Removes messages from current channel.
/// </summary>
[SlashCommand("clean", "Removes messages from current channel.")]
[SlashCommand("clean", "Removes messages from the current server channel.")]
[SlashRequirePermissions(Permissions.ManageMessages)]
public async Task DeleteChannelMessages(InteractionContext ctx, [Option("count", "Number of messages to remove from the current channel.")] double count)
{
Expand All @@ -143,10 +124,7 @@ public async Task DeleteChannelMessages(InteractionContext ctx, [Option("count",
await ctx.CreateResponseAsync($"Removed {Formatter.Bold(messages.Count.ToString())} message(s) removed from #{ctx.Channel.Name}.").ConfigureAwait(false);
}

/// <summary>
/// Rename a server channel.
/// </summary>
[SlashCommand("rename", "Rename a server channel.")]
[SlashCommand("rename", "Changes the server channel name.")]
[SlashRequirePermissions(Permissions.ManageChannels)]
public async Task SetChannelName(InteractionContext ctx, [Option("channel", "Channel to rename.")] DiscordChannel channel, [Option("name", "New channel name.")] string name)
{
Expand All @@ -161,9 +139,6 @@ public async Task SetChannelName(InteractionContext ctx, [Option("channel", "Cha
await ctx.CreateResponseAsync($"Renamed channel #{Formatter.Bold(oldName)} to #{Formatter.Bold(name)}.").ConfigureAwait(false);
}

/// <summary>
/// Changes the server channel topic.
/// </summary>
[SlashCommand("topic", "Changes the server channel topic.")]
[SlashRequirePermissions(Permissions.ManageChannels)]
public async Task SetChannelTopic(InteractionContext ctx, [Option("topic", "New channel topic.")] string topic = "")
Expand Down
3 changes: 0 additions & 3 deletions src/FlawBOT/Modules/DictionaryModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ namespace FlawBOT.Modules
{
public class DictionaryModule : ApplicationCommandModule
{
/// <summary>
/// Returns a definition for a word of phrase from Urban Dictionary.
/// </summary>
[SlashCommand("define", "Returns a definition for a word of phrase from Urban Dictionary.")]
public async Task GetDictionaryDefinition(InteractionContext ctx, [Option("query", "Word or phrase to search on Urban Dictionary.")] string query = "")
{
Expand Down
Loading

0 comments on commit 8fa10b3

Please sign in to comment.