Code cleanup

This commit is contained in:
2022-10-12 20:29:00 +03:00
parent 21f1975fbc
commit 0abbd24b86
24 changed files with 1521 additions and 1438 deletions

View File

@@ -1,10 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using Discord;
using Discord.Commands;
using Discord.WebSocket;
using PluginManager;
using PluginManager.Interfaces;
using PluginManager.Loaders;
@@ -62,16 +58,14 @@ internal class Help : DBCommand
var embedBuilder = new EmbedBuilder();
var adminCommands = "";
var adminCommands = "";
var normalCommands = "";
foreach (var cmd in PluginLoader.Commands!)
{
if (cmd.requireAdmin)
adminCommands += cmd.Command + " ";
else
normalCommands += cmd.Command + " ";
}
embedBuilder.AddField("Admin Commands", adminCommands);
embedBuilder.AddField("Normal Commands", normalCommands);
@@ -81,7 +75,8 @@ internal class Help : DBCommand
private EmbedBuilder GenerateHelpCommand(string command)
{
var embedBuilder = new EmbedBuilder();
var cmd = PluginLoader.Commands!.Find(p => p.Command == command || (p.Aliases is not null && p.Aliases.Contains(command)));
var cmd = PluginLoader.Commands!.Find(p => p.Command == command ||
(p.Aliases is not null && p.Aliases.Contains(command)));
if (cmd == null) return null;
embedBuilder.AddField("Usage", Config.GetValue<string>("prefix") + cmd.Usage);
@@ -92,4 +87,4 @@ internal class Help : DBCommand
return embedBuilder;
}
}
}

View File

@@ -1,10 +1,8 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Discord.WebSocket;
using PluginManager.Interfaces;
using PluginManager.Others;
using PluginManager.Others.Permissions;
using DiscordLibCommands = Discord.Commands;
using DiscordLib = Discord;
using OperatingSystem = PluginManager.Others.OperatingSystem;
@@ -42,7 +40,7 @@ internal class Restart : DBCommand
public async void ExecuteServer(DiscordLibCommands.SocketCommandContext context)
{
var args = Functions.GetArguments(context.Message);
var OS = Functions.GetOperatingSystem();
var OS = Functions.GetOperatingSystem();
if (args.Count == 0)
{
switch (OS)
@@ -99,4 +97,4 @@ internal class Restart : DBCommand
break;
}
}
}
}

View File

@@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using Discord;
using Discord.Commands;
using Discord.WebSocket;
using PluginManager;
using PluginManager.Interfaces;
@@ -44,12 +40,14 @@ internal class Settings : DBCommand
try
{
var content = context.Message.Content;
var data = content.Split(' ');
var data = content.Split(' ');
var keyword = data[1];
if (keyword.ToLower() == "help")
{
await channel.SendMessageAsync("set token [new value] -- set the value of the new token (require restart)");
await channel.SendMessageAsync("set prefix [new value] -- set the value of the new preifx (require restart)");
await channel.SendMessageAsync(
"set token [new value] -- set the value of the new token (require restart)");
await channel.SendMessageAsync(
"set prefix [new value] -- set the value of the new preifx (require restart)");
return;
}
@@ -86,4 +84,4 @@ internal class Settings : DBCommand
await channel.SendMessageAsync("Unknown usage to this command !\nUsage: " + Usage);
}
}
}
}