-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GRIDBOT-25: Deployment and log file commands (#39)
* GRIDBOT-25 (Deployment and log file commands): Make FileName public * GRIDBOT-25 (Deployment and log file commands): Add Commands and Slash Commands
- Loading branch information
1 parent
1742e3d
commit 85f2a68
Showing
7 changed files
with
129 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using Discord; | ||
using Discord.WebSocket; | ||
using MFDLabs.Grid.Bot.Extensions; | ||
using MFDLabs.Grid.Bot.Interfaces; | ||
|
||
namespace MFDLabs.Grid.Bot.Commands | ||
{ | ||
internal sealed class DeploymentId : IStateSpecificCommandHandler | ||
{ | ||
public string CommandName => "Get Deployment ID"; | ||
public string CommandDescription => "Fetches the deployment ID for the current instance."; | ||
public string[] CommandAliases => new[] { "dep", "dply", "deploy", "depid", "deployment", "deploymentid" }; | ||
public bool Internal => false; | ||
public bool IsEnabled { get; set; } = true; | ||
|
||
public async Task Invoke(string[] messageContentArray, SocketMessage message, string originalCommand) | ||
{ | ||
// The deployment ID is literally just the name of the current directory that the executable is in. | ||
// This is not a great way to do this, but it's the best I can think of for now. | ||
|
||
// Fetch current directory name. | ||
var currentDirectory = Directory.GetCurrentDirectory(); | ||
var currentDirectoryName = Path.GetFileName(currentDirectory); | ||
|
||
// Reply with the deployment ID. | ||
await message.ReplyAsync($"The deployment ID for this instance is: `{currentDirectoryName}`\nPlease paste this into the `Deployment ID` field in grid-bot-support templates to that the internal team can easily identify this instance."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.Threading.Tasks; | ||
using Discord; | ||
using Discord.WebSocket; | ||
using MFDLabs.Logging; | ||
using MFDLabs.Grid.Bot.Extensions; | ||
using MFDLabs.Grid.Bot.Interfaces; | ||
|
||
namespace MFDLabs.Grid.Bot.Commands | ||
{ | ||
internal sealed class LogFile : IStateSpecificCommandHandler | ||
{ | ||
public string CommandName => "Get Log File Name"; | ||
public string CommandDescription => "Fetches the log file name for the current instance."; | ||
public string[] CommandAliases => new[] { "log", "lfile", "logfile", "log-file-name", "log-file", "log-name" }; | ||
public bool Internal => false; | ||
public bool IsEnabled { get; set; } = true; | ||
|
||
public async Task Invoke(string[] messageContentArray, SocketMessage message, string originalCommand) | ||
{ | ||
await message.ReplyAsync($"The log file name for this instance is: `{SystemLogger.FileName}`\nPlease paste this into the `Log File Name` field in grid-bot-support templates to that the internal team can easily identify this instance's log files."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#if WE_LOVE_EM_SLASH_COMMANDS | ||
|
||
using System.IO; | ||
using System.Threading.Tasks; | ||
using Discord; | ||
using Discord.WebSocket; | ||
using MFDLabs.Grid.Bot.Extensions; | ||
using MFDLabs.Grid.Bot.Interfaces; | ||
using MFDLabs.Grid.Bot.Utility; | ||
|
||
namespace MFDLabs.Grid.Bot.SlashCommands | ||
{ | ||
internal sealed class DeploymentId : IStateSpecificSlashCommandHandler | ||
{ | ||
public string CommandDescription => "Get Deployment ID"; | ||
public string CommandAlias => "deployment"; | ||
public bool Internal => false; | ||
public bool IsEnabled { get; set; } = true; | ||
public ulong? GuildId => null; | ||
public SlashCommandOptionBuilder[] Options => null; | ||
|
||
public async Task Invoke(SocketSlashCommand command) | ||
{ | ||
using (await command.DeferEphemeralAsync()) | ||
{ | ||
// The deployment ID is literally just the name of the current directory that the executable is in. | ||
// This is not a great way to do this, but it's the best I can think of for now. | ||
|
||
// Fetch current directory name. | ||
var currentDirectory = Directory.GetCurrentDirectory(); | ||
var currentDirectoryName = Path.GetFileName(currentDirectory); | ||
|
||
// Reply with the deployment ID. | ||
await command.RespondEphemeralAsync($"The deployment ID for this instance is: `{currentDirectoryName}`\nPlease paste this into the `Deployment ID` field in grid-bot-support templates to that the internal team can easily identify this instance."); | ||
} | ||
} | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#if WE_LOVE_EM_SLASH_COMMANDS | ||
|
||
using System.Threading.Tasks; | ||
using Discord; | ||
using Discord.WebSocket; | ||
using MFDLabs.Logging; | ||
using MFDLabs.Grid.Bot.Extensions; | ||
using MFDLabs.Grid.Bot.Interfaces; | ||
using MFDLabs.Grid.Bot.Utility; | ||
|
||
namespace MFDLabs.Grid.Bot.SlashCommands | ||
{ | ||
internal sealed class LogFile : IStateSpecificSlashCommandHandler | ||
{ | ||
public string CommandDescription => "Get Log File Name"; | ||
public string CommandAlias => "log-file-name"; | ||
public bool Internal => false; | ||
public bool IsEnabled { get; set; } = true; | ||
public ulong? GuildId => null; | ||
public SlashCommandOptionBuilder[] Options => null; | ||
|
||
public async Task Invoke(SocketSlashCommand command) | ||
{ | ||
using (await command.DeferEphemeralAsync()) | ||
{ | ||
await command.RespondEphemeralAsync($"The log file name for this instance is: `{SystemLogger.FileName}`\nPlease paste this into the `Log File Name` field in grid-bot-support templates to that the internal team can easily identify this instance's log files."); | ||
} | ||
} | ||
} | ||
} | ||
|
||
#endif |