Skip to content

Commit

Permalink
Merge pull request #59 from egebilecen/v1.9.x
Browse files Browse the repository at this point in the history
v1.9.0
- Added new command: `!server_cmd`

`!server_cmd`
Allows you to send inputs to the server console. (!server_cmd [text])
  • Loading branch information
egebilecen authored Jan 17, 2023
2 parents c6d4203 + ab2e8c6 commit 0f814ff
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ Bot Commands:
- `!localization` Get/change current localization. (!localization [*(optional)* new localization name])<br>

Server Commands:
- `!server_cmd` Allows you to send inputs to the server console. (!server_cmd [text])<br>
- `!server_msg` Broadcasts a message to all players in the server. (!server_msg "[message]")<br>
- `!start_server` Starts the server. (!start_server)<br>
- `!stop_server` Saves and stops the server. (!stop_server)<br>
Expand Down
24 changes: 22 additions & 2 deletions src/Bot/Commands/PZServerCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,29 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Windows.Forms;

public class PZServerCommands : ModuleBase<SocketCommandContext>
{
[Command("server_cmd")]
[Summary("Allows you to send inputs to the server console. (!server_cmd <text>)")]
public async Task ServerCommand(params string[] strList)
{
try
{
ServerUtility.ServerProcess.StandardInput.WriteLine(string.Format("{0}", string.Join(" ", strList)));
ServerUtility.ServerProcess.StandardInput.Flush();
}
catch(Exception ex)
{
await Context.Message.AddReactionAsync(EmojiList.RedCross);
await Context.Channel.SendMessageAsync(ex.Message);
return;
}

await Context.Message.AddReactionAsync(EmojiList.GreenCheck);
}

[Command("server_msg")]
[Summary("Broadcasts a message to all players in the server. (!server_msg \"<message>\")")]
public async Task ServerMessage(string message)
Expand Down Expand Up @@ -373,7 +393,7 @@ public async Task NoClip(string username)
}

[Command("show_options")]
[Summary("Shows a list of current server options and values. (Prints to the server console)")]
[Summary("Shows a list of current server options and values. (Prints to the server console) (!show_options)")]
public async Task ShowOptions()
{
ServerUtility.Commands.ShowOptions();
Expand All @@ -383,7 +403,7 @@ public async Task ShowOptions()
}

[Command("reload_options")]
[Summary("Reloads server options.")]
[Summary("Reloads server options. (!reload_options)")]
public async Task ReloadOptions()
{
ServerUtility.Commands.ReloadOptions();
Expand Down
2 changes: 1 addition & 1 deletion src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
public static class Application
{
public const string BotRepoURL = "https://github.com/egebilecen/PZServerDiscordBot";
public static readonly SemanticVersion BotVersion = new SemanticVersion(1, 8, 2, DevelopmentStage.Release);
public static readonly SemanticVersion BotVersion = new SemanticVersion(1, 9, 0, DevelopmentStage.Release);
public static Settings.BotSettings BotSettings;

public static DiscordSocketClient Client;
Expand Down

0 comments on commit 0f814ff

Please sign in to comment.