hypherionmc / sdlink

A simple to use Minecraft to Discord Chat linker with Whitelisting
MIT License
21 stars 7 forks source link

Add console channel #28

Closed ChristopherHaws closed 1 year ago

ChristopherHaws commented 1 year ago

With DiscordSRV on spigot you could assign a specific discord channel to contain console messages and you can execute commands as console from the discord channel. I would love this feature to be added to SDLink! :)

https://docs.discordsrv.com/config/#DiscordConsoleChannelId

hypherionmc commented 1 year ago

The console messages part has been suggested before, I am just a bit concerned about Discord ratelimits on the sending of messages. I've seen some console logs and they are scary.

That has to either be implemented in such a way that the messages are sent in batches, OR, that it only sends new messages after the server has already started.

The commands part has also been on the table for a while. I'm looking at a way to link discord commands back to MC commands while keeping up with perms etc, but yes, it's definitely going to be added in a future release, once I'm confident with the implementation

akaep commented 1 year ago

Thanks for the work on this, it's really great. This is the only feature I miss from DSRV. Having the console available in its own channel on Discord that's accessible anywhere and by specific people. Super helpful for monitoring security / breakfix. Just out of curiosity, are you worried about Discord's ability to ingest the data from console? Or is there a reason the rate limit would be approached or tested by Fabric, but not Paper/Spigot? Thanks!

hypherionmc commented 1 year ago

My concern is because of the Forge/Fabric/Quilt abuses the console. I've had a couple of issue reports with a mod using particle commands to spawn particles, and sdlink would completely lock up the server because of how many times the command was executed, when discord ratelimits got triggered.

Paper/Spigot consoles are a lot cleaner and don't log as much. So it's more a case of implementing this in a way that it doesn't

A) Dump the entire log at once (which would cross the 2000 character limit) B) Send 100's of messages in a minute, which would trigger the rate-limit

akaep commented 1 year ago

Oh that makes a lot of sense. Are there different designations for types of console output? Or is it all or nothing?

hypherionmc commented 1 year ago

So, Both Console Relaying and Discord To MC commands have been implemented. So far, both seem to be working as intended.

Here is a sample of the console channel... As I feared, it spamming the hell out of the channel, even with a delay, and the channel relay only starting after the "Server Starting..." message has fired.

[22:30:32] [Server thread/INFO] (DedicatedServer) Loading properties
[22:30:32] [Server thread/INFO] (DedicatedServer) Default game type: SURVIVAL
[22:30:32] [Server thread/INFO] (MinecraftServer) Generating keypair
[22:30:32] [Server thread/INFO] (DedicatedServer) Starting Minecraft server on:25565*
[22:30:32] [Server thread/INFO] (ServerConnectionListener) Using default channel type
[22:30:32] [Server thread/INFO] (DedicatedServer) Preparing level "world"
[22:30:33] [Server thread/INFO] (MinecraftServer) Preparing start region for dimension minecraft:overworld
[22:30:38] [Worker-Main-5/INFO] (LoggerChunkProgressListener) Preparing spawn area: 0%
[22:30:38] [Worker-Main-1/INFO] (LoggerChunkProgressListener) Preparing spawn area: 0%
[22:30:38] [Worker-Main-5/INFO] (LoggerChunkProgressListener) Preparing spawn area: 0%
[22:30:38] [Worker-Main-7/INFO] (LoggerChunkProgressListener) Preparing spawn area: 0%
[22:30:38] [Worker-Main-7/INFO] (LoggerChunkProgressListener) Preparing spawn area: 0%
[22:30:38] [Worker-Main-1/INFO] (LoggerChunkProgressListener) Preparing spawn area: 0%
[22:30:38] [Worker-Main-5/INFO] (LoggerChunkProgressListener) Preparing spawn area: 0%
[22:30:38] [Worker-Main-7/INFO] (LoggerChunkProgressListener) Preparing spawn area: 0%
[22:30:38] [Worker-Main-5/INFO] (LoggerChunkProgressListener) Preparing spawn area: 0%
[22:30:38] [Worker-Main-1/INFO] (LoggerChunkProgressListener) Preparing spawn area: 0%
[22:30:38] [Worker-Main-7/INFO] (LoggerChunkProgressListener) Preparing spawn area: 0%
[22:30:39] [Worker-Main-1/INFO] (LoggerChunkProgressListener) Preparing spawn area: 0%
[22:30:39] [Worker-Main-5/INFO] (LoggerChunkProgressListener) Preparing spawn area: 13%
[22:30:40] [Worker-Main-4/INFO] (LoggerChunkProgressListener) Preparing spawn area: 52%
[22:30:40] [Worker-Main-4/INFO] (LoggerChunkProgressListener) Preparing spawn area: 83%
[22:30:40] [Server thread/INFO] (LoggerChunkProgressListener) Time elapsed: 7364 ms
[22:30:40] [Server thread/INFO] (DedicatedServer) Done (7.973s)! For help, type "help"
[22:31:07] [User Authenticator #1/INFO] (ServerLoginPacketListenerImpl) UUID of player HypherionSA is REDACTED
[22:31:08] [Server thread/INFO] (PlayerList) HypherionSA[/127.0.0.1:55113] logged in with entity id 174 at (-49.816027638023854, 64.0, -6.934446760754822)
[22:31:08] [Server thread/INFO] (MinecraftServer) HypherionSA joined the game
[22:31:15] [Server thread/INFO] (MinecraftServer) <HypherionSA> Hello World
[22:31:35] [Server thread/INFO] (ServerGamePacketListenerImpl) HypherionSA lost connection: Disconnected
[22:31:35] [Server thread/INFO] (MinecraftServer) HypherionSA left the game

I might change this to only start relaying messages once the server has fully started, OR, I'll leave it as is and see what the feedback is on it

hypherionmc commented 1 year ago

Here is the config sample for linking commands:

First one anyone can execute, the second one is locked behind a role.

#Execute Minecraft commands in Discord
[linkedCommands]
    #Should linked commands be enabled
    enabled = true
    #Commands to be linked
    [[linkedCommands.commands]]
        mcCommand = "say %args%"
        discordCommand = "saymc"
        discordRole = ""

    [[linkedCommands.commands]]
        mcCommand = "stop"
        discordCommand = "stopmc"
        discordRole = "MacOS"

Commands are executed in game as a "fake" player, so permission control is possible

hypherionmc commented 1 year ago

Alrighty. Test builds with the Console channel/commands and formatting are ready!

You can find them here: Jenkins

And a rough guide/changelog HERE.

If all goes well, this will be pushed to release on Saturday

hypherionmc commented 1 year ago

Features were released today with SDLink 2.1

akaep commented 1 year ago

Amazing. Thanks for all the work on this!