This commit is contained in:
26
.vscode/launch.json
vendored
Normal file
26
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
// Use IntelliSense to find out which attributes exist for C# debugging
|
||||||
|
// Use hover for the description of the existing attributes
|
||||||
|
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
|
||||||
|
"name": ".NET Core Launch (console)",
|
||||||
|
"type": "coreclr",
|
||||||
|
"request": "launch",
|
||||||
|
"preLaunchTask": "build",
|
||||||
|
// If you have changed target frameworks, make sure to update the program path.
|
||||||
|
"program": "${workspaceFolder}/DiscordBot/bin/Debug/net5.0/DiscordBot.dll",
|
||||||
|
"args": [],
|
||||||
|
"cwd": "${workspaceFolder}/DiscordBot",
|
||||||
|
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
|
||||||
|
"console": "internalConsole",
|
||||||
|
"stopAtEntry": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": ".NET Core Attach",
|
||||||
|
"type": "coreclr",
|
||||||
|
"request": "attach"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
5
.vscode/solution-explorer/class.cs-template
vendored
Normal file
5
.vscode/solution-explorer/class.cs-template
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
namespace {{namespace}};
|
||||||
|
|
||||||
|
public class {{name}}
|
||||||
|
{
|
||||||
|
}
|
||||||
3
.vscode/solution-explorer/class.ts-template
vendored
Normal file
3
.vscode/solution-explorer/class.ts-template
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export class {{name}} {
|
||||||
|
|
||||||
|
}
|
||||||
9
.vscode/solution-explorer/class.vb-template
vendored
Normal file
9
.vscode/solution-explorer/class.vb-template
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
Imports System
|
||||||
|
|
||||||
|
Namespace {{namespace}}
|
||||||
|
|
||||||
|
Public Class {{name}}
|
||||||
|
|
||||||
|
End Class
|
||||||
|
|
||||||
|
End Namespace
|
||||||
3
.vscode/solution-explorer/default.ts-template
vendored
Normal file
3
.vscode/solution-explorer/default.ts-template
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export default {{name}} {
|
||||||
|
|
||||||
|
}
|
||||||
5
.vscode/solution-explorer/enum.cs-template
vendored
Normal file
5
.vscode/solution-explorer/enum.cs-template
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
namespace {{namespace}};
|
||||||
|
|
||||||
|
public enum {{name}}
|
||||||
|
{
|
||||||
|
}
|
||||||
5
.vscode/solution-explorer/interface.cs-template
vendored
Normal file
5
.vscode/solution-explorer/interface.cs-template
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
namespace {{namespace}};
|
||||||
|
|
||||||
|
public interface {{name}}
|
||||||
|
{
|
||||||
|
}
|
||||||
3
.vscode/solution-explorer/interface.ts-template
vendored
Normal file
3
.vscode/solution-explorer/interface.ts-template
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export interface {{name}} {
|
||||||
|
|
||||||
|
}
|
||||||
46
.vscode/solution-explorer/template-list.json
vendored
Normal file
46
.vscode/solution-explorer/template-list.json
vendored
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
{
|
||||||
|
"templates": [
|
||||||
|
{
|
||||||
|
"name": "Class",
|
||||||
|
"extension": "cs",
|
||||||
|
"file": "./class.cs-template",
|
||||||
|
"parameters": "./template-parameters.js"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Interface",
|
||||||
|
"extension": "cs",
|
||||||
|
"file": "./interface.cs-template",
|
||||||
|
"parameters": "./template-parameters.js"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Enum",
|
||||||
|
"extension": "cs",
|
||||||
|
"file": "./enum.cs-template",
|
||||||
|
"parameters": "./template-parameters.js"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Class",
|
||||||
|
"extension": "ts",
|
||||||
|
"file": "./class.ts-template",
|
||||||
|
"parameters": "./template-parameters.js"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Interface",
|
||||||
|
"extension": "ts",
|
||||||
|
"file": "./interface.ts-template",
|
||||||
|
"parameters": "./template-parameters.js"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Default",
|
||||||
|
"extension": "ts",
|
||||||
|
"file": "./default.ts-template",
|
||||||
|
"parameters": "./template-parameters.js"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Class",
|
||||||
|
"extension": "vb",
|
||||||
|
"file": "./class.vb-template",
|
||||||
|
"parameters": "./template-parameters.js"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
17
.vscode/solution-explorer/template-parameters.js
vendored
Normal file
17
.vscode/solution-explorer/template-parameters.js
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
var path = require("path");
|
||||||
|
|
||||||
|
module.exports = function(filename, projectPath, folderPath) {
|
||||||
|
var namespace = "Unknown";
|
||||||
|
if (projectPath) {
|
||||||
|
namespace = path.basename(projectPath, path.extname(projectPath));
|
||||||
|
if (folderPath) {
|
||||||
|
namespace += "." + folderPath.replace(path.dirname(projectPath), "").substring(1).replace(/[\\\/]/g, ".");
|
||||||
|
}
|
||||||
|
namespace = namespace.replace(/[\\\-]/g, "_");
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
namespace: namespace,
|
||||||
|
name: path.basename(filename, path.extname(filename))
|
||||||
|
}
|
||||||
|
};
|
||||||
42
.vscode/tasks.json
vendored
Normal file
42
.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "build",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"build",
|
||||||
|
"${workspaceFolder}/DiscordBot/DiscordBot.csproj",
|
||||||
|
"/property:GenerateFullPaths=true",
|
||||||
|
"/consoleloggerparameters:NoSummary"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "publish",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"publish",
|
||||||
|
"${workspaceFolder}/DiscordBot/DiscordBot.csproj",
|
||||||
|
"/property:GenerateFullPaths=true",
|
||||||
|
"/consoleloggerparameters:NoSummary"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "watch",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"watch",
|
||||||
|
"run",
|
||||||
|
"${workspaceFolder}/DiscordBot/DiscordBot.csproj",
|
||||||
|
"/property:GenerateFullPaths=true",
|
||||||
|
"/consoleloggerparameters:NoSummary"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -20,6 +20,8 @@ public class level : DBCommand
|
|||||||
|
|
||||||
public bool canUseServer => true;
|
public bool canUseServer => true;
|
||||||
|
|
||||||
|
public bool requireAdmin => false;
|
||||||
|
|
||||||
public async void Execute(SocketCommandContext context, SocketMessage message, DiscordSocketClient client, bool isDM)
|
public async void Execute(SocketCommandContext context, SocketMessage message, DiscordSocketClient client, bool isDM)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ internal class Echo : DBCommand
|
|||||||
public bool canUseDM => true;
|
public bool canUseDM => true;
|
||||||
public bool canUseServer => true;
|
public bool canUseServer => true;
|
||||||
|
|
||||||
|
public bool requireAdmin => false;
|
||||||
|
|
||||||
public async void Execute(SocketCommandContext context, SocketMessage message, DiscordSocketClient client, bool isDM)
|
public async void Execute(SocketCommandContext context, SocketMessage message, DiscordSocketClient client, bool isDM)
|
||||||
{
|
{
|
||||||
string m = message.Content.Substring(6);
|
string m = message.Content.Substring(6);
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ namespace CMD_Utils
|
|||||||
|
|
||||||
public bool canUseServer => true;
|
public bool canUseServer => true;
|
||||||
|
|
||||||
|
public bool requireAdmin => false;
|
||||||
|
|
||||||
public async void Execute(SocketCommandContext context, SocketMessage message, DiscordSocketClient client, bool isDM)
|
public async void Execute(SocketCommandContext context, SocketMessage message, DiscordSocketClient client, bool isDM)
|
||||||
{
|
{
|
||||||
System.Random random = new System.Random();
|
System.Random random = new System.Random();
|
||||||
|
|||||||
53
CMD_Utils/Poll.cs
Normal file
53
CMD_Utils/Poll.cs
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
using Discord;
|
||||||
|
using Discord.Commands;
|
||||||
|
using Discord.WebSocket;
|
||||||
|
|
||||||
|
using PluginManager.Interfaces;
|
||||||
|
|
||||||
|
namespace CMD_Utils
|
||||||
|
{
|
||||||
|
public class Poll : DBCommand
|
||||||
|
{
|
||||||
|
public string Command => "poll";
|
||||||
|
|
||||||
|
public string Description => "Create a poll with options";
|
||||||
|
|
||||||
|
public string Usage => "poll [This-is-question] [This-is-answer-1] [This-is-answer-2] ... ";
|
||||||
|
|
||||||
|
public bool canUseDM => false;
|
||||||
|
|
||||||
|
public bool canUseServer => true;
|
||||||
|
|
||||||
|
public bool requireAdmin => true;
|
||||||
|
|
||||||
|
public async void Execute(SocketCommandContext context, SocketMessage message, DiscordSocketClient client, bool isDM)
|
||||||
|
{
|
||||||
|
if (isDM) return;
|
||||||
|
string question = message.Content.Split(' ')[1].Replace('-', ' ');
|
||||||
|
string[] answers = PluginManager.Others.Functions.MergeStrings(message.Content.Split(' '), 2).Split(' ');
|
||||||
|
EmbedBuilder embedBuilder = new EmbedBuilder();
|
||||||
|
embedBuilder.Title = question;
|
||||||
|
int len = answers.Length;
|
||||||
|
for (int i = 0; i < len; i++)
|
||||||
|
embedBuilder.AddField($"Answer {i + 1}", answers[i].Replace('-', ' '), true);
|
||||||
|
var msg = await context.Channel.SendMessageAsync(embed: embedBuilder.Build());
|
||||||
|
|
||||||
|
List<IEmote> emotes = new List<IEmote>();
|
||||||
|
emotes.Add(Emoji.Parse(":one:"));
|
||||||
|
emotes.Add(Emoji.Parse(":two:"));
|
||||||
|
emotes.Add(Emoji.Parse(":three:"));
|
||||||
|
emotes.Add(Emoji.Parse(":four:"));
|
||||||
|
emotes.Add(Emoji.Parse(":five:"));
|
||||||
|
emotes.Add(Emoji.Parse(":six:"));
|
||||||
|
|
||||||
|
for (int i = 0; i < len; i++)
|
||||||
|
await msg.AddReactionAsync(emotes[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,6 +13,7 @@ public class Random : DBCommand
|
|||||||
|
|
||||||
public bool canUseDM => true;
|
public bool canUseDM => true;
|
||||||
public bool canUseServer => true;
|
public bool canUseServer => true;
|
||||||
|
public bool requireAdmin => false;
|
||||||
|
|
||||||
public async void Execute(SocketCommandContext context, SocketMessage message, DiscordSocketClient client, bool isDM)
|
public async void Execute(SocketCommandContext context, SocketMessage message, DiscordSocketClient client, bool isDM)
|
||||||
{
|
{
|
||||||
|
|||||||
16
DiscordBot/Data/Languages/Romanian.lng
Normal file
16
DiscordBot/Data/Languages/Romanian.lng
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
########################
|
||||||
|
# #
|
||||||
|
# Language Config File #
|
||||||
|
# Romanian #
|
||||||
|
# #
|
||||||
|
########################
|
||||||
|
|
||||||
|
#Language name
|
||||||
|
LANGUAGE_NAME=Romanian
|
||||||
|
|
||||||
|
#Language on plugins
|
||||||
|
PLUGIN_LOADING_START=Incarcare extensii...
|
||||||
|
COMMAND_LOAD_SUCCESS=[COMANDA] Comanda {0} a fost incarcata cu succes
|
||||||
|
COMMAND_LOAD_FAIL=[COMANDA] Comanda {0} nu a fost incarcata pentru ca {1}
|
||||||
|
EVENT_LOAD_SUCCESS=[EVENIMENT] Evenimentul {0} a fost initializat cu succes
|
||||||
|
EVENT_LOAD_FAIL=[EVENIMENT] Evenimentul {0} nu a fost initializat pentru ca {1}
|
||||||
BIN
DiscordBot/Data/Plugins/Commands/CMD_LevelingSystem.dll
Normal file
BIN
DiscordBot/Data/Plugins/Commands/CMD_LevelingSystem.dll
Normal file
Binary file not shown.
BIN
DiscordBot/Data/Plugins/Commands/CMD_Utils.dll
Normal file
BIN
DiscordBot/Data/Plugins/Commands/CMD_Utils.dll
Normal file
Binary file not shown.
BIN
DiscordBot/Data/Plugins/Events/EVE_LevelingSystem.dll
Normal file
BIN
DiscordBot/Data/Plugins/Events/EVE_LevelingSystem.dll
Normal file
Binary file not shown.
BIN
DiscordBot/Data/Plugins/Events/Leveling System.dll
Normal file
BIN
DiscordBot/Data/Plugins/Events/Leveling System.dll
Normal file
Binary file not shown.
BIN
DiscordBot/Data/Plugins/Events/StartupEvents.dll
Normal file
BIN
DiscordBot/Data/Plugins/Events/StartupEvents.dll
Normal file
Binary file not shown.
2
DiscordBot/Data/Resources/DiscordBotCore.data
Normal file
2
DiscordBot/Data/Resources/DiscordBotCore.data
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
BOT_TOKEN NzEzNzczNTM1MTIxNzY4NTU5.Xsk_aA.5ZDlK_bBm_7kqTALuuzhMyjDbXI
|
||||||
|
BOT_PREFIX ;
|
||||||
1
DiscordBot/Data/Resources/Language.txt
Normal file
1
DiscordBot/Data/Resources/Language.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Language=English
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Level=1,EXP=6,REXP=75
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Level=2,EXP=10,REXP=78
|
||||||
7
DiscordBot/Data/Resources/StartupEvents/LoginEvent.txt
Normal file
7
DiscordBot/Data/Resources/StartupEvents/LoginEvent.txt
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
Enabled=False
|
||||||
|
|
||||||
|
Dynamic Title=False
|
||||||
|
#For dynamic title add titles like this:
|
||||||
|
#Title=Hello,World,Test,Test2
|
||||||
|
Title=Hello World
|
||||||
|
Dynamic Title Change Rate=3501
|
||||||
13
DiscordBot/Data/Resources/StartupEvents/UserJoinEvent.txt
Normal file
13
DiscordBot/Data/Resources/StartupEvents/UserJoinEvent.txt
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
Enabled=True
|
||||||
|
Embed=True
|
||||||
|
#Available placeholders:
|
||||||
|
#{user.Name} => Username of the user
|
||||||
|
#{time.date} => Current Date
|
||||||
|
#{time.time} => Current time (hh:mm::ss)
|
||||||
|
MessageTitle = Welcome {user.Name}
|
||||||
|
MessageDescription=Embed description
|
||||||
|
MessageField1Title=Custom Title
|
||||||
|
MessageFiled1Text=Custom Filed 1 text
|
||||||
|
MessageField2Title=Custom Title
|
||||||
|
MessageFiled2Text=Custom Filed 2 text
|
||||||
|
MessageFooter=Today: {time.date} at {time.time}
|
||||||
@@ -3,6 +3,7 @@ using Discord.WebSocket;
|
|||||||
|
|
||||||
using PluginManager.Loaders;
|
using PluginManager.Loaders;
|
||||||
using PluginManager.Interfaces;
|
using PluginManager.Interfaces;
|
||||||
|
using PluginManager.Others.Permissions;
|
||||||
|
|
||||||
namespace PluginManager.Commands
|
namespace PluginManager.Commands
|
||||||
{
|
{
|
||||||
@@ -17,20 +18,46 @@ namespace PluginManager.Commands
|
|||||||
public bool canUseDM => true;
|
public bool canUseDM => true;
|
||||||
public bool canUseServer => true;
|
public bool canUseServer => true;
|
||||||
|
|
||||||
|
public bool requireAdmin => false;
|
||||||
|
|
||||||
public void Execute(SocketCommandContext context, SocketMessage message, DiscordSocketClient client, bool isDM)
|
public void Execute(SocketCommandContext context, SocketMessage message, DiscordSocketClient client, bool isDM)
|
||||||
|
{
|
||||||
|
bool isAdmin = ((SocketGuildUser)message.Author).isAdmin();
|
||||||
|
if (isAdmin)
|
||||||
{
|
{
|
||||||
if (isDM)
|
if (isDM)
|
||||||
{
|
{
|
||||||
foreach (DBCommand p in PluginLoader.Plugins!)
|
foreach (DBCommand p in PluginLoader.Plugins!)
|
||||||
if (p.canUseDM)
|
if (p.canUseDM)
|
||||||
context.Channel.SendMessageAsync(p.Usage + "\t" + p.Description);
|
if (p.requireAdmin)
|
||||||
|
context.Channel.SendMessageAsync("[ADMIN] " + p.Usage + "\t" + p.Description);
|
||||||
|
else context.Channel.SendMessageAsync(p.Usage + "\t" + p.Description);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
foreach (DBCommand p in PluginLoader.Plugins!)
|
foreach (DBCommand p in PluginLoader.Plugins!)
|
||||||
if (p.canUseServer)
|
if (p.canUseServer)
|
||||||
|
if (p.requireAdmin)
|
||||||
|
context.Channel.SendMessageAsync("[ADMIN] " + p.Usage + "\t" + p.Description);
|
||||||
|
else context.Channel.SendMessageAsync(p.Usage + "\t" + p.Description);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (isDM)
|
||||||
|
{
|
||||||
|
foreach (DBCommand p in PluginLoader.Plugins!)
|
||||||
|
if (p.canUseDM && !p.requireAdmin)
|
||||||
context.Channel.SendMessageAsync(p.Usage + "\t" + p.Description);
|
context.Channel.SendMessageAsync(p.Usage + "\t" + p.Description);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (DBCommand p in PluginLoader.Plugins!)
|
||||||
|
if (p.canUseServer && !p.requireAdmin)
|
||||||
|
context.Channel.SendMessageAsync(p.Usage + "\t" + p.Description);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
78
DiscordBot/Discord/Commands/Settings.cs
Normal file
78
DiscordBot/Discord/Commands/Settings.cs
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
using Discord;
|
||||||
|
using Discord.Commands;
|
||||||
|
using Discord.WebSocket;
|
||||||
|
|
||||||
|
using PluginManager.Core;
|
||||||
|
using PluginManager.Interfaces;
|
||||||
|
using PluginManager.Others;
|
||||||
|
using PluginManager.Others.Permissions;
|
||||||
|
|
||||||
|
namespace DiscordBot.Discord.Commands
|
||||||
|
{
|
||||||
|
class Settings : DBCommand
|
||||||
|
{
|
||||||
|
public string Command => "set";
|
||||||
|
|
||||||
|
public string Description => "This command allows you change all settings. Use \"set help\" to show details";
|
||||||
|
|
||||||
|
public string Usage => "set [keyword] [new Value]";
|
||||||
|
|
||||||
|
public bool canUseDM => true;
|
||||||
|
public bool canUseServer => true;
|
||||||
|
public bool requireAdmin => true;
|
||||||
|
|
||||||
|
public async void Execute(SocketCommandContext context, SocketMessage message, DiscordSocketClient client, bool isDM)
|
||||||
|
{
|
||||||
|
var channel = message.Channel;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
string content = message.Content;
|
||||||
|
string[] data = content.Split(' ');
|
||||||
|
string 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)");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (keyword.ToLower())
|
||||||
|
{
|
||||||
|
case "token":
|
||||||
|
if (data.Length != 3)
|
||||||
|
{
|
||||||
|
await channel.SendMessageAsync("Invalid token !");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Functions.WriteToSettings("./Data/Resources/DiscordBotCore.data", "BOT_TOKEN", data[2], '\t');
|
||||||
|
break;
|
||||||
|
case "prefix":
|
||||||
|
if (data.Length != 3)
|
||||||
|
{
|
||||||
|
await channel.SendMessageAsync("Invalid token !");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Functions.WriteToSettings("./Data/Resources/DiscordBotCore.data", "BOT_PREFIX", data[2], '\t');
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await channel.SendMessageAsync("Restart required ...");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await channel.SendMessageAsync("Unknown usage to this command !\nUsage: " + Usage);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -46,13 +46,13 @@ namespace PluginManager.Core
|
|||||||
public async Task ShutDown()
|
public async Task ShutDown()
|
||||||
{
|
{
|
||||||
if (client == null) return;
|
if (client == null) return;
|
||||||
|
await client.LogoutAsync();
|
||||||
await client.StopAsync();
|
await client.StopAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CommonTasks()
|
private void CommonTasks()
|
||||||
{
|
{
|
||||||
if (client == null)
|
if (client == null) return;
|
||||||
return;
|
|
||||||
client.LoggedOut += Client_LoggedOut;
|
client.LoggedOut += Client_LoggedOut;
|
||||||
client.Log += Log;
|
client.Log += Log;
|
||||||
client.LoggedIn += LoggedIn;
|
client.LoggedIn += LoggedIn;
|
||||||
|
|||||||
@@ -5,10 +5,12 @@ using PluginManager.Interfaces;
|
|||||||
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using PluginManager.Others;
|
using PluginManager.Others;
|
||||||
|
using PluginManager.Others.Permissions;
|
||||||
using PluginManager.Loaders;
|
using PluginManager.Loaders;
|
||||||
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Discord;
|
||||||
|
|
||||||
namespace PluginManager.Core
|
namespace PluginManager.Core
|
||||||
{
|
{
|
||||||
@@ -18,6 +20,9 @@ namespace PluginManager.Core
|
|||||||
private readonly CommandService commandService;
|
private readonly CommandService commandService;
|
||||||
private readonly string botPrefix;
|
private readonly string botPrefix;
|
||||||
|
|
||||||
|
internal static bool awaitRestartOnSetCommand = false;
|
||||||
|
internal static SocketUser? RestartOnSetCommandCaster = null;
|
||||||
|
|
||||||
public CommandHandler(DiscordSocketClient client, CommandService commandService, string botPrefix)
|
public CommandHandler(DiscordSocketClient client, CommandService commandService, string botPrefix)
|
||||||
{
|
{
|
||||||
this.client = client;
|
this.client = client;
|
||||||
@@ -51,7 +56,26 @@ namespace PluginManager.Core
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!(message.HasStringPrefix(botPrefix, ref argPos) || message.Author.IsBot))
|
if (!(message.HasStringPrefix(botPrefix, ref argPos) || message.Author.IsBot))
|
||||||
|
if (message.Author.IsBot) return;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (awaitRestartOnSetCommand && RestartOnSetCommandCaster is not null)
|
||||||
|
{
|
||||||
|
if (message.Content.ToLower() == "yes")
|
||||||
|
{
|
||||||
|
if (!(((SocketGuildUser)message.Author).hasPermission(GuildPermission.Administrator)))
|
||||||
|
{
|
||||||
|
await message.Channel.SendMessageAsync("You do not have permission to use this command !");
|
||||||
|
awaitRestartOnSetCommand = false;
|
||||||
|
RestartOnSetCommandCaster = null;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
var fileName = Assembly.GetExecutingAssembly().Location;
|
||||||
|
System.Diagnostics.Process.Start(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var context = new SocketCommandContext(client, message);
|
var context = new SocketCommandContext(client, message);
|
||||||
|
|
||||||
@@ -63,19 +87,51 @@ namespace PluginManager.Core
|
|||||||
|
|
||||||
DBCommand? plugin = PluginLoader.Plugins!.Where(p => p.Command == (message.Content.Split(' ')[0]).Substring(botPrefix.Length)).FirstOrDefault();
|
DBCommand? plugin = PluginLoader.Plugins!.Where(p => p.Command == (message.Content.Split(' ')[0]).Substring(botPrefix.Length)).FirstOrDefault();
|
||||||
|
|
||||||
|
|
||||||
if (plugin != null)
|
if (plugin != null)
|
||||||
{
|
{
|
||||||
if (message.Channel == await message.Author.CreateDMChannelAsync())
|
if (message.Channel == await message.Author.CreateDMChannelAsync())
|
||||||
{
|
{
|
||||||
if (plugin.canUseDM)
|
if (plugin.canUseDM)
|
||||||
|
{
|
||||||
|
if (plugin.requireAdmin)
|
||||||
|
{
|
||||||
|
if (message.Author.isAdmin())
|
||||||
{
|
{
|
||||||
plugin.Execute(context, message, client, true);
|
plugin.Execute(context, message, client, true);
|
||||||
Functions.WriteLogFile("Executed command (DM) : " + plugin.Command);
|
Functions.WriteLogFile($"[{message.Author.Id}] Executed command (DM) : " + plugin.Command);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
await message.Channel.SendMessageAsync("This command is for administrators only !");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
plugin.Execute(context, message, client, true);
|
||||||
|
Functions.WriteLogFile($"[{message.Author.Id}] Executed command (DM) : " + plugin.Command);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await message.Channel.SendMessageAsync("This command is not for DMs");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (plugin.canUseServer)
|
||||||
|
{
|
||||||
|
if (plugin.requireAdmin)
|
||||||
|
{
|
||||||
|
if (message.Author.isAdmin())
|
||||||
|
{
|
||||||
|
plugin.Execute(context, message, client, false);
|
||||||
|
Functions.WriteLogFile($"[{message.Author.Id}] Executed command : " + plugin.Command);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await message.Channel.SendMessageAsync("This command is for administrators only !");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
plugin.Execute(context, message, client, false);
|
plugin.Execute(context, message, client, false);
|
||||||
Functions.WriteLogFile("Executed command : " + plugin.Command);
|
Functions.WriteLogFile($"[{message.Author.Id}] Executed command : " + plugin.Command);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
using PluginManager.Core;
|
using PluginManager.Core;
|
||||||
using PluginManager.Others;
|
using PluginManager.Others;
|
||||||
|
|
||||||
using PluginManager.Loaders;
|
using PluginManager.Loaders;
|
||||||
using PluginManager.LanguageSystem;
|
using PluginManager.LanguageSystem;
|
||||||
using PluginManager.Online;
|
using PluginManager.Online;
|
||||||
|
|
||||||
namespace DiscordBot
|
namespace DiscordBot
|
||||||
{
|
{
|
||||||
public class Program
|
public class Program
|
||||||
@@ -26,8 +26,6 @@ namespace DiscordBot
|
|||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
AppDomain.CurrentDomain.AppendPrivatePath(".\\Requirements");
|
|
||||||
Console.Clear();
|
|
||||||
Directory.CreateDirectory("./Data/Resources");
|
Directory.CreateDirectory("./Data/Resources");
|
||||||
Directory.CreateDirectory("./Data/Languages");
|
Directory.CreateDirectory("./Data/Languages");
|
||||||
Directory.CreateDirectory("./Data/Plugins/Commands");
|
Directory.CreateDirectory("./Data/Plugins/Commands");
|
||||||
@@ -39,10 +37,10 @@ namespace DiscordBot
|
|||||||
{
|
{
|
||||||
Console.WriteLine("Please insert your token: ");
|
Console.WriteLine("Please insert your token: ");
|
||||||
Console.Write("TOKEN: ");
|
Console.Write("TOKEN: ");
|
||||||
string botToken = Console.ReadLine();
|
string? botToken = Console.ReadLine();
|
||||||
if (botToken.Length == 59)
|
if (botToken.Length == 59)
|
||||||
{
|
{
|
||||||
string prefix = Functions.readCodeFromFile("./Data/Resources/DiscordBotCore.data", "BOT_PREFIX",
|
string? prefix = Functions.readCodeFromFile("./Data/Resources/DiscordBotCore.data", "BOT_PREFIX",
|
||||||
'\t');
|
'\t');
|
||||||
if (prefix == String.Empty || prefix == null)
|
if (prefix == String.Empty || prefix == null)
|
||||||
prefix = "!";
|
prefix = "!";
|
||||||
@@ -123,8 +121,10 @@ namespace DiscordBot
|
|||||||
break;
|
break;
|
||||||
case "dwlang":
|
case "dwlang":
|
||||||
string Lname = data.MergeStrings(1);
|
string Lname = data.MergeStrings(1);
|
||||||
string[] link = await languageManager.GetDownloadLink(Lname);
|
string?[] link = await languageManager.GetDownloadLink(Lname);
|
||||||
if (link[0] == null)
|
try
|
||||||
|
{
|
||||||
|
if (link[0] is null || link is null)
|
||||||
{
|
{
|
||||||
if (Lname == "")
|
if (Lname == "")
|
||||||
{
|
{
|
||||||
@@ -141,6 +141,18 @@ namespace DiscordBot
|
|||||||
}
|
}
|
||||||
else Functions.WriteColorText("The language you are trying to download (&b" + Lname + "&c) is not compatible with the version of this bot. User &glistlang &ccommand in order to see all available languages for your current version !\n" + link[1]);
|
else Functions.WriteColorText("The language you are trying to download (&b" + Lname + "&c) is not compatible with the version of this bot. User &glistlang &ccommand in order to see all available languages for your current version !\n" + link[1]);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
if (Lname == "")
|
||||||
|
{
|
||||||
|
Functions.WriteColorText($"Name is invalid");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Functions.WriteColorText("Failed to find language &b" + Lname + " &c! Use &glistlang &ccommand to display all available languages !");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case "loadplugins":
|
case "loadplugins":
|
||||||
case "lp":
|
case "lp":
|
||||||
LoadPlugins(discordbooter);
|
LoadPlugins(discordbooter);
|
||||||
@@ -283,18 +295,7 @@ namespace DiscordBot
|
|||||||
|
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
Console.ForegroundColor = ConsoleColor.DarkYellow;
|
Console.ForegroundColor = ConsoleColor.DarkYellow;
|
||||||
Console.WriteLine("Discord BOT for Cross Platform\n\nCreated by: Wizzy\nDiscord: Wizzy#9181\nCommands:");
|
Console.WriteLine("Discord BOT for Cross Platform\n\nCreated by: Wizzy\nDiscord: Wizzy#9181");
|
||||||
Console.WriteLine(
|
|
||||||
"lp | loadplugins -> load all plugins\n" +
|
|
||||||
"sd | shutdown->close connection to the server(stop bot)\n" +
|
|
||||||
"token -> display the current token\n" +
|
|
||||||
"listplugs -> list all available plugins\n" +
|
|
||||||
"dwplug [name] -> download plugin by name\n" +
|
|
||||||
"listlang -> list all available languages\n" +
|
|
||||||
"dwlang -> download language by name\n" +
|
|
||||||
"setlang [name] -> set language from the downloaded languages\n" +
|
|
||||||
"set-setting [setting.path] [value] -> set setting value"
|
|
||||||
);
|
|
||||||
Console.ForegroundColor = ConsoleColor.White;
|
Console.ForegroundColor = ConsoleColor.White;
|
||||||
Console.WriteLine("============================ Discord BOT - Cross Platform ============================");
|
Console.WriteLine("============================ Discord BOT - Cross Platform ============================");
|
||||||
string token =
|
string token =
|
||||||
@@ -327,42 +328,22 @@ namespace DiscordBot
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Replace text in the file
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="file">The file location (path)</param>
|
|
||||||
/// <param name="code">The setting key code where to replace</param>
|
|
||||||
/// <param name="value">The new value</param>
|
|
||||||
/// <exception cref="FileNotFoundException">If the <paramref name="file"/> does not exist, then this error is thrown</exception>
|
|
||||||
private static void ReplaceText(string file, string code, string value)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var f = false;
|
|
||||||
string[] text = File.ReadAllLines(file);
|
|
||||||
foreach (string line in text)
|
|
||||||
if (line.StartsWith(code))
|
|
||||||
{
|
|
||||||
line.Replace(line.Split('\t')[1], value);
|
|
||||||
f = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (f)
|
|
||||||
File.WriteAllLines(@"./Data/Resources/DiscordBotCore.data", text);
|
|
||||||
else throw new FileNotFoundException();
|
|
||||||
}
|
|
||||||
catch (FileNotFoundException)
|
|
||||||
{
|
|
||||||
File.AppendAllText(file, code + "\t" + value + "\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handle user input arguments from the startup of the application
|
/// Handle user input arguments from the startup of the application
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="args">The arguments</param>
|
/// <param name="args">The arguments</param>
|
||||||
private static async Task HandleInput(string[] args)
|
private static async Task HandleInput(string[] args)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (args.Length == 0)
|
||||||
|
{
|
||||||
|
if (File.Exists("./ref/startupArguments.txt"))
|
||||||
|
{
|
||||||
|
var lines = await File.ReadAllLinesAsync("./ref/startupArguments.txt");
|
||||||
|
args = lines;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int len = args.Length;
|
int len = args.Length;
|
||||||
if (len == 1 && args[0] == "--help")
|
if (len == 1 && args[0] == "--help")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
bool canUseDM { get; }
|
bool canUseDM { get; }
|
||||||
bool canUseServer { get; }
|
bool canUseServer { get; }
|
||||||
|
bool requireAdmin { get; }
|
||||||
|
|
||||||
void Execute(Discord.Commands.SocketCommandContext context,
|
void Execute(Discord.Commands.SocketCommandContext context,
|
||||||
Discord.WebSocket.SocketMessage message,
|
Discord.WebSocket.SocketMessage message,
|
||||||
|
|||||||
@@ -3,18 +3,21 @@ using Discord.WebSocket;
|
|||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace PluginManager.Others
|
namespace PluginManager.Others.Permissions
|
||||||
{
|
{
|
||||||
public static class Permissions
|
public static class DiscordPermissions
|
||||||
{
|
{
|
||||||
public static bool hasPermission(this IRole role, GuildPermission permission) => role.Permissions.Has(permission);
|
public static bool hasPermission(this IRole role, GuildPermission permission) => role.Permissions.Has(permission);
|
||||||
|
|
||||||
public static bool hasRole(this SocketGuildUser user, IRole role) => user.Roles.Contains(role);
|
public static bool hasRole(this SocketGuildUser user, IRole role) => user.Roles.Contains(role);
|
||||||
|
|
||||||
public static bool hasPermission(this SocketGuildUser user, GuildPermission permission)
|
public static bool hasPermission(this SocketGuildUser user, GuildPermission permission)
|
||||||
=> user.Roles.Where(role => role.hasPermission(permission)).Any();
|
=> user.Roles.Where(role => role.hasPermission(permission)).Any() || user.Guild.Owner == user;
|
||||||
|
public static bool isAdmin(this SocketGuildUser user) => user.hasPermission(GuildPermission.Administrator);
|
||||||
|
public static bool isAdmin(this SocketUser user) => isAdmin((SocketGuildUser)user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user