momentum-mod / discord-bot

The Discord bot used in the official Momentum Mod Discord Server.
https://discord.gg/momentummod
MIT License
9 stars 7 forks source link

Add Docker Compose setup #109

Closed tsa96 closed 2 years ago

tsa96 commented 2 years ago

This adds Docker Compose files for development and deployment. The MySQL setup will now be handled fully by Docker. Should make development a lot easier (includes an empty config, rather than telling you to reconstruct anything manually from the Configuration.cs file...).

Also adds makes the bot print errors to #bot-config, since they're unlikely to actually get noticed otherwise. (Sorry, I probs should've done in a separate commit but I'm tired and don't want to spend any more time on bot stuff today)

Once this is merged I'll do all the migration work on the VPS.

tsa96 commented 2 years ago

Maybe you should call LogError before SendMessage just in case the exception we are catching here is because we cant send. Doesn't seem to cause infinite loops though.

Good shout, I'll change that later.

tsa96 commented 2 years ago

I've changed the order just to be safe, though why should it be a problem anyway? This is just handling the SlashCommandErrored event - why would that be fired here?

BIRD311 commented 2 years ago

SendMessageAsync can throw and when it does the rest of the function won't be executed and because this is inside the exception handling you wouldn't see anything of the original exception. It can throws authentication error, server errors (whatever that means exactly) and others.

tsa96 commented 2 years ago

Note that this will need a significant rebase on the custom commands branch or vice versa, when the other is merged. GuildID will need adding to config.

tsa96 commented 2 years ago

Rebased and added the guild_id config property. Also added an extra catch in the Slash Commands exception handling just to be sure we don't get any looping like you mentioned BIRD.

BIRD311 commented 2 years ago

config.template.json.txt A few things I noticed in the config.template: guild_id is not a string commandprefix and keybegging_role can be removed Because I was to lazy to create a server with every role and channel when I started doing this, I set every role in the config to the same ID and the same for channels. Later I changed some so I could test stuff better but for the template it would be nice to just search replace the roles and channels. I changed the guild_id to something like this too so its obvious what you have to change. I attached the file here but github doesn't like uploading json so I renamed it.

I also noticed that some of you new files (including the config) have CRLF newlines. Maybe you want to change it but I don't care too much. Everything else has LF newlines afaik. Maybe we shouldn't put config/ in the gitignore and put the 2 config files there instead just so we don't forget to add new stuff in the future.

I forgot to remove the commandprefix from the uploaded file

tsa96 commented 2 years ago

Oh thanks, the line ending thing I completely missed, was using a different editor for those non-C# files.

The config types I've fixed, I'm not keen on the temp naming scheme though, I prefer to just have a clean file. I dunno, if you want to update the readme to include a guide to making a mock config that could work.

Changed the .gitignore to just ignore the actual config file.