marcelropos / HM-DiscordBot

A Discordbot by and for first semester students of HM.
8 stars 5 forks source link

Setup logging outputs and formatting #193

Closed schitcrafter closed 10 months ago

schitcrafter commented 10 months ago

Closes #140

schitcrafter commented 10 months ago

So the logic of sending discord messages on certain logs should all be implemented now, was honestly a complete pain, but it should work now. Problems still remaining are mostly that I don't know where to get the main guild id / main log channel id from, as well as how to get all the per-server log channel id's.

maxwai commented 10 months ago

I don't know where to get the main guild id / main log channel id from

The main guild id is a env variable. Just use MAIN_GUILD_ID. As for the channel id, use the first text channel in the guild.

as well as how to get all the per-server log channel id's.

these are stored in the Database, so it can be retrieved with mysql_lid::get_guild

schitcrafter commented 10 months ago

Just wanna mention two things: The fields inside all structs from mysql_lib should probably be public, might wanna change that, and all the FromRow implementations are quite useless - there's a derive macro which should create those automatically. Alternatively there's the query!(..) and query_as!(..) macros that would also check against the database while compiling to make sure that the columns exist and can be converted from/to the rust types. I've mentioned this already, but I wanna mention it again because it's a very cool thing that sqlx has, and because we have >100 lines of code that is basically copy-pasted.

maxwai commented 10 months ago

The fields inside all structs from mysql_lib should probably be public, might wanna change that

Oh yeah, I missed that, will change once this PR is merged to avoid conflicts

there's a derive macro which should create those automatically.

I will look at that later for now it works even if not pretty