-
Notifications
You must be signed in to change notification settings - Fork 2
feat: per-guild configuration (multi-tenancy) #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 13 commits
c355e53
57d78a6
8e6fccb
f0f3b45
315fda7
46ad327
997a5cd
ea38be2
2e79b6b
adce7dd
57f643b
eecf123
0e4bce1
ef56576
9aae5e1
0f53822
41fa503
b73267f
214cfdf
244598c
cea74f6
4c62040
a247577
45ebc00
240d1de
b950452
8b9510c
763aa1c
cb7ae74
f5f4dd0
31948cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -121,7 +121,7 @@ function collectConfigPaths(source, prefix = '', paths = []) { | |
| export async function autocomplete(interaction) { | ||
| const focusedOption = interaction.options.getFocused(true); | ||
| const focusedValue = focusedOption.value.toLowerCase().trim(); | ||
| const config = getConfig(); | ||
| const config = getConfig(interaction.guildId); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: The Line 161 should be: const config = getConfig(interaction.guildId); |
||
|
|
||
| let choices; | ||
| if (focusedOption.name === 'section') { | ||
|
|
@@ -186,7 +186,7 @@ const EMBED_CHAR_LIMIT = 6000; | |
| */ | ||
| async function handleView(interaction) { | ||
| try { | ||
| const config = getConfig(); | ||
| const config = getConfig(interaction.guildId); | ||
| const section = interaction.options.getString('section'); | ||
|
|
||
| const embed = new EmbedBuilder() | ||
|
|
@@ -275,7 +275,7 @@ async function handleSet(interaction) { | |
|
|
||
| // Validate section exists in live config | ||
| const section = path.split('.')[0]; | ||
| const validSections = Object.keys(getConfig()); | ||
| const validSections = Object.keys(getConfig(interaction.guildId)); | ||
| if (!validSections.includes(section)) { | ||
| const safeSection = escapeInlineCode(section); | ||
| return await safeReply(interaction, { | ||
|
|
@@ -287,7 +287,7 @@ async function handleSet(interaction) { | |
| try { | ||
| await interaction.deferReply({ ephemeral: true }); | ||
|
|
||
| const updatedSection = await setConfigValue(path, value); | ||
| const updatedSection = await setConfigValue(path, value, interaction.guildId); | ||
|
|
||
| // Traverse to the actual leaf value for display | ||
| const leafValue = path | ||
|
|
@@ -331,7 +331,7 @@ async function handleReset(interaction) { | |
| try { | ||
| await interaction.deferReply({ ephemeral: true }); | ||
|
|
||
| await resetConfig(section || undefined); | ||
| await resetConfig(section || undefined, interaction.guildId); | ||
|
|
||
| const embed = new EmbedBuilder() | ||
| .setColor(0xfee75c) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -125,8 +125,16 @@ async function handleSetup(interaction) { | |
|
|
||
| if (i.customId === 'modlog_channel' && selectedCategory) { | ||
| const channelId = i.values[0]; | ||
| await setConfigValue(`moderation.logging.channels.${selectedCategory}`, channelId); | ||
| info('Modlog channel configured', { category: selectedCategory, channelId }); | ||
| await setConfigValue( | ||
| `moderation.logging.channels.${selectedCategory}`, | ||
| channelId, | ||
| interaction.guildId, | ||
| ); | ||
| info('Modlog channel configured', { | ||
| category: selectedCategory, | ||
| channelId, | ||
| guildId: interaction.guildId, | ||
| }); | ||
| await i.update({ | ||
| embeds: [ | ||
| embed.setDescription( | ||
|
|
@@ -166,7 +174,7 @@ async function handleSetup(interaction) { | |
| */ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug (same pattern as config.js): The permission check at the top of If a guild has customized The fix is the same as what needs to happen in const config = getConfig(interaction.guildId); |
||
| async function handleView(interaction) { | ||
| try { | ||
| const config = getConfig(); | ||
| const config = getConfig(interaction.guildId); | ||
| const channels = config.moderation?.logging?.channels || {}; | ||
|
|
||
| const embed = new EmbedBuilder() | ||
|
|
@@ -199,10 +207,10 @@ async function handleDisable(interaction) { | |
| try { | ||
| const keys = ['default', 'warns', 'bans', 'kicks', 'timeouts', 'purges', 'locks']; | ||
| for (const key of keys) { | ||
| await setConfigValue(`moderation.logging.channels.${key}`, null); | ||
| await setConfigValue(`moderation.logging.channels.${key}`, null, interaction.guildId); | ||
| } | ||
|
|
||
| info('Mod logging disabled', { moderator: interaction.user.tag }); | ||
| info('Mod logging disabled', { moderator: interaction.user.tag, guildId: interaction.guildId }); | ||
| await safeEditReply( | ||
| interaction, | ||
| '✅ Mod logging has been disabled. All log channels have been cleared.', | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.