-
Notifications
You must be signed in to change notification settings - Fork 2
feat: configurable community commands — enabled toggles for all features #106
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 all commits
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 |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ import { getPool } from '../db.js'; | |
| import { info, error as logError } from '../logger.js'; | ||
| import { getConfig } from '../modules/config.js'; | ||
| import { isModerator } from '../utils/permissions.js'; | ||
| import { safeEditReply } from '../utils/safeSend.js'; | ||
| import { safeEditReply, safeReply } from '../utils/safeSend.js'; | ||
|
|
||
| const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
|
|
||
|
|
@@ -325,6 +325,15 @@ async function handleList(interaction) { | |
| * @param {import('discord.js').ChatInputCommandInteraction} interaction | ||
| */ | ||
| export async function execute(interaction) { | ||
| const config = getConfig(interaction.guildId); | ||
| if (!config.help?.enabled) { | ||
BillChirico marked this conversation as resolved.
Show resolved
Hide resolved
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. 🟡 Warning: When Add the same gate at the top of export async function autocomplete(interaction) {
const config = getConfig(interaction.guildId);
if (!config.help?.enabled) {
return await interaction.respond([]);
}
// ... existing logic
} |
||
| await safeReply(interaction, { | ||
| content: '❌ The /help command is not enabled on this server.', | ||
| ephemeral: true, | ||
| }); | ||
| return; | ||
| } | ||
|
|
||
| await interaction.deferReply({ ephemeral: true }); | ||
|
|
||
| const subcommand = interaction.options.getSubcommand(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ vi.mock('../../src/logger.js', () => ({ | |
|
|
||
| vi.mock('../../src/modules/config.js', () => ({ | ||
| getConfig: vi.fn().mockReturnValue({ | ||
| announce: { enabled: true }, | ||
BillChirico marked this conversation as resolved.
Show resolved
Hide resolved
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. 🟡 Warning: No test for the Same as Add a test like: it('should reject when announce is disabled', async () => {
const { getConfig } = await import('../../src/modules/config.js');
getConfig.mockReturnValueOnce({
announce: { enabled: false },
permissions: { enabled: true, adminRoleId: null, usePermissions: true },
});
const interaction = createMockInteraction('list');
await execute(interaction);
expect(interaction.reply).toHaveBeenCalledWith(
expect.objectContaining({
content: expect.stringContaining('not enabled'),
ephemeral: true,
}),
);
expect(interaction.deferReply).not.toHaveBeenCalled();
});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. consider adding test case for when Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! Prompt To Fix With AIThis is a comment left during a code review.
Path: tests/commands/announce.test.js
Line: 16
Comment:
consider adding test case for when `announce.enabled` is false to verify the gate check works
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise. |
||
| permissions: { enabled: true, adminRoleId: null, usePermissions: true }, | ||
| }), | ||
| })); | ||
BillChirico marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ vi.mock('../../src/db.js', () => ({ | |
| getPool: vi.fn(), | ||
| })); | ||
| vi.mock('../../src/modules/config.js', () => ({ | ||
| getConfig: vi.fn().mockReturnValue({}), | ||
| getConfig: vi.fn().mockReturnValue({ help: { enabled: true } }), | ||
BillChirico marked this conversation as resolved.
Show resolved
Hide resolved
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. 🟡 Warning: No test for the The mock was updated to return Add a test like: it('should reject when help is disabled', async () => {
const { getConfig } = await import('../../src/modules/config.js');
getConfig.mockReturnValueOnce({ help: { enabled: false } });
const interaction = createInteraction('view');
await execute(interaction);
expect(interaction.reply).toHaveBeenCalledWith(
expect.objectContaining({
content: expect.stringContaining('not enabled'),
ephemeral: true,
}),
);
expect(interaction.deferReply).not.toHaveBeenCalled();
});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. consider adding test case for when Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! Prompt To Fix With AIThis is a comment left during a code review.
Path: tests/commands/help.test.js
Line: 13
Comment:
consider adding test case for when `help.enabled` is false to verify the gate check works
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise. |
||
| })); | ||
BillChirico marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| vi.mock('../../src/utils/permissions.js', () => ({ | ||
| isModerator: vi.fn().mockReturnValue(true), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Warning: New config sections not documented in README.md
Per AGENTS.md: "Document new config sections and keys in
README.md's config reference when updatingconfig.json."The
help,announce,snippet,poll, andtldrsections need entries in the README config reference. Each needs at minimum theenabledboolean documented, andtldralso needsdefaultMessages,maxMessages, andcooldownSeconds.🔵 Nitpick: Missing trailing newline — File doesn't end with a newline character.