This commit is contained in:
13
.idea/.idea.SethDiscordBot/.idea/.gitignore
generated
vendored
Normal file
13
.idea/.idea.SethDiscordBot/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Rider ignored files
|
||||||
|
/projectSettingsUpdater.xml
|
||||||
|
/contentModel.xml
|
||||||
|
/.idea.SethDiscordBot.iml
|
||||||
|
/modules.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
1
.idea/.idea.SethDiscordBot/.idea/.name
generated
Normal file
1
.idea/.idea.SethDiscordBot/.idea/.name
generated
Normal file
@@ -0,0 +1 @@
|
|||||||
|
SethDiscordBot
|
||||||
4
.idea/.idea.SethDiscordBot/.idea/encodings.xml
generated
Normal file
4
.idea/.idea.SethDiscordBot/.idea/encodings.xml
generated
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||||
|
</project>
|
||||||
8
.idea/.idea.SethDiscordBot/.idea/indexLayout.xml
generated
Normal file
8
.idea/.idea.SethDiscordBot/.idea/indexLayout.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="UserContentModel">
|
||||||
|
<attachedFolders />
|
||||||
|
<explicitIncludes />
|
||||||
|
<explicitExcludes />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/.idea.SethDiscordBot/.idea/vcs.xml
generated
Normal file
6
.idea/.idea.SethDiscordBot/.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -11,6 +11,8 @@ internal class Level : DBCommand
|
|||||||
{
|
{
|
||||||
public string Command => "level";
|
public string Command => "level";
|
||||||
|
|
||||||
|
public List<string> Aliases => new() { "lvl" };
|
||||||
|
|
||||||
public string Description => "Display tour current level";
|
public string Description => "Display tour current level";
|
||||||
|
|
||||||
public string Usage => "level";
|
public string Usage => "level";
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using PluginManager.Interfaces;
|
using PluginManager.Interfaces;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
internal class Echo : DBCommand
|
internal class Echo : DBCommand
|
||||||
{
|
{
|
||||||
public string Command => "echo";
|
public string Command => "echo";
|
||||||
|
|
||||||
|
public List<string> Aliases => null;
|
||||||
|
|
||||||
public string Description => "Replay with the same message";
|
public string Description => "Replay with the same message";
|
||||||
|
|
||||||
public string Usage => "echo [message]";
|
public string Usage => "echo [message]";
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using PluginManager.Interfaces;
|
using PluginManager.Interfaces;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace CMD_Utils;
|
namespace CMD_Utils;
|
||||||
|
|
||||||
@@ -8,6 +9,8 @@ internal class FlipCoin : DBCommand
|
|||||||
{
|
{
|
||||||
public string Command => "flip";
|
public string Command => "flip";
|
||||||
|
|
||||||
|
public List<string> Aliases => null;
|
||||||
|
|
||||||
public string Description => "Flip a coin";
|
public string Description => "Flip a coin";
|
||||||
|
|
||||||
public string Usage => "flip";
|
public string Usage => "flip";
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ public class Poll : DBCommand
|
|||||||
{
|
{
|
||||||
public string Command => "poll";
|
public string Command => "poll";
|
||||||
|
|
||||||
|
public List<string> Aliases => null;
|
||||||
|
|
||||||
public string Description => "Create a poll with options";
|
public string Description => "Create a poll with options";
|
||||||
|
|
||||||
public string Usage => "poll [This-is-question] [This-is-answer-1] [This-is-answer-2] ... ";
|
public string Usage => "poll [This-is-question] [This-is-answer-1] [This-is-answer-2] ... ";
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Discord.Commands;
|
using System.Collections.Generic;
|
||||||
|
using Discord.Commands;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using PluginManager.Interfaces;
|
using PluginManager.Interfaces;
|
||||||
|
|
||||||
@@ -6,6 +7,8 @@ public class Random : DBCommand
|
|||||||
{
|
{
|
||||||
public string Command => "random";
|
public string Command => "random";
|
||||||
|
|
||||||
|
public List<string> Aliases => new() { "rnd" };
|
||||||
|
|
||||||
public string Description => "random number between number1 and number2";
|
public string Description => "random number between number1 and number2";
|
||||||
|
|
||||||
public string Usage => "random [number1] [number2]";
|
public string Usage => "random [number1] [number2]";
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using Discord;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Discord;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using PluginManager.Interfaces;
|
using PluginManager.Interfaces;
|
||||||
@@ -17,15 +19,17 @@ internal class Help : DBCommand
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string Command => "help";
|
public string Command => "help";
|
||||||
|
|
||||||
|
public List<string> Aliases => null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Command Description
|
/// Command Description
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Description => "This command allows you to check all loadded commands";
|
public string Description => "This command allows you to check all loaded commands";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Command usage
|
/// Command usage
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Usage => "help";
|
public string Usage => "help <command>";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check if the command can be used <inheritdoca DM <see cref="IChannel" />/>
|
/// Check if the command can be used <inheritdoca DM <see cref="IChannel" />/>
|
||||||
@@ -57,10 +61,10 @@ internal class Help : DBCommand
|
|||||||
foreach (var item in args)
|
foreach (var item in args)
|
||||||
{
|
{
|
||||||
var e = GenerateHelpCommand(item);
|
var e = GenerateHelpCommand(item);
|
||||||
if (e != null)
|
if (e is null)
|
||||||
context.Channel.SendMessageAsync(embed: e.Build());
|
|
||||||
else
|
|
||||||
context.Channel.SendMessageAsync("Unknown Command " + item);
|
context.Channel.SendMessageAsync("Unknown Command " + item);
|
||||||
|
else
|
||||||
|
context.Channel.SendMessageAsync(embed: e.Build());
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -74,10 +78,12 @@ internal class Help : DBCommand
|
|||||||
|
|
||||||
foreach (var cmd in PluginLoader.Commands!)
|
foreach (var cmd in PluginLoader.Commands!)
|
||||||
{
|
{
|
||||||
if (cmd.canUseDM) DMCommands += cmd.Command + " ";
|
if (cmd.canUseDM)
|
||||||
|
DMCommands += cmd.Command + " ";
|
||||||
if (cmd.requireAdmin)
|
if (cmd.requireAdmin)
|
||||||
adminCommands += cmd.Command + " ";
|
adminCommands += cmd.Command + " ";
|
||||||
else if (cmd.canUseServer) normalCommands += cmd.Command + " ";
|
if (cmd.canUseServer)
|
||||||
|
normalCommands += cmd.Command + " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
embedBuilder.AddField("Admin Commands", adminCommands);
|
embedBuilder.AddField("Admin Commands", adminCommands);
|
||||||
@@ -89,11 +95,14 @@ internal class Help : DBCommand
|
|||||||
private EmbedBuilder GenerateHelpCommand(string command)
|
private EmbedBuilder GenerateHelpCommand(string command)
|
||||||
{
|
{
|
||||||
var embedBuilder = new EmbedBuilder();
|
var embedBuilder = new EmbedBuilder();
|
||||||
var cmd = PluginLoader.Commands.Find(p => p.Command == command);
|
var cmd = PluginLoader.Commands!.Find(p => p.Command == command || (p.Aliases is not null && p.Aliases.Contains(command)));
|
||||||
if (cmd == null) return null;
|
if (cmd == null) return null;
|
||||||
|
|
||||||
embedBuilder.AddField("Usage", cmd.Usage);
|
embedBuilder.AddField("Usage", cmd.Usage);
|
||||||
embedBuilder.AddField("Description", cmd.Description);
|
embedBuilder.AddField("Description", cmd.Description);
|
||||||
|
if (cmd.Aliases is null)
|
||||||
|
return embedBuilder;
|
||||||
|
embedBuilder.AddField("Alias", cmd.Aliases.Count == 0 ? "-" : string.Join(", ", cmd.Aliases));
|
||||||
|
|
||||||
return embedBuilder;
|
return embedBuilder;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using PluginManager.Interfaces;
|
using PluginManager.Interfaces;
|
||||||
@@ -17,6 +18,8 @@ internal class Restart : DBCommand
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string Command => "restart";
|
public string Command => "restart";
|
||||||
|
|
||||||
|
public List<string> Aliases => null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Command Description
|
/// Command Description
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using Discord;
|
using Discord;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
@@ -14,6 +15,8 @@ internal class Settings : DBCommand
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string Command => "set";
|
public string Command => "set";
|
||||||
|
|
||||||
|
public List<string> Aliases => null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Command Description
|
/// Command Description
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -60,7 +60,9 @@ internal class Boot
|
|||||||
/// <returns>Task</returns>
|
/// <returns>Task</returns>
|
||||||
public async Task Awake()
|
public async Task Awake()
|
||||||
{
|
{
|
||||||
client = new DiscordSocketClient();
|
DiscordSocketConfig config = new DiscordSocketConfig { AlwaysDownloadUsers = true };
|
||||||
|
|
||||||
|
client = new DiscordSocketClient(config);
|
||||||
service = new CommandService();
|
service = new CommandService();
|
||||||
|
|
||||||
CommonTasks();
|
CommonTasks();
|
||||||
|
|||||||
@@ -47,13 +47,16 @@ internal class CommandHandler
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (Message as SocketUserMessage == null) return;
|
if (Message as SocketUserMessage == null)
|
||||||
|
return;
|
||||||
|
|
||||||
var message = Message as SocketUserMessage;
|
var message = Message as SocketUserMessage;
|
||||||
|
|
||||||
if (message == null) return;
|
if (message == null)
|
||||||
|
return;
|
||||||
|
|
||||||
if (!message.Content.StartsWith(botPrefix)) return;
|
if (!message.Content.StartsWith(botPrefix))
|
||||||
|
return;
|
||||||
|
|
||||||
var argPos = 0;
|
var argPos = 0;
|
||||||
|
|
||||||
@@ -63,17 +66,14 @@ internal class CommandHandler
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.Author.IsBot) return;
|
if (message.Author.IsBot)
|
||||||
|
return;
|
||||||
|
|
||||||
var context = new SocketCommandContext(client, message);
|
var context = new SocketCommandContext(client, message);
|
||||||
|
|
||||||
await commandService.ExecuteAsync(
|
await commandService.ExecuteAsync(context, argPos, null);
|
||||||
context,
|
|
||||||
argPos,
|
|
||||||
null
|
|
||||||
);
|
|
||||||
|
|
||||||
var plugin = PluginLoader.Commands!.Where(p => p.Command == message.Content.Split(' ')[0].Substring(botPrefix.Length)).FirstOrDefault();
|
var plugin = PluginLoader.Commands!.Where(p => p.Command == message.Content.Split(' ')[0].Substring(botPrefix.Length) || (p.Aliases is not null && p.Aliases.Contains(message.Content.Split(' ')[0].Substring(botPrefix.Length)))).FirstOrDefault();
|
||||||
|
|
||||||
|
|
||||||
if (plugin != null)
|
if (plugin != null)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<StartupObject />
|
<StartupObject />
|
||||||
<SignAssembly>False</SignAssembly>
|
<SignAssembly>False</SignAssembly>
|
||||||
<IsPublishable>True</IsPublishable>
|
<IsPublishable>True</IsPublishable>
|
||||||
<AssemblyVersion>1.0.0.1</AssemblyVersion>
|
<AssemblyVersion>1.0.0.2</AssemblyVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
|||||||
@@ -34,6 +34,38 @@ public class Program
|
|||||||
Directory.CreateDirectory("./Data/Plugins/Events");
|
Directory.CreateDirectory("./Data/Plugins/Events");
|
||||||
PreLoadComponents().Wait();
|
PreLoadComponents().Wait();
|
||||||
|
|
||||||
|
if (!Config.ContainsKey("ServerID"))
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
Console.Clear();
|
||||||
|
Console.WriteLine("Please enter the server ID: ");
|
||||||
|
Console_Utilities.WriteColorText("You can find it in the Server Settings at &r\"Widget\"&c section");
|
||||||
|
Console.WriteLine("Example: 1234567890123456789");
|
||||||
|
|
||||||
|
Console.WriteLine("This is not required, but is recommended. If you refuse to provide the ID, just press enter.\nThe server id is required to make easier for the bot to interact with the server.\nRemember: this bot is for one server ONLY.");
|
||||||
|
Console.Write("User Input > ");
|
||||||
|
ConsoleKeyInfo key = Console.ReadKey();
|
||||||
|
if (key.Key == ConsoleKey.Enter)
|
||||||
|
Config.AddValueToVariables("ServerID", "null", false);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string SID = key.KeyChar + Console.ReadLine();
|
||||||
|
if (SID.Length != 18)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Your server ID is not 18 characters long. Please try again.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Config.AddValueToVariables("ServerID", SID, false);
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
} while (true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (!Config.ContainsKey("token") || Config.GetValue<string>("token") == null || Config.GetValue<string>("token")?.Length != 70)
|
if (!Config.ContainsKey("token") || Config.GetValue<string>("token") == null || Config.GetValue<string>("token")?.Length != 70)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Please insert your token");
|
Console.WriteLine("Please insert your token");
|
||||||
@@ -75,9 +107,13 @@ public class Program
|
|||||||
private static void NoGUI(Boot discordbooter)
|
private static void NoGUI(Boot discordbooter)
|
||||||
{
|
{
|
||||||
var consoleCommandsHandler = new ConsoleCommandsHandler(discordbooter.client);
|
var consoleCommandsHandler = new ConsoleCommandsHandler(discordbooter.client);
|
||||||
|
#if DEBUG
|
||||||
|
Console.WriteLine();
|
||||||
|
consoleCommandsHandler.HandleCommand("lp");
|
||||||
|
#else
|
||||||
if (loadPluginsOnStartup) consoleCommandsHandler.HandleCommand("lp");
|
if (loadPluginsOnStartup) consoleCommandsHandler.HandleCommand("lp");
|
||||||
if (listPluginsAtStartup) consoleCommandsHandler.HandleCommand("listplugs");
|
if (listPluginsAtStartup) consoleCommandsHandler.HandleCommand("listplugs");
|
||||||
|
#endif
|
||||||
Config.SaveConfig();
|
Config.SaveConfig();
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
@@ -264,9 +300,9 @@ public class Program
|
|||||||
Config.PluginConfig.Load();
|
Config.PluginConfig.Load();
|
||||||
|
|
||||||
if (!Config.ContainsKey("Version"))
|
if (!Config.ContainsKey("Version"))
|
||||||
Config.AddValueToVariables("Version", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(), false);
|
Config.AddValueToVariables("Version", Assembly.GetExecutingAssembly().GetName().Version.ToString(), false);
|
||||||
else
|
else
|
||||||
Config.SetValue("Version", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
|
Config.SetValue("Version", Assembly.GetExecutingAssembly().GetName().Version.ToString());
|
||||||
|
|
||||||
foreach (var key in OnlineDefaultKeys)
|
foreach (var key in OnlineDefaultKeys)
|
||||||
{
|
{
|
||||||
@@ -311,7 +347,7 @@ public class Program
|
|||||||
Console.WriteLine("\n\n");
|
Console.WriteLine("\n\n");
|
||||||
await Task.Delay(1000);
|
await Task.Delay(1000);
|
||||||
|
|
||||||
int waitTime = 20; //wait time to proceed
|
int waitTime = 10; //wait time to proceed
|
||||||
|
|
||||||
Console.Write($"The bot will start in {waitTime} seconds");
|
Console.Write($"The bot will start in {waitTime} seconds");
|
||||||
while (waitTime > 0)
|
while (waitTime > 0)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Discord.Commands;
|
using System.Collections.Generic;
|
||||||
|
using Discord.Commands;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using PluginManager.Interfaces;
|
using PluginManager.Interfaces;
|
||||||
|
|
||||||
@@ -8,6 +9,8 @@ internal class Leave : DBCommand
|
|||||||
{
|
{
|
||||||
public string Command => "leave";
|
public string Command => "leave";
|
||||||
|
|
||||||
|
public List<string> Aliases => null;
|
||||||
|
|
||||||
public string Description => "Leave the voice channel";
|
public string Description => "Leave the voice channel";
|
||||||
|
|
||||||
public string Usage => "leave";
|
public string Usage => "leave";
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ namespace MusicCommands;
|
|||||||
|
|
||||||
internal class MusicPlayer
|
internal class MusicPlayer
|
||||||
{
|
{
|
||||||
private Stream outputStream { get; }
|
private Stream outputStream { get; }
|
||||||
|
internal AudioFile NowPlaying = null;
|
||||||
|
|
||||||
internal bool isPlaying, isPaused;
|
internal bool isPlaying, isPaused;
|
||||||
|
|
||||||
@@ -14,9 +15,10 @@ internal class MusicPlayer
|
|||||||
outputStream = outputChannel;
|
outputStream = outputChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Play(Stream source, int byteSize)
|
public async Task Play(Stream source, int byteSize, AudioFile songPlaying)
|
||||||
{
|
{
|
||||||
isPlaying = true;
|
isPlaying = true;
|
||||||
|
NowPlaying = songPlaying;
|
||||||
while (isPlaying)
|
while (isPlaying)
|
||||||
{
|
{
|
||||||
if (isPaused)
|
if (isPaused)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Discord.Commands;
|
using System.Collections.Generic;
|
||||||
|
using Discord.Commands;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using PluginManager.Interfaces;
|
using PluginManager.Interfaces;
|
||||||
|
|
||||||
@@ -8,6 +9,8 @@ internal class Pause : DBCommand
|
|||||||
{
|
{
|
||||||
public string Command => "pause";
|
public string Command => "pause";
|
||||||
|
|
||||||
|
public List<string> Aliases => null;
|
||||||
|
|
||||||
public string Description => "Pause/Unpause the music that is currently running";
|
public string Description => "Pause/Unpause the music that is currently running";
|
||||||
|
|
||||||
public string Usage => "pause";
|
public string Usage => "pause";
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Discord;
|
using Discord;
|
||||||
@@ -14,6 +15,8 @@ internal class Play : DBCommand
|
|||||||
{
|
{
|
||||||
public string Command => "play";
|
public string Command => "play";
|
||||||
|
|
||||||
|
public List<string> Aliases => new() { "p" };
|
||||||
|
|
||||||
public string Description => "Play music from a file";
|
public string Description => "Play music from a file";
|
||||||
|
|
||||||
public string Usage => "play [name/url]";
|
public string Usage => "play [name/url]";
|
||||||
@@ -69,11 +72,11 @@ internal class Play : DBCommand
|
|||||||
|
|
||||||
if (Data.MusicPlayer is not null)
|
if (Data.MusicPlayer is not null)
|
||||||
{
|
{
|
||||||
await context.Channel.SendMessageAsync("Enqueued your request");
|
await context.Channel.SendMessageAsync("Queued your request: " + splitted.MergeStrings(1));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (false);
|
while (false); // run only one time !
|
||||||
|
|
||||||
|
|
||||||
Data.voiceChannel = (context.User as IGuildUser)?.VoiceChannel;
|
Data.voiceChannel = (context.User as IGuildUser)?.VoiceChannel;
|
||||||
@@ -93,15 +96,14 @@ internal class Play : DBCommand
|
|||||||
|
|
||||||
using (var discordChanneAudioOutStream = Data.audioClient.CreatePCMStream(AudioApplication.Mixed))
|
using (var discordChanneAudioOutStream = Data.audioClient.CreatePCMStream(AudioApplication.Mixed))
|
||||||
{
|
{
|
||||||
if (Data.MusicPlayer is null)
|
Data.MusicPlayer ??= new MusicPlayer(discordChanneAudioOutStream);
|
||||||
Data.MusicPlayer = new MusicPlayer(discordChanneAudioOutStream);
|
|
||||||
while (Data.Playlist.Count > 0)
|
while (Data.Playlist.Count > 0)
|
||||||
{
|
{
|
||||||
var nowPlaying = Data.Playlist.GetNextSong;
|
var nowPlaying = Data.Playlist.GetNextSong;
|
||||||
using (var ffmpeg = CreateStream(nowPlaying.Name))
|
using (var ffmpeg = CreateStream(nowPlaying.Name))
|
||||||
using (var ffmpegOutputBaseStream = ffmpeg.StandardOutput.BaseStream)
|
using (var ffmpegOutputBaseStream = ffmpeg.StandardOutput.BaseStream)
|
||||||
{
|
{
|
||||||
await Data.MusicPlayer.Play(ffmpegOutputBaseStream, 1024);
|
await Data.MusicPlayer.Play(ffmpegOutputBaseStream, 1024, nowPlaying);
|
||||||
Console.WriteLine("Finished playing from " + nowPlaying.Url);
|
Console.WriteLine("Finished playing from " + nowPlaying.Url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,7 +112,7 @@ internal class Play : DBCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Process CreateStream(string path)
|
private static Process CreateStream(string path)
|
||||||
{
|
{
|
||||||
return Process.Start(new ProcessStartInfo { FileName = "ffmpeg", Arguments = $"-hide_banner -loglevel panic -i \"{path}\" -ac 2 -f s16le -ar 48000 pipe:1", UseShellExecute = false, RedirectStandardOutput = true });
|
return Process.Start(new ProcessStartInfo { FileName = "ffmpeg", Arguments = $"-hide_banner -loglevel panic -i \"{path}\" -ac 2 -f s16le -ar 48000 pipe:1", UseShellExecute = false, RedirectStandardOutput = true });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ namespace MusicCommands
|
|||||||
{
|
{
|
||||||
public string Command => "skip";
|
public string Command => "skip";
|
||||||
|
|
||||||
|
public List<string> Aliases => null;
|
||||||
|
|
||||||
public string Description => "skip the music that is currently running";
|
public string Description => "skip the music that is currently running";
|
||||||
|
|
||||||
public string Usage => "skip";
|
public string Usage => "skip";
|
||||||
@@ -25,7 +27,16 @@ namespace MusicCommands
|
|||||||
|
|
||||||
public void Execute(SocketCommandContext context, SocketMessage message, DiscordSocketClient client, bool isDM)
|
public void Execute(SocketCommandContext context, SocketMessage message, DiscordSocketClient client, bool isDM)
|
||||||
{
|
{
|
||||||
|
var loadedSong = Data.MusicPlayer.NowPlaying;
|
||||||
|
|
||||||
|
if (loadedSong is null || Data.MusicPlayer.isPlaying == false)
|
||||||
|
{
|
||||||
|
message.Channel.SendMessageAsync("There is no music playing");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Data.MusicPlayer.isPlaying = false;
|
Data.MusicPlayer.isPlaying = false;
|
||||||
|
message.Channel.SendMessageAsync($"You have skipped {loadedSong.Name}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ namespace MusicCommands
|
|||||||
{
|
{
|
||||||
public class queue : DBCommand
|
public class queue : DBCommand
|
||||||
{
|
{
|
||||||
public string Command => "queue";
|
public string Command => "queue";
|
||||||
|
public List<string> Aliases => new() { "q" };
|
||||||
|
|
||||||
public string Description => "check queue";
|
public string Description => "check queue";
|
||||||
|
|
||||||
|
|||||||
@@ -67,9 +67,9 @@ namespace PluginManager
|
|||||||
public static PluginType GetPluginType(string pluginName)
|
public static PluginType GetPluginType(string pluginName)
|
||||||
{
|
{
|
||||||
foreach (var tuple in InstalledPlugins)
|
foreach (var tuple in InstalledPlugins)
|
||||||
{
|
if (tuple.Item1 == pluginName)
|
||||||
if (tuple.Item1 == pluginName) return tuple.Item2;
|
return tuple.Item2;
|
||||||
}
|
|
||||||
|
|
||||||
return PluginType.Unknown;
|
return PluginType.Unknown;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Discord.Commands;
|
using System.Collections.Generic;
|
||||||
|
using Discord.Commands;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
|
|
||||||
namespace PluginManager.Interfaces;
|
namespace PluginManager.Interfaces;
|
||||||
@@ -11,6 +12,11 @@ public interface DBCommand
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
string Command { get; }
|
string Command { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Command aliases. Users may use this to execute the command
|
||||||
|
/// </summary>
|
||||||
|
List<string>? Aliases { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Command description
|
/// Command description
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -44,8 +50,5 @@ public interface DBCommand
|
|||||||
/// <param name="message">The message that the user types</param>
|
/// <param name="message">The message that the user types</param>
|
||||||
/// <param name="client">The discord client of the bot</param>
|
/// <param name="client">The discord client of the bot</param>
|
||||||
/// <param name="isDM">true if the message was sent from DM, otherwise false. It is always false if canUseDM is false</param>
|
/// <param name="isDM">true if the message was sent from DM, otherwise false. It is always false if canUseDM is false</param>
|
||||||
void Execute(SocketCommandContext context,
|
void Execute(SocketCommandContext context, SocketMessage message, DiscordSocketClient client, bool isDM);
|
||||||
SocketMessage message,
|
|
||||||
DiscordSocketClient client,
|
|
||||||
bool isDM);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ public class Command
|
|||||||
|
|
||||||
public class ConsoleCommand
|
public class ConsoleCommand
|
||||||
{
|
{
|
||||||
public string CommandName { get; set; }
|
public string CommandName { get; init; }
|
||||||
public string Description { get; set; }
|
public string Description { get; init; }
|
||||||
public string Usage { get; set; }
|
public string Usage { get; init; }
|
||||||
public Action<string[]> Action { get; set; }
|
public Action<string[]> Action { get; init; }
|
||||||
}
|
}
|
||||||
@@ -233,15 +233,15 @@ public class ConsoleCommandsHandler
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
AddCommand("sd", "Shuts down the discord bot", async () =>
|
AddCommand("sd", "Shuts down the discord bot", () =>
|
||||||
{
|
{
|
||||||
if (client is null)
|
if (client is null)
|
||||||
return;
|
return;
|
||||||
await client.StopAsync();
|
client.StopAsync();
|
||||||
await client.DisposeAsync();
|
client.DisposeAsync();
|
||||||
Config.SaveConfig();
|
Config.SaveConfig();
|
||||||
Console.WriteLine("Bot is closing in 2 seconds ! Please wait to save data !");
|
Console.WriteLine("Bot is closing in 2 seconds ! Please wait to save data !");
|
||||||
await Task.Delay(2000);
|
Thread.Sleep(2000);
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -268,7 +268,7 @@ public class ConsoleCommandsHandler
|
|||||||
|
|
||||||
public static bool CommandExists(string command)
|
public static bool CommandExists(string command)
|
||||||
{
|
{
|
||||||
return !(GetCommand(command) is null);
|
return GetCommand(command) is not null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ConsoleCommand? GetCommand(string command)
|
public static ConsoleCommand? GetCommand(string command)
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ namespace PluginManager.Others
|
|||||||
if (!File.Exists(archFile)) throw new FileNotFoundException("Failed to load file !");
|
if (!File.Exists(archFile)) throw new FileNotFoundException("Failed to load file !");
|
||||||
|
|
||||||
using ZipArchive archive = ZipFile.OpenRead(archFile);
|
using ZipArchive archive = ZipFile.OpenRead(archFile);
|
||||||
ZipArchiveEntry? entry = archive.GetEntry(FileName);
|
ZipArchiveEntry? entry = archive.GetEntry(FileName);
|
||||||
return entry?.Open();
|
return entry?.Open();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,8 +91,8 @@ namespace PluginManager.Others
|
|||||||
/// <returns>A string built based on the array</returns>
|
/// <returns>A string built based on the array</returns>
|
||||||
public static string MergeStrings(this string[] s, int indexToStart)
|
public static string MergeStrings(this string[] s, int indexToStart)
|
||||||
{
|
{
|
||||||
string r = "";
|
string r = "";
|
||||||
int len = s.Length;
|
int len = s.Length;
|
||||||
if (len <= indexToStart) return "";
|
if (len <= indexToStart) return "";
|
||||||
for (int i = indexToStart; i < len - 1; ++i)
|
for (int i = indexToStart; i < len - 1; ++i)
|
||||||
{
|
{
|
||||||
@@ -142,9 +142,9 @@ namespace PluginManager.Others
|
|||||||
if (!stream.CanRead) throw new InvalidOperationException("The stream is not readable.");
|
if (!stream.CanRead) throw new InvalidOperationException("The stream is not readable.");
|
||||||
if (!destination.CanWrite) throw new ArgumentException("Destination stream is not writable", nameof(destination));
|
if (!destination.CanWrite) throw new ArgumentException("Destination stream is not writable", nameof(destination));
|
||||||
|
|
||||||
byte[] buffer = new byte[bufferSize];
|
byte[] buffer = new byte[bufferSize];
|
||||||
long totalBytesRead = 0;
|
long totalBytesRead = 0;
|
||||||
int bytesRead;
|
int bytesRead;
|
||||||
while ((bytesRead = await stream.ReadAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(false)) != 0)
|
while ((bytesRead = await stream.ReadAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(false)) != 0)
|
||||||
{
|
{
|
||||||
await destination.WriteAsync(buffer, 0, bytesRead, cancellationToken).ConfigureAwait(false);
|
await destination.WriteAsync(buffer, 0, bytesRead, cancellationToken).ConfigureAwait(false);
|
||||||
@@ -171,11 +171,11 @@ namespace PluginManager.Others
|
|||||||
{
|
{
|
||||||
if (type == UnzipProgressType.PercentageFromNumberOfFiles)
|
if (type == UnzipProgressType.PercentageFromNumberOfFiles)
|
||||||
{
|
{
|
||||||
int totalZIPFiles = archive.Entries.Count();
|
int totalZIPFiles = archive.Entries.Count();
|
||||||
int currentZIPFile = 0;
|
int currentZIPFile = 0;
|
||||||
foreach (ZipArchiveEntry entry in archive.Entries)
|
foreach (ZipArchiveEntry entry in archive.Entries)
|
||||||
{
|
{
|
||||||
if (entry.FullName.EndsWith("/"))
|
if (entry.FullName.EndsWith("/")) // it is a folder
|
||||||
Directory.CreateDirectory(Path.Combine(folder, entry.FullName));
|
Directory.CreateDirectory(Path.Combine(folder, entry.FullName));
|
||||||
|
|
||||||
else
|
else
|
||||||
@@ -335,7 +335,7 @@ namespace PluginManager.Others
|
|||||||
using (MD5 md5 = MD5.Create())
|
using (MD5 md5 = MD5.Create())
|
||||||
{
|
{
|
||||||
byte[] inputBytes = Encoding.ASCII.GetBytes(input);
|
byte[] inputBytes = Encoding.ASCII.GetBytes(input);
|
||||||
byte[] hashBytes = md5.ComputeHash(inputBytes);
|
byte[] hashBytes = md5.ComputeHash(inputBytes);
|
||||||
return Convert.ToHexString(hashBytes);
|
return Convert.ToHexString(hashBytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EVE_LevelingSystem", "EVE_L
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CMD_LevelingSystem", "CMD_LevelingSystem\CMD_LevelingSystem.csproj", "{1A4E49FF-9A0A-4C54-AF35-CFFBA64353D9}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CMD_LevelingSystem", "CMD_LevelingSystem\CMD_LevelingSystem.csproj", "{1A4E49FF-9A0A-4C54-AF35-CFFBA64353D9}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Roles", "Roles\Roles.csproj", "{954F2AA9-6624-4554-946D-0F17B84487C3}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -51,6 +53,10 @@ Global
|
|||||||
{1A4E49FF-9A0A-4C54-AF35-CFFBA64353D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{1A4E49FF-9A0A-4C54-AF35-CFFBA64353D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{1A4E49FF-9A0A-4C54-AF35-CFFBA64353D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{1A4E49FF-9A0A-4C54-AF35-CFFBA64353D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{1A4E49FF-9A0A-4C54-AF35-CFFBA64353D9}.Release|Any CPU.Build.0 = Release|Any CPU
|
{1A4E49FF-9A0A-4C54-AF35-CFFBA64353D9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{954F2AA9-6624-4554-946D-0F17B84487C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{954F2AA9-6624-4554-946D-0F17B84487C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{954F2AA9-6624-4554-946D-0F17B84487C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{954F2AA9-6624-4554-946D-0F17B84487C3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@@ -62,6 +68,7 @@ Global
|
|||||||
{B1B4976E-5112-4217-B57B-3A03C5207B6E} = {449FA364-0B72-43FF-B3A3-806E2916200E}
|
{B1B4976E-5112-4217-B57B-3A03C5207B6E} = {449FA364-0B72-43FF-B3A3-806E2916200E}
|
||||||
{EEC445DC-0C4B-43EA-8694-606BA0390B77} = {A290C028-77C4-4D1D-AB43-DDFE6ABD9012}
|
{EEC445DC-0C4B-43EA-8694-606BA0390B77} = {A290C028-77C4-4D1D-AB43-DDFE6ABD9012}
|
||||||
{1A4E49FF-9A0A-4C54-AF35-CFFBA64353D9} = {449FA364-0B72-43FF-B3A3-806E2916200E}
|
{1A4E49FF-9A0A-4C54-AF35-CFFBA64353D9} = {449FA364-0B72-43FF-B3A3-806E2916200E}
|
||||||
|
{954F2AA9-6624-4554-946D-0F17B84487C3} = {449FA364-0B72-43FF-B3A3-806E2916200E}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {3FB3C5DE-ED21-4D2E-ABDD-3A00EE4A2FFF}
|
SolutionGuid = {3FB3C5DE-ED21-4D2E-ABDD-3A00EE4A2FFF}
|
||||||
|
|||||||
Reference in New Issue
Block a user