Compare commits
13 Commits
v1.0.2-bet
...
v1.0.4-pre
| Author | SHA1 | Date | |
|---|---|---|---|
| fd28a166f7 | |||
| 4fbea983da | |||
| 690b7fe5f1 | |||
| e88d654da1 | |||
| 0b6b57cc84 | |||
| 8fcd33e734 | |||
| 0d524cdf65 | |||
| ab6f14e74c | |||
| 3e01e75de3 | |||
| 1ae48a100e | |||
| 4855c8495d | |||
| f8de1536b2 | |||
| c1d0155867 |
13
.idea/.idea.DiscordBotWithAPI/.idea/.gitignore
generated
vendored
Normal file
13
.idea/.idea.DiscordBotWithAPI/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Rider ignored files
|
||||
/modules.xml
|
||||
/contentModel.xml
|
||||
/.idea.DiscordBotWithAPI.iml
|
||||
/projectSettingsUpdater.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
13
.idea/.idea.DiscordBotWithAPI/.idea/avalonia.xml
generated
Normal file
13
.idea/.idea.DiscordBotWithAPI/.idea/avalonia.xml
generated
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AvaloniaProject">
|
||||
<option name="projectPerEditor">
|
||||
<map>
|
||||
<entry key="DiscordBotGUI/App.axaml" value="DiscordBotGUI/DiscordBotGUI.csproj" />
|
||||
<entry key="DiscordBotGUI/AppUpdater.axaml" value="DiscordBotGUI/DiscordBotGUI.csproj" />
|
||||
<entry key="DiscordBotGUI/Settings/Commands.axaml" value="DiscordBotGUI/DiscordBotGUI.csproj" />
|
||||
<entry key="DiscordBotGUI/Settings/Events.axaml" value="DiscordBotGUI/DiscordBotGUI.csproj" />
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
4
.idea/.idea.DiscordBotWithAPI/.idea/encodings.xml
generated
Normal file
4
.idea/.idea.DiscordBotWithAPI/.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.DiscordBotWithAPI/.idea/indexLayout.xml
generated
Normal file
8
.idea/.idea.DiscordBotWithAPI/.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.DiscordBotWithAPI/.idea/vcs.xml
generated
Normal file
6
.idea/.idea.DiscordBotWithAPI/.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>
|
||||
@@ -1,268 +0,0 @@
|
||||
{
|
||||
"runtimeTarget": {
|
||||
"name": ".NETCoreApp,Version=v6.0",
|
||||
"signature": ""
|
||||
},
|
||||
"compilationOptions": {},
|
||||
"targets": {
|
||||
".NETCoreApp,Version=v6.0": {
|
||||
"CMD_LevelingSystem/1.0.0": {
|
||||
"dependencies": {
|
||||
"PluginManager": "1.0.0"
|
||||
},
|
||||
"runtime": {
|
||||
"CMD_LevelingSystem.dll": {}
|
||||
}
|
||||
},
|
||||
"Discord.Net/3.6.1": {
|
||||
"dependencies": {
|
||||
"Discord.Net.Commands": "3.6.1",
|
||||
"Discord.Net.Core": "3.6.1",
|
||||
"Discord.Net.Interactions": "3.6.1",
|
||||
"Discord.Net.Rest": "3.6.1",
|
||||
"Discord.Net.WebSocket": "3.6.1",
|
||||
"Discord.Net.Webhook": "3.6.1"
|
||||
}
|
||||
},
|
||||
"Discord.Net.Commands/3.6.1": {
|
||||
"dependencies": {
|
||||
"Discord.Net.Core": "3.6.1"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net6.0/Discord.Net.Commands.dll": {
|
||||
"assemblyVersion": "3.6.1.0",
|
||||
"fileVersion": "3.6.1.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Discord.Net.Core/3.6.1": {
|
||||
"dependencies": {
|
||||
"Newtonsoft.Json": "13.0.1",
|
||||
"System.Collections.Immutable": "5.0.0",
|
||||
"System.Interactive.Async": "5.0.0",
|
||||
"System.ValueTuple": "4.5.0"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net6.0/Discord.Net.Core.dll": {
|
||||
"assemblyVersion": "3.6.1.0",
|
||||
"fileVersion": "3.6.1.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Discord.Net.Interactions/3.6.1": {
|
||||
"dependencies": {
|
||||
"Discord.Net.Core": "3.6.1",
|
||||
"Discord.Net.Rest": "3.6.1",
|
||||
"Discord.Net.WebSocket": "3.6.1",
|
||||
"Microsoft.Extensions.DependencyInjection.Abstractions": "5.0.0",
|
||||
"System.Collections.Immutable": "5.0.0",
|
||||
"System.Reactive": "5.0.0"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net6.0/Discord.Net.Interactions.dll": {
|
||||
"assemblyVersion": "3.6.1.0",
|
||||
"fileVersion": "3.6.1.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Discord.Net.Rest/3.6.1": {
|
||||
"dependencies": {
|
||||
"Discord.Net.Core": "3.6.1"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net6.0/Discord.Net.Rest.dll": {
|
||||
"assemblyVersion": "3.6.1.0",
|
||||
"fileVersion": "3.6.1.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Discord.Net.Webhook/3.6.1": {
|
||||
"dependencies": {
|
||||
"Discord.Net.Core": "3.6.1",
|
||||
"Discord.Net.Rest": "3.6.1"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net6.0/Discord.Net.Webhook.dll": {
|
||||
"assemblyVersion": "3.6.1.0",
|
||||
"fileVersion": "3.6.1.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Discord.Net.WebSocket/3.6.1": {
|
||||
"dependencies": {
|
||||
"Discord.Net.Core": "3.6.1",
|
||||
"Discord.Net.Rest": "3.6.1"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net6.0/Discord.Net.WebSocket.dll": {
|
||||
"assemblyVersion": "3.6.1.0",
|
||||
"fileVersion": "3.6.1.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.DependencyInjection.Abstractions/5.0.0": {
|
||||
"runtime": {
|
||||
"lib/netstandard2.0/Microsoft.Extensions.DependencyInjection.Abstractions.dll": {
|
||||
"assemblyVersion": "5.0.0.0",
|
||||
"fileVersion": "5.0.20.51904"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Newtonsoft.Json/13.0.1": {
|
||||
"runtime": {
|
||||
"lib/netstandard2.0/Newtonsoft.Json.dll": {
|
||||
"assemblyVersion": "13.0.0.0",
|
||||
"fileVersion": "13.0.1.25517"
|
||||
}
|
||||
}
|
||||
},
|
||||
"System.Collections.Immutable/5.0.0": {},
|
||||
"System.Interactive.Async/5.0.0": {
|
||||
"dependencies": {
|
||||
"System.Linq.Async": "5.0.0"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/netcoreapp3.1/System.Interactive.Async.dll": {
|
||||
"assemblyVersion": "5.0.0.0",
|
||||
"fileVersion": "5.0.0.1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"System.Linq.Async/5.0.0": {
|
||||
"runtime": {
|
||||
"lib/netcoreapp3.1/System.Linq.Async.dll": {
|
||||
"assemblyVersion": "5.0.0.0",
|
||||
"fileVersion": "5.0.0.1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"System.Reactive/5.0.0": {
|
||||
"runtime": {
|
||||
"lib/net5.0/System.Reactive.dll": {
|
||||
"assemblyVersion": "5.0.0.0",
|
||||
"fileVersion": "5.0.0.1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"System.ValueTuple/4.5.0": {},
|
||||
"PluginManager/1.0.0": {
|
||||
"dependencies": {
|
||||
"Discord.Net": "3.6.1"
|
||||
},
|
||||
"runtime": {
|
||||
"PluginManager.dll": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"libraries": {
|
||||
"CMD_LevelingSystem/1.0.0": {
|
||||
"type": "project",
|
||||
"serviceable": false,
|
||||
"sha512": ""
|
||||
},
|
||||
"Discord.Net/3.6.1": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-TfcL/HG57fVt//WVJ2XyF2PlytY9IYkkwwkPLIhvu5FW4wf9rm7+N8RPh4qtELLfsa5ES0FK2RbgYjABRR9AjA==",
|
||||
"path": "discord.net/3.6.1",
|
||||
"hashPath": "discord.net.3.6.1.nupkg.sha512"
|
||||
},
|
||||
"Discord.Net.Commands/3.6.1": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-kK7m571yzSzPd93o+n8Z+TfvX62BT1HtOEZIWXKwXWO8itP/sgqBNExjWK/6DOpkbD6+khc2f3rp+TA0rJD88g==",
|
||||
"path": "discord.net.commands/3.6.1",
|
||||
"hashPath": "discord.net.commands.3.6.1.nupkg.sha512"
|
||||
},
|
||||
"Discord.Net.Core/3.6.1": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-ibVjQiWzgqh0GyP/GXE2kv3TA/9ysmmNFG/WmRE7GepQQAXXGxVUO9IMJ8h14EvIXMQ0m0DktMe5DkUnilo3Ag==",
|
||||
"path": "discord.net.core/3.6.1",
|
||||
"hashPath": "discord.net.core.3.6.1.nupkg.sha512"
|
||||
},
|
||||
"Discord.Net.Interactions/3.6.1": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-WGOxz6SMUu4WS5b/JdrhlwQletcplBIYqvjFBBDfnqE+uNJqcNGtAdyjLqIILfXGx8aSSSSYZSCeAUa7FZ8Yew==",
|
||||
"path": "discord.net.interactions/3.6.1",
|
||||
"hashPath": "discord.net.interactions.3.6.1.nupkg.sha512"
|
||||
},
|
||||
"Discord.Net.Rest/3.6.1": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-T7RRThIS23roFEJwTL1l7aawjVyn7ZB5yH3tMge0d6TiCzzp4V4FAZ+ArTt19LHRFhPly90v8V3sWqmTMN+5Zg==",
|
||||
"path": "discord.net.rest/3.6.1",
|
||||
"hashPath": "discord.net.rest.3.6.1.nupkg.sha512"
|
||||
},
|
||||
"Discord.Net.Webhook/3.6.1": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-xikKHIGAIMz0BzHkaTKb48DNpFjKW8mvJjLJSezJ1xQOu+laHNk/hav4qxVtyZz7HSI/vGTkmlq9hKVhWzpaUA==",
|
||||
"path": "discord.net.webhook/3.6.1",
|
||||
"hashPath": "discord.net.webhook.3.6.1.nupkg.sha512"
|
||||
},
|
||||
"Discord.Net.WebSocket/3.6.1": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-hF22Xy7URlVEDQZ69INOgzPvFUsIDfd+r6U+1yF9HWdBn3d4THnvAAhkv1TraSx/T/MKS7g+jvk/HZ3mh5S3aw==",
|
||||
"path": "discord.net.websocket/3.6.1",
|
||||
"hashPath": "discord.net.websocket.3.6.1.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.Extensions.DependencyInjection.Abstractions/5.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-ORj7Zh81gC69TyvmcUm9tSzytcy8AVousi+IVRAI8nLieQjOFryRusSFh7+aLk16FN9pQNqJAiMd7BTKINK0kA==",
|
||||
"path": "microsoft.extensions.dependencyinjection.abstractions/5.0.0",
|
||||
"hashPath": "microsoft.extensions.dependencyinjection.abstractions.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"Newtonsoft.Json/13.0.1": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-ppPFpBcvxdsfUonNcvITKqLl3bqxWbDCZIzDWHzjpdAHRFfZe0Dw9HmA0+za13IdyrgJwpkDTDA9fHaxOrt20A==",
|
||||
"path": "newtonsoft.json/13.0.1",
|
||||
"hashPath": "newtonsoft.json.13.0.1.nupkg.sha512"
|
||||
},
|
||||
"System.Collections.Immutable/5.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-FXkLXiK0sVVewcso0imKQoOxjoPAj42R8HtjjbSjVPAzwDfzoyoznWxgA3c38LDbN9SJux1xXoXYAhz98j7r2g==",
|
||||
"path": "system.collections.immutable/5.0.0",
|
||||
"hashPath": "system.collections.immutable.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"System.Interactive.Async/5.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-QaqhQVDiULcu4vm6o89+iP329HcK44cETHOYgy/jfEjtzeFy0ZxmuM7nel9ocjnKxEM4yh1mli7hgh8Q9o+/Iw==",
|
||||
"path": "system.interactive.async/5.0.0",
|
||||
"hashPath": "system.interactive.async.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"System.Linq.Async/5.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-cPtIuuH8TIjVHSi2ewwReWGW1PfChPE0LxPIDlfwVcLuTM9GANFTXiMB7k3aC4sk3f0cQU25LNKzx+jZMxijqw==",
|
||||
"path": "system.linq.async/5.0.0",
|
||||
"hashPath": "system.linq.async.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"System.Reactive/5.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==",
|
||||
"path": "system.reactive/5.0.0",
|
||||
"hashPath": "system.reactive.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"System.ValueTuple/4.5.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-okurQJO6NRE/apDIP23ajJ0hpiNmJ+f0BwOlB/cSqTLQlw5upkf+5+96+iG2Jw40G1fCVCyPz/FhIABUjMR+RQ==",
|
||||
"path": "system.valuetuple/4.5.0",
|
||||
"hashPath": "system.valuetuple.4.5.0.nupkg.sha512"
|
||||
},
|
||||
"PluginManager/1.0.0": {
|
||||
"type": "project",
|
||||
"serviceable": false,
|
||||
"sha512": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -1,268 +0,0 @@
|
||||
{
|
||||
"runtimeTarget": {
|
||||
"name": ".NETCoreApp,Version=v6.0",
|
||||
"signature": ""
|
||||
},
|
||||
"compilationOptions": {},
|
||||
"targets": {
|
||||
".NETCoreApp,Version=v6.0": {
|
||||
"EVE_LevelingSystem/1.0.0": {
|
||||
"dependencies": {
|
||||
"PluginManager": "1.0.0"
|
||||
},
|
||||
"runtime": {
|
||||
"EVE_LevelingSystem.dll": {}
|
||||
}
|
||||
},
|
||||
"Discord.Net/3.6.1": {
|
||||
"dependencies": {
|
||||
"Discord.Net.Commands": "3.6.1",
|
||||
"Discord.Net.Core": "3.6.1",
|
||||
"Discord.Net.Interactions": "3.6.1",
|
||||
"Discord.Net.Rest": "3.6.1",
|
||||
"Discord.Net.WebSocket": "3.6.1",
|
||||
"Discord.Net.Webhook": "3.6.1"
|
||||
}
|
||||
},
|
||||
"Discord.Net.Commands/3.6.1": {
|
||||
"dependencies": {
|
||||
"Discord.Net.Core": "3.6.1"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net6.0/Discord.Net.Commands.dll": {
|
||||
"assemblyVersion": "3.6.1.0",
|
||||
"fileVersion": "3.6.1.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Discord.Net.Core/3.6.1": {
|
||||
"dependencies": {
|
||||
"Newtonsoft.Json": "13.0.1",
|
||||
"System.Collections.Immutable": "5.0.0",
|
||||
"System.Interactive.Async": "5.0.0",
|
||||
"System.ValueTuple": "4.5.0"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net6.0/Discord.Net.Core.dll": {
|
||||
"assemblyVersion": "3.6.1.0",
|
||||
"fileVersion": "3.6.1.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Discord.Net.Interactions/3.6.1": {
|
||||
"dependencies": {
|
||||
"Discord.Net.Core": "3.6.1",
|
||||
"Discord.Net.Rest": "3.6.1",
|
||||
"Discord.Net.WebSocket": "3.6.1",
|
||||
"Microsoft.Extensions.DependencyInjection.Abstractions": "5.0.0",
|
||||
"System.Collections.Immutable": "5.0.0",
|
||||
"System.Reactive": "5.0.0"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net6.0/Discord.Net.Interactions.dll": {
|
||||
"assemblyVersion": "3.6.1.0",
|
||||
"fileVersion": "3.6.1.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Discord.Net.Rest/3.6.1": {
|
||||
"dependencies": {
|
||||
"Discord.Net.Core": "3.6.1"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net6.0/Discord.Net.Rest.dll": {
|
||||
"assemblyVersion": "3.6.1.0",
|
||||
"fileVersion": "3.6.1.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Discord.Net.Webhook/3.6.1": {
|
||||
"dependencies": {
|
||||
"Discord.Net.Core": "3.6.1",
|
||||
"Discord.Net.Rest": "3.6.1"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net6.0/Discord.Net.Webhook.dll": {
|
||||
"assemblyVersion": "3.6.1.0",
|
||||
"fileVersion": "3.6.1.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Discord.Net.WebSocket/3.6.1": {
|
||||
"dependencies": {
|
||||
"Discord.Net.Core": "3.6.1",
|
||||
"Discord.Net.Rest": "3.6.1"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net6.0/Discord.Net.WebSocket.dll": {
|
||||
"assemblyVersion": "3.6.1.0",
|
||||
"fileVersion": "3.6.1.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.DependencyInjection.Abstractions/5.0.0": {
|
||||
"runtime": {
|
||||
"lib/netstandard2.0/Microsoft.Extensions.DependencyInjection.Abstractions.dll": {
|
||||
"assemblyVersion": "5.0.0.0",
|
||||
"fileVersion": "5.0.20.51904"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Newtonsoft.Json/13.0.1": {
|
||||
"runtime": {
|
||||
"lib/netstandard2.0/Newtonsoft.Json.dll": {
|
||||
"assemblyVersion": "13.0.0.0",
|
||||
"fileVersion": "13.0.1.25517"
|
||||
}
|
||||
}
|
||||
},
|
||||
"System.Collections.Immutable/5.0.0": {},
|
||||
"System.Interactive.Async/5.0.0": {
|
||||
"dependencies": {
|
||||
"System.Linq.Async": "5.0.0"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/netcoreapp3.1/System.Interactive.Async.dll": {
|
||||
"assemblyVersion": "5.0.0.0",
|
||||
"fileVersion": "5.0.0.1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"System.Linq.Async/5.0.0": {
|
||||
"runtime": {
|
||||
"lib/netcoreapp3.1/System.Linq.Async.dll": {
|
||||
"assemblyVersion": "5.0.0.0",
|
||||
"fileVersion": "5.0.0.1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"System.Reactive/5.0.0": {
|
||||
"runtime": {
|
||||
"lib/net5.0/System.Reactive.dll": {
|
||||
"assemblyVersion": "5.0.0.0",
|
||||
"fileVersion": "5.0.0.1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"System.ValueTuple/4.5.0": {},
|
||||
"PluginManager/1.0.0": {
|
||||
"dependencies": {
|
||||
"Discord.Net": "3.6.1"
|
||||
},
|
||||
"runtime": {
|
||||
"PluginManager.dll": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"libraries": {
|
||||
"EVE_LevelingSystem/1.0.0": {
|
||||
"type": "project",
|
||||
"serviceable": false,
|
||||
"sha512": ""
|
||||
},
|
||||
"Discord.Net/3.6.1": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-TfcL/HG57fVt//WVJ2XyF2PlytY9IYkkwwkPLIhvu5FW4wf9rm7+N8RPh4qtELLfsa5ES0FK2RbgYjABRR9AjA==",
|
||||
"path": "discord.net/3.6.1",
|
||||
"hashPath": "discord.net.3.6.1.nupkg.sha512"
|
||||
},
|
||||
"Discord.Net.Commands/3.6.1": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-kK7m571yzSzPd93o+n8Z+TfvX62BT1HtOEZIWXKwXWO8itP/sgqBNExjWK/6DOpkbD6+khc2f3rp+TA0rJD88g==",
|
||||
"path": "discord.net.commands/3.6.1",
|
||||
"hashPath": "discord.net.commands.3.6.1.nupkg.sha512"
|
||||
},
|
||||
"Discord.Net.Core/3.6.1": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-ibVjQiWzgqh0GyP/GXE2kv3TA/9ysmmNFG/WmRE7GepQQAXXGxVUO9IMJ8h14EvIXMQ0m0DktMe5DkUnilo3Ag==",
|
||||
"path": "discord.net.core/3.6.1",
|
||||
"hashPath": "discord.net.core.3.6.1.nupkg.sha512"
|
||||
},
|
||||
"Discord.Net.Interactions/3.6.1": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-WGOxz6SMUu4WS5b/JdrhlwQletcplBIYqvjFBBDfnqE+uNJqcNGtAdyjLqIILfXGx8aSSSSYZSCeAUa7FZ8Yew==",
|
||||
"path": "discord.net.interactions/3.6.1",
|
||||
"hashPath": "discord.net.interactions.3.6.1.nupkg.sha512"
|
||||
},
|
||||
"Discord.Net.Rest/3.6.1": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-T7RRThIS23roFEJwTL1l7aawjVyn7ZB5yH3tMge0d6TiCzzp4V4FAZ+ArTt19LHRFhPly90v8V3sWqmTMN+5Zg==",
|
||||
"path": "discord.net.rest/3.6.1",
|
||||
"hashPath": "discord.net.rest.3.6.1.nupkg.sha512"
|
||||
},
|
||||
"Discord.Net.Webhook/3.6.1": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-xikKHIGAIMz0BzHkaTKb48DNpFjKW8mvJjLJSezJ1xQOu+laHNk/hav4qxVtyZz7HSI/vGTkmlq9hKVhWzpaUA==",
|
||||
"path": "discord.net.webhook/3.6.1",
|
||||
"hashPath": "discord.net.webhook.3.6.1.nupkg.sha512"
|
||||
},
|
||||
"Discord.Net.WebSocket/3.6.1": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-hF22Xy7URlVEDQZ69INOgzPvFUsIDfd+r6U+1yF9HWdBn3d4THnvAAhkv1TraSx/T/MKS7g+jvk/HZ3mh5S3aw==",
|
||||
"path": "discord.net.websocket/3.6.1",
|
||||
"hashPath": "discord.net.websocket.3.6.1.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.Extensions.DependencyInjection.Abstractions/5.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-ORj7Zh81gC69TyvmcUm9tSzytcy8AVousi+IVRAI8nLieQjOFryRusSFh7+aLk16FN9pQNqJAiMd7BTKINK0kA==",
|
||||
"path": "microsoft.extensions.dependencyinjection.abstractions/5.0.0",
|
||||
"hashPath": "microsoft.extensions.dependencyinjection.abstractions.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"Newtonsoft.Json/13.0.1": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-ppPFpBcvxdsfUonNcvITKqLl3bqxWbDCZIzDWHzjpdAHRFfZe0Dw9HmA0+za13IdyrgJwpkDTDA9fHaxOrt20A==",
|
||||
"path": "newtonsoft.json/13.0.1",
|
||||
"hashPath": "newtonsoft.json.13.0.1.nupkg.sha512"
|
||||
},
|
||||
"System.Collections.Immutable/5.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-FXkLXiK0sVVewcso0imKQoOxjoPAj42R8HtjjbSjVPAzwDfzoyoznWxgA3c38LDbN9SJux1xXoXYAhz98j7r2g==",
|
||||
"path": "system.collections.immutable/5.0.0",
|
||||
"hashPath": "system.collections.immutable.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"System.Interactive.Async/5.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-QaqhQVDiULcu4vm6o89+iP329HcK44cETHOYgy/jfEjtzeFy0ZxmuM7nel9ocjnKxEM4yh1mli7hgh8Q9o+/Iw==",
|
||||
"path": "system.interactive.async/5.0.0",
|
||||
"hashPath": "system.interactive.async.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"System.Linq.Async/5.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-cPtIuuH8TIjVHSi2ewwReWGW1PfChPE0LxPIDlfwVcLuTM9GANFTXiMB7k3aC4sk3f0cQU25LNKzx+jZMxijqw==",
|
||||
"path": "system.linq.async/5.0.0",
|
||||
"hashPath": "system.linq.async.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"System.Reactive/5.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==",
|
||||
"path": "system.reactive/5.0.0",
|
||||
"hashPath": "system.reactive.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"System.ValueTuple/4.5.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-okurQJO6NRE/apDIP23ajJ0hpiNmJ+f0BwOlB/cSqTLQlw5upkf+5+96+iG2Jw40G1fCVCyPz/FhIABUjMR+RQ==",
|
||||
"path": "system.valuetuple/4.5.0",
|
||||
"hashPath": "system.valuetuple.4.5.0.nupkg.sha512"
|
||||
},
|
||||
"PluginManager/1.0.0": {
|
||||
"type": "project",
|
||||
"serviceable": false,
|
||||
"sha512": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,268 +0,0 @@
|
||||
{
|
||||
"runtimeTarget": {
|
||||
"name": ".NETCoreApp,Version=v6.0",
|
||||
"signature": ""
|
||||
},
|
||||
"compilationOptions": {},
|
||||
"targets": {
|
||||
".NETCoreApp,Version=v6.0": {
|
||||
"StartupEvents/1.0.0": {
|
||||
"dependencies": {
|
||||
"PluginManager": "1.0.0"
|
||||
},
|
||||
"runtime": {
|
||||
"StartupEvents.dll": {}
|
||||
}
|
||||
},
|
||||
"Discord.Net/3.6.1": {
|
||||
"dependencies": {
|
||||
"Discord.Net.Commands": "3.6.1",
|
||||
"Discord.Net.Core": "3.6.1",
|
||||
"Discord.Net.Interactions": "3.6.1",
|
||||
"Discord.Net.Rest": "3.6.1",
|
||||
"Discord.Net.WebSocket": "3.6.1",
|
||||
"Discord.Net.Webhook": "3.6.1"
|
||||
}
|
||||
},
|
||||
"Discord.Net.Commands/3.6.1": {
|
||||
"dependencies": {
|
||||
"Discord.Net.Core": "3.6.1"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net6.0/Discord.Net.Commands.dll": {
|
||||
"assemblyVersion": "3.6.1.0",
|
||||
"fileVersion": "3.6.1.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Discord.Net.Core/3.6.1": {
|
||||
"dependencies": {
|
||||
"Newtonsoft.Json": "13.0.1",
|
||||
"System.Collections.Immutable": "5.0.0",
|
||||
"System.Interactive.Async": "5.0.0",
|
||||
"System.ValueTuple": "4.5.0"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net6.0/Discord.Net.Core.dll": {
|
||||
"assemblyVersion": "3.6.1.0",
|
||||
"fileVersion": "3.6.1.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Discord.Net.Interactions/3.6.1": {
|
||||
"dependencies": {
|
||||
"Discord.Net.Core": "3.6.1",
|
||||
"Discord.Net.Rest": "3.6.1",
|
||||
"Discord.Net.WebSocket": "3.6.1",
|
||||
"Microsoft.Extensions.DependencyInjection.Abstractions": "5.0.0",
|
||||
"System.Collections.Immutable": "5.0.0",
|
||||
"System.Reactive": "5.0.0"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net6.0/Discord.Net.Interactions.dll": {
|
||||
"assemblyVersion": "3.6.1.0",
|
||||
"fileVersion": "3.6.1.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Discord.Net.Rest/3.6.1": {
|
||||
"dependencies": {
|
||||
"Discord.Net.Core": "3.6.1"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net6.0/Discord.Net.Rest.dll": {
|
||||
"assemblyVersion": "3.6.1.0",
|
||||
"fileVersion": "3.6.1.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Discord.Net.Webhook/3.6.1": {
|
||||
"dependencies": {
|
||||
"Discord.Net.Core": "3.6.1",
|
||||
"Discord.Net.Rest": "3.6.1"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net6.0/Discord.Net.Webhook.dll": {
|
||||
"assemblyVersion": "3.6.1.0",
|
||||
"fileVersion": "3.6.1.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Discord.Net.WebSocket/3.6.1": {
|
||||
"dependencies": {
|
||||
"Discord.Net.Core": "3.6.1",
|
||||
"Discord.Net.Rest": "3.6.1"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net6.0/Discord.Net.WebSocket.dll": {
|
||||
"assemblyVersion": "3.6.1.0",
|
||||
"fileVersion": "3.6.1.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.DependencyInjection.Abstractions/5.0.0": {
|
||||
"runtime": {
|
||||
"lib/netstandard2.0/Microsoft.Extensions.DependencyInjection.Abstractions.dll": {
|
||||
"assemblyVersion": "5.0.0.0",
|
||||
"fileVersion": "5.0.20.51904"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Newtonsoft.Json/13.0.1": {
|
||||
"runtime": {
|
||||
"lib/netstandard2.0/Newtonsoft.Json.dll": {
|
||||
"assemblyVersion": "13.0.0.0",
|
||||
"fileVersion": "13.0.1.25517"
|
||||
}
|
||||
}
|
||||
},
|
||||
"System.Collections.Immutable/5.0.0": {},
|
||||
"System.Interactive.Async/5.0.0": {
|
||||
"dependencies": {
|
||||
"System.Linq.Async": "5.0.0"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/netcoreapp3.1/System.Interactive.Async.dll": {
|
||||
"assemblyVersion": "5.0.0.0",
|
||||
"fileVersion": "5.0.0.1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"System.Linq.Async/5.0.0": {
|
||||
"runtime": {
|
||||
"lib/netcoreapp3.1/System.Linq.Async.dll": {
|
||||
"assemblyVersion": "5.0.0.0",
|
||||
"fileVersion": "5.0.0.1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"System.Reactive/5.0.0": {
|
||||
"runtime": {
|
||||
"lib/net5.0/System.Reactive.dll": {
|
||||
"assemblyVersion": "5.0.0.0",
|
||||
"fileVersion": "5.0.0.1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"System.ValueTuple/4.5.0": {},
|
||||
"PluginManager/1.0.0": {
|
||||
"dependencies": {
|
||||
"Discord.Net": "3.6.1"
|
||||
},
|
||||
"runtime": {
|
||||
"PluginManager.dll": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"libraries": {
|
||||
"StartupEvents/1.0.0": {
|
||||
"type": "project",
|
||||
"serviceable": false,
|
||||
"sha512": ""
|
||||
},
|
||||
"Discord.Net/3.6.1": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-TfcL/HG57fVt//WVJ2XyF2PlytY9IYkkwwkPLIhvu5FW4wf9rm7+N8RPh4qtELLfsa5ES0FK2RbgYjABRR9AjA==",
|
||||
"path": "discord.net/3.6.1",
|
||||
"hashPath": "discord.net.3.6.1.nupkg.sha512"
|
||||
},
|
||||
"Discord.Net.Commands/3.6.1": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-kK7m571yzSzPd93o+n8Z+TfvX62BT1HtOEZIWXKwXWO8itP/sgqBNExjWK/6DOpkbD6+khc2f3rp+TA0rJD88g==",
|
||||
"path": "discord.net.commands/3.6.1",
|
||||
"hashPath": "discord.net.commands.3.6.1.nupkg.sha512"
|
||||
},
|
||||
"Discord.Net.Core/3.6.1": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-ibVjQiWzgqh0GyP/GXE2kv3TA/9ysmmNFG/WmRE7GepQQAXXGxVUO9IMJ8h14EvIXMQ0m0DktMe5DkUnilo3Ag==",
|
||||
"path": "discord.net.core/3.6.1",
|
||||
"hashPath": "discord.net.core.3.6.1.nupkg.sha512"
|
||||
},
|
||||
"Discord.Net.Interactions/3.6.1": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-WGOxz6SMUu4WS5b/JdrhlwQletcplBIYqvjFBBDfnqE+uNJqcNGtAdyjLqIILfXGx8aSSSSYZSCeAUa7FZ8Yew==",
|
||||
"path": "discord.net.interactions/3.6.1",
|
||||
"hashPath": "discord.net.interactions.3.6.1.nupkg.sha512"
|
||||
},
|
||||
"Discord.Net.Rest/3.6.1": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-T7RRThIS23roFEJwTL1l7aawjVyn7ZB5yH3tMge0d6TiCzzp4V4FAZ+ArTt19LHRFhPly90v8V3sWqmTMN+5Zg==",
|
||||
"path": "discord.net.rest/3.6.1",
|
||||
"hashPath": "discord.net.rest.3.6.1.nupkg.sha512"
|
||||
},
|
||||
"Discord.Net.Webhook/3.6.1": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-xikKHIGAIMz0BzHkaTKb48DNpFjKW8mvJjLJSezJ1xQOu+laHNk/hav4qxVtyZz7HSI/vGTkmlq9hKVhWzpaUA==",
|
||||
"path": "discord.net.webhook/3.6.1",
|
||||
"hashPath": "discord.net.webhook.3.6.1.nupkg.sha512"
|
||||
},
|
||||
"Discord.Net.WebSocket/3.6.1": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-hF22Xy7URlVEDQZ69INOgzPvFUsIDfd+r6U+1yF9HWdBn3d4THnvAAhkv1TraSx/T/MKS7g+jvk/HZ3mh5S3aw==",
|
||||
"path": "discord.net.websocket/3.6.1",
|
||||
"hashPath": "discord.net.websocket.3.6.1.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.Extensions.DependencyInjection.Abstractions/5.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-ORj7Zh81gC69TyvmcUm9tSzytcy8AVousi+IVRAI8nLieQjOFryRusSFh7+aLk16FN9pQNqJAiMd7BTKINK0kA==",
|
||||
"path": "microsoft.extensions.dependencyinjection.abstractions/5.0.0",
|
||||
"hashPath": "microsoft.extensions.dependencyinjection.abstractions.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"Newtonsoft.Json/13.0.1": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-ppPFpBcvxdsfUonNcvITKqLl3bqxWbDCZIzDWHzjpdAHRFfZe0Dw9HmA0+za13IdyrgJwpkDTDA9fHaxOrt20A==",
|
||||
"path": "newtonsoft.json/13.0.1",
|
||||
"hashPath": "newtonsoft.json.13.0.1.nupkg.sha512"
|
||||
},
|
||||
"System.Collections.Immutable/5.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-FXkLXiK0sVVewcso0imKQoOxjoPAj42R8HtjjbSjVPAzwDfzoyoznWxgA3c38LDbN9SJux1xXoXYAhz98j7r2g==",
|
||||
"path": "system.collections.immutable/5.0.0",
|
||||
"hashPath": "system.collections.immutable.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"System.Interactive.Async/5.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-QaqhQVDiULcu4vm6o89+iP329HcK44cETHOYgy/jfEjtzeFy0ZxmuM7nel9ocjnKxEM4yh1mli7hgh8Q9o+/Iw==",
|
||||
"path": "system.interactive.async/5.0.0",
|
||||
"hashPath": "system.interactive.async.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"System.Linq.Async/5.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-cPtIuuH8TIjVHSi2ewwReWGW1PfChPE0LxPIDlfwVcLuTM9GANFTXiMB7k3aC4sk3f0cQU25LNKzx+jZMxijqw==",
|
||||
"path": "system.linq.async/5.0.0",
|
||||
"hashPath": "system.linq.async.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"System.Reactive/5.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==",
|
||||
"path": "system.reactive/5.0.0",
|
||||
"hashPath": "system.reactive.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"System.ValueTuple/4.5.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-okurQJO6NRE/apDIP23ajJ0hpiNmJ+f0BwOlB/cSqTLQlw5upkf+5+96+iG2Jw40G1fCVCyPz/FhIABUjMR+RQ==",
|
||||
"path": "system.valuetuple/4.5.0",
|
||||
"hashPath": "system.valuetuple.4.5.0.nupkg.sha512"
|
||||
},
|
||||
"PluginManager/1.0.0": {
|
||||
"type": "project",
|
||||
"serviceable": false,
|
||||
"sha512": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -2,16 +2,9 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<OutputPath>..\BUILDS\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<DebugType>none</DebugType>
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
<WarningsAsErrors />
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<BaseOutputPath>..\DiscordBot\bin\Debug\net6.0\Data\Plugins\Commands\LevelingSystem</BaseOutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
using Discord.WebSocket;
|
||||
|
||||
using PluginManager.Interfaces;
|
||||
using PluginManager.LanguageSystem;
|
||||
|
||||
using System;
|
||||
|
||||
|
||||
public class level : DBCommand
|
||||
{
|
||||
public string Command => "rank";
|
||||
|
||||
public string Description => "Display your current level";
|
||||
|
||||
public string Usage => "rank";
|
||||
|
||||
public bool canUseDM => false;
|
||||
|
||||
public bool canUseServer => true;
|
||||
|
||||
public bool requireAdmin => false;
|
||||
|
||||
public async void Execute(SocketCommandContext context, SocketMessage message, DiscordSocketClient client, bool isDM)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
int cLv = Data.GetLevel(message.Author.Id);
|
||||
Int64 cEXP = Data.GetExp(message.Author.Id);
|
||||
Int64 rEXP = Data.GetReqEXP(message.Author.Id);
|
||||
|
||||
var embed = new EmbedBuilder()
|
||||
{
|
||||
Title = "Leveling System",
|
||||
Description = message.Author.Mention
|
||||
};
|
||||
Random r = new Random();
|
||||
int _r = r.Next(0, 256);
|
||||
int _g = r.Next(0, 256);
|
||||
int _b = r.Next(0, 256);
|
||||
embed.WithColor(new Color(_r, _g, _b));
|
||||
embed.AddField("Level", cLv);
|
||||
embed.AddField("Current EXP", cEXP);
|
||||
embed.AddField("Required Exp to Level up", rEXP);
|
||||
embed.WithCurrentTimestamp();
|
||||
await message.Channel.SendMessageAsync(embed: embed.Build());
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (Language.ActiveLanguage != null)
|
||||
await message.Channel.SendMessageAsync(Language.ActiveLanguage.LanguageWords["DB_COMMAND_RANK_NO_RANK"]);
|
||||
else await message.Channel.SendMessageAsync("You are unranked now. Please type a message in chat that is not a command and try again this command");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
public class Core
|
||||
{
|
||||
|
||||
public static Dictionary<ulong, string> playerMessages = new Dictionary<ulong, string>();
|
||||
|
||||
private static readonly string folder = @".\Data\Resources\LevelingSystem\";
|
||||
|
||||
public static int GetLevel(ulong id) => int.Parse(File.ReadAllText(Path.Combine(folder, id.ToString() + ".data")).Split(',')[0].Split('=')[1]);
|
||||
|
||||
|
||||
public static Int64 GetExp(ulong id) => Int64.Parse(File.ReadAllText(Path.Combine(folder, id.ToString() + ".data")).Split(',')[1].Split('=')[1]);
|
||||
|
||||
|
||||
public static Int64 GetReqEXP(ulong id) => Int64.Parse(File.ReadAllText(Path.Combine(folder, id.ToString() + ".data")).Split(',')[2].Split('=')[1]);
|
||||
public static void SaveData(ulong id, int lv, Int64 cexp, Int64 rexp)
|
||||
{
|
||||
Directory.CreateDirectory(folder);
|
||||
File.WriteAllText(Path.Combine(folder, id.ToString() + ".data"), $"Level={lv},EXP={cexp},REXP={rexp}");
|
||||
}
|
||||
private static Int64 NextLevelXP(int level)
|
||||
{
|
||||
return (level * level) + 2 * level + 75;
|
||||
}
|
||||
|
||||
public static (bool, int) MessageSent(ulong id, int messageLength)
|
||||
{
|
||||
WaitForTimeToRemoveFromList(id, 60);
|
||||
|
||||
if (!File.Exists(Path.Combine(folder, id.ToString() + ".data")))
|
||||
{
|
||||
SaveData(id, 0, 0, 0);
|
||||
}
|
||||
Int64 cEXp = GetExp(id);
|
||||
Int64 rExp = GetReqEXP(id);
|
||||
int random = new System.Random().Next(3, 6) + messageLength;
|
||||
cEXp += random;
|
||||
if (cEXp >= rExp)
|
||||
{
|
||||
cEXp = cEXp - rExp;
|
||||
int lv = GetLevel(id);
|
||||
rExp = NextLevelXP(lv);
|
||||
lv++;
|
||||
SaveData(id, lv, cEXp, rExp);
|
||||
return (true, lv);
|
||||
}
|
||||
|
||||
SaveData(id, GetLevel(id), cEXp, rExp);
|
||||
return (false, -1);
|
||||
}
|
||||
|
||||
public static async void WaitForTimeToRemoveFromList(ulong id, int time_seconds)
|
||||
{
|
||||
await Task.Delay(time_seconds * 1000);
|
||||
playerMessages.Remove(id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using Discord.WebSocket;
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
public static class Data
|
||||
{
|
||||
private static readonly string folder = @".\Data\Resources\LevelingSystem\";
|
||||
public static void registerPlayer(SocketGuildUser user)
|
||||
{
|
||||
ulong id = user.Id;
|
||||
Directory.CreateDirectory(folder);
|
||||
File.WriteAllText(Path.Combine(folder, id.ToString() + ".data"), "Level=0,EXP=0,REXP=100");
|
||||
}
|
||||
|
||||
public static int GetLevel(ulong id) => int.Parse(File.ReadAllText(Path.Combine(folder, id.ToString() + ".data")).Split(',')[0].Split('=')[1]);
|
||||
|
||||
|
||||
public static Int64 GetExp(ulong id) => Int64.Parse(File.ReadAllText(Path.Combine(folder, id.ToString() + ".data")).Split(',')[1].Split('=')[1]);
|
||||
|
||||
|
||||
public static Int64 GetReqEXP(ulong id) => Int64.Parse(File.ReadAllText(Path.Combine(folder, id.ToString() + ".data")).Split(',')[2].Split('=')[1]);
|
||||
|
||||
|
||||
}
|
||||
48
CMD_LevelingSystem/Level.cs
Normal file
48
CMD_LevelingSystem/Level.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
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;
|
||||
using PluginManager.Interfaces;
|
||||
using PluginManager.Others;
|
||||
|
||||
namespace CMD_LevelingSystem
|
||||
{
|
||||
internal class Level : DBCommand
|
||||
{
|
||||
public string Command => "level";
|
||||
|
||||
public string Description => "Display tour current level";
|
||||
|
||||
public string Usage => "level";
|
||||
|
||||
public bool canUseDM => false;
|
||||
|
||||
public bool canUseServer => true;
|
||||
|
||||
public bool requireAdmin => false;
|
||||
|
||||
public async void Execute(SocketCommandContext context, SocketMessage message, DiscordSocketClient client, bool isDM)
|
||||
{
|
||||
User user = await Functions.ConvertFromJson<User>(Config.GetValue("LevelingSystemPath") + $"/{message.Author.Id}.dat");
|
||||
if (user == null)
|
||||
{
|
||||
await context.Channel.SendMessageAsync("You are now unranked !");
|
||||
return;
|
||||
}
|
||||
|
||||
var builder = new EmbedBuilder();
|
||||
Random r = new Random();
|
||||
builder.WithColor(r.Next(256), r.Next(256), r.Next(256));
|
||||
builder.AddField("Current Level", user.CurrentLevel, true)
|
||||
.AddField("Current EXP", user.CurrentEXP, true)
|
||||
.AddField("Required Exp", user.RequiredEXPToLevelUp, true);
|
||||
builder.WithTimestamp(DateTimeOffset.Now);
|
||||
await context.Channel.SendMessageAsync(embed: builder.Build());
|
||||
}
|
||||
}
|
||||
}
|
||||
16
CMD_LevelingSystem/User.cs
Normal file
16
CMD_LevelingSystem/User.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CMD_LevelingSystem
|
||||
{
|
||||
public class User
|
||||
{
|
||||
public string userID { get; set; }
|
||||
public int CurrentLevel { get; set; }
|
||||
public Int64 CurrentEXP { get; set; }
|
||||
public Int64 RequiredEXPToLevelUp { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="4.0.0.0"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="4.0.0.0"/>
|
||||
</dependentAssembly>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -75,12 +75,11 @@ namespace DiscordBot.Discord.Commands
|
||||
string normalCommands = "";
|
||||
string DMCommands = "";
|
||||
|
||||
foreach (var cmd in PluginLoader.Plugins!)
|
||||
foreach (var cmd in PluginLoader.Commands!)
|
||||
{
|
||||
if (cmd.canUseDM)
|
||||
DMCommands += cmd.Command + " ";
|
||||
if (cmd.canUseDM) DMCommands += cmd.Command + " ";
|
||||
if (cmd.requireAdmin)
|
||||
adminCommands += cmd.Command + " ";
|
||||
adminCommands += cmd.Command + " ";
|
||||
else if (cmd.canUseServer) normalCommands += cmd.Command + " ";
|
||||
}
|
||||
|
||||
@@ -94,7 +93,7 @@ namespace DiscordBot.Discord.Commands
|
||||
private EmbedBuilder GenerateHelpCommand(string command)
|
||||
{
|
||||
EmbedBuilder embedBuilder = new EmbedBuilder();
|
||||
DBCommand cmd = PluginLoader.Plugins.Find(p => p.Command == command);
|
||||
DBCommand cmd = PluginLoader.Commands.Find(p => p.Command == command);
|
||||
if (cmd == null)
|
||||
return null;
|
||||
|
||||
|
||||
@@ -3,12 +3,11 @@ 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 DiscordBot.Discord.Core;
|
||||
using PluginManager;
|
||||
using PluginManager.Interfaces;
|
||||
using PluginManager.Others;
|
||||
using PluginManager.Others.Permissions;
|
||||
@@ -60,10 +59,9 @@ namespace DiscordBot.Discord.Commands
|
||||
var channel = message.Channel;
|
||||
try
|
||||
{
|
||||
|
||||
string content = message.Content;
|
||||
string[] data = content.Split(' ');
|
||||
string keyword = data[1];
|
||||
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)");
|
||||
@@ -80,7 +78,8 @@ namespace DiscordBot.Discord.Commands
|
||||
await channel.SendMessageAsync("Invalid token !");
|
||||
return;
|
||||
}
|
||||
Functions.WriteToSettings("./Data/Resources/DiscordBotCore.data", "BOT_TOKEN", data[2], '\t');
|
||||
|
||||
Config.SetValue("token", data[2]);
|
||||
break;
|
||||
case "prefix":
|
||||
if (data.Length != 3)
|
||||
@@ -88,7 +87,8 @@ namespace DiscordBot.Discord.Commands
|
||||
await channel.SendMessageAsync("Invalid token !");
|
||||
return;
|
||||
}
|
||||
Functions.WriteToSettings("./Data/Resources/DiscordBotCore.data", "BOT_PREFIX", data[2], '\t');
|
||||
|
||||
Config.SetValue("token", data[2]);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
@@ -96,8 +96,9 @@ namespace DiscordBot.Discord.Commands
|
||||
|
||||
await channel.SendMessageAsync("Restart required ...");
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
await channel.SendMessageAsync("Unknown usage to this command !\nUsage: " + Usage);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
using Discord.WebSocket;
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using PluginManager;
|
||||
using static PluginManager.Others.Functions;
|
||||
|
||||
namespace PluginManager.Core
|
||||
namespace DiscordBot.Discord.Core
|
||||
{
|
||||
internal class Boot
|
||||
{
|
||||
@@ -76,17 +76,6 @@ namespace PluginManager.Core
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The method that stops the bot from running
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task ShutDown()
|
||||
{
|
||||
if (client == null) return;
|
||||
await client.LogoutAsync();
|
||||
await client.StopAsync();
|
||||
}
|
||||
|
||||
private void CommonTasks()
|
||||
{
|
||||
if (client == null) return;
|
||||
@@ -107,6 +96,17 @@ namespace PluginManager.Core
|
||||
{
|
||||
Console.Title = "ONLINE";
|
||||
isReady = true;
|
||||
|
||||
new Thread(async () =>
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
Config.SaveConfig();
|
||||
Thread.Sleep(10000);
|
||||
}
|
||||
}
|
||||
).Start();
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ using System.Linq;
|
||||
using Discord;
|
||||
using System;
|
||||
|
||||
namespace PluginManager.Core
|
||||
namespace DiscordBot.Discord.Core
|
||||
{
|
||||
internal class CommandHandler
|
||||
{
|
||||
@@ -80,7 +80,7 @@ namespace PluginManager.Core
|
||||
services: null
|
||||
);
|
||||
|
||||
DBCommand plugin = PluginLoader.Plugins!.Where(p => p.Command == (message.Content.Split(' ')[0]).Substring(botPrefix.Length)).FirstOrDefault();
|
||||
DBCommand plugin = PluginLoader.Commands!.Where(p => p.Command == (message.Content.Split(' ')[0]).Substring(botPrefix.Length)).FirstOrDefault();
|
||||
|
||||
|
||||
if (plugin != null)
|
||||
|
||||
@@ -6,6 +6,16 @@
|
||||
<Nullable>disable</Nullable>
|
||||
<ApplicationIcon />
|
||||
<StartupObject />
|
||||
<SignAssembly>False</SignAssembly>
|
||||
<IsPublishable>True</IsPublishable>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DebugType>none</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<DebugType>none</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
using Discord;
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using PluginManager.Core;
|
||||
using PluginManager.Others;
|
||||
using PluginManager.LanguageSystem;
|
||||
using PluginManager.Online;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using DiscordBot.Discord.Core;
|
||||
using PluginManager;
|
||||
using PluginManager.Items;
|
||||
using PluginManager.Others;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DiscordBot
|
||||
{
|
||||
@@ -19,40 +14,47 @@ namespace DiscordBot
|
||||
{
|
||||
private static bool loadPluginsOnStartup = false;
|
||||
private static bool listPluginsAtStartup = false;
|
||||
private static bool listLanguagAtStartup = false;
|
||||
|
||||
private static bool ShowStartupMessage = true;
|
||||
private static bool listLanguagAtStartup = false;
|
||||
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
[Obsolete]
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Directory.CreateDirectory("./Data/Resources");
|
||||
Directory.CreateDirectory("./Data/Languages");
|
||||
Directory.CreateDirectory("./Data/Plugins/Commands");
|
||||
Directory.CreateDirectory("./Data/Plugins/Events");
|
||||
if (!File.Exists("./Data/Resources/DiscordBotCore.data") || (Functions.readCodeFromFile("./Data/Resources/DiscordBotCore.data", "BOT_TOKEN", '=').Length != 59 && Functions.readCodeFromFile("./Data/Resources/DiscordBotCore.data", "BOT_TOKEN", '=').Length != 70))
|
||||
Config.LoadConfig().Wait();
|
||||
if (!Config.ContainsKey("token") || Config.GetValue("token") == null || Config.GetValue("token")?.Length != 70)
|
||||
{
|
||||
File.WriteAllText("./Data/Resources/DiscordBotCore.data", "BOT_TOKEN=token\nBOT_PREFIX=!\n");
|
||||
while (true)
|
||||
{
|
||||
Console.WriteLine("Please insert your token: ");
|
||||
Console.Write("TOKEN: ");
|
||||
string botToken = Console.ReadLine();
|
||||
if (botToken.Length == 59 || botToken.Length == 70)
|
||||
Console.WriteLine("Please insert your token");
|
||||
Console.Write("Token = ");
|
||||
string token = Console.ReadLine();
|
||||
if (token?.Length == 59 || token?.Length == 70)
|
||||
Config.AddValueToVariables("token", token, true);
|
||||
else
|
||||
{
|
||||
string prefix = Functions.readCodeFromFile("./Data/Resources/DiscordBotCore.data", "BOT_PREFIX", '=');
|
||||
if (prefix == string.Empty || prefix == null)
|
||||
prefix = "!";
|
||||
File.WriteAllText("./Data/Resources/DiscordBotCore.data", $"BOT_TOKEN={botToken}\nBOT_PREFIX={prefix}\n");
|
||||
break;
|
||||
Console.WriteLine("Invalid token");
|
||||
continue;
|
||||
}
|
||||
else Console.WriteLine("Invalid Token !");
|
||||
|
||||
Console.WriteLine("Please insert your prefix (max. 1 character long):");
|
||||
Console.WriteLine("For a prefix longer then one character, the first character will be saved and the others will be ignored. No spaces or numbers allowed");
|
||||
Console.Write("Prefix = ");
|
||||
char prefix = Console.ReadLine()[0];
|
||||
|
||||
if (prefix == ' ' || char.IsDigit(prefix)) continue;
|
||||
Config.AddValueToVariables("prefix", prefix.ToString(), false);
|
||||
break;
|
||||
}
|
||||
|
||||
Config.SaveConfig();
|
||||
}
|
||||
|
||||
HandleInput(args).Wait();
|
||||
@@ -61,33 +63,28 @@ namespace DiscordBot
|
||||
/// <summary>
|
||||
/// Reset all settings for the bot
|
||||
/// </summary>
|
||||
private static Task ResetSettings()
|
||||
private static async Task ResetSettings()
|
||||
{
|
||||
string[] files = Directory.GetFiles(@"./Data/Resources");
|
||||
foreach (string file in files) File.Delete(file);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The main loop for the discord bot
|
||||
/// </summary>
|
||||
/// <param name="discordbooter">The discord booter used to start the application</param>
|
||||
private static async Task NoGUI(Boot discordbooter)
|
||||
private static Task NoGUI(Boot discordbooter)
|
||||
{
|
||||
Language.LoadLanguage();
|
||||
|
||||
ConsoleCommandsHandler consoleCommandsHandler = new ConsoleCommandsHandler(discordbooter.client);
|
||||
if (loadPluginsOnStartup)
|
||||
consoleCommandsHandler.HandleCommand("lp");
|
||||
if (listPluginsAtStartup)
|
||||
consoleCommandsHandler.HandleCommand("listplugs");
|
||||
if (listLanguagAtStartup)
|
||||
consoleCommandsHandler.HandleCommand("listlang");
|
||||
|
||||
if (loadPluginsOnStartup) consoleCommandsHandler.HandleCommand("lp");
|
||||
if (listPluginsAtStartup) consoleCommandsHandler.HandleCommand("listplugs");
|
||||
if (listLanguagAtStartup) consoleCommandsHandler.HandleCommand("listlang");
|
||||
Config.SaveConfig();
|
||||
while (true)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.White;
|
||||
consoleCommandsHandler.HandleCommand(Console.ReadLine());
|
||||
string cmd = Console.ReadLine();
|
||||
consoleCommandsHandler.HandleCommand(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,24 +94,15 @@ namespace DiscordBot
|
||||
/// <returns>Returns the boot loader for the Discord Bot</returns>
|
||||
private static async Task<Boot> StartNoGUI()
|
||||
{
|
||||
|
||||
Console.Clear();
|
||||
Console.ForegroundColor = ConsoleColor.DarkYellow;
|
||||
Console.WriteLine("Discord BOT for Cross Platform");
|
||||
Console.WriteLine("Created by: Wizzy\nDiscord: Wizzy#9181");
|
||||
if (ShowStartupMessage)
|
||||
try
|
||||
{
|
||||
Console.WriteLine("Connecting to server ...");
|
||||
List<string> text = await ServerCom.ReadTextFromFile("https://sethdiscordbot.000webhostapp.com/Storage/Discord%20Bot/StartupMessage");
|
||||
foreach (var t in text) Console_Utilities.WriteColorText(t);
|
||||
|
||||
}
|
||||
catch { Console.WriteLine("Failed to connect to server."); }
|
||||
Console.ForegroundColor = ConsoleColor.White;
|
||||
Console.WriteLine("============================ Discord BOT - Cross Platform ============================");
|
||||
string token = Functions.readCodeFromFile(Functions.dataFolder + "DiscordBotCore.data", "BOT_TOKEN", '=');
|
||||
string prefix = Functions.readCodeFromFile(Functions.dataFolder + "DiscordBotCore.data", "BOT_PREFIX", '=');
|
||||
string token = Config.GetValue("token");
|
||||
string prefix = Config.GetValue("prefix");
|
||||
|
||||
var discordbooter = new Boot(token, prefix);
|
||||
await discordbooter.Awake();
|
||||
@@ -127,8 +115,8 @@ namespace DiscordBot
|
||||
/// <param name="d">Directory path</param>
|
||||
private static Task ClearFolder(string d)
|
||||
{
|
||||
string[] files = Directory.GetFiles(d);
|
||||
int fileNumb = files.Length;
|
||||
string[] files = Directory.GetFiles(d);
|
||||
int fileNumb = files.Length;
|
||||
for (var i = 0; i < fileNumb; i++)
|
||||
{
|
||||
File.Delete(files[i]);
|
||||
@@ -144,16 +132,6 @@ namespace DiscordBot
|
||||
/// <param name="args">The arguments</param>
|
||||
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;
|
||||
if (len == 1 && args[0] == "--help")
|
||||
{
|
||||
@@ -163,8 +141,13 @@ namespace DiscordBot
|
||||
|
||||
if (len == 1 && args[0] == "--logout")
|
||||
{
|
||||
File.Delete(Functions.dataFolder + "Login.dat");
|
||||
Console.WriteLine("Logged out. Please restart the application !");
|
||||
File.Delete(Functions.dataFolder + "var.dat");
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(1000);
|
||||
Environment.Exit(0x08);
|
||||
}
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -178,20 +161,14 @@ namespace DiscordBot
|
||||
|
||||
if (len > 0 && (args.Contains("--cmd") || args.Contains("--args") || args.Contains("--nomessage")))
|
||||
{
|
||||
if (args.Contains("lp") || args.Contains("loadplugins"))
|
||||
loadPluginsOnStartup = true;
|
||||
if (args.Contains("listplugs"))
|
||||
listPluginsAtStartup = true;
|
||||
if (args.Contains("listlang"))
|
||||
listLanguagAtStartup = true;
|
||||
if (args.Contains("--nomessage"))
|
||||
ShowStartupMessage = false;
|
||||
if (args.Contains("lp") || args.Contains("loadplugins")) loadPluginsOnStartup = true;
|
||||
if (args.Contains("listplugs")) listPluginsAtStartup = true;
|
||||
if (args.Contains("listlang")) listLanguagAtStartup = true;
|
||||
//if (args.Contains("--nomessage")) ShowStartupMessage = false;
|
||||
len = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (len == 0 || args[0] != "--exec" && args[0] != "--execute")
|
||||
{
|
||||
Boot b = await StartNoGUI();
|
||||
@@ -240,7 +217,6 @@ namespace DiscordBot
|
||||
await ClearFolder("./Output/Logs/");
|
||||
await ClearFolder("./Output/Errors");
|
||||
await ClearFolder("./Data/Languages/");
|
||||
await ClearFolder("./Data/Plugins/Addons");
|
||||
await ClearFolder("./Data/Plugins/Commands");
|
||||
await ClearFolder("./Data/Plugins/Events");
|
||||
Console.WriteLine("Successfully cleared all folders");
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System.IO;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using PluginManager.Others;
|
||||
|
||||
namespace DiscordBotGUI
|
||||
{
|
||||
@@ -13,13 +15,7 @@ namespace DiscordBotGUI
|
||||
|
||||
public override void OnFrameworkInitializationCompleted()
|
||||
{
|
||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
|
||||
|
||||
desktop.MainWindow = new AppUpdater() { Width = 300, Height = 50, WindowStartupLocation = Avalonia.Controls.WindowStartupLocation.CenterScreen };
|
||||
|
||||
}
|
||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { desktop.MainWindow = new AppUpdater() { Width = 300, Height = 50, WindowStartupLocation = Avalonia.Controls.WindowStartupLocation.CenterScreen }; }
|
||||
|
||||
base.OnFrameworkInitializationCompleted();
|
||||
}
|
||||
|
||||
@@ -1,62 +1,66 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
using PluginManager.Online;
|
||||
using PluginManager.Others;
|
||||
using System.Threading.Tasks;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Drawing;
|
||||
using Avalonia.Media;
|
||||
using PluginManager;
|
||||
|
||||
namespace DiscordBotGUI
|
||||
{
|
||||
public partial class AppUpdater : Window
|
||||
{
|
||||
private string _version;
|
||||
|
||||
public AppUpdater()
|
||||
{
|
||||
InitializeComponent();
|
||||
if (!File.Exists("./Version.txt"))
|
||||
{
|
||||
textBox1.Text = "Checking ...";
|
||||
File.WriteAllText("./Version.txt", "DiscordBotVersion=0");
|
||||
//DownloadDiscordBotClientNoGUIAsDLL();
|
||||
DownloadDiscordBotClientNoGUIAsDLL();
|
||||
}
|
||||
|
||||
if (!File.Exists("./DiscordBot.exe")) DownloadDiscordBotClientNoGUIAsDLL();
|
||||
Updates();
|
||||
|
||||
}
|
||||
|
||||
/* private async void DownloadDiscordBotClientNoGUIAsDLL()
|
||||
{
|
||||
private async void DownloadDiscordBotClientNoGUIAsDLL()
|
||||
{
|
||||
//await Task.Delay(5000);
|
||||
string url_bot_dll = "https://sethdiscordbot.000webhostapp.com/Storage/Discord%20Bot/Updates/DiscordBot.zip";
|
||||
int actiontype = 0; //0 - downolad, 1- extract
|
||||
IProgress<float> progress = new Progress<float>((percent) =>
|
||||
{
|
||||
if (actiontype == 0)
|
||||
textBox1.Text = "Downloading DiscordBot ... " + MathF.Round(percent, 2) + "%";
|
||||
else
|
||||
textBox1.Text = "Extracting package ..." + MathF.Round(percent, 2) + "%";
|
||||
this.progressBar1.Value = percent;
|
||||
});
|
||||
|
||||
//await Task.Delay(5000);
|
||||
string url_bot_dll = "https://sethdiscordbot.000webhostapp.com/Storage/Discord%20Bot/Updates/DiscordBot.dll";
|
||||
IProgress<float> progress = new Progress<float>((percent) =>
|
||||
{
|
||||
textBox1.Text = "Downloading DiscordBot.dll ... " + (percent * 100).ToString() + "%";
|
||||
this.progressBar1.Value = percent * 100;
|
||||
});
|
||||
this.progressBar1.IsIndeterminate = false;
|
||||
try
|
||||
{
|
||||
await ServerCom.DownloadFileAsync(url_bot_dll, "./DiscordBot.zip", progress);
|
||||
|
||||
this.progressBar1.IsIndeterminate = false;
|
||||
try
|
||||
{
|
||||
await ServerCom.DownloadFileAsync(url_bot_dll, "./DiscordBot.dll", progress);
|
||||
}
|
||||
catch
|
||||
{
|
||||
textBox1.Text = "Error downloading DiscordBot.dll. Server is not responding.";
|
||||
actiontype++;
|
||||
|
||||
await Task.Delay(1000);
|
||||
return;
|
||||
}
|
||||
await Functions.ExtractArchive("./DiscordBot.zip", "./", progress);
|
||||
}
|
||||
catch
|
||||
{
|
||||
textBox1.Text = "Error downloading DiscordBot.dll. Server is not responding.";
|
||||
|
||||
//new MainWindow() { Height = 425, Width = 500 }.Show();
|
||||
//Close();
|
||||
}*/
|
||||
await Task.Delay(1000);
|
||||
|
||||
new MainWindow() { Height = 425, Width = 500 }.Show();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
private async void Updates()
|
||||
{
|
||||
@@ -82,31 +86,27 @@ namespace DiscordBotGUI
|
||||
return;
|
||||
}
|
||||
|
||||
IProgress<float> progress = new Progress<float>((percent) =>
|
||||
{
|
||||
this.progressBar1.Value = percent;
|
||||
});
|
||||
IProgress<float> progress = new Progress<float>((percent) => { this.progressBar1.Value = percent; });
|
||||
|
||||
textBox1.Text = "Extracting update files ...";
|
||||
await Functions.ExtractArchive(file, "./", progress);
|
||||
progressBar1.IsIndeterminate = true;
|
||||
textBox1.Text = "Setting up the new version ...";
|
||||
textBox1.Text = "Setting up the new version ...";
|
||||
File.Delete(file);
|
||||
File.WriteAllText("./Version.txt", "DiscordBotVersion=" + _version);
|
||||
await Task.Delay(5000);
|
||||
new MainWindow() { Height = 425, Width = 650 }.Show();
|
||||
this.Close();
|
||||
|
||||
}
|
||||
|
||||
private async Task<string> DownloadNewUpdate()
|
||||
{
|
||||
string urlNewUpdateZip = (await ServerCom.ReadTextFromFile("https://sethdiscordbot.000webhostapp.com/Storage/Discord%20Bot/Updates/Version"))[1];
|
||||
int secondsPast = 0;
|
||||
int secondsPast = 0;
|
||||
|
||||
bool isDownloading = true;
|
||||
this.progressBar1.IsIndeterminate = true;
|
||||
textBox1.Text = "Downloading update ...";
|
||||
textBox1.Text = "Downloading update ...";
|
||||
|
||||
|
||||
IProgress<long> downloaded = new Progress<long>((bytes) =>
|
||||
@@ -117,14 +117,13 @@ namespace DiscordBotGUI
|
||||
IProgress<float> progress = new Progress<float>((percent) =>
|
||||
{
|
||||
progressBar1.IsIndeterminate = false;
|
||||
this.progressBar1.Value = percent;
|
||||
this.progressBar1.Value = percent;
|
||||
});
|
||||
|
||||
|
||||
string FileName = $"{urlNewUpdateZip.Split('/')[urlNewUpdateZip.Split('/').Length - 1]}";
|
||||
try
|
||||
{
|
||||
|
||||
new Thread(new Task(() =>
|
||||
{
|
||||
while (isDownloading)
|
||||
@@ -142,6 +141,7 @@ namespace DiscordBotGUI
|
||||
await Task.Delay(1000);
|
||||
return null;
|
||||
}
|
||||
|
||||
isDownloading = false;
|
||||
return FileName;
|
||||
}
|
||||
@@ -150,20 +150,20 @@ namespace DiscordBotGUI
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
string current_version = Functions.readCodeFromFile("Version.txt", "DiscordBotVersion", '=') ?? "0";
|
||||
string latest_version = (await ServerCom.ReadTextFromFile("https://sethdiscordbot.000webhostapp.com/Storage/Discord%20Bot/Updates/Version"))[0];
|
||||
string current_version = Config.GetValue("Version");
|
||||
if (current_version == null)
|
||||
if (!Config.SetValue("Version", "0"))
|
||||
Config.AddValueToVariables("Version", "0", false);
|
||||
string latest_version = (await ServerCom.ReadTextFromFile("https://sethdiscordbot.000webhostapp.com/Storage/Discord%20Bot/Updates/Version"))[0];
|
||||
_version = latest_version;
|
||||
if (current_version != latest_version)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (current_version != latest_version) { return true; }
|
||||
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
textBox1.Text = "Error while checking for updates. Server is not responding.";
|
||||
Functions.WriteErrFile(ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using PluginManager.Others;
|
||||
using System.IO;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using DiscordBotGUI.Settings;
|
||||
using Avalonia.Themes.Fluent;
|
||||
using PluginManager;
|
||||
|
||||
namespace DiscordBotGUI
|
||||
{
|
||||
@@ -27,8 +26,7 @@ namespace DiscordBotGUI
|
||||
|
||||
|
||||
textBox3.Watermark = "Insert start arguments";
|
||||
if (File.Exists("./Version.txt"))
|
||||
label5.Content = Functions.readCodeFromFile("./Version.txt", "DiscordBotVersion", '=');
|
||||
if (File.Exists("./Version.txt")) label5.Content = Config.GetValue("Version");
|
||||
button1.Click += async (sender, e) =>
|
||||
{
|
||||
|
||||
@@ -44,8 +42,8 @@ namespace DiscordBotGUI
|
||||
return;
|
||||
}
|
||||
|
||||
Functions.WriteToSettings(Functions.dataFolder + "DiscordBotCore.data", "BOT_TOKEN", token, '=');
|
||||
Functions.WriteToSettings(Functions.dataFolder + "DiscordBotCore.data", "BOT_PREFIX", prefix, '=');
|
||||
Config.SetValue("token", token);
|
||||
Config.SetValue("prefix", prefix);
|
||||
RunDiscordBot(args);
|
||||
|
||||
};
|
||||
@@ -58,8 +56,8 @@ namespace DiscordBotGUI
|
||||
Directory.CreateDirectory(Functions.dataFolder);
|
||||
try
|
||||
{
|
||||
string? botToken = Functions.readCodeFromFile(folder, "BOT_TOKEN", '=');
|
||||
string? botPrefix = Functions.readCodeFromFile(folder, "BOT_PREFIX", '=');
|
||||
string? botToken = Config.GetValue("token") as string;
|
||||
string? botPrefix = Config.GetValue("prefix") as string;
|
||||
if (botToken == null || botPrefix == null)
|
||||
{
|
||||
textBox1.IsReadOnly = false;
|
||||
|
||||
@@ -13,19 +13,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Events", "Events", "{A290C0
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Commands", "Commands", "{449FA364-0B72-43FF-B3A3-806E2916200E}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CMD_LevelingSystem", "CMD_LevelingSystem\CMD_LevelingSystem.csproj", "{A48E8DC6-DBA2-4B47-9D59-46F4835F82CC}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EVE_LevelingSystem", "EVE_LevelingSystem\EVE_LevelingSystem.csproj", "{1C1E7F3D-E05A-4A87-9789-62D98904C200}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StartupEvents", "StartupEvents\StartupEvents.csproj", "{CE9DBF06-38A0-4192-8B3E-4009210D040D}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CMD_Utils", "CMD_Utils\CMD_Utils.csproj", "{E26C87A4-3DD6-4B58-B14B-C8E086B852F9}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MusicCommands", "MusicCommands\MusicCommands.csproj", "{B1B4976E-5112-4217-B57B-3A03C5207B6E}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Games", "FreeGames\Games.csproj", "{7CC0819E-2BC0-44F0-8D92-EC442F36E1BB}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiscordBotGUI", "DiscordBotGUI\DiscordBotGUI.csproj", "{7B5899F0-0218-4537-8C74-6210ED2D3690}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiscordBotGUI", "DiscordBotGUI\DiscordBotGUI.csproj", "{7B5899F0-0218-4537-8C74-6210ED2D3690}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EVE_LevelingSystem", "EVE_LevelingSystem\EVE_LevelingSystem.csproj", "{EEC445DC-0C4B-43EA-8694-606BA0390B77}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CMD_LevelingSystem", "CMD_LevelingSystem\CMD_LevelingSystem.csproj", "{1A4E49FF-9A0A-4C54-AF35-CFFBA64353D9}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -41,18 +37,6 @@ Global
|
||||
{EDD4D9B3-98DD-4367-A09F-D1C5ACB61132}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EDD4D9B3-98DD-4367-A09F-D1C5ACB61132}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EDD4D9B3-98DD-4367-A09F-D1C5ACB61132}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A48E8DC6-DBA2-4B47-9D59-46F4835F82CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A48E8DC6-DBA2-4B47-9D59-46F4835F82CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A48E8DC6-DBA2-4B47-9D59-46F4835F82CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A48E8DC6-DBA2-4B47-9D59-46F4835F82CC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1C1E7F3D-E05A-4A87-9789-62D98904C200}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1C1E7F3D-E05A-4A87-9789-62D98904C200}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1C1E7F3D-E05A-4A87-9789-62D98904C200}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1C1E7F3D-E05A-4A87-9789-62D98904C200}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{CE9DBF06-38A0-4192-8B3E-4009210D040D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{CE9DBF06-38A0-4192-8B3E-4009210D040D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{CE9DBF06-38A0-4192-8B3E-4009210D040D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{CE9DBF06-38A0-4192-8B3E-4009210D040D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E26C87A4-3DD6-4B58-B14B-C8E086B852F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E26C87A4-3DD6-4B58-B14B-C8E086B852F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E26C87A4-3DD6-4B58-B14B-C8E086B852F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
@@ -61,14 +45,18 @@ Global
|
||||
{B1B4976E-5112-4217-B57B-3A03C5207B6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B1B4976E-5112-4217-B57B-3A03C5207B6E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B1B4976E-5112-4217-B57B-3A03C5207B6E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7CC0819E-2BC0-44F0-8D92-EC442F36E1BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7CC0819E-2BC0-44F0-8D92-EC442F36E1BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7CC0819E-2BC0-44F0-8D92-EC442F36E1BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7CC0819E-2BC0-44F0-8D92-EC442F36E1BB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7B5899F0-0218-4537-8C74-6210ED2D3690}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7B5899F0-0218-4537-8C74-6210ED2D3690}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7B5899F0-0218-4537-8C74-6210ED2D3690}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7B5899F0-0218-4537-8C74-6210ED2D3690}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{EEC445DC-0C4B-43EA-8694-606BA0390B77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{EEC445DC-0C4B-43EA-8694-606BA0390B77}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EEC445DC-0C4B-43EA-8694-606BA0390B77}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EEC445DC-0C4B-43EA-8694-606BA0390B77}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1A4E49FF-9A0A-4C54-AF35-CFFBA64353D9}.Debug|Any CPU.ActiveCfg = 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.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -76,12 +64,10 @@ Global
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{A290C028-77C4-4D1D-AB43-DDFE6ABD9012} = {1862ABD5-7C30-4F15-A561-45AC8A9CA10E}
|
||||
{449FA364-0B72-43FF-B3A3-806E2916200E} = {1862ABD5-7C30-4F15-A561-45AC8A9CA10E}
|
||||
{A48E8DC6-DBA2-4B47-9D59-46F4835F82CC} = {449FA364-0B72-43FF-B3A3-806E2916200E}
|
||||
{1C1E7F3D-E05A-4A87-9789-62D98904C200} = {A290C028-77C4-4D1D-AB43-DDFE6ABD9012}
|
||||
{CE9DBF06-38A0-4192-8B3E-4009210D040D} = {A290C028-77C4-4D1D-AB43-DDFE6ABD9012}
|
||||
{E26C87A4-3DD6-4B58-B14B-C8E086B852F9} = {449FA364-0B72-43FF-B3A3-806E2916200E}
|
||||
{B1B4976E-5112-4217-B57B-3A03C5207B6E} = {449FA364-0B72-43FF-B3A3-806E2916200E}
|
||||
{7CC0819E-2BC0-44F0-8D92-EC442F36E1BB} = {449FA364-0B72-43FF-B3A3-806E2916200E}
|
||||
{EEC445DC-0C4B-43EA-8694-606BA0390B77} = {A290C028-77C4-4D1D-AB43-DDFE6ABD9012}
|
||||
{1A4E49FF-9A0A-4C54-AF35-CFFBA64353D9} = {449FA364-0B72-43FF-B3A3-806E2916200E}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {3FB3C5DE-ED21-4D2E-ABDD-3A00EE4A2FFF}
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
public class Core
|
||||
{
|
||||
|
||||
public static Dictionary<ulong, string> playerMessages = new Dictionary<ulong, string>();
|
||||
|
||||
private static readonly string folder = @".\Data\Resources\LevelingSystem\";
|
||||
|
||||
public static int GetLevel(ulong id) => int.Parse(File.ReadAllText(Path.Combine(folder, id.ToString() + ".data")).Split(',')[0].Split('=')[1]);
|
||||
|
||||
|
||||
public static Int64 GetExp(ulong id) => Int64.Parse(File.ReadAllText(Path.Combine(folder, id.ToString() + ".data")).Split(',')[1].Split('=')[1]);
|
||||
|
||||
|
||||
public static Int64 GetReqEXP(ulong id) => Int64.Parse(File.ReadAllText(Path.Combine(folder, id.ToString() + ".data")).Split(',')[2].Split('=')[1]);
|
||||
public static void SaveData(ulong id, int lv, Int64 cexp, Int64 rexp)
|
||||
{
|
||||
Directory.CreateDirectory(folder);
|
||||
File.WriteAllText(Path.Combine(folder, id.ToString() + ".data"), $"Level={lv},EXP={cexp},REXP={rexp}");
|
||||
}
|
||||
private static Int64 NextLevelXP(int level)
|
||||
{
|
||||
return (level * level) + 2 * level + 75;
|
||||
}
|
||||
|
||||
public static (bool, int) MessageSent(ulong id, int messageLength)
|
||||
{
|
||||
WaitForTimeToRemoveFromList(id, 60);
|
||||
|
||||
if (!File.Exists(Path.Combine(folder, id.ToString() + ".data")))
|
||||
{
|
||||
SaveData(id, 0, 0, 0);
|
||||
}
|
||||
Int64 cEXp = GetExp(id);
|
||||
Int64 rExp = GetReqEXP(id);
|
||||
int random = new System.Random().Next(3, 6) + messageLength;
|
||||
cEXp += random;
|
||||
if (cEXp >= rExp)
|
||||
{
|
||||
cEXp = cEXp - rExp;
|
||||
int lv = GetLevel(id);
|
||||
rExp = NextLevelXP(lv);
|
||||
lv++;
|
||||
SaveData(id, lv, cEXp, rExp);
|
||||
return (true, lv);
|
||||
}
|
||||
|
||||
SaveData(id, GetLevel(id), cEXp, rExp);
|
||||
return (false, -1);
|
||||
}
|
||||
|
||||
public static async void WaitForTimeToRemoveFromList(ulong id, int time_seconds)
|
||||
{
|
||||
await Task.Delay(time_seconds * 1000);
|
||||
playerMessages.Remove(id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using Discord.WebSocket;
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
public static class Data
|
||||
{
|
||||
private static readonly string folder = @".\Data\Resources\LevelingSystem\";
|
||||
public static void registerPlayer(SocketGuildUser user)
|
||||
{
|
||||
ulong id = user.Id;
|
||||
Directory.CreateDirectory(folder);
|
||||
File.WriteAllText(Path.Combine(folder, id.ToString() + ".data"), "Level=0,EXP=0,REXP=100");
|
||||
}
|
||||
|
||||
public static int GetLevel(ulong id) => int.Parse(File.ReadAllText(Path.Combine(folder, id.ToString() + ".data")).Split(',')[0].Split('=')[1]);
|
||||
|
||||
|
||||
public static Int64 GetExp(ulong id) => Int64.Parse(File.ReadAllText(Path.Combine(folder, id.ToString() + ".data")).Split(',')[1].Split('=')[1]);
|
||||
|
||||
|
||||
public static Int64 GetReqEXP(ulong id) => Int64.Parse(File.ReadAllText(Path.Combine(folder, id.ToString() + ".data")).Split(',')[2].Split('=')[1]);
|
||||
|
||||
|
||||
}
|
||||
@@ -1,17 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<BaseOutputPath>..\DiscordBot\bin\Debug\net6.0\Data\Plugins\Events\LevelingSystem</BaseOutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<OutputPath>..\BUILDS\</OutputPath>
|
||||
<DebugType>none</DebugType>
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Remove="bin\**" />
|
||||
<EmbeddedResource Remove="bin\**" />
|
||||
<None Remove="bin\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PluginManager\PluginManager.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PluginManager\PluginManager.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
53
EVE_LevelingSystem/Level.cs
Normal file
53
EVE_LevelingSystem/Level.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using Discord.WebSocket;
|
||||
using EVE_LevelingSystem.LevelingSystemCore;
|
||||
using PluginManager;
|
||||
using PluginManager.Interfaces;
|
||||
using PluginManager.Others;
|
||||
|
||||
namespace EVE_LevelingSystem
|
||||
{
|
||||
internal class Level : DBEvent
|
||||
{
|
||||
public string name => "Leveling System Event Handler";
|
||||
public string description => "The Leveling System Event Handler";
|
||||
internal static Settings globalSettings = new();
|
||||
|
||||
|
||||
public async void Start(DiscordSocketClient client)
|
||||
{
|
||||
Directory.CreateDirectory("./Data/Resources/LevelingSystem");
|
||||
Config.AddValueToVariables("LevelingSystemPath", "./Data/Resources/LevelingSystem", true);
|
||||
Config.AddValueToVariables("LevelingSystemSettingsFile", "./Data/Resources/LevelingSystemSettings.txt", true);
|
||||
|
||||
if (!File.Exists(Config.GetValue("LevelingSystemSettingsFile")))
|
||||
{
|
||||
globalSettings = new Settings { TimeToWaitBetweenMessages = 5 };
|
||||
await Functions.SaveToJsonFile<Settings>(Config.GetValue("LevelingSystemSettingsFile"), globalSettings);
|
||||
}
|
||||
else
|
||||
globalSettings = await Functions.ConvertFromJson<Settings>(Config.GetValue("LevelingSystemSettingsFile"));
|
||||
|
||||
// Console.WriteLine(globalSettings.TimeToWaitBetweenMessages);
|
||||
client.MessageReceived += ClientOnMessageReceived;
|
||||
}
|
||||
|
||||
private async Task ClientOnMessageReceived(SocketMessage arg)
|
||||
{
|
||||
if (arg.Author.IsBot || arg.IsTTS || arg.Content.StartsWith(Config.GetValue("prefix"))) return;
|
||||
string userID = arg.Author.Id.ToString();
|
||||
User user;
|
||||
if (File.Exists($"{Config.GetValue("LevelingSystemPath")}/{userID}.dat"))
|
||||
{
|
||||
user = await Functions.ConvertFromJson<User>(Config.GetValue("LevelingSystemPath")! + $"/{userID}.dat");
|
||||
// Console.WriteLine(Config.GetValue("LevelingSystemPath"));
|
||||
if (user.AddEXP()) await arg.Channel.SendMessageAsync($"{arg.Author.Mention} is now level {user.CurrentLevel}");
|
||||
await Functions.SaveToJsonFile(Config.GetValue("LevelingSystemPath") + $"/{userID}.dat", user);
|
||||
return;
|
||||
}
|
||||
|
||||
user = new User() { CurrentEXP = 0, CurrentLevel = 1, RequiredEXPToLevelUp = LevelCalculator.GetNextLevelRequiredEXP(1), userID = userID };
|
||||
if (user.AddEXP()) await arg.Channel.SendMessageAsync($"{arg.Author.Mention} is now level {user.CurrentLevel}");
|
||||
await Functions.SaveToJsonFile($"{Config.GetValue("LevelingSystemPath")}/{userID}.dat", user);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Discord.WebSocket;
|
||||
|
||||
using PluginManager.Others;
|
||||
using PluginManager.Interfaces;
|
||||
using PluginManager.LanguageSystem;
|
||||
public class LevelingSystem : DBEvent
|
||||
{
|
||||
public string name => "Leveling System";
|
||||
|
||||
public string description => "Leveling System Event";
|
||||
|
||||
public void Start(DiscordSocketClient client)
|
||||
{
|
||||
client.MessageReceived += Client_MessageReceived;
|
||||
}
|
||||
|
||||
private async Task Client_MessageReceived(SocketMessage arg)
|
||||
{
|
||||
if (arg.Author.IsBot || arg.Attachments.Count > 0 ||
|
||||
arg.Content.StartsWith
|
||||
(
|
||||
Functions.readCodeFromFile
|
||||
(
|
||||
fileName: System.IO.Path.Combine(Functions.dataFolder, "DiscordBotCore.data"),
|
||||
Code: "BOT_PREFIX",
|
||||
separator: '='
|
||||
)
|
||||
)
|
||||
)
|
||||
return;
|
||||
//Console_Utilities.WriteColorText("Message from : " + arg.Author.Username);
|
||||
if (Core.playerMessages.ContainsKey(arg.Author.Id))
|
||||
return;
|
||||
|
||||
(bool x, int lv) = Core.MessageSent(arg.Author.Id, arg.Content.Length);
|
||||
Core.playerMessages.Add(arg.Author.Id, arg.Content);
|
||||
if (x)
|
||||
if (Language.ActiveLanguage != null)
|
||||
await arg.Channel.SendMessageAsync(Language.ActiveLanguage.LanguageWords["DB_EVENT_LEVEL_SYSTEM_LEVEL_UP"].Replace("{0}", lv.ToString()));
|
||||
else await arg.Channel.SendMessageAsync("You've successfully leveled up to level " + lv);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
57
EVE_LevelingSystem/LevelingSystemCore/LevelCalculator.cs
Normal file
57
EVE_LevelingSystem/LevelingSystemCore/LevelCalculator.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using PluginManager;
|
||||
|
||||
namespace EVE_LevelingSystem.LevelingSystemCore
|
||||
{
|
||||
internal static class LevelCalculator
|
||||
{
|
||||
internal static List<string> OnWaitingList = new();
|
||||
|
||||
internal static Int64 GetNextLevelRequiredEXP(int currentLevel)
|
||||
{
|
||||
return currentLevel * 8 + 24;
|
||||
}
|
||||
|
||||
internal static void LevelUp(this User user)
|
||||
{
|
||||
user.CurrentEXP = 0;
|
||||
user.RequiredEXPToLevelUp = GetNextLevelRequiredEXP(user.CurrentLevel);
|
||||
user.CurrentLevel++;
|
||||
}
|
||||
|
||||
internal static bool AddEXP(this User user)
|
||||
{
|
||||
if (OnWaitingList.Contains(user.userID)) return false;
|
||||
Random r = new Random();
|
||||
int exp = r.Next(2, 12);
|
||||
Int64 userXP = user.CurrentEXP;
|
||||
Int64 reqEXP = user.RequiredEXPToLevelUp;
|
||||
if (userXP + exp >= reqEXP)
|
||||
{
|
||||
user.LevelUp();
|
||||
user.CurrentEXP = exp - (reqEXP - userXP);
|
||||
Console.WriteLine("Level up");
|
||||
return true;
|
||||
}
|
||||
|
||||
user.CurrentEXP += exp;
|
||||
|
||||
OnWaitingList.Add(user.userID);
|
||||
|
||||
|
||||
new Thread(() =>
|
||||
{
|
||||
int minutesToWait = Level.globalSettings.TimeToWaitBetweenMessages;
|
||||
Thread.Sleep(60000 * minutesToWait);
|
||||
OnWaitingList.Remove(user.userID);
|
||||
}
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
16
EVE_LevelingSystem/LevelingSystemCore/User.cs
Normal file
16
EVE_LevelingSystem/LevelingSystemCore/User.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EVE_LevelingSystem.LevelingSystemCore
|
||||
{
|
||||
public class User
|
||||
{
|
||||
public string userID { get; set; }
|
||||
public int CurrentLevel { get; set; }
|
||||
public Int64 CurrentEXP { get; set; }
|
||||
public Int64 RequiredEXPToLevelUp { get; set; }
|
||||
}
|
||||
}
|
||||
13
EVE_LevelingSystem/Settings.cs
Normal file
13
EVE_LevelingSystem/Settings.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EVE_LevelingSystem
|
||||
{
|
||||
public class Settings
|
||||
{
|
||||
public int TimeToWaitBetweenMessages { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
using PluginManager.Interfaces;
|
||||
using Games.Objects;
|
||||
namespace Games;
|
||||
|
||||
public class Game : DBCommand
|
||||
{
|
||||
public string Command => "game";
|
||||
public string Description => "Display info about the specified game";
|
||||
public string Usage => "game <game>";
|
||||
|
||||
public bool canUseDM => false;
|
||||
public bool canUseServer => true;
|
||||
public bool requireAdmin => false;
|
||||
|
||||
public async void Execute(Discord.Commands.SocketCommandContext context, Discord.WebSocket.SocketMessage message,
|
||||
Discord.WebSocket.DiscordSocketClient client, bool isDM)
|
||||
{
|
||||
string game_name = PluginManager.Others.Functions.MergeStrings(message.Content.Split(' '), 1);
|
||||
string game_url = await GameData.GetSteamLinkFromGame(game_name);
|
||||
if (game_url is null || game_url == null)
|
||||
{
|
||||
await message.Channel.SendMessageAsync("Could not find the game. Try to be more specific or check for spelling errors.");
|
||||
return;
|
||||
}
|
||||
await context.Channel.SendMessageAsync(game_url);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Server\**" />
|
||||
<EmbeddedResource Remove="Server\**" />
|
||||
<None Remove="Server\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PluginManager\PluginManager.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,24 +0,0 @@
|
||||
using PluginManager.Online;
|
||||
namespace Games.Objects;
|
||||
|
||||
public class GameData
|
||||
{
|
||||
internal async static Task<string> GetSteamLinkFromGame(string GameName)
|
||||
{
|
||||
string URL = $"https://store.steampowered.com/search?term={GameName.Replace(" ", "+")}";
|
||||
List<string> lines = await ServerCom.ReadTextFromFile(URL);
|
||||
|
||||
string? gameData = (
|
||||
from s in lines
|
||||
where s.Contains(GameName.Replace(" ", "_"), StringComparison.OrdinalIgnoreCase)
|
||||
select s).FirstOrDefault();
|
||||
if (gameData is null) return null;
|
||||
string GameURL = gameData.Split('\"')[1].Split('?')[0];
|
||||
|
||||
if (GameURL == "menuitem")
|
||||
return null;
|
||||
|
||||
return GameURL;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
<Window
|
||||
x:Class="PluginManager.BlankWindow1"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:PluginManager"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
75
PluginManager/Config.cs
Normal file
75
PluginManager/Config.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using PluginManager.Others;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PluginManager
|
||||
{
|
||||
internal class AppConfig
|
||||
{
|
||||
public Dictionary<string, string> ApplicationVariables { get; set; }
|
||||
public List<string> ProtectedKeyWords { get; set; }
|
||||
}
|
||||
|
||||
public static class Config
|
||||
{
|
||||
private static AppConfig appConfig = null;
|
||||
|
||||
public static bool AddValueToVariables(string key, string value, bool isProtected)
|
||||
{
|
||||
if (appConfig.ApplicationVariables.ContainsKey(key)) return false;
|
||||
appConfig.ApplicationVariables.Add(key, value);
|
||||
if (isProtected) appConfig.ProtectedKeyWords.Add(key);
|
||||
SaveConfig();
|
||||
return true;
|
||||
}
|
||||
|
||||
public static string? GetValue(string key)
|
||||
{
|
||||
if (!appConfig.ApplicationVariables.ContainsKey(key)) return null;
|
||||
return appConfig.ApplicationVariables[key];
|
||||
}
|
||||
|
||||
public static bool SetValue(string key, string value)
|
||||
{
|
||||
if (!appConfig.ApplicationVariables.ContainsKey(key)) return false;
|
||||
if (appConfig.ProtectedKeyWords.Contains(key)) return false;
|
||||
appConfig.ApplicationVariables[key] = value;
|
||||
SaveConfig();
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool RemoveKey(string key)
|
||||
{
|
||||
appConfig.ApplicationVariables.Remove(key);
|
||||
appConfig.ProtectedKeyWords.Remove(key);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static async void SaveConfig()
|
||||
{
|
||||
string path = Functions.dataFolder + "var.dat";
|
||||
await Functions.SaveToJsonFile<AppConfig>(path, appConfig);
|
||||
}
|
||||
|
||||
public static async Task LoadConfig()
|
||||
{
|
||||
string path = Functions.dataFolder + "var.dat";
|
||||
if (File.Exists(path))
|
||||
{
|
||||
appConfig = await Functions.ConvertFromJson<AppConfig>(path);
|
||||
Functions.WriteLogFile($"Loaded {appConfig.ApplicationVariables.Keys.Count} application variables.\nLoaded {appConfig.ProtectedKeyWords.Count} readonly variables.");
|
||||
}
|
||||
else
|
||||
appConfig = new() { ApplicationVariables = new Dictionary<string, string>(), ProtectedKeyWords = new List<string>() };
|
||||
}
|
||||
|
||||
public static string? GetKey(string value) => appConfig.ApplicationVariables.Keys.FirstOrDefault(x => appConfig.ApplicationVariables[x] == value);
|
||||
public static bool ContainsValue(string value) => appConfig.ApplicationVariables.ContainsValue(value);
|
||||
public static bool ContainsKey(string key) => appConfig.ApplicationVariables.ContainsKey(key);
|
||||
|
||||
public static Dictionary<string, string> GetAllVariables() => new Dictionary<string, string>(appConfig.ApplicationVariables);
|
||||
}
|
||||
}
|
||||
@@ -1,45 +1,40 @@
|
||||
using Discord.WebSocket;
|
||||
|
||||
using PluginManager.Loaders;
|
||||
using PluginManager.Online;
|
||||
using PluginManager.Others;
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using PluginManager.LanguageSystem;
|
||||
using System.Linq;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
|
||||
namespace PluginManager.Items
|
||||
{
|
||||
public class ConsoleCommandsHandler
|
||||
{
|
||||
private static PluginsManager manager = new("https://sethdiscordbot.000webhostapp.com/Storage/Discord%20Bot/Plugins");
|
||||
|
||||
private static PluginsManager manager = new PluginsManager("https://sethdiscordbot.000webhostapp.com/Storage/Discord%20Bot/Plugins");
|
||||
private static LanguageManager languageManager = new LanguageManager("https://sethdiscordbot.000webhostapp.com/Storage/Discord%20Bot/Languages");
|
||||
|
||||
|
||||
public static List<Tuple<string, string, Action<string[]>>> commandList = new List<Tuple<string, string, Action<string[]>>>();
|
||||
private DiscordSocketClient client;
|
||||
public static List<Tuple<string, string, Action<string[]>>>? commandList = new List<Tuple<string, string, Action<string[]>>>();
|
||||
private DiscordSocketClient client;
|
||||
|
||||
public ConsoleCommandsHandler(DiscordSocketClient client)
|
||||
{
|
||||
this.client = client;
|
||||
//commandList = new List<Tuple<string, string, Action<string[]>>>();
|
||||
InitializeBasicCommands();
|
||||
//Console.WriteLine("ConsoleCommandsHandler enabled");
|
||||
Console.WriteLine("Initalized console command handeler !");
|
||||
}
|
||||
|
||||
private void InitializeBasicCommands()
|
||||
{
|
||||
|
||||
bool pluginsLoaded = false;
|
||||
commandList.Clear();
|
||||
|
||||
AddCommand("help", "Show help", (args) =>
|
||||
{
|
||||
if (args.Length == 1)
|
||||
if (args.Length <= 1)
|
||||
{
|
||||
Console.WriteLine("Available commands:");
|
||||
foreach (var command in commandList)
|
||||
@@ -51,7 +46,7 @@ namespace PluginManager.Items
|
||||
{
|
||||
foreach (var command in commandList)
|
||||
{
|
||||
if (command.Item1 == args[0])
|
||||
if (command.Item1 == args[1])
|
||||
{
|
||||
Console.WriteLine(command.Item2);
|
||||
return;
|
||||
@@ -71,14 +66,9 @@ namespace PluginManager.Items
|
||||
if (name == null || name.Length < 2)
|
||||
name = typeName;
|
||||
if (success)
|
||||
if (LanguageSystem.Language.ActiveLanguage == null)
|
||||
Console.WriteLine("[CMD] Successfully loaded command : " + name);
|
||||
else Console.WriteLine(LanguageSystem.Language.ActiveLanguage.FormatText(LanguageSystem.Language.ActiveLanguage.LanguageWords["COMMAND_LOAD_SUCCESS"], name));
|
||||
Console.WriteLine("[CMD] Successfully loaded command : " + name);
|
||||
else
|
||||
if (LanguageSystem.Language.ActiveLanguage == null)
|
||||
Console.WriteLine("[CMD] Failed to load command : " + name + " because " + exception.Message);
|
||||
else
|
||||
Console.WriteLine(LanguageSystem.Language.ActiveLanguage.FormatText(LanguageSystem.Language.ActiveLanguage.LanguageWords["COMMAND_LOAD_FAIL"], name, exception.Message));
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
};
|
||||
loader.onEVELoad += (name, typeName, success, exception) =>
|
||||
@@ -87,15 +77,9 @@ namespace PluginManager.Items
|
||||
name = typeName;
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
if (success)
|
||||
if (LanguageSystem.Language.ActiveLanguage == null)
|
||||
Console.WriteLine("[EVENT] Successfully loaded event : " + name);
|
||||
else
|
||||
Console.WriteLine(LanguageSystem.Language.ActiveLanguage.FormatText(LanguageSystem.Language.ActiveLanguage.LanguageWords["EVENT_LOAD_SUCCESS"], name));
|
||||
Console.WriteLine("[EVENT] Successfully loaded event : " + name);
|
||||
else
|
||||
if (LanguageSystem.Language.ActiveLanguage == null)
|
||||
Console.WriteLine("[EVENT] Failed to load event : " + name + " because " + exception.Message);
|
||||
else
|
||||
Console.WriteLine(LanguageSystem.Language.ActiveLanguage.FormatText(LanguageSystem.Language.ActiveLanguage.LanguageWords["EVENT_LOAD_FAIL"], name, exception.Message));
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
};
|
||||
loader.LoadPlugins();
|
||||
@@ -203,89 +187,72 @@ namespace PluginManager.Items
|
||||
|
||||
});
|
||||
|
||||
AddCommand("setlang", "set language", (args) =>
|
||||
{
|
||||
if (args.Length == 1)
|
||||
|
||||
AddCommand("value", "read value from VariableStack", (args) =>
|
||||
{
|
||||
Console.WriteLine("Please specify language");
|
||||
return;
|
||||
if (args.Length != 2) return;
|
||||
if (!Config.ContainsKey(args[1])) return;
|
||||
|
||||
string data = Config.GetValue(args[1]);
|
||||
Console.WriteLine($"{args[1]} => {data}");
|
||||
}
|
||||
Language.SetLanguage(args[0]);
|
||||
});
|
||||
);
|
||||
|
||||
AddCommand("listlang", "List all available languages", async () =>
|
||||
{
|
||||
await languageManager.ListAllLanguages();
|
||||
});
|
||||
|
||||
AddCommand("dwlang", "Download language", async (args) =>
|
||||
{
|
||||
if (args.Length == 1)
|
||||
AddCommand("addv", "add variable to the system variables", async (args) =>
|
||||
{
|
||||
Console.WriteLine("Please specify language");
|
||||
return;
|
||||
if (args.Length < 3) return;
|
||||
string in1 = args[1];
|
||||
if (!Config.ContainsKey(in1))
|
||||
Config.AddValueToVariables(in1, Functions.MergeStrings(args, 2), false);
|
||||
else
|
||||
Config.SetValue(in1, Functions.MergeStrings(args, 2));
|
||||
|
||||
Console.WriteLine($"Updated config file with the following command: {in1} => {Config.GetValue(in1)}");
|
||||
Config.SaveConfig();
|
||||
}
|
||||
string Lname = args.MergeStrings(1);
|
||||
string[] link = await languageManager!.GetDownloadLink(Lname);
|
||||
try
|
||||
);
|
||||
|
||||
AddCommand("remv", "remove variable from system variables", (args) =>
|
||||
{
|
||||
if (link[0] is null || link is null)
|
||||
{
|
||||
if (Lname == "")
|
||||
{
|
||||
Console_Utilities.WriteColorText($"Name is invalid");
|
||||
return;
|
||||
}
|
||||
Console_Utilities.WriteColorText("Failed to find language &b" + Lname + " &c! Use &glistlang &ccommand to display all available languages !");
|
||||
return;
|
||||
}
|
||||
if (link[1].Contains("CrossPlatform") || link[1].Contains("cp"))
|
||||
{
|
||||
|
||||
string path2 = Functions.langFolder + Lname + ".lng";
|
||||
|
||||
await ServerCom.DownloadFileAsync(link[0], path2);
|
||||
Console.WriteLine("\n");
|
||||
}
|
||||
else Console_Utilities.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]);
|
||||
return;
|
||||
if (args.Length < 2) return;
|
||||
Config.RemoveKey(args[1]);
|
||||
Config.SaveConfig();
|
||||
}
|
||||
catch
|
||||
);
|
||||
|
||||
AddCommand("vars", "Display all variables", () =>
|
||||
{
|
||||
if (Lname == "")
|
||||
{
|
||||
Console_Utilities.WriteColorText($"Name is invalid");
|
||||
return;
|
||||
}
|
||||
Console_Utilities.WriteColorText("Failed to find language &b" + Lname + " &c! Use &glistlang &ccommand to display all available languages !");
|
||||
return;
|
||||
var d = Config.GetAllVariables();
|
||||
List<string[]> data = new List<string[]>();
|
||||
data.Add(new string[] { "-", "-" });
|
||||
data.Add(new string[] { "Key", "Value" });
|
||||
data.Add(new string[] { "-", "-" });
|
||||
foreach (var kvp in d) data.Add(new string[] { kvp.Key, kvp.Value });
|
||||
data.Add(new string[] { "-", "-" });
|
||||
Console_Utilities.FormatAndAlignTable(data);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
AddCommand("token", "Display the token used by the bot", () =>
|
||||
{
|
||||
if (System.IO.File.Exists("./Data/Resources/DiscordBotCore.data"))
|
||||
Console.WriteLine("Token: " + Functions.readCodeFromFile("./Data/Resources/DiscordBotCore.data", "BOT_TOKEN", '='));
|
||||
else Console.WriteLine("File could not be found. Please register token");
|
||||
});
|
||||
);
|
||||
|
||||
AddCommand("sd", "Shuts down the discord bot", async () =>
|
||||
{
|
||||
await client.StopAsync();
|
||||
await client.DisposeAsync();
|
||||
Config.SaveConfig();
|
||||
Environment.Exit(0);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public static void AddCommand(string command, string description, Action<string[]> action)
|
||||
{
|
||||
commandList.Add(new Tuple<string, string, Action<string[]>>(command, description, action));
|
||||
Console.ForegroundColor = ConsoleColor.White;
|
||||
Console_Utilities.WriteColorText($"Command &r{command} &cadded to the list of commands");
|
||||
}
|
||||
|
||||
public static void AddCommand(string command, string description, Action action)
|
||||
{
|
||||
AddCommand(command, description, (args) =>
|
||||
{
|
||||
action();
|
||||
});
|
||||
|
||||
/* Console.WriteLine("Added command: " + command);*/
|
||||
AddCommand(command, description, (args) => action());
|
||||
}
|
||||
|
||||
public static void RemoveCommand(string command)
|
||||
@@ -293,15 +260,20 @@ namespace PluginManager.Items
|
||||
commandList.RemoveAll(x => x.Item1 == command);
|
||||
}
|
||||
|
||||
public static Tuple<string, string, Action<string[]>>? SearchCommand(string command)
|
||||
{
|
||||
return commandList.FirstOrDefault(t => t.Item1 == command);
|
||||
}
|
||||
|
||||
public void HandleCommand(string command)
|
||||
{
|
||||
string[] args = command.Split(' ');
|
||||
foreach (var item in commandList)
|
||||
foreach (var item in commandList.ToList())
|
||||
{
|
||||
if (item.Item1 == args[0])
|
||||
{
|
||||
item.Item3(args);
|
||||
return;
|
||||
//Console.WriteLine($"Executing: {args[0]} with the following parameters: {args.MergeStrings(1)}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,161 +0,0 @@
|
||||
using PluginManager.Others;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PluginManager.LanguageSystem
|
||||
{
|
||||
public class Language
|
||||
{
|
||||
/// <summary>
|
||||
/// The active language
|
||||
/// </summary>
|
||||
public static Language? ActiveLanguage = null;
|
||||
|
||||
private static readonly string LanguageFileExtension = ".lng";
|
||||
|
||||
/// <summary>
|
||||
/// The name of the language
|
||||
/// </summary>
|
||||
public string LanguageName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The file where the language is imported from
|
||||
/// </summary>
|
||||
public string fileName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The dictionary of the language
|
||||
/// </summary>
|
||||
public Dictionary<string, string> LanguageWords { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The Language constructor
|
||||
/// </summary>
|
||||
/// <param name="fileName">The file to import the language from</param>
|
||||
/// <param name="words">The dictionary of the language</param>
|
||||
/// <param name="LanguageName">The name of the language</param>
|
||||
private Language(string fileName, Dictionary<string, string> words, string LanguageName)
|
||||
{
|
||||
this.fileName = fileName;
|
||||
this.LanguageName = LanguageName;
|
||||
LanguageWords = words;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load language from file
|
||||
/// </summary>
|
||||
/// <param name="LanguageFileLocation">The file path</param>
|
||||
/// <returns></returns>
|
||||
public static Language? CreateLanguageFromFile(string LanguageFileLocation)
|
||||
{
|
||||
if (!LanguageFileLocation.EndsWith(LanguageFileExtension))
|
||||
{
|
||||
Console.WriteLine("Failed to load language from file: " + LanguageFileLocation +
|
||||
"\nFile extension is not " + LanguageFileExtension);
|
||||
return null;
|
||||
}
|
||||
|
||||
string[] lines = File.ReadAllLines(LanguageFileLocation);
|
||||
var languageName = "Unknown";
|
||||
var words = new Dictionary<string, string>();
|
||||
|
||||
foreach (string line in lines)
|
||||
{
|
||||
if (line.StartsWith("#") || line.Length < 4)
|
||||
continue;
|
||||
string[] sLine = line.Split('=');
|
||||
|
||||
if (sLine[0] == "LANGUAGE_NAME")
|
||||
{
|
||||
languageName = sLine[1];
|
||||
continue;
|
||||
}
|
||||
|
||||
words.Add(sLine[0], sLine[1]);
|
||||
}
|
||||
|
||||
Functions.WriteLogFile("Successfully loaded language: " + languageName + " from file : " +
|
||||
LanguageFileLocation.Replace('\\', '/'));
|
||||
return new Language(LanguageFileLocation, words, languageName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Format text by inserting parameters
|
||||
/// </summary>
|
||||
/// <param name="text">The raw text</param>
|
||||
/// <param name="args">The arguments</param>
|
||||
/// <returns></returns>
|
||||
public string FormatText(string text, params string[] args)
|
||||
{
|
||||
if (ActiveLanguage == null) return text;
|
||||
int l = args.Length;
|
||||
for (var i = 0; i < l; i++) text = text.Replace($"{i}", args[i]);
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
public static bool LoadLanguage()
|
||||
{
|
||||
string folder = Functions.langFolder;
|
||||
string langSettings = "./Data/Resources/Language.txt";
|
||||
if (!File.Exists(langSettings))
|
||||
File.WriteAllText(langSettings, "Language=English");
|
||||
//Load language from the specified file ...
|
||||
Language.ActiveLanguage = null;
|
||||
|
||||
string langname = Functions.readCodeFromFile(langSettings, "Language", '=');
|
||||
if (langname == "English")
|
||||
{
|
||||
Language.ActiveLanguage = null;
|
||||
return true;
|
||||
}
|
||||
foreach (var file in Directory.GetFiles(folder))
|
||||
{
|
||||
if (Functions.readCodeFromFile(file, "LANGUAGE_NAME", '=') == langname)
|
||||
{
|
||||
Language.ActiveLanguage = Language.CreateLanguageFromFile(file);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (Language.ActiveLanguage == null)
|
||||
{
|
||||
File.WriteAllText(langSettings, "Language=English");
|
||||
Console_Utilities.WriteColorText($"Failed to find language &r{langname} &c! Check available languages using command: &glistlang");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void SetLanguage(string LanguageName)
|
||||
{
|
||||
string langSettings = Functions.dataFolder + "Language.txt";
|
||||
File.WriteAllText(langSettings, "Language=" + LanguageName);
|
||||
|
||||
try
|
||||
{
|
||||
bool success = LoadLanguage();
|
||||
if (success)
|
||||
{
|
||||
Console_Utilities.WriteColorText($"Language has been setted to: &g{LanguageName}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console_Utilities.WriteColorText($"Could not find language &r{LanguageName}.");
|
||||
Functions.WriteErrFile(ex.ToString());
|
||||
File.WriteAllText(langSettings, "Language=English");
|
||||
LoadLanguage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
using PluginManager.Interfaces;
|
||||
|
||||
namespace PluginManager.Loaders
|
||||
{
|
||||
internal class CommandsLoader
|
||||
{
|
||||
private readonly string CMDPath;
|
||||
private readonly string CMDExtension;
|
||||
|
||||
|
||||
internal delegate void onCommandLoaded(string name, bool success, DBCommand? command = null, Exception? exception = null);
|
||||
internal delegate void onCommandFileLoaded(string path);
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when a command is loaded
|
||||
/// </summary>
|
||||
internal onCommandLoaded? OnCommandLoaded;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when the file is loaded
|
||||
/// </summary>
|
||||
internal onCommandFileLoaded? OnCommandFileLoaded;
|
||||
|
||||
/// <summary>
|
||||
/// Command Loader contructor
|
||||
/// </summary>
|
||||
/// <param name="CommandPath">The path to the commands</param>
|
||||
/// <param name="CommandExtension">The extension to search for in the <paramref name="CommandPath"/></param>
|
||||
internal CommandsLoader(string CommandPath, string CommandExtension)
|
||||
{
|
||||
CMDPath = CommandPath;
|
||||
CMDExtension = CommandExtension;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The method that loads all commands
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
internal List<DBCommand>? LoadCommands()
|
||||
{
|
||||
if (!Directory.Exists(CMDPath))
|
||||
{
|
||||
Directory.CreateDirectory(CMDPath);
|
||||
return null;
|
||||
}
|
||||
string[] files = Directory.GetFiles(CMDPath, $"*{CMDExtension}", SearchOption.AllDirectories);
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
Assembly.LoadFile(Path.GetFullPath(file));
|
||||
if (OnCommandFileLoaded != null)
|
||||
OnCommandFileLoaded.Invoke(file);
|
||||
}
|
||||
|
||||
List<DBCommand> plugins = new List<DBCommand>();
|
||||
|
||||
try
|
||||
{
|
||||
Type interfaceType = typeof(DBCommand);
|
||||
Type[] types = AppDomain.CurrentDomain.GetAssemblies()
|
||||
.SelectMany(a => a.GetTypes())
|
||||
.Where(p => interfaceType.IsAssignableFrom(p) && p.IsClass)
|
||||
.ToArray();
|
||||
foreach (Type type in types)
|
||||
{
|
||||
try
|
||||
{
|
||||
DBCommand plugin = (DBCommand)Activator.CreateInstance(type)!;
|
||||
plugins.Add(plugin);
|
||||
|
||||
if (OnCommandLoaded != null)
|
||||
OnCommandLoaded.Invoke(type.FullName!, true, plugin);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (OnCommandLoaded != null)
|
||||
OnCommandLoaded.Invoke(type.FullName!, false, null, e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
return null;
|
||||
}
|
||||
|
||||
return plugins;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
using PluginManager.Interfaces;
|
||||
|
||||
namespace PluginManager.Loaders
|
||||
{
|
||||
internal class EventsLoader
|
||||
{
|
||||
|
||||
private readonly string EVPath;
|
||||
private readonly string EVExtension;
|
||||
|
||||
internal delegate void onEventLoad(string name, bool success, DBEvent? ev = null, Exception? e = null);
|
||||
internal delegate void onEventFileLoaded(string path);
|
||||
|
||||
/// <summary>
|
||||
/// An event that is fired whenever a <see cref="DBEvent"/> event is loaded in memory
|
||||
/// </summary>
|
||||
internal onEventLoad? EventLoad;
|
||||
|
||||
/// <summary>
|
||||
/// An event that is fired whenever a <see cref="DBEvent"/> event file is loaded
|
||||
/// </summary>
|
||||
internal onEventFileLoaded? EventFileLoaded;
|
||||
|
||||
/// <summary>
|
||||
/// The Event Loader constructor
|
||||
/// </summary>
|
||||
/// <param name="path">The path to all events</param>
|
||||
/// <param name="ext">The extension for events</param>
|
||||
internal EventsLoader(string path, string ext)
|
||||
{
|
||||
EVPath = path;
|
||||
EVExtension = ext;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The method that loads all events
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
internal List<DBEvent>? LoadEvents()
|
||||
{
|
||||
|
||||
if (!Directory.Exists(EVPath))
|
||||
{
|
||||
Directory.CreateDirectory(EVPath);
|
||||
return null;
|
||||
}
|
||||
|
||||
string[] files = Directory.GetFiles(EVPath, $"*{EVExtension}", SearchOption.AllDirectories);
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
Assembly.LoadFile(Path.GetFullPath(file));
|
||||
if (EventFileLoaded != null)
|
||||
EventFileLoaded.Invoke(file);
|
||||
}
|
||||
|
||||
List<DBEvent> events = new List<DBEvent>();
|
||||
|
||||
try
|
||||
{
|
||||
Type interfaceType = typeof(DBEvent);
|
||||
Type[] types = AppDomain.CurrentDomain.GetAssemblies()
|
||||
.SelectMany(a => a.GetTypes())
|
||||
.Where(p => interfaceType.IsAssignableFrom(p) && p.IsClass)
|
||||
.ToArray();
|
||||
foreach (Type type in types)
|
||||
{
|
||||
try
|
||||
{
|
||||
DBEvent ev = (DBEvent)Activator.CreateInstance(type)!;
|
||||
events.Add(ev);
|
||||
|
||||
if (EventLoad != null)
|
||||
EventLoad.Invoke(type.FullName!, true, ev, null);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (EventLoad != null)
|
||||
EventLoad.Invoke(type.FullName!, false, null, e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
return null;
|
||||
}
|
||||
|
||||
return events;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
118
PluginManager/Loaders/Loader.cs
Normal file
118
PluginManager/Loaders/Loader.cs
Normal file
@@ -0,0 +1,118 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using PluginManager.Interfaces;
|
||||
using PluginManager.Others;
|
||||
|
||||
namespace PluginManager.Loaders
|
||||
{
|
||||
internal class LoaderArgs : EventArgs
|
||||
{
|
||||
internal string? PluginName { get; init; }
|
||||
internal string? TypeName { get; init; }
|
||||
internal bool IsLoaded { get; init; }
|
||||
internal Exception? Exception { get; init; }
|
||||
internal object? Plugin { get; init; }
|
||||
}
|
||||
|
||||
internal class Loader<T>
|
||||
{
|
||||
internal delegate void FileLoadedEventHandler(LoaderArgs args);
|
||||
|
||||
internal event FileLoadedEventHandler? FileLoaded;
|
||||
|
||||
internal delegate void PluginLoadedEventHandler(LoaderArgs args);
|
||||
|
||||
internal event PluginLoadedEventHandler? PluginLoaded;
|
||||
|
||||
|
||||
private string path { get; }
|
||||
private string extension { get; }
|
||||
|
||||
|
||||
internal Loader(string path, string extension)
|
||||
{
|
||||
this.path = path;
|
||||
this.extension = extension;
|
||||
}
|
||||
|
||||
internal List<T>? Load()
|
||||
{
|
||||
List<T> list = new List<T>();
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
return null;
|
||||
}
|
||||
|
||||
string[] files = Directory.GetFiles(path, $"*.{extension}", SearchOption.AllDirectories);
|
||||
foreach (var file in files)
|
||||
{
|
||||
Assembly.LoadFrom(file);
|
||||
if (FileLoaded != null)
|
||||
{
|
||||
LoaderArgs args = new LoaderArgs()
|
||||
{
|
||||
Exception = null,
|
||||
TypeName = nameof(T),
|
||||
IsLoaded = false,
|
||||
PluginName = file,
|
||||
Plugin = null
|
||||
};
|
||||
FileLoaded.Invoke(args);
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Type interfaceType = typeof(T);
|
||||
Type[] types = AppDomain.CurrentDomain.GetAssemblies()
|
||||
.SelectMany(a => a.GetTypes())
|
||||
.Where(p => interfaceType.IsAssignableFrom(p) && p.IsClass)
|
||||
.ToArray();
|
||||
|
||||
|
||||
list.Clear();
|
||||
foreach (Type type in types)
|
||||
{
|
||||
try
|
||||
{
|
||||
T plugin = (T)(Activator.CreateInstance(type)!);
|
||||
list.Add(plugin);
|
||||
|
||||
|
||||
if (PluginLoaded != null)
|
||||
{
|
||||
PluginLoaded.Invoke(new()
|
||||
{
|
||||
Exception = null,
|
||||
IsLoaded = true,
|
||||
PluginName = type.FullName,
|
||||
TypeName = nameof(T),
|
||||
Plugin = plugin
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (PluginLoaded != null)
|
||||
{
|
||||
PluginLoaded.Invoke(new() { Exception = ex, IsLoaded = false, PluginName = type.FullName, TypeName = nameof(T) });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Functions.WriteErrFile(ex.ToString());
|
||||
}
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +1,32 @@
|
||||
using Discord.WebSocket;
|
||||
|
||||
using PluginManager.Interfaces;
|
||||
using PluginManager.Others;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace PluginManager.Loaders
|
||||
{
|
||||
public class PluginLoader
|
||||
{
|
||||
private DiscordSocketClient client;
|
||||
private readonly DiscordSocketClient _client;
|
||||
|
||||
/// <summary>
|
||||
/// The Plugin Loader constructor
|
||||
/// </summary>
|
||||
/// <param name="discordSocketClient">The discord bot client where the plugins will pe attached to</param>
|
||||
public PluginLoader(DiscordSocketClient discordSocketClient)
|
||||
{
|
||||
this.client = discordSocketClient;
|
||||
}
|
||||
public PluginLoader(DiscordSocketClient discordSocketClient) { this._client = discordSocketClient; }
|
||||
|
||||
private const string pluginCMDFolder = @"./Data/Plugins/Commands/";
|
||||
private const string pluginEVEFolder = @"./Data/Plugins/Events/";
|
||||
|
||||
private const string pluginCMDExtension = ".dll";
|
||||
private const string pluginEVEExtension = ".dll";
|
||||
private const string pluginCMDExtension = "dll";
|
||||
private const string pluginEVEExtension = "dll";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A list of <see cref="DBCommand"/> commands
|
||||
/// </summary>
|
||||
public static List<DBCommand>? Plugins { get; set; }
|
||||
public static List<DBCommand>? Commands { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A list of <see cref="DBEvent"/> commands
|
||||
@@ -38,6 +35,7 @@ namespace PluginManager.Loaders
|
||||
|
||||
|
||||
public delegate void CMDLoaded(string name, string typeName, bool success, Exception? e = null);
|
||||
|
||||
public delegate void EVELoaded(string name, string typeName, bool success, Exception? e = null);
|
||||
|
||||
/// <summary>
|
||||
@@ -55,57 +53,45 @@ namespace PluginManager.Loaders
|
||||
/// </summary>
|
||||
public void LoadPlugins()
|
||||
{
|
||||
Commands = new List<DBCommand>();
|
||||
Events = new List<DBEvent>();
|
||||
|
||||
Plugins = new List<DBCommand>();
|
||||
Events = new List<DBEvent>();
|
||||
Functions.WriteLogFile("Starting plugin loader ... Client: " + _client.CurrentUser.Username);
|
||||
Console.WriteLine("Loading plugins");
|
||||
|
||||
Functions.WriteLogFile("Starting plugin loader ... Client: " + client.CurrentUser.Username);
|
||||
if (LanguageSystem.Language.ActiveLanguage != null)
|
||||
Console_Utilities.WriteColorText(
|
||||
LanguageSystem.Language.ActiveLanguage.FormatText(
|
||||
LanguageSystem.Language.ActiveLanguage.LanguageWords["PLUGIN_LOADING_START"]
|
||||
)
|
||||
);
|
||||
Loader<DBCommand> commandsLoader = new Loader<DBCommand>(pluginCMDFolder, pluginCMDExtension);
|
||||
Loader<DBEvent> eventsLoader = new Loader<DBEvent>(pluginEVEFolder, pluginEVEExtension);
|
||||
|
||||
//Load commands
|
||||
CommandsLoader CMDLoader = new CommandsLoader(pluginCMDFolder, pluginCMDExtension);
|
||||
CMDLoader.OnCommandLoaded += OnCommandLoaded!;
|
||||
CMDLoader.OnCommandFileLoaded += OnCommandFileLoaded;
|
||||
Plugins = CMDLoader.LoadCommands();
|
||||
commandsLoader.FileLoaded += OnCommandFileLoaded;
|
||||
commandsLoader.PluginLoaded += OnCommandLoaded;
|
||||
|
||||
eventsLoader.FileLoaded += EventFileLoaded;
|
||||
eventsLoader.PluginLoaded += OnEventLoaded;
|
||||
|
||||
//Load Events
|
||||
EventsLoader EVLoader = new EventsLoader(pluginEVEFolder, pluginEVEExtension);
|
||||
EVLoader.EventLoad += OnEventLoaded!;
|
||||
EVLoader.EventFileLoaded += EventFileLoaded;
|
||||
Events = EVLoader.LoadEvents();
|
||||
|
||||
Commands = commandsLoader.Load();
|
||||
Events = eventsLoader.Load();
|
||||
}
|
||||
|
||||
private void EventFileLoaded(string path)
|
||||
private void EventFileLoaded(LoaderArgs e)
|
||||
{
|
||||
if (path != null)
|
||||
Functions.WriteLogFile($"[EVENT] Event from file [{path}] has been successfully created !");
|
||||
if (e.IsLoaded) Functions.WriteLogFile($"[EVENT] Event from file [{e.PluginName}] has been successfully created !");
|
||||
}
|
||||
|
||||
private void OnCommandFileLoaded(string path)
|
||||
private void OnCommandFileLoaded(LoaderArgs e)
|
||||
{
|
||||
if (path != null)
|
||||
Functions.WriteLogFile($"[CMD] Command from file [{path}] has been successfully loaded !");
|
||||
if (e.IsLoaded) Functions.WriteLogFile($"[CMD] Command from file [{e.PluginName}] has been successfully loaded !");
|
||||
}
|
||||
|
||||
private void OnEventLoaded(string typename, bool success, DBEvent eve, Exception exception)
|
||||
private void OnEventLoaded(LoaderArgs e)
|
||||
{
|
||||
if (eve != null && success)
|
||||
eve.Start(client);
|
||||
if (onEVELoad != null)
|
||||
onEVELoad.Invoke(eve!.name, typename, success, exception);
|
||||
if (e.IsLoaded) { ((DBEvent)e.Plugin!).Start(_client); }
|
||||
|
||||
if (onEVELoad != null) onEVELoad.Invoke(((DBEvent)e.Plugin!).name, e.TypeName!, e.IsLoaded, e.Exception);
|
||||
}
|
||||
|
||||
private void OnCommandLoaded(string name, bool success, DBCommand command, Exception exception)
|
||||
private void OnCommandLoaded(LoaderArgs e)
|
||||
{
|
||||
if (onCMDLoad != null)
|
||||
onCMDLoad.Invoke(command.Command, name, success, exception);
|
||||
if (onCMDLoad != null) onCMDLoad.Invoke(((DBCommand)e.Plugin!).Command, e.TypeName!, e.IsLoaded, e.Exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PluginManager.Others
|
||||
{
|
||||
@@ -14,17 +10,20 @@ namespace PluginManager.Others
|
||||
/// </summary>
|
||||
public class ProgressBar
|
||||
{
|
||||
public int Progress { get; set; }
|
||||
public int Max { get; set; }
|
||||
public string Message { get; set; }
|
||||
public int Max { get; set; }
|
||||
public string Message { get; set; }
|
||||
public ConsoleColor Color { get; init; }
|
||||
|
||||
|
||||
public ProgressBar(int max, string message)
|
||||
{
|
||||
Max = max;
|
||||
Max = max;
|
||||
Message = message;
|
||||
var consoleColors = Enum.GetValues(typeof(ConsoleColor));
|
||||
while ((Color = (ConsoleColor)consoleColors.GetValue(new Random().Next(consoleColors.Length))!) == ConsoleColor.White && Color != ConsoleColor.Black) ;
|
||||
}
|
||||
|
||||
public async void Update(int progress, double speed = -1, string? unit = null)
|
||||
public void Update(int progress, double speed = -1, string? unit = null)
|
||||
{
|
||||
|
||||
//progress bar
|
||||
@@ -39,8 +38,8 @@ namespace PluginManager.Others
|
||||
|
||||
for (int i = 0; i < onechunk * progress; i++)
|
||||
{
|
||||
Console.BackgroundColor = ConsoleColor.Green;
|
||||
Console.CursorLeft = position++;
|
||||
Console.BackgroundColor = this.Color;
|
||||
Console.CursorLeft = position++;
|
||||
Console.Write(" ");
|
||||
}
|
||||
|
||||
@@ -72,9 +71,9 @@ namespace PluginManager.Others
|
||||
/// <param name="data">The List of arrays of strings that represent the rows.</param>
|
||||
public static void FormatAndAlignTable(List<string[]> data)
|
||||
{
|
||||
char tableLine = '-';
|
||||
char tableLine = '-';
|
||||
char tableCross = '+';
|
||||
char tableWall = '|';
|
||||
char tableWall = '|';
|
||||
|
||||
int[] len = new int[data[0].Length];
|
||||
foreach (var line in data)
|
||||
@@ -130,11 +129,12 @@ namespace PluginManager.Others
|
||||
ConsoleColor fg = Console.ForegroundColor;
|
||||
Dictionary<string, ConsoleColor> colors = new Dictionary<string, ConsoleColor>()
|
||||
{
|
||||
{"&g", ConsoleColor.Green },
|
||||
{"&b", ConsoleColor.Blue },
|
||||
{"&r", ConsoleColor.Red },
|
||||
{"&m", ConsoleColor.Magenta },
|
||||
{"&c", fg }
|
||||
{ "&g", ConsoleColor.Green },
|
||||
{ "&b", ConsoleColor.Blue },
|
||||
{ "&r", ConsoleColor.Red },
|
||||
{ "&m", ConsoleColor.Magenta },
|
||||
{ "&y", ConsoleColor.Yellow },
|
||||
{ "&c", fg }
|
||||
};
|
||||
foreach (string word in words)
|
||||
{
|
||||
@@ -145,7 +145,9 @@ namespace PluginManager.Others
|
||||
Console.ForegroundColor = colors[prefix];
|
||||
}
|
||||
|
||||
string m = word.Replace("&g", "").Replace("&b", "").Replace("&r", "").Replace("&c", "").Replace("&m", "");
|
||||
string m = word;
|
||||
foreach (var key in colors.Keys) { m = m.Replace(key, ""); }
|
||||
|
||||
Console.Write(m + " ");
|
||||
}
|
||||
if (appendNewLine)
|
||||
|
||||
@@ -7,6 +7,8 @@ using System.Collections.Generic;
|
||||
using Discord.WebSocket;
|
||||
using PluginManager.Items;
|
||||
using System.Threading;
|
||||
using System.Text.Json;
|
||||
using System.Text;
|
||||
|
||||
namespace PluginManager.Others
|
||||
{
|
||||
@@ -40,22 +42,6 @@ namespace PluginManager.Others
|
||||
/// </summary>
|
||||
public static readonly string pakFolder = @"./Data/Resources/PAKS/";
|
||||
|
||||
/// <summary>
|
||||
/// The mark that the line is a comment
|
||||
/// </summary>
|
||||
private static readonly char commentMark = '#';
|
||||
|
||||
/// <summary>
|
||||
/// Read data from file
|
||||
/// </summary>
|
||||
/// <param name="fileName">File name</param>
|
||||
/// <param name="Code">Setting name</param>
|
||||
/// <param name="separator">Separator between setting key code and its value</param>
|
||||
/// <returns>The value of the specified setting key code in the specified file (<see cref="string"/>)</returns>
|
||||
public static string? readCodeFromFile(string fileName, string Code, char separator)
|
||||
=> File.ReadAllLines(fileName)
|
||||
.Where(p => p.StartsWith(Code) && !p.StartsWith(commentMark.ToString()))
|
||||
.First().Split(separator)[1] ?? null;
|
||||
|
||||
/// <summary>
|
||||
/// Read data from a file that is inside an archive (ZIP format)
|
||||
@@ -67,17 +53,16 @@ namespace PluginManager.Others
|
||||
{
|
||||
archFile = pakFolder + archFile;
|
||||
Directory.CreateDirectory(pakFolder);
|
||||
if (!File.Exists(archFile))
|
||||
throw new FileNotFoundException("Failed to load file !");
|
||||
if (!File.Exists(archFile)) throw new FileNotFoundException("Failed to load file !");
|
||||
|
||||
string? textValue = null;
|
||||
var fs = new FileStream(archFile, FileMode.Open);
|
||||
var zip = new ZipArchive(fs, ZipArchiveMode.Read);
|
||||
var fs = new FileStream(archFile, FileMode.Open);
|
||||
var zip = new ZipArchive(fs, ZipArchiveMode.Read);
|
||||
foreach (var entry in zip.Entries)
|
||||
{
|
||||
if (entry.Name == FileName || entry.FullName == FileName)
|
||||
{
|
||||
Stream s = entry.Open();
|
||||
Stream s = entry.Open();
|
||||
StreamReader reader = new StreamReader(s);
|
||||
textValue = await reader.ReadToEndAsync();
|
||||
reader.Close();
|
||||
@@ -86,6 +71,7 @@ namespace PluginManager.Others
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return textValue;
|
||||
}
|
||||
|
||||
@@ -96,8 +82,7 @@ namespace PluginManager.Others
|
||||
public static void WriteLogFile(string LogMessage)
|
||||
{
|
||||
string logsPath = logFolder + "Log.txt";
|
||||
if (!Directory.Exists(logFolder))
|
||||
Directory.CreateDirectory(logFolder);
|
||||
if (!Directory.Exists(logFolder)) Directory.CreateDirectory(logFolder);
|
||||
File.AppendAllText(logsPath, LogMessage + " \n");
|
||||
}
|
||||
|
||||
@@ -108,36 +93,10 @@ namespace PluginManager.Others
|
||||
public static void WriteErrFile(string ErrMessage)
|
||||
{
|
||||
string errPath = errFolder + "Error.txt";
|
||||
if (!Directory.Exists(errFolder))
|
||||
Directory.CreateDirectory(errFolder);
|
||||
if (!Directory.Exists(errFolder)) Directory.CreateDirectory(errFolder);
|
||||
File.AppendAllText(errPath, ErrMessage + " \n");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write to settings file
|
||||
/// </summary>
|
||||
/// <param name="file">The settings file path</param>
|
||||
/// <param name="Code">The Key value of the setting</param>
|
||||
/// <param name="newValue">The new value of the settings</param>
|
||||
/// <param name="separator">The separator between the key and the value</param>
|
||||
public static void WriteToSettings(string file, string Code, string newValue, char separator)
|
||||
{
|
||||
|
||||
string[] lines = File.ReadAllLines(file);
|
||||
File.Delete(file);
|
||||
bool ok = false;
|
||||
foreach (var line in lines)
|
||||
if (line.StartsWith(Code))
|
||||
{
|
||||
File.AppendAllText(file, Code + separator + newValue + "\n");
|
||||
ok = true;
|
||||
}
|
||||
else File.AppendAllText(file, line + "\n");
|
||||
|
||||
if (!ok)
|
||||
File.AppendAllText(file, Code + separator + newValue + "\n");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Merge one array of strings into one string
|
||||
/// </summary>
|
||||
@@ -146,8 +105,8 @@ namespace PluginManager.Others
|
||||
/// <returns>A string built based on the array</returns>
|
||||
public static string MergeStrings(this string[] s, int indexToStart)
|
||||
{
|
||||
string r = "";
|
||||
int len = s.Length;
|
||||
string r = "";
|
||||
int len = s.Length;
|
||||
if (len <= indexToStart) return "";
|
||||
for (int i = indexToStart; i < len - 1; ++i)
|
||||
{
|
||||
@@ -177,30 +136,6 @@ namespace PluginManager.Others
|
||||
return command.Arguments;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Write setting
|
||||
/// </summary>
|
||||
/// <param name="SettingName">The full path to the setting</param>
|
||||
/// <param name="NewValue">The new Value</param>
|
||||
public static void WriteToSettingsFast(string SettingName, string NewValue)
|
||||
{
|
||||
|
||||
string path = dataFolder; // Resources/
|
||||
|
||||
string[] args = SettingName.Split('.');
|
||||
|
||||
int len = args.Length;
|
||||
if (len < 2) return;
|
||||
for (int i = 0; i < len - 2; i++)
|
||||
path += args[i] + "/";
|
||||
path += args[len - 2] + ".txt";
|
||||
|
||||
|
||||
WriteToSettings(path, args[len - 1].Replace('_', ' '), NewValue, '=');
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copy one Stream to another <see langword="async"/>
|
||||
/// </summary>
|
||||
@@ -215,20 +150,15 @@ namespace PluginManager.Others
|
||||
/// <exception cref="ArgumentException">Triggered in <paramref name="destination"/> is not writable</exception>
|
||||
public static async Task CopyToOtherStreamAsync(this Stream stream, Stream destination, int bufferSize, IProgress<long>? progress = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (stream == null)
|
||||
throw new ArgumentNullException(nameof(stream));
|
||||
if (destination == null)
|
||||
throw new ArgumentNullException(nameof(destination));
|
||||
if (bufferSize <= 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(bufferSize));
|
||||
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 (stream == null) throw new ArgumentNullException(nameof(stream));
|
||||
if (destination == null) throw new ArgumentNullException(nameof(destination));
|
||||
if (bufferSize <= 0) throw new ArgumentOutOfRangeException(nameof(bufferSize));
|
||||
if (!stream.CanRead) throw new InvalidOperationException("The stream is not readable.");
|
||||
if (!destination.CanWrite) throw new ArgumentException("Destination stream is not writable", nameof(destination));
|
||||
|
||||
byte[] buffer = new byte[bufferSize];
|
||||
long totalBytesRead = 0;
|
||||
int bytesRead;
|
||||
byte[] buffer = new byte[bufferSize];
|
||||
long totalBytesRead = 0;
|
||||
int bytesRead;
|
||||
while ((bytesRead = await stream.ReadAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(false)) != 0)
|
||||
{
|
||||
await destination.WriteAsync(buffer, 0, bytesRead, cancellationToken).ConfigureAwait(false);
|
||||
@@ -246,29 +176,28 @@ namespace PluginManager.Others
|
||||
/// <returns></returns>
|
||||
public static async Task ExtractArchive(string zip, string folder, IProgress<float> progress)
|
||||
{
|
||||
if (!Directory.Exists(folder))
|
||||
Directory.CreateDirectory(folder);
|
||||
|
||||
|
||||
if (!Directory.Exists(folder)) Directory.CreateDirectory(folder);
|
||||
|
||||
|
||||
using (ZipArchive archive = ZipFile.OpenRead(zip))
|
||||
{
|
||||
int totalZIPFiles = archive.Entries.Count();
|
||||
int totalZIPFiles = archive.Entries.Count();
|
||||
int currentZIPFile = 0;
|
||||
foreach (ZipArchiveEntry entry in archive.Entries)
|
||||
{
|
||||
if (entry.FullName.EndsWith("/"))
|
||||
{
|
||||
currentZIPFile++;
|
||||
Directory.CreateDirectory(Path.Combine(folder, entry.FullName));
|
||||
}
|
||||
else
|
||||
{
|
||||
entry.ExtractToFile(Path.Combine(folder, entry.FullName), true);
|
||||
currentZIPFile++;
|
||||
}
|
||||
|
||||
else
|
||||
try
|
||||
{
|
||||
entry.ExtractToFile(Path.Combine(folder, entry.FullName), true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
currentZIPFile++;
|
||||
await Task.Delay(10);
|
||||
progress.Report((float)currentZIPFile / totalZIPFiles * 100);
|
||||
}
|
||||
@@ -276,6 +205,11 @@ namespace PluginManager.Others
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Convert Bytes to highest measurement unit possible
|
||||
/// </summary>
|
||||
/// <param name="bytes">The amount of bytes</param>
|
||||
/// <returns></returns>
|
||||
public static (double, string) ConvertBytes(long bytes)
|
||||
{
|
||||
if (bytes < 1024) return (bytes, "B");
|
||||
@@ -284,5 +218,53 @@ namespace PluginManager.Others
|
||||
return (bytes / 1024.0 / 1024.0 / 1024.0, "GB");
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save to JSON file
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The class type</typeparam>
|
||||
/// <param name="file">The file path</param>
|
||||
/// <param name="Data">The values</param>
|
||||
/// <returns></returns>
|
||||
public static async Task SaveToJsonFile<T>(string file, T Data)
|
||||
{
|
||||
string jsonText = JsonSerializer.Serialize(Data, typeof(T), new JsonSerializerOptions { WriteIndented = true });
|
||||
await File.WriteAllTextAsync(file, jsonText);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert json text or file to some kind of data
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The data type</typeparam>
|
||||
/// <param name="input">The file or json text</param>
|
||||
/// <returns></returns>
|
||||
public static async Task<T> ConvertFromJson<T>(string input)
|
||||
{
|
||||
Stream text;
|
||||
if (File.Exists(input))
|
||||
text = File.Open(input, FileMode.OpenOrCreate);
|
||||
|
||||
else
|
||||
text = new MemoryStream(Encoding.ASCII.GetBytes(input));
|
||||
text.Position = 0;
|
||||
var obj = await JsonSerializer.DeserializeAsync<T>(text);
|
||||
text.Close();
|
||||
return obj;
|
||||
}
|
||||
|
||||
public static bool TryReadValueFromJson(string input, string codeName, out JsonElement element)
|
||||
{
|
||||
Stream text;
|
||||
if (File.Exists(input))
|
||||
text = File.OpenRead(input);
|
||||
|
||||
else
|
||||
text = new MemoryStream(Encoding.ASCII.GetBytes(input));
|
||||
|
||||
var jsonObject = JsonDocument.Parse(text);
|
||||
|
||||
var data = jsonObject.RootElement.TryGetProperty(codeName, out element);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,10 +19,4 @@
|
||||
<PackageReference Include="Discord.Net" Version="3.6.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Page Include="BlankWindow1.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
using PluginManager.Others;
|
||||
using PluginManager.Interfaces;
|
||||
using Discord;
|
||||
|
||||
public class OnUserJoin : DBEvent
|
||||
{
|
||||
public string name => "OnPlayerJoin";
|
||||
|
||||
public string description => "An event that is triggered when an user joins the server";
|
||||
|
||||
private string UtilsPath = Functions.dataFolder + "/StartupEvents";
|
||||
private string ConfigFile = Functions.dataFolder + "/StartupEvents/" + "UserJoinEvent.txt";
|
||||
|
||||
public async void Start(Discord.WebSocket.DiscordSocketClient client)
|
||||
{
|
||||
|
||||
System.IO.Directory.CreateDirectory(UtilsPath);
|
||||
|
||||
if (!System.IO.File.Exists(ConfigFile))
|
||||
{
|
||||
await System.IO.File.WriteAllTextAsync(ConfigFile,
|
||||
"Enabled=True\nEmbed=True\n" +
|
||||
"#Available placeholders:\n" +
|
||||
"#{user.Name} => Username of the user\n" +
|
||||
"#{time.date} => Current Date\n" +
|
||||
"#{time.time} => Current time (hh:mm::ss)\n" +
|
||||
"MessageTitle = Welcome {user.Name}\n" +
|
||||
"MessageDescription=Embed description\n" +
|
||||
"MessageField1Title=Custom Title\n" +
|
||||
"MessageFiled1Text=Custom Filed 1 text\n" +
|
||||
"MessageField2Title=Custom Title\n" +
|
||||
"MessageFiled2Text=Custom Filed 2 text\n" +
|
||||
"MessageFooter=Today: {time.date} at {time.time}\n");
|
||||
}
|
||||
|
||||
if (Functions.readCodeFromFile(ConfigFile, "Enabled", '=') != "True") return;
|
||||
//System.Console.WriteLine("Awaiting user join event ...");
|
||||
|
||||
client.UserJoined += Client_UserJoined;
|
||||
|
||||
}
|
||||
|
||||
private async System.Threading.Tasks.Task Client_UserJoined(Discord.WebSocket.SocketGuildUser user)
|
||||
{
|
||||
Console_Utilities.WriteColorText("A new user joins: " + user.Username);
|
||||
EmbedBuilder embed = new EmbedBuilder
|
||||
{
|
||||
Title = Functions.readCodeFromFile(ConfigFile, "MessageTitle", '='),
|
||||
Description = Functions.readCodeFromFile(ConfigFile, "MessageDescription", '=')
|
||||
};
|
||||
embed
|
||||
.AddField(Functions.readCodeFromFile(ConfigFile, "MessageField1Title", '=').Replace("{user.Name}", user.Username).Replace("{time.date}", System.DateTime.Now.ToShortDateString()).Replace("{time.time}", System.DateTime.Now.ToShortTimeString()), Functions.readCodeFromFile(ConfigFile, "MessageField1Text", '=').Replace("{user.Name}", user.Username).Replace("{time.date}", System.DateTime.Now.ToShortDateString()).Replace("{time.time}", System.DateTime.Now.ToShortTimeString()))
|
||||
.AddField(Functions.readCodeFromFile(ConfigFile, "MessageField2Title", '=').Replace("{user.Name}", user.Username).Replace("{time.date}", System.DateTime.Now.ToShortDateString()).Replace("{time.time}", System.DateTime.Now.ToShortTimeString()), Functions.readCodeFromFile(ConfigFile, "MessageField2Text", '=').Replace("{user.Name}", user.Username).Replace("{time.date}", System.DateTime.Now.ToShortDateString()).Replace("{time.time}", System.DateTime.Now.ToShortTimeString()))
|
||||
.WithFooter(Functions.readCodeFromFile(ConfigFile, "MessageFooter", '=').Replace("{user.Name}", user.Username).Replace("{time.date}", System.DateTime.Now.ToShortDateString()).Replace("{time.time}", System.DateTime.Now.ToShortTimeString()));
|
||||
await user.Guild.DefaultChannel.SendMessageAsync(embed: embed.Build());
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
public class SetGameOnLogin : PluginManager.Interfaces.DBEvent
|
||||
{
|
||||
public string name => "Set Game on Startup";
|
||||
public string description => "Set Custom Game to the bot at initialization";
|
||||
public async void Start(Discord.WebSocket.DiscordSocketClient client)
|
||||
{
|
||||
string UtilsPath = PluginManager.Others.Functions.dataFolder + "StartupEvents/";
|
||||
string ConfigFile = UtilsPath + "LoginEvent.txt";
|
||||
|
||||
System.IO.Directory.CreateDirectory(UtilsPath);
|
||||
if (!System.IO.File.Exists(ConfigFile))
|
||||
{
|
||||
System.Console.WriteLine($"First time setup. Open file: {ConfigFile} to change settings or use the following commands\nNote: For space ( ) use underline (_). Example: 'Hello_World' will output 'Hello World'");
|
||||
System.Console.WriteLine($"set-setting StartupEvents.LoginEvent.Title [Custom_Title(s)]");
|
||||
System.Console.WriteLine($"set-setting StartupEvents.LoginEvent.Dynamic_Title [True/False]");
|
||||
System.Console.WriteLine($"set-setting StartupEvents.LoginEvent.Dynamic_Title_Change_Rate [interval in milliseconds]");
|
||||
await System.IO.File.WriteAllTextAsync(ConfigFile, "Enabled=True\n\nDynamic Title=False\n#For dynamic title add titles like this:\n#Title=Hello,World,Test,Test2\nTitle=!help\nDynamic Title Change Rate=3500\n");
|
||||
}
|
||||
|
||||
if (PluginManager.Others.Functions.readCodeFromFile(ConfigFile, "Enabled", '=') != "True")
|
||||
return;
|
||||
|
||||
bool isDynamic = PluginManager.Others.Functions.readCodeFromFile(ConfigFile, "Dynamic Title", '=') == "True";
|
||||
string Title = PluginManager.Others.Functions.readCodeFromFile(ConfigFile, "Title", '=');
|
||||
if (Title == null || Title.Length < 2) return;
|
||||
if (!isDynamic)
|
||||
await client.SetGameAsync(Title, null, Discord.ActivityType.Playing);
|
||||
else
|
||||
{
|
||||
string[] Titles = Title.Split(',');
|
||||
int delayMS = 3500;
|
||||
try
|
||||
{
|
||||
delayMS = int.Parse(PluginManager.Others.Functions.readCodeFromFile(ConfigFile, "Dynamic Title Change Rate", '='));
|
||||
}
|
||||
catch { }
|
||||
while (true)
|
||||
{
|
||||
foreach (var title in Titles)
|
||||
{
|
||||
await client.SetGameAsync(title, null, Discord.ActivityType.Playing);
|
||||
await System.Threading.Tasks.Task.Delay(delayMS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<OutputPath>..\BUILDS\</OutputPath>
|
||||
<DebugType>none</DebugType>
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PluginManager\PluginManager.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user