Moved some logic to commandhandler, to be able to use it externally easier
This commit is contained in:
parent
f5523c8469
commit
8f894e095b
28
.vscode/launch.json
vendored
Normal file
28
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
// Use IntelliSense to find out which attributes exist for C# debugging
|
||||||
|
// Use hover for the description of the existing attributes
|
||||||
|
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": ".NET Core Launch (console)",
|
||||||
|
"type": "coreclr",
|
||||||
|
"request": "launch",
|
||||||
|
"preLaunchTask": "build",
|
||||||
|
// If you have changed target frameworks, make sure to update the program path.
|
||||||
|
"program": "${workspaceRoot}/src/NadekoBot/bin/Debug/netcoreapp1.0/NadekoBot.dll",
|
||||||
|
"args": [],
|
||||||
|
"cwd": "${workspaceRoot}/src/NadekoBot",
|
||||||
|
// For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
|
||||||
|
"console": "internalConsole",
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"internalConsoleOptions": "openOnSessionStart"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": ".NET Core Attach",
|
||||||
|
"type": "coreclr",
|
||||||
|
"request": "attach",
|
||||||
|
"processId": "${command:pickProcess}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
16
.vscode/tasks.json
vendored
Normal file
16
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"version": "0.1.0",
|
||||||
|
"command": "dotnet",
|
||||||
|
"isShellCommand": true,
|
||||||
|
"args": [],
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"taskName": "build",
|
||||||
|
"args": [
|
||||||
|
"${workspaceRoot}/src/NadekoBot/project.json"
|
||||||
|
],
|
||||||
|
"isBuildCommand": true,
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -41,22 +41,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
|
|
||||||
foreach (var cmd in NadekoBot.BotConfig.StartupCommands)
|
foreach (var cmd in NadekoBot.BotConfig.StartupCommands)
|
||||||
{
|
{
|
||||||
if (cmd.GuildId != null)
|
await NadekoBot.CommandHandler.ExecuteExternal(cmd.GuildId, cmd.ChannelId, cmd.CommandText);
|
||||||
{
|
|
||||||
var guild = NadekoBot.Client.GetGuild(cmd.GuildId.Value);
|
|
||||||
var channel = guild?.GetChannel(cmd.ChannelId) as SocketTextChannel;
|
|
||||||
if (channel == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
IUserMessage msg = await channel.SendMessageAsync(cmd.CommandText).ConfigureAwait(false);
|
|
||||||
msg = (IUserMessage)await channel.GetMessageAsync(msg.Id).ConfigureAwait(false);
|
|
||||||
await NadekoBot.CommandHandler.TryRunCommand(guild, channel, msg).ConfigureAwait(false);
|
|
||||||
//msg.DeleteAfter(5);
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
}
|
|
||||||
await Task.Delay(400).ConfigureAwait(false);
|
await Task.Delay(400).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -55,6 +55,27 @@ namespace NadekoBot.Services
|
|||||||
UsersOnShortCooldown.Clear();
|
UsersOnShortCooldown.Clear();
|
||||||
}, null, GlobalCommandsCooldown, GlobalCommandsCooldown);
|
}, null, GlobalCommandsCooldown, GlobalCommandsCooldown);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task ExecuteExternal(ulong? guildId, ulong channelId, string commandText)
|
||||||
|
{
|
||||||
|
if (guildId != null)
|
||||||
|
{
|
||||||
|
var guild = NadekoBot.Client.GetGuild(guildId.Value);
|
||||||
|
var channel = guild?.GetChannel(channelId) as SocketTextChannel;
|
||||||
|
if (channel == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IUserMessage msg = await channel.SendMessageAsync(commandText).ConfigureAwait(false);
|
||||||
|
msg = (IUserMessage)await channel.GetMessageAsync(msg.Id).ConfigureAwait(false);
|
||||||
|
await TryRunCommand(guild, channel, msg).ConfigureAwait(false);
|
||||||
|
//msg.DeleteAfter(5);
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Task StartHandling()
|
public Task StartHandling()
|
||||||
{
|
{
|
||||||
var _ = Task.Run(async () =>
|
var _ = Task.Run(async () =>
|
||||||
|
Loading…
Reference in New Issue
Block a user