Skip to content

Commit 4817174

Browse files
committed
fix: error when invalid command
1 parent 69853bc commit 4817174

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

DiscordLab.Administration/Events.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,20 @@ public override void OnServerCommandExecuted(CommandExecutedEventArgs ev)
7777
if (ev.Sender == null || !Player.TryGet(ev.Sender, out Player player))
7878
return;
7979

80+
if (string.IsNullOrEmpty(ev.Command.Command))
81+
return;
82+
83+
ArraySegment<string> args = ev.Arguments;
84+
85+
if (args == null)
86+
args = [];
87+
8088
SocketTextChannel channel;
8189
TranslationBuilder builder = new TranslationBuilder("player", player)
8290
.AddCustomReplacer("type", ev.CommandType.ToString())
83-
.AddCustomReplacer("arguments", () => string.Join(" ", ev.Arguments))
91+
.AddCustomReplacer("arguments", () => string.Join(" ", args))
8492
.AddCustomReplacer("command", ev.Command.Command)
85-
.AddCustomReplacer("commanddescription", ev.Command.Description);
93+
.AddCustomReplacer("commanddescription", ev.Command.Description ?? "Unknown");
8694

8795
if (ev.CommandType == CommandType.RemoteAdmin)
8896
{

0 commit comments

Comments
 (0)