Archived
0
0
Fork 0

feat: just lots of stuff added

This commit is contained in:
Daryl Ronningen 2021-10-01 19:11:21 -07:00
parent 061ea355af
commit 2ae87f1c2d
Signed by: Daryl Ronningen
GPG key ID: FD23F0C934A5EC6B
13 changed files with 163 additions and 93 deletions

2
.gitignore vendored
View file

@ -1,4 +1,4 @@
.vs .vs
appsettings.json appsettings.json
bin bin
obj obj

View file

@ -1,4 +1,4 @@
 GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007 Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>

View file

@ -1,4 +1,4 @@

Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sharpy", "Sharpy\Sharpy.csproj", "{57AEE340-B119-49C8-9217-D87250628498}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sharpy", "Sharpy\Sharpy.csproj", "{57AEE340-B119-49C8-9217-D87250628498}"
EndProject EndProject

View file

@ -14,7 +14,9 @@ namespace Sharpy.Commands.Msg.General
{ {
public class Info : BaseCommandModule 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) public async Task InfoCommand(CommandContext ctx)
{ {
var clientMember = from member in ctx.Guild.Members var clientMember = from member in ctx.Guild.Members

View file

@ -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}!");
}
}
}

View file

@ -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());
}
}
}

View file

@ -1,4 +1,4 @@
using System; using System;
using System.Reflection; using System.Reflection;
using System.Threading.Tasks; using System.Threading.Tasks;
using DSharpPlus; using DSharpPlus;
@ -49,7 +49,6 @@ var services = new ServiceCollection()
/* /*
var interactivity = discord.UseInteractivity(); var interactivity = discord.UseInteractivity();
var voice = discord.UseVoiceNext();
*/ */
// Register Msg Commands // Register Msg Commands
@ -85,7 +84,7 @@ await lavalink.ConnectAsync(new LavalinkConfiguration
{ {
Hostname = config.GetSection("lavalink").GetValue<string>("host"), Hostname = config.GetSection("lavalink").GetValue<string>("host"),
Port = config.GetSection("lavalink").GetValue<int>("port"), Port = config.GetSection("lavalink").GetValue<int>("port"),
Secured = true Secured = false
}, },
ResumeTimeout = 30, ResumeTimeout = 30,
SocketAutoReconnect = true, SocketAutoReconnect = true,
@ -93,7 +92,7 @@ await lavalink.ConnectAsync(new LavalinkConfiguration
{ {
Hostname = config.GetSection("lavalink").GetValue<string>("host"), Hostname = config.GetSection("lavalink").GetValue<string>("host"),
Port = config.GetSection("lavalink").GetValue<int>("port"), Port = config.GetSection("lavalink").GetValue<int>("port"),
Secured = true Secured = false
}, },
WebSocketCloseTimeout = 30 WebSocketCloseTimeout = 30
}); });

View file

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>x64</Platform>
<PublishDir>bin\x64\Release\net6.0\publish\linux-x64\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>net6.0</TargetFramework>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
<SelfContained>false</SelfContained>
<PublishSingleFile>True</PublishSingleFile>
</PropertyGroup>
</Project>

View file

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>x64</Platform>
<PublishDir>bin\x64\Release\net6.0\publish\linux-x64\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>net6.0</TargetFramework>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>True</PublishSingleFile>
<PublishTrimmed>True</PublishTrimmed>
</PropertyGroup>
</Project>

View file

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>x64</Platform>
<PublishDir>bin\x64\Release\net6.0\publish\win-x64\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>net6.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>false</SelfContained>
<PublishSingleFile>True</PublishSingleFile>
<PublishReadyToRun>False</PublishReadyToRun>
</PropertyGroup>
</Project>

View file

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>x64</Platform>
<PublishDir>bin\x64\Release\net6.0\publish\win-x64\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>net6.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>True</PublishSingleFile>
<PublishReadyToRun>False</PublishReadyToRun>
<PublishTrimmed>True</PublishTrimmed>
</PropertyGroup>
</Project>

View file

@ -33,19 +33,17 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ByteSize" Version="2.0.0" /> <PackageReference Include="ByteSize" Version="2.1.0" />
<PackageReference Include="DSharpPlus" Version="4.2.0-nightly-00987" /> <PackageReference Include="DSharpPlus" Version="4.2.0-nightly-01011" />
<PackageReference Include="DSharpPlus.CommandsNext" Version="4.2.0-nightly-00987" /> <PackageReference Include="DSharpPlus.CommandsNext" Version="4.2.0-nightly-01011" />
<PackageReference Include="DSharpPlus.Interactivity" Version="4.2.0-nightly-00987" /> <PackageReference Include="DSharpPlus.Interactivity" Version="4.2.0-nightly-01011" />
<PackageReference Include="DSharpPlus.Lavalink" Version="4.2.0-nightly-00987" /> <PackageReference Include="DSharpPlus.Lavalink" Version="4.2.0-nightly-01011" />
<PackageReference Include="DSharpPlus.Rest" Version="4.2.0-nightly-00987" /> <PackageReference Include="Hardware.Info" Version="1.1.1.1" />
<PackageReference Include="DSharpPlus.VoiceNext" Version="4.2.0-nightly-00987" /> <PackageReference Include="IDoEverything.DSharpPlus.SlashCommands" Version="2.0.4" />
<PackageReference Include="Hardware.Info" Version="1.1.1" /> <PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.0-rc.1.21451.13" />
<PackageReference Include="IDoEverything.DSharpPlus.SlashCommands" Version="2.0.1" /> <PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0-rc.1.21451.13" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.0-preview.7.21377.19" /> <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="6.0.0-rc.1.21451.13" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0-preview.7.21377.19" /> <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0-rc.1.21451.13" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="6.0.0-preview.7.21377.19" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0-preview.7.21377.19" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -54,8 +52,4 @@
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Commands\Msg\Music" />
</ItemGroup>
</Project> </Project>

48
application.yml Normal file
View file

@ -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