Compare commits
No commits in common. "c7b933b3f83ce0b07ce25d674d9ff78c505daa2b" and "e44338c1da39f6e43d9371537500547f31701a0a" have entirely different histories.
c7b933b3f8
...
e44338c1da
27 changed files with 208 additions and 570 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,4 +1,4 @@
|
||||||
.vs
|
.vs
|
||||||
appsettings.json
|
appsettings.json
|
||||||
bin
|
bin
|
||||||
obj
|
obj
|
||||||
|
|
1
.idea/.idea.CSharpBot/.idea/.name
Normal file
1
.idea/.idea.CSharpBot/.idea/.name
Normal file
|
@ -0,0 +1 @@
|
||||||
|
CSharpBot
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
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}") = "CSharpBot", "CSharpBot\CSharpBot.csproj", "{57AEE340-B119-49C8-9217-D87250628498}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
61
CSharpBot/CSharpBot.csproj
Normal file
61
CSharpBot/CSharpBot.csproj
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<IsPackable>false</IsPackable>
|
||||||
|
<Configurations>Release;Debug</Configurations>
|
||||||
|
<Platforms>x64</Platforms>
|
||||||
|
<Authors>Relms</Authors>
|
||||||
|
<Company>Relms</Company>
|
||||||
|
<Version>0.0.1</Version>
|
||||||
|
<Description>Advanced C# Discord Bot made in DSharpPlus and .NET 6 Preview</Description>
|
||||||
|
<Copyright>Copyright 2021 Relms</Copyright>
|
||||||
|
<PackageProjectUrl>https://code.relms.dev/Relms/Sharpy</PackageProjectUrl>
|
||||||
|
<RepositoryUrl>https://code.relms.dev/Relms/Sharpy</RepositoryUrl>
|
||||||
|
<NeutralLanguage>en-US</NeutralLanguage>
|
||||||
|
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
|
||||||
|
<AssemblyName>CSharpBot</AssemblyName>
|
||||||
|
<PackageId>CSharpBot</PackageId>
|
||||||
|
<RepositoryType>git</RepositoryType>
|
||||||
|
<AssemblyVersion>0.0.1.0</AssemblyVersion>
|
||||||
|
<FileVersion>0.0.1.0</FileVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
|
||||||
|
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
||||||
|
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||||
|
<WarningLevel>5</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
|
||||||
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
|
<WarningLevel>5</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="DSharpPlus" Version="4.2.0-nightly-00973" />
|
||||||
|
<PackageReference Include="DSharpPlus.CommandsNext" Version="4.2.0-nightly-00973" />
|
||||||
|
<PackageReference Include="DSharpPlus.Interactivity" Version="4.2.0-nightly-00973" />
|
||||||
|
<PackageReference Include="DSharpPlus.Lavalink" Version="4.2.0-nightly-00973" />
|
||||||
|
<PackageReference Include="DSharpPlus.Rest" Version="4.2.0-nightly-00973" />
|
||||||
|
<PackageReference Include="DSharpPlus.VoiceNext" Version="4.2.0-nightly-00973" />
|
||||||
|
<PackageReference Include="IDoEverything.DSharpPlus.SlashCommands" Version="2.0.1" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.0-preview.7.21377.19" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0-preview.7.21377.19" />
|
||||||
|
<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>
|
||||||
|
<None Update="appsettings.json">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Commands" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
74
CSharpBot/Program.cs
Normal file
74
CSharpBot/Program.cs
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using DSharpPlus;
|
||||||
|
using DSharpPlus.CommandsNext;
|
||||||
|
using DSharpPlus.Entities;
|
||||||
|
using DSharpPlus.Interactivity.Extensions;
|
||||||
|
using DSharpPlus.Lavalink;
|
||||||
|
using DSharpPlus.SlashCommands;
|
||||||
|
using DSharpPlus.VoiceNext;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
IConfiguration config = new ConfigurationBuilder()
|
||||||
|
.AddJsonFile("appsettings.json", false, true)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
var discord = new DiscordClient(new DiscordConfiguration
|
||||||
|
{
|
||||||
|
AlwaysCacheMembers = true,
|
||||||
|
AutoReconnect = true,
|
||||||
|
GatewayCompressionLevel = GatewayCompressionLevel.Stream,
|
||||||
|
HttpTimeout = TimeSpan.FromSeconds(10),
|
||||||
|
Intents = DiscordIntents.All,
|
||||||
|
LogTimestampFormat = "MMM dd yyyy - hh:mm:ss tt",
|
||||||
|
MinimumLogLevel = LogLevel.Debug,
|
||||||
|
ReconnectIndefinitely = false,
|
||||||
|
Token = config.GetValue<string>("token"),
|
||||||
|
TokenType = TokenType.Bot
|
||||||
|
});
|
||||||
|
#else
|
||||||
|
var discord = new DiscordClient(new DiscordConfiguration
|
||||||
|
{
|
||||||
|
AlwaysCacheMembers = true,
|
||||||
|
AutoReconnect = true,
|
||||||
|
GatewayCompressionLevel = GatewayCompressionLevel.Stream,
|
||||||
|
HttpTimeout = TimeSpan.FromSeconds(10),
|
||||||
|
Intents = DiscordIntents.All,
|
||||||
|
LogTimestampFormat = "MMM dd yyyy - hh:mm:ss tt",
|
||||||
|
MinimumLogLevel = LogLevel.Information,
|
||||||
|
ReconnectIndefinitely = false,
|
||||||
|
Token = config.GetValue<string>("token"),
|
||||||
|
TokenType = TokenType.Bot,
|
||||||
|
});
|
||||||
|
#endif
|
||||||
|
|
||||||
|
var services = new ServiceCollection()
|
||||||
|
.BuildServiceProvider();
|
||||||
|
|
||||||
|
/*var slash = discord.UseSlashCommands();
|
||||||
|
var lavalink = discord.UseLavalink();
|
||||||
|
var interactivity = discord.UseInteractivity();
|
||||||
|
var voice = discord.UseVoiceNext();*/
|
||||||
|
|
||||||
|
// register commands
|
||||||
|
var commands = discord.UseCommandsNext(new CommandsNextConfiguration
|
||||||
|
{
|
||||||
|
CaseSensitive = false,
|
||||||
|
DmHelp = false,
|
||||||
|
EnableDefaultHelp = true,
|
||||||
|
EnableDms = true,
|
||||||
|
EnableMentionPrefix = true,
|
||||||
|
IgnoreExtraArguments = false,
|
||||||
|
Services = services,
|
||||||
|
StringPrefixes = new[] { "!" },
|
||||||
|
UseDefaultCommandHandler = true
|
||||||
|
});
|
||||||
|
|
||||||
|
commands.RegisterCommands(Assembly.GetExecutingAssembly());
|
||||||
|
|
||||||
|
await discord.ConnectAsync(new DiscordActivity("With DSharpPlus"));
|
||||||
|
await Task.Delay(-1);
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?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>
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?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>
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?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>
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?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>
|
|
@ -1,7 +0,0 @@
|
||||||
FROM debian:11.0-slim
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
COPY Sharpy/bin/x64/Release/net6.0/publish/linux-x64/Sharpy .
|
|
||||||
|
|
||||||
ENTRYPOINT [ "./Sharpy" ]
|
|
2
LICENSE
2
LICENSE
|
@ -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/>
|
||||||
|
|
|
@ -1,62 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using ByteSizeLib;
|
|
||||||
using DSharpPlus;
|
|
||||||
using DSharpPlus.Entities;
|
|
||||||
using DSharpPlus.SlashCommands;
|
|
||||||
using Hardware.Info;
|
|
||||||
|
|
||||||
namespace Sharpy.Commands.General
|
|
||||||
{
|
|
||||||
public class Info : ApplicationCommandModule
|
|
||||||
{
|
|
||||||
[SlashCommand("info", "Get info about the bot")]
|
|
||||||
public async Task InfoCommand(InteractionContext ctx)
|
|
||||||
{
|
|
||||||
var clientMember = from member in ctx.Guild.Members
|
|
||||||
where member.Value.Id == ctx.Client.CurrentUser.Id
|
|
||||||
select member.Value;
|
|
||||||
|
|
||||||
var roleColor = clientMember.First().Color;
|
|
||||||
|
|
||||||
await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource,
|
|
||||||
new DiscordInteractionResponseBuilder { Content = "Loading..." });
|
|
||||||
|
|
||||||
var hardwareInfo = new HardwareInfo();
|
|
||||||
hardwareInfo.RefreshCPUList();
|
|
||||||
hardwareInfo.RefreshMemoryStatus();
|
|
||||||
|
|
||||||
var currentRamUsage =
|
|
||||||
Math.Round(
|
|
||||||
Convert.ToDecimal(ByteSize
|
|
||||||
.FromBytes(hardwareInfo.MemoryStatus.TotalPhysical - hardwareInfo.MemoryStatus.AvailablePhysical)
|
|
||||||
.GibiBytes), 2);
|
|
||||||
|
|
||||||
var totalRamUsage =
|
|
||||||
Math.Round(Convert.ToDecimal(ByteSize.FromBytes(hardwareInfo.MemoryStatus.TotalPhysical).GibiBytes), 2);
|
|
||||||
|
|
||||||
var embed = new DiscordEmbedBuilder()
|
|
||||||
.WithAuthor("Sharpy")
|
|
||||||
.WithColor(roleColor)
|
|
||||||
.WithDescription(@$"**Library Version**: DSharpPlus Version {ctx.Client.VersionString}
|
|
||||||
**Bot Version**: {Assembly.GetExecutingAssembly().GetName().Name} Version {Assembly.GetExecutingAssembly().GetName().Version}
|
|
||||||
|
|
||||||
**Bot Stats**
|
|
||||||
**Servers**: {ctx.Client.Guilds.Count}
|
|
||||||
**Shards**: {ctx.Client.ShardCount} (Current Shard: {ctx.Client.ShardId})
|
|
||||||
|
|
||||||
**System Stats**
|
|
||||||
**OS**: {RuntimeInformation.RuntimeIdentifier}
|
|
||||||
**CPU**: {hardwareInfo.CpuList.First().Name} (x{hardwareInfo.CpuList.Count})
|
|
||||||
**Process RAM Usage**: {Math.Round(Convert.ToDecimal(ByteSize.FromBytes(Process.GetCurrentProcess().WorkingSet64).MebiBytes), 2)}MB
|
|
||||||
**Total RAM Usage**: {currentRamUsage}GB/{totalRamUsage}GB ({Math.Round(currentRamUsage / totalRamUsage * 100, 2)}%)")
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
await ctx.EditResponseAsync(new DiscordWebhookBuilder().AddEmbed(embed));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,52 +0,0 @@
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using DSharpPlus;
|
|
||||||
using DSharpPlus.Entities;
|
|
||||||
using DSharpPlus.Lavalink;
|
|
||||||
using DSharpPlus.SlashCommands;
|
|
||||||
using DSharpPlus.SlashCommands.Attributes;
|
|
||||||
|
|
||||||
namespace Sharpy.Commands.Music
|
|
||||||
{
|
|
||||||
public class Play : ApplicationCommandModule
|
|
||||||
{
|
|
||||||
[SlashCommand("play", "Plays a song")]
|
|
||||||
[SlashRequireGuild]
|
|
||||||
public async Task PlayCommand(InteractionContext ctx,
|
|
||||||
[Option("song", "The song to play. (Accepts YouTube URLs too)")] string song)
|
|
||||||
{
|
|
||||||
if (ctx.Member.VoiceState == null || ctx.Member.VoiceState.Channel == null)
|
|
||||||
{
|
|
||||||
await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource,
|
|
||||||
new DiscordInteractionResponseBuilder { Content = "You are not in a voice channel." });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var lava = ctx.Client.GetLavalink();
|
|
||||||
|
|
||||||
if (!lava.ConnectedNodes.Any())
|
|
||||||
{
|
|
||||||
await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource,
|
|
||||||
new DiscordInteractionResponseBuilder { Content = "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(song);
|
|
||||||
|
|
||||||
if (loadResult.LoadResultType is LavalinkLoadResultType.LoadFailed or LavalinkLoadResultType.NoMatches)
|
|
||||||
{
|
|
||||||
await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource,
|
|
||||||
new DiscordInteractionResponseBuilder { Content = $"Track search failed for {song}." });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var track = loadResult.Tracks.First();
|
|
||||||
|
|
||||||
await conn.PlayAsync(track);
|
|
||||||
await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource,
|
|
||||||
new DiscordInteractionResponseBuilder { Content = $"Now playing {track.Title}!" });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,49 +0,0 @@
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using DSharpPlus;
|
|
||||||
using DSharpPlus.Entities;
|
|
||||||
using DSharpPlus.Lavalink;
|
|
||||||
using DSharpPlus.SlashCommands;
|
|
||||||
using DSharpPlus.SlashCommands.Attributes;
|
|
||||||
|
|
||||||
namespace Sharpy.Commands.Music
|
|
||||||
{
|
|
||||||
public class Search : ApplicationCommandModule
|
|
||||||
{
|
|
||||||
[SlashCommand("search", "Searches for songs")]
|
|
||||||
[SlashRequireGuild]
|
|
||||||
public async Task SearchCommand(InteractionContext ctx,
|
|
||||||
[Option("search", "The song to search for. (Accepts YouTube URLs too)")] string search)
|
|
||||||
{
|
|
||||||
var lava = ctx.Client.GetLavalink();
|
|
||||||
|
|
||||||
if (!lava.ConnectedNodes.Any())
|
|
||||||
{
|
|
||||||
await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource,
|
|
||||||
new DiscordInteractionResponseBuilder { Content = "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.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource,
|
|
||||||
new DiscordInteractionResponseBuilder { Content = $"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.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource,
|
|
||||||
new DiscordInteractionResponseBuilder().AddEmbed(embed.Build()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Sharpy.Database.Models;
|
|
||||||
|
|
||||||
namespace Sharpy.Database
|
|
||||||
{
|
|
||||||
public class Context : DbContext
|
|
||||||
{
|
|
||||||
public DbSet<Infractions> Infractions { get; set; }
|
|
||||||
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
||||||
{
|
|
||||||
optionsBuilder.UseNpgsql(
|
|
||||||
$"Host={Sharpy.config.GetSection("database").GetValue<string>("host")};Port={Sharpy.config.GetSection("database").GetValue<string>("port")};Database={Sharpy.config.GetSection("database").GetValue<string>("database")};Username={Sharpy.config.GetSection("database").GetValue<string>("username")};Password={Sharpy.config.GetSection("database").GetValue<string>("password")}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
|
|
||||||
namespace Sharpy.Database.Models
|
|
||||||
{
|
|
||||||
public class Infractions
|
|
||||||
{
|
|
||||||
[Key]
|
|
||||||
public Guid InfractionId { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public InfractionTypes InfractionType { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public string InfractionReason { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public ulong UserId { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum InfractionTypes
|
|
||||||
{
|
|
||||||
Ban,
|
|
||||||
Kick,
|
|
||||||
Mute,
|
|
||||||
Warn
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
using Sharpy.Database;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace Sharpy.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(Context))]
|
|
||||||
[Migration("20211016030853_InitialCreate")]
|
|
||||||
partial class InitialCreate
|
|
||||||
{
|
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("ProductVersion", "6.0.0-rc.2.21480.5")
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
|
||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
|
||||||
|
|
||||||
modelBuilder.Entity("Sharpy.Database.Models.Infractions", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("InfractionId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("InfractionReason")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<int>("InfractionType")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<decimal>("UserId")
|
|
||||||
.HasColumnType("numeric(20,0)");
|
|
||||||
|
|
||||||
b.HasKey("InfractionId");
|
|
||||||
|
|
||||||
b.ToTable("Infractions");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace Sharpy.Migrations
|
|
||||||
{
|
|
||||||
public partial class InitialCreate : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Infractions",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
InfractionId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
||||||
InfractionType = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
InfractionReason = table.Column<string>(type: "text", nullable: false),
|
|
||||||
UserId = table.Column<decimal>(type: "numeric(20,0)", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Infractions", x => x.InfractionId);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Infractions");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,48 +0,0 @@
|
||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
using Sharpy.Database;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace Sharpy.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(Context))]
|
|
||||||
partial class ContextModelSnapshot : ModelSnapshot
|
|
||||||
{
|
|
||||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("ProductVersion", "6.0.0-rc.2.21480.5")
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
|
||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
|
||||||
|
|
||||||
modelBuilder.Entity("Sharpy.Database.Models.Infractions", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("InfractionId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("InfractionReason")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<int>("InfractionType")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<decimal>("UserId")
|
|
||||||
.HasColumnType("numeric(20,0)");
|
|
||||||
|
|
||||||
b.HasKey("InfractionId");
|
|
||||||
|
|
||||||
b.ToTable("Infractions");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,103 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using DSharpPlus;
|
|
||||||
using DSharpPlus.Entities;
|
|
||||||
using DSharpPlus.Lavalink;
|
|
||||||
using DSharpPlus.Net;
|
|
||||||
using DSharpPlus.SlashCommands;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Sharpy.Commands.General;
|
|
||||||
using Sharpy.Commands.Music;
|
|
||||||
#if RELEASE
|
|
||||||
using System.Net;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace Sharpy
|
|
||||||
{
|
|
||||||
public static class Sharpy
|
|
||||||
{
|
|
||||||
public static readonly IConfiguration config = new ConfigurationBuilder()
|
|
||||||
.AddJsonFile("appsettings.json", false, true)
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
public static async Task Main()
|
|
||||||
{
|
|
||||||
#if DEBUG
|
|
||||||
var discord = new DiscordClient(new DiscordConfiguration
|
|
||||||
{
|
|
||||||
AlwaysCacheMembers = true,
|
|
||||||
AutoReconnect = true,
|
|
||||||
GatewayCompressionLevel = GatewayCompressionLevel.Stream,
|
|
||||||
HttpTimeout = TimeSpan.FromSeconds(10),
|
|
||||||
Intents = DiscordIntents.All,
|
|
||||||
LogTimestampFormat = "MMM dd yyyy - hh:mm:ss tt",
|
|
||||||
MinimumLogLevel = LogLevel.Debug,
|
|
||||||
ReconnectIndefinitely = false,
|
|
||||||
Token = config.GetValue<string>("token"),
|
|
||||||
TokenType = TokenType.Bot
|
|
||||||
});
|
|
||||||
#else
|
|
||||||
var discord = new DiscordClient(new DiscordConfiguration
|
|
||||||
{
|
|
||||||
AlwaysCacheMembers = true,
|
|
||||||
AutoReconnect = true,
|
|
||||||
GatewayCompressionLevel = GatewayCompressionLevel.Stream,
|
|
||||||
HttpTimeout = TimeSpan.FromSeconds(10),
|
|
||||||
Intents = DiscordIntents.All,
|
|
||||||
LogTimestampFormat = "MMM dd yyyy - hh:mm:ss tt",
|
|
||||||
MinimumLogLevel = LogLevel.Information,
|
|
||||||
ReconnectIndefinitely = false,
|
|
||||||
ShardCount = Convert.ToInt32(Dns.GetHostName().Substring(Dns.GetHostName().IndexOf('-') + 1)),
|
|
||||||
ShardId = Convert.ToInt32(Dns.GetHostName().Substring(Dns.GetHostName().IndexOf('-') + 1)),
|
|
||||||
Token = config.GetValue<string>("token"),
|
|
||||||
TokenType = TokenType.Bot,
|
|
||||||
});
|
|
||||||
#endif
|
|
||||||
|
|
||||||
var services = new ServiceCollection()
|
|
||||||
.BuildServiceProvider();
|
|
||||||
|
|
||||||
// Register Lavalink
|
|
||||||
var lavalink = discord.UseLavalink();
|
|
||||||
|
|
||||||
// Register Slash Commands
|
|
||||||
var slash = discord.UseSlashCommands(new SlashCommandsConfiguration
|
|
||||||
{
|
|
||||||
Services = services
|
|
||||||
});
|
|
||||||
|
|
||||||
// Register Commands
|
|
||||||
// General
|
|
||||||
slash.RegisterCommands<Info>(772228301552222258);
|
|
||||||
|
|
||||||
// Music
|
|
||||||
slash.RegisterCommands<Play>(772228301552222258);
|
|
||||||
slash.RegisterCommands<Search>(772228301552222258);
|
|
||||||
|
|
||||||
await discord.ConnectAsync(new DiscordActivity("With DSharpPlus"));
|
|
||||||
await lavalink.ConnectAsync(new LavalinkConfiguration
|
|
||||||
{
|
|
||||||
Password = config.GetSection("lavalink").GetValue<string>("password"),
|
|
||||||
RestEndpoint = new ConnectionEndpoint
|
|
||||||
{
|
|
||||||
Hostname = config.GetSection("lavalink").GetValue<string>("host"),
|
|
||||||
Port = config.GetSection("lavalink").GetValue<int>("port"),
|
|
||||||
Secured = false
|
|
||||||
},
|
|
||||||
ResumeTimeout = 30,
|
|
||||||
SocketAutoReconnect = true,
|
|
||||||
SocketEndpoint = new ConnectionEndpoint
|
|
||||||
{
|
|
||||||
Hostname = config.GetSection("lavalink").GetValue<string>("host"),
|
|
||||||
Port = config.GetSection("lavalink").GetValue<int>("port"),
|
|
||||||
Secured = false
|
|
||||||
},
|
|
||||||
WebSocketCloseTimeout = 30
|
|
||||||
});
|
|
||||||
|
|
||||||
await Task.Delay(-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,69 +0,0 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>Exe</OutputType>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<Nullable>disable</Nullable>
|
|
||||||
<IsPackable>false</IsPackable>
|
|
||||||
<Configurations>Release;Debug</Configurations>
|
|
||||||
<Platforms>x64</Platforms>
|
|
||||||
<TrimMode>link</TrimMode>
|
|
||||||
<TrimmerRemoveSymbols>true</TrimmerRemoveSymbols>
|
|
||||||
<DebuggerSupport>false</DebuggerSupport>
|
|
||||||
<EnableUnsafeBinaryFormatterSerialization>false</EnableUnsafeBinaryFormatterSerialization>
|
|
||||||
<EventSourceSupport>false</EventSourceSupport>
|
|
||||||
<HttpActivityPropagationSupport>false</HttpActivityPropagationSupport>
|
|
||||||
<InvariantGlobalization>true</InvariantGlobalization>
|
|
||||||
<MetadataUpdaterSupport>false</MetadataUpdaterSupport>
|
|
||||||
<UseNativeHttpHandler>true</UseNativeHttpHandler>
|
|
||||||
<UseSystemResourceKeys>true</UseSystemResourceKeys>
|
|
||||||
<AssemblyVersion>0.0.1.0</AssemblyVersion>
|
|
||||||
<FileVersion>0.0.1.0</FileVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
|
|
||||||
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
|
||||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
|
||||||
<DebugType>none</DebugType>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
|
|
||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
|
||||||
<DebugType>full</DebugType>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="ByteSize" Version="2.1.0" />
|
|
||||||
<PackageReference Include="DSharpPlus" Version="4.2.0-nightly-01030" />
|
|
||||||
<PackageReference Include="DSharpPlus.Interactivity" Version="4.2.0-nightly-01030" />
|
|
||||||
<PackageReference Include="DSharpPlus.Lavalink" Version="4.2.0-nightly-01030" />
|
|
||||||
<PackageReference Include="DSharpPlus.SlashCommands" Version="4.2.0-nightly-01030" />
|
|
||||||
<PackageReference Include="Hardware.Info" Version="1.1.1.1" />
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0-rc.2.21480.5" />
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0-rc.2.21480.5">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0-rc.2.21480.5">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.0-rc.2.21480.5" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0-rc.2.21480.5" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="6.0.0-rc.2.21480.5" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0-rc.2.21480.5" />
|
|
||||||
<PackageReference Include="NATS.Client" Version="0.14.0-pre3" />
|
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.0-rc.2" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Update="appsettings.json">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Commands\Moderation" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
|
@ -1,48 +0,0 @@
|
||||||
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
|
|
Reference in a new issue