diff --git a/.gitignore b/.gitignore
index 04452b3..ece4fbd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
-.vs
+.vs
appsettings.json
bin
obj
diff --git a/LICENSE b/LICENSE
index a28fa47..f288702 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
- GNU GENERAL PUBLIC LICENSE
+ GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
diff --git a/Sharpy.sln b/Sharpy.sln
index e1e302e..82dce01 100644
--- a/Sharpy.sln
+++ b/Sharpy.sln
@@ -1,4 +1,4 @@
-
+
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sharpy", "Sharpy\Sharpy.csproj", "{57AEE340-B119-49C8-9217-D87250628498}"
EndProject
diff --git a/Sharpy/Commands/Msg/General/Info.cs b/Sharpy/Commands/Msg/General/Info.cs
index a08ec85..6ac21af 100644
--- a/Sharpy/Commands/Msg/General/Info.cs
+++ b/Sharpy/Commands/Msg/General/Info.cs
@@ -14,7 +14,9 @@ namespace Sharpy.Commands.Msg.General
{
public class Info : BaseCommandModule
{
- [Command("info"), Description("Get info about the bot"), Cooldown(5, 5, CooldownBucketType.Global)]
+ [Command("info")]
+ [Cooldown(5, 5, CooldownBucketType.User)]
+ [Description("Get info about the bot")]
public async Task InfoCommand(CommandContext ctx)
{
var clientMember = from member in ctx.Guild.Members
diff --git a/Sharpy/Commands/Msg/Music/Play.cs b/Sharpy/Commands/Msg/Music/Play.cs
new file mode 100644
index 0000000..7b61526
--- /dev/null
+++ b/Sharpy/Commands/Msg/Music/Play.cs
@@ -0,0 +1,47 @@
+using System.Linq;
+using System.Threading.Tasks;
+using DSharpPlus.CommandsNext;
+using DSharpPlus.CommandsNext.Attributes;
+using DSharpPlus.Lavalink;
+
+namespace Sharpy.Commands.Msg.Music
+{
+ public class Play : BaseCommandModule
+ {
+ [Command("play")]
+ [Cooldown(5, 5, CooldownBucketType.User)]
+ [Description("Plays a song")]
+ [RequireGuild]
+ public async Task PlayCommand(CommandContext ctx, [RemainingText] string search)
+ {
+ if (ctx.Member.VoiceState == null || ctx.Member.VoiceState.Channel == null)
+ {
+ await ctx.RespondAsync("You are not in a voice channel.");
+ return;
+ }
+
+ var lava = ctx.Client.GetLavalink();
+
+ if (!lava.ConnectedNodes.Any())
+ {
+ await ctx.RespondAsync("The Lavalink connection is not established");
+ return;
+ }
+
+ var node = lava.ConnectedNodes.Values.First();
+ var conn = await node.ConnectAsync(ctx.Member.VoiceState.Channel);
+ var loadResult = await node.Rest.GetTracksAsync(search);
+
+ if (loadResult.LoadResultType is LavalinkLoadResultType.LoadFailed or LavalinkLoadResultType.NoMatches)
+ {
+ await ctx.RespondAsync($"Track search failed for {search}.");
+ return;
+ }
+
+ var track = loadResult.Tracks.First();
+
+ await conn.PlayAsync(track);
+ await ctx.RespondAsync($"Now playing {track.Title}!");
+ }
+ }
+}
diff --git a/Sharpy/Commands/Msg/Music/Search.cs b/Sharpy/Commands/Msg/Music/Search.cs
new file mode 100644
index 0000000..199fddf
--- /dev/null
+++ b/Sharpy/Commands/Msg/Music/Search.cs
@@ -0,0 +1,48 @@
+using System.Linq;
+using System.Threading.Tasks;
+using DSharpPlus.CommandsNext;
+using DSharpPlus.CommandsNext.Attributes;
+using DSharpPlus.Entities;
+using DSharpPlus.Lavalink;
+
+namespace Sharpy.Commands.Msg.Music
+{
+ public class Search : BaseCommandModule
+ {
+ [Command("search")]
+ [Cooldown(5, 5, CooldownBucketType.User)]
+ [Description("Searches for songs")]
+ [RequireGuild]
+ public async Task SearchCommand(CommandContext ctx, [RemainingText] string search)
+ {
+ var lava = ctx.Client.GetLavalink();
+
+ if (!lava.ConnectedNodes.Any())
+ {
+ await ctx.RespondAsync("The Lavalink connection is not established");
+ return;
+ }
+
+ var node = lava.ConnectedNodes.Values.First();
+ var loadResult = await node.Rest.GetTracksAsync(search);
+
+ if (loadResult.LoadResultType is LavalinkLoadResultType.LoadFailed or LavalinkLoadResultType.NoMatches)
+ {
+ await ctx.RespondAsync($"Track search failed for {search}.");
+ return;
+ }
+
+ var embed = new DiscordEmbedBuilder();
+ embed.WithTitle($"Search Results for: `{search}`");
+
+ foreach (var loadResultTrack in loadResult.Tracks)
+ {
+ embed.AddField($"**{loadResultTrack.Title}**", @$"**URL**: {loadResultTrack.Uri}
+**Author**: {loadResultTrack.Author}
+**Length**: {loadResultTrack.Length}", true);
+ }
+
+ await ctx.RespondAsync(embed.Build());
+ }
+ }
+}
diff --git a/Sharpy/Program.cs b/Sharpy/Program.cs
index cf916ea..d310518 100644
--- a/Sharpy/Program.cs
+++ b/Sharpy/Program.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Reflection;
using System.Threading.Tasks;
using DSharpPlus;
@@ -49,7 +49,6 @@ var services = new ServiceCollection()
/*
var interactivity = discord.UseInteractivity();
-var voice = discord.UseVoiceNext();
*/
// Register Msg Commands
@@ -85,7 +84,7 @@ await lavalink.ConnectAsync(new LavalinkConfiguration
{
Hostname = config.GetSection("lavalink").GetValue("host"),
Port = config.GetSection("lavalink").GetValue("port"),
- Secured = true
+ Secured = false
},
ResumeTimeout = 30,
SocketAutoReconnect = true,
@@ -93,7 +92,7 @@ await lavalink.ConnectAsync(new LavalinkConfiguration
{
Hostname = config.GetSection("lavalink").GetValue("host"),
Port = config.GetSection("lavalink").GetValue("port"),
- Secured = true
+ Secured = false
},
WebSocketCloseTimeout = 30
});
diff --git a/Sharpy/Properties/PublishProfiles/publish-linux-x64-fd.pubxml b/Sharpy/Properties/PublishProfiles/publish-linux-x64-fd.pubxml
deleted file mode 100644
index a1dd140..0000000
--- a/Sharpy/Properties/PublishProfiles/publish-linux-x64-fd.pubxml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
- Release
- x64
- bin\x64\Release\net6.0\publish\linux-x64\
- FileSystem
- net6.0
- linux-x64
- false
- True
-
-
\ No newline at end of file
diff --git a/Sharpy/Properties/PublishProfiles/publish-linux-x64-sd.pubxml b/Sharpy/Properties/PublishProfiles/publish-linux-x64-sd.pubxml
deleted file mode 100644
index 678187d..0000000
--- a/Sharpy/Properties/PublishProfiles/publish-linux-x64-sd.pubxml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
- Release
- x64
- bin\x64\Release\net6.0\publish\linux-x64\
- FileSystem
- net6.0
- linux-x64
- true
- True
- True
-
-
\ No newline at end of file
diff --git a/Sharpy/Properties/PublishProfiles/publish-win-x64-fd.pubxml b/Sharpy/Properties/PublishProfiles/publish-win-x64-fd.pubxml
deleted file mode 100644
index 1d2824f..0000000
--- a/Sharpy/Properties/PublishProfiles/publish-win-x64-fd.pubxml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
- Release
- x64
- bin\x64\Release\net6.0\publish\win-x64\
- FileSystem
- net6.0
- win-x64
- false
- True
- False
-
-
\ No newline at end of file
diff --git a/Sharpy/Properties/PublishProfiles/publish-win-x64-sd.pubxml b/Sharpy/Properties/PublishProfiles/publish-win-x64-sd.pubxml
deleted file mode 100644
index b540fcf..0000000
--- a/Sharpy/Properties/PublishProfiles/publish-win-x64-sd.pubxml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
- Release
- x64
- bin\x64\Release\net6.0\publish\win-x64\
- FileSystem
- net6.0
- win-x64
- true
- True
- False
- True
-
-
\ No newline at end of file
diff --git a/Sharpy/Sharpy.csproj b/Sharpy/Sharpy.csproj
index 7a7be53..6e7a44a 100644
--- a/Sharpy/Sharpy.csproj
+++ b/Sharpy/Sharpy.csproj
@@ -33,19 +33,17 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
@@ -54,8 +52,4 @@
-
-
-
-
diff --git a/application.yml b/application.yml
new file mode 100644
index 0000000..eff4e68
--- /dev/null
+++ b/application.yml
@@ -0,0 +1,48 @@
+server: # REST and WS server
+ port: 2333
+ address: 0.0.0.0
+lavalink:
+ server:
+ password: "youshallnotpass"
+ sources:
+ youtube: true
+ bandcamp: true
+ soundcloud: true
+ twitch: true
+ vimeo: true
+ http: true
+ local: false
+ bufferDurationMs: 400
+ youtubePlaylistLoadLimit: 6 # Number of pages at 100 each
+ playerUpdateInterval: 5 # How frequently to send player updates to clients, in seconds
+ youtubeSearchEnabled: true
+ soundcloudSearchEnabled: true
+ gc-warnings: true
+ #ratelimit:
+ #ipBlocks: ["1.0.0.0/8", "..."] # list of ip blocks
+ #excludedIps: ["...", "..."] # ips which should be explicit excluded from usage by lavalink
+ #strategy: "RotateOnBan" # RotateOnBan | LoadBalance | NanoSwitch | RotatingNanoSwitch
+ #searchTriggersFail: true # Whether a search 429 should trigger marking the ip as failing
+ #retryLimit: -1 # -1 = use default lavaplayer value | 0 = infinity | >0 = retry will happen this numbers times
+
+metrics:
+ prometheus:
+ enabled: false
+ endpoint: /metrics
+
+sentry:
+ dsn: ""
+ environment: ""
+# tags:
+# some_key: some_value
+# another_key: another_value
+
+logging:
+ file:
+ max-history: 30
+ max-size: 1GB
+ path: ./logs/
+
+ level:
+ root: INFO
+ lavalink: INFO
\ No newline at end of file