Mods / DiscordBot

Category:
Author: BillyGalbreath
Side: Server
Created: Sep 22nd 2023 at 10:39 PM
Last modified: 5 days ago
Downloads: 1684
Follow Unfollow 33

Latest file for Various v1.19.x:
DiscordBot-0.0.20.zip 1-click install


This is currently a work in progress project.

I started this because there is no other up-to-date discord bot that isn't wrapped up with other non-discord related features (like homes and stuff) or with the features/style that I personally prefer.

Features:

  • Forward in-game chat to discord, and vice versa
  • Use proper avatars in discord that match player's in-game skins
  • Use discord embeds for as much non-chat messages as possible
  • Display server events:
    • Show server start/stop
    • Show player join/leave
    • Show player deaths
    • Show player character updates (.charsel, etc)
    • Show temporal storm warnings
  • Show player count in bot's presence/status
  • Display console output to separate console channel (can run commands from here!)
  • (NEW!) Discord slash commands!

More features will be added over time.

Slash commands:

  • /nexttempstorm - Shows how long until the next storm
  • /players [ping] true/false - Shows a list of currently online players (optionally with ping times).
  • /time - Shows the current in-game time and date.

More commands will be added over time.

You can disable any of these commands in the config by setting "Enabled" to false.

Installation:

  • Create a discord bot with presense, server members, and message content intents (yes, all three)
  • Invite your bot to your guild with the "send messages" and "manage webhooks" permissions
  • Put zip in your Mods folder and start/stop server (this will create the default config)
  • Open the discordbot.yaml config and set your bot's secret token
  • Set your chat channel id in the config
  • Optionally, set your console channel id in the config (WARNING: messages sent to this channel will be ran as commands. it is up to you to protect this channel so only you/your staff can access it)
  • Edit other things in the config to your heart's content
  • Start server and enjoy

If you dont know how to get create your bot or get it's token, etc, refer to Google on how to do so.

 

-------------------------------------------------------------------------------------------------------------

Remember, I build these mods for myself and my family. Not you. I owe you nothing. I just like sharing what I've built with others for free. You will receive minimal to no support when using any of my mods.

-------------------------------------------------------------------------------------------------------------

Version For Game version Downloads Release date Changelog Download 1-click mod install*
v0.0.20 20 5 days ago Show DiscordBot-0.0.20.zip Install now
v0.0.19 68 Mar 16th at 2:20 AM Show DiscordBot-0.0.19.zip Install now
v0.0.18 119 Jan 26th at 6:52 PM Show DiscordBot-0.0.18.zip Install now
v0.0.17 35 Jan 26th at 6:37 PM Show DiscordBot-0.0.17.zip Install now
v0.0.16 192 Nov 2nd 2023 at 4:29 PM Show DiscordBot-0.0.16.zip Install now
v0.0.15 67 Oct 31st 2023 at 11:29 PM Show DiscordBot-0.0.15.zip Install now
v0.0.14 88 Oct 28th 2023 at 4:31 PM Show DiscordBot-0.0.14.zip Install now
v0.0.13 88 Oct 25th 2023 at 8:29 PM Show DiscordBot-0.0.13.zip Install now
v0.0.12 91 Oct 25th 2023 at 1:58 AM Show DiscordBot-0.0.12.zip Install now
v0.0.11 81 Oct 23rd 2023 at 9:15 AM Show DiscordBot-0.0.11.zip Install now
v0.0.10 76 Oct 22nd 2023 at 10:52 AM Show DiscordBot-0.0.10.zip Install now
v0.0.9 90 Oct 20th 2023 at 3:47 PM Show DiscordBot-0.0.9.zip Install now
v0.0.8 82 Oct 18th 2023 at 2:22 PM Show DiscordBot-0.0.8.zip Install now
v0.0.7 76 Oct 14th 2023 at 12:50 PM Show DiscordBot-0.0.7.zip Install now
v0.0.6 71 Oct 14th 2023 at 12:44 PM Show DiscordBot-0.0.6.zip Install now
v0.0.5 77 Oct 12th 2023 at 6:58 AM Show DiscordBot-0.0.5.zip Install now
v0.0.4 88 Oct 5th 2023 at 12:57 PM Show DiscordBot-0.0.4.zip Install now
v0.0.3 74 Oct 5th 2023 at 9:24 AM Show DiscordBot-0.0.3.zip Install now
v0.0.2 79 Oct 5th 2023 at 8:29 AM Show DiscordBot-0.0.2.zip Install now
v0.0.1 122 Sep 22nd 2023 at 10:46 PM Show DiscordBot.zip Install now

42 Comments (oldest first | newest first)

💬 Bazim, 4 days ago

Thank you, will test it.

💬 BillyGalbreathAuthor, 5 days ago

Sorry about that, Bazim. I'm surprised no one told me that was an issue for over a month now :3 All fixed in 0.0.20

💬 Bazim, 5 days ago

Server is crashing with this mod installed

 

System.IO.FileNotFoundException: Could not load file or assembly 'SilentSave, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

💬 bringitonwimps, Mar 6th at 4:19 AM

that's fine, i mean it makes sense, just trying to find a way to auto backup, is there a way to program this bot to have a setting to auto backup x minutes, or whatever?

💬 BillyGalbreathAuthor, Mar 2nd at 9:39 PM

bringitonwimps, the bot is programmed to ignore commands and text from other bots. It's to prevent circular situations where bots respond to bots respond to bots respond to bots, etc. I can't personally think of a sane way to fix this :3

💬 bringitonwimps, Feb 29th at 12:59 AM

so i am trying to get an auto backup running from this bot.  if i type the command for it to genbackup it obviously has the serever backup.  so we set up atlas to send the genbackup command text every x interval.  for some reason it posts it in the server command discord channel just fine, but it never triggers the server to run the backup.  any ideas?

💬 DonnieDreams, Jan 30th at 5:22 AM

So followed the guide to a t... bot is forwarding Ingame chat to discord fine. Am not seeing the vice versa though. Is there a config that I need to enable to get discord chat to forward to in game. Just curious... Or did i do something wrong. Very probable that it it user error. Otherwise. Very awesome. 

💬 BillyGalbreathAuthor, Jan 26th at 6:46 PM

Sorry about that, EmperrorAlpha

Has nothing to do with the operating system. I code this on a Windows desktop, but I also run it on a Linux server. (Debian masterrace!)

The problem was the game devs changed a private variable to be public, and my reflection methods were not expecting that. It has now been fixed ^_^

💬 EmperrorAlpha, Jan 26th at 2:50 PM

The message about the player's death does not appear.

I keep the server on Linux. And it looks like you made this mod for Windows? Is that why I have such a mistake?

Mod writes this:

at DiscordBot.Bot.OnPlayerDeath(IServerPlayer player, String deathMessage) in C:\Users\Billy\RiderProjects\DiscordBot\src\Bot.cs:line 200 at DiscordBot.Patches.ServerSystemEntitySimulationPatches.GetDeathMessagePatch.Postfix(ConnectedClient client, String __result) in C:\Users\Billy\RiderProjects\DiscordBot\src\Patches\ServerSystemEntitySimulationPatches.cs:line 22 at Vintagestory.Server.ServerSystemEntitySimulation.GetDeathMessage_Patch1(ServerSystemEntitySimulation this, ConnectedClient client, DamageSource src) at Vintagestory.Server.ServerSystemEntitySimulation.SendPlayerEntityDeaths() in VintagestoryLib\Server\Systems\World\EntitySimulation.cs:line 682 at Vintagestory.Server.ServerSystemEntitySimulation.OnServerTick(Single dt) in VintagestoryLib\Server\Systems\World\EntitySimulation.cs:line 168 at Vintagestory.Server.ServerMain.Process() in VintagestoryLib\Server\ServerMain.cs:line 886

💬 Angellord, Jan 20th at 4:35 AM

Nice mod, simple concise clearly calibrated.
We hope for further development, such wonderful mod.
Others, so cool - there is no in the community.

Just for approach, you need to say a total thank you. 💪😼

Potential users take into account - you will need to configure an autoreboot server, or patched the current problem.
Mod with different periodicity crashes server. Day - Week. Unless, of course, you're a code guru.

💬 BillyGalbreathAuthor, Jan 9th at 5:27 AM

Cpt_C0nfus3d

Sorry about that. I ran into some issues and my server was offline for a little over 24 hours. All should be fine as of ~12 hours ago.

💬 Cpt_C0nfus3d, Jan 8th at 5:31 AM

I have the error on the server and the avatars are no longer displayed when someone joins.

 

Game Version: v1.18.15 (Stable)
08.01.2024 00:22:32: Critical error occurred
Loaded Mods:
System.AggregateException: One or more errors occurred. (The operation has timed out.)
---> System.TimeoutException: The operation has timed out.
at Discord.Net.Queue.RequestBucket.EnterAsync(Int32 id, IRequest request)
at Discord.Net.Queue.RequestBucket.SendAsync(RestRequest request)
at Discord.Net.Queue.RequestQueue.SendAsync(RestRequest request)
at Discord.API.DiscordRestApiClient.SendInternalAsync(String method, String endpoint, RestRequest request)
at Discord.API.DiscordRestApiClient.SendJsonAsync[TResponse](String method, String endpoint, Object payload, BucketId bucketId, ClientBucketType clientBucket, RequestOptions options)
at Discord.API.DiscordRestApiClient.CreateMessageAsync(UInt64 channelId, CreateMessageParams args, RequestOptions options)
at Discord.Rest.ChannelHelper.SendMessageAsync(IMessageChannel channel, BaseDiscordClient client, String text, Boolean isTTS, Embed embed, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent components, ISticker[] stickers, RequestOptions options, Embed[] embeds, MessageFlags flags)
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at DiscordBot.Bot.SendMessageToDiscordConsole(String message) in C:\Users\Billy\RiderProjects\DiscordBot\src\Bot.cs:line 360
at DiscordBot.Util.MessageQueue.<Process>b__4_0(Object _) in C:\Users\Billy\RiderProjects\DiscordBot\src\Util\MessageQueue.cs:line 32
at System.Threading.QueueUserWorkItemCallback.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
System.TimeoutException: The operation has timed out.
at Discord.Net.Queue.RequestBucket.EnterAsync(Int32 id, IRequest request)
at Discord.Net.Queue.RequestBucket.SendAsync(RestRequest request)
at Discord.Net.Queue.RequestQueue.SendAsync(RestRequest request)
at Discord.API.DiscordRestApiClient.SendInternalAsync(String method, String endpoint, RestRequest request)
at Discord.API.DiscordRestApiClient.SendJsonAsync[TResponse](String method, String endpoint, Object payload, BucketId bucketId, ClientBucketType clientBucket, RequestOptions options)
at Discord.API.DiscordRestApiClient.CreateMessageAsync(UInt64 channelId, CreateMessageParams args, RequestOptions options)
at Discord.Rest.ChannelHelper.SendMessageAsync(IMessageChannel channel, BaseDiscordClient client, String text, Boolean isTTS, Embed embed, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent components, ISticker[] stickers, RequestOptions options, Embed[] embeds, MessageFlags flags)

💬 BoolyStudy, Nov 11th 2023 at 6:07 AM

10.11.2023 22:05:11 [Server Warning] [vsdiscordbot] Rate limit triggered: POST channels/1162457488210284626/messages Remaining: 6s (Bucket: 1d3c67957bcdccc6709861c232df8529)
10.11.2023 22:05:12 [Server Warning] SpawnEntity: Duplicate entity id discovered, will updating SaveGameData.LastEntityId to reflect this. This was likely caused by an ungraceful server exit.

💬 XurxoMF, Nov 10th 2023 at 3:43 PM

10.11.2023 15:37:47 [Event] Offthread save of 0 map chunks done.
10.11.2023 15:37:47 [Event] Offthread save of savegame done.
10.11.2023 15:38:32 [Warning] [vsdiscordbot] WebSocket connection was closed
10.11.2023 15:38:32 [Event] [vsdiscordbot] Disconnecting
10.11.2023 15:38:32 [Event] [vsdiscordbot] Disconnected
10.11.2023 15:38:33 [Event] [vsdiscordbot] Connecting

This is the last logs in server-main before the server closes instantly. No crash reports, no more logs anywhere...
The server was working 24/7 but since I installed this mods it's closing every day.

💬 Ragolution, Nov 5th 2023 at 6:06 PM

Thanks for this. Much better than installing some bot with 130 features I don't want and will never use.

💬 XurxoMF, Nov 4th 2023 at 8:52 AM

This is a suggestion that culd be great, logs in sepparate channels. You couls choose via channel-id where each type of log will be sent to. That way we can sent start/stop logs to a status channel, player join/leave to a players channel, chat to a in-game chat channel.... That could be great for sure.

💬 BoolyStudy, Oct 30th 2023 at 5:37 AM

29.10.2023 22:29:42 [Server Warning] [vsdiscordbot] A SlashCommandExecuted handler is blocking the gateway task.
29.10.2023 22:29:42 [Server Error] [vsdiscordbot] Exception: The server responded with error 10015: Unknown Webhook
at Discord.Net.Queue.RequestBucket.SendAsync(RestRequest request)
at Discord.Net.Queue.RequestQueue.SendAsync(RestRequest request)
at Discord.API.DiscordRestApiClient.SendInternalAsync(String method, String endpoint, RestRequest request)
at Discord.API.DiscordRestApiClient.SendAsync(String method, String endpoint, BucketId bucketId, ClientBucketType clientBucket, RequestOptions options)
at Discord.API.DiscordRestApiClient.DeleteInteractionResponseAsync(String interactionToken, RequestOptions options)
at Discord.Rest.InteractionHelper.DeleteInteractionResponseAsync(BaseDiscordClient client, IDiscordInteraction interaction, RequestOptions options)
at DiscordBot.Command.CommandHandler.HandleSlashCommands(SocketSlashCommand command) in C:\Users\Billy\RiderProjects\DiscordBot\src\Command\CommandHandler.cs:line 67

💬 Whiteshadoh, Oct 23rd 2023 at 6:09 PM

BillyGalbreath Can we filter what messages are sent from the console to the discord server? As it stands now it spams discord and it allows the user's IP to be posted which isnt safe for the player effected. The ability to filter in and out certain messages from the console is needed greatly.

💬 LeBastion, Oct 21st 2023 at 7:49 PM

You know what would be awesome? to have a command that allows us to know the weather, date and time in game from discord.
Do you think it is possible to implement it?

💬 Chumber, Oct 20th 2023 at 5:03 PM

You are an absolute beast. I also just noticed you snuck in the first slash command and it just... works.

AND this yml config is fantastic. Holy crap, just finding new bits as I type. You are a hero.

💬 BillyGalbreathAuthor, Oct 20th 2023 at 3:56 PM

Chumber

Those are some good ideas for commands. I'll get on implemeting those soon. I don't think I can make a /whenwillitstopraining command since rain/weather isn't global like minecraft.

Thanks for the bug report, too. It turned out to be processing the console message queue on the main thread was a bad idea (it was slower than I thought it would be). So I off loaded that to a thread pool in 0.0.9 and all seems fine now ^_^

💬 Chumber, Oct 20th 2023 at 12:15 PM

BillyGalbreath

I'd say any commands that can be run publicly to give game status info may be useful, like /date, /nexttempstorm, /whenwillitstopraining, etc. but not super important.

 

Chiming in with another report, but may or may not be a "bug" per se. I noticed some pretty significant tick times in the console while a bunch of people were online, and it seems to be coming from this mod:

324.94ms, call :all
310.71ms, 1 call : gmleDiscordBot.Bot+<>c__DisplayClass12_0

That DisplayClass pops up pretty consistently with 250-600ms calls. I'm not sure how much that's actually affecting game performance, because my server provider's network is coincidentally on fire for the last few weeks, but I thought I'd let you know as you may be able to tune that call to occur less or something idk.

💬 BillyGalbreathAuthor, Oct 20th 2023 at 8:29 AM

ItsCheif Same place almost all json files for mods are. In the ModConfig directory.

💬 BillyGalbreathAuthor, Oct 19th 2023 at 1:43 PM

BoolyStudy I forgot to respond the other day, but something like that isn't really possible for a game that's so easily moddable. Discord has no idea how any of the graphics should look, so they all have to be premade and hosted on a web server somewhere. There is no way for me to be able to do that for all items and blocks that can show up in a player's inventory since it's so easy for mods to add more. It's why the plugin you mentioned doesnt work for forge/fabric modded servers and only for vanilla spigot servers.

The player avatars, for example are a set of images hosted on a webserver of each different type of option (skin/hair/beard/etc) and combined into a single image using some php magic. I am unable to do clothing/armor/etc because mods can add those in easily. In fact, some servers cant even use the existing implementation since they change skin colors (CoB Servers, for example).

Lithos I can definitely add commands like that to the bot fairly easily. I'll start off with adding a /players command on the next update. If you have any more you'd like to see just let me know.

💬 BillyGalbreathAuthor, Oct 18th 2023 at 4:53 PM

Frodo It does use quite a bit of harmony patching. Sorry about that :3

💬 Frodo, Oct 18th 2023 at 3:56 PM

Does it use harmony patching? If so it woudnt work on my arm x64 server

💬 BillyGalbreathAuthor, Oct 18th 2023 at 2:23 PM

Lithos Good find ^_^ It's fixed in 0.0.8 (it will now convert emoji/unicode to :shortnames:)

💬 Chumber, Oct 18th 2023 at 3:11 AM

One of my players discovered an interesting bug, which is if any emojis are posted in the bot's chat channel, it breaks the in-game chat until someone leaves. Messages get half-shown or hidden entirely and it doesn't update properly, then everything shows up once someone leaves. A workaround would be to disallow emojis in that channel, but unfortunately you can't do that in threads. If you can't or don't want to fix that, I can switch back to a regular channel.

Would you prefer I submit an issue report on the github?

💬 Chumber, Oct 16th 2023 at 11:49 PM

The threads work great, thanks so much.

Do you have plans to add commands to the Discord side, or is that out of scope? The one thing I'm missing after switching to this is the lack of a way to see who's online without jumping in or going to the console. It'd be nice to have a way for everyone to see who's online.

💬 BoolyStudy, Oct 14th 2023 at 7:34 PM

Hello, could you add a bot command to see player inventories, through discord? Here is an example, Minecraft plugin: www.spigotmc.org/resources/interactivechat-discordsrv-addon-show-items-and-invs-on-discord-preview-discord-images-in-game.83917/

💬 BillyGalbreathAuthor, Oct 14th 2023 at 12:52 PM

Lithos Threads are now supported in v0.0.6 (just put the thread id as the chat channel in the config)

BoolyStudy Ooooh, good catch. Fixed in v0.0.7

💬 BoolyStudy, Oct 14th 2023 at 12:32 PM

Hello, the bot also reads messages from private chats within the game, could you solve that problem?

💬 BillyGalbreathAuthor, Oct 13th 2023 at 2:58 AM

Lithos I've never actually messed with threads before, but I'll look into it and see what I can do ^_^

💬 Chumber, Oct 13th 2023 at 12:17 AM

Is there any chance you could get this to work with threads? I like the way this one looks and functions, coming from th3essentials, and had a thread set up for the bot feed, but this one throws an error if a thread is used as the channel:

12.10.2023 17:16:23 [Event] [vsdiscordbot] Ready
12.10.2023 17:16:23 [Error] [vsdiscordbot] An exception was thrown when trying to start the mod:
System.AggregateException: One or more errors occurred. (This method is not supported in threads.)
---> System.NotSupportedException: This method is not supported in threads.
at Discord.WebSocket.SocketThreadChannel.GetWebhooksAsync(RequestOptions options)
at DiscordBot.Bot.SetupWebhooks() in C:\Users\Billy\RiderProjects\DiscordBot\src\Bot.cs:line 115
at DiscordBot.Bot.Connect() in C:\Users\Billy\RiderProjects\DiscordBot\src\Bot.cs:line 86
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at DiscordBot.DiscordBotMod.StartServerSide(ICoreServerAPI api) in C:\Users\Billy\RiderProjects\DiscordBot\src\DiscordBotMod.cs:line 61
at Vintagestory.Common.ModLoader.TryRunModPhase(Mod mod, ModSystem system, ICoreAPI api, ModRunPhase phase) in C:\Users\Tyron\Documents\vintagestory\game\VintagestoryLib\Common\API\ModLoader.cs:line 651

💬 McTaco, Oct 12th 2023 at 7:47 PM

Works great now!

💬 Whiteshadoh, Oct 10th 2023 at 10:47 PM

ImgBB Tutorial for DiscordBot.
Discord Bot Setup Tutorial

If I missed or messedup something let me know McTaco

💬 McTaco, Oct 6th 2023 at 5:44 PM

Thank you, would love that Whiteshadoh

💬 Whiteshadoh, Oct 5th 2023 at 1:28 PM

It does work, I'll post a guide hopefully by the weekend as it took me a few days to configure and get it working cause I eat crayons. McTaco

💬 BillyGalbreathAuthor, Oct 5th 2023 at 8:30 AM

McTaco It works just fine.

💬 McTaco, Oct 5th 2023 at 1:56 AM

Discord bot never comes online, stays offline and doesn't update channel. I will wait for more updates once you are ready.

💬 Th3Dilli, Sep 26th 2023 at 7:52 PM

looks nice

💬 Ruyeex, Sep 23rd 2023 at 2:38 PM

Will you implement a feature to access to Wiki Information with commands?

 

(edit comment delete)