Skip to content

Commit

Permalink
Merge pull request #209 from TogetherCrew/delete-guildCommands-for-rn…
Browse files Browse the repository at this point in the history
…dao-and-make-question-command-public

Delete guild commands for rndao and make question command public
  • Loading branch information
Behzad-rabiei authored May 25, 2024
2 parents 894bfd8 + 3607e6c commit c89ac14
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 24 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"migrate:create": "migrate create --template-file ./src/migrations/utils/template.ts --migrations-dir=\"./src/migrations/db\"",
"migrate:up": "migrate --migrations-dir=\"./lib/migrations/db\" up",
"migrate:down": "migrate --migrations-dir=\"./lib/migrations/db\" down",
"cleanupCompletedJobs": "node ./lib/scripts/cleanupCompletedJobs.js"
"cleanupCompletedJobs": "node ./lib/scripts/cleanupCompletedJobs.js",
"deleteRnDAOGuildCommands": "node ./lib/scripts/deleteRnDAOGuildCommands.js"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -80,4 +81,4 @@
"files": [
"lib/**/*"
]
}
}
16 changes: 0 additions & 16 deletions src/commands/info/question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,6 @@ export default {
},
});
}
// RnDAO:915914985140531240 TogetherCrew-Leads: 983364577096003604 TogetherCrew-Contributors: 983364691692748832
if (
interaction.guildId === '915914985140531240' &&
!(
interaction.member?.roles.cache.has('983364577096003604') ||
interaction.member?.roles.cache.has('983364691692748832')
)
) {
return await interactionService.createInteractionResponse(interaction, {
type: 4,
data: {
content: 'You do not have the required role to use this command!',
flags: 64,
},
});
}
const serializedInteraction = interactionService.constructSerializableInteraction(interaction);
const processedInteraction = handleBigInts(serializedInteraction);
const cleanInteraction = removeCircularReferences(processedInteraction); // Pass processedInteraction here
Expand Down
28 changes: 28 additions & 0 deletions src/scripts/deleteRnDAOGuildCommands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'dotenv/config';
import { REST, Routes } from 'discord.js';
import parentLogger from '../config/logger';
import config from '../config';
const logger = parentLogger.child({ module: `deleteRnDAOGuildCommands` });

/**
* Delete RnDAO guild commands
*/
async function deleteRnDAOGuildCommands(): Promise<void> {
try {
const rest = new REST().setToken(config.discord.botToken);
const guildCommands: any = await rest.get(
// RnDAO:915914985140531240
Routes.applicationGuildCommands(config.discord.clientId, '915914985140531240'),
);
guildCommands.forEach(async (command: any) => {
await rest.delete(Routes.applicationGuildCommand(config.discord.clientId, '915914985140531240', command.id));
});
} catch (error) {
console.log(error);
logger.error('Failed to delete RnDAO guild commands', error);
}
}

deleteRnDAOGuildCommands().catch((error) => {
logger.error('Unhandled exception in deleting RnDAO guild commands', error);
});
7 changes: 1 addition & 6 deletions src/services/command.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,7 @@ async function registerCommand(): Promise<void> {
const client = await coreService.DiscordBotManager.getClient();
const rest = new REST().setToken(config.discord.botToken);
const commandData = [...client.commands.values()].map((command) => command.data.toJSON());
await rest.put(
// RnDAO: 915914985140531240
// Routes.applicationGuildCommands(config.discord.clientId, '915914985140531240'),
Routes.applicationCommands(config.discord.clientId),
{ body: commandData },
);
await rest.put(Routes.applicationCommands(config.discord.clientId), { body: commandData });
logger.info('Commands Registerd');
} catch (err) {
logger.error({ err }, 'Failed to register the slash command');
Expand Down

0 comments on commit c89ac14

Please sign in to comment.