Closed RalphORama closed 1 month ago
Add permission checks - admins only?
It's possible to set permissions for a command using SlashCommandBuilder#setDefaultMemberPermissions()
: https://discordjs.guide/slash-commands/permissions.html#member-permissions
e.g.
new SlashCommandBuilder()
.setName(...)
// ...
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
should make the command admin-only.
Should settings.guild
be an FK (with REFERENCES guilds(id)
)?
Additionally, should it have ON DELETE CASCADE
so that the settings
rows are deleted when /forget
is run? (Or should we keep the rows so that we can restore settings on /configure
?)
Also FYI: guilds.id
is a bigint
while settings.guild
is an integer
Summary
As LinkFix gets added to more servers, several people have reached out requesting features that would require per-server configuration. We need to store those configurations.
Methodology
Firstly, I am going to try to avoid using ORMs as much as possible. the
pg
package offers the ability to execute raw queries which should be good enough for our requirements. If, in the future, the database gets more complicated, I wouldn't have an issue moving to something like Sequelize.Secondly, I want LinkFix to store as little data as possible. I think we shouldn't create records for guilds until someone in the guild actually sets configuration options. This keeps us in the clear for crap like GDPR, plus I personally believe in data privacy myself and don't want to become a vector of attack for other people.
Database Structire
https://dbdiagram.io/d/LinkFix-658b15e289dea6279992fb74
To-Do
/configure
command to get and store settings/forget
command to wipe guild from databaseAfter we move into production: