Created
December 25, 2022 04:16
-
-
Save antishok/bf9fc110acde454f8849b7d4804c3f70 to your computer and use it in GitHub Desktop.
discord command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { ContextMenuCommandBuilder } = require('@discordjs/builders'); | |
const { REST } = require('@discordjs/rest'); | |
const { Routes, ApplicationCommandType } = require('discord-api-types/v9'); | |
const config = require('./config/local.json'); | |
const commands = [ | |
new ContextMenuCommandBuilder() | |
.setName('Is user online?') | |
.setType(ApplicationCommandType.Message), | |
] | |
.map(command => command.toJSON()); | |
const rest = new REST({ version: '9' }).setToken(config.discord.token); | |
rest.put(Routes.applicationGuildCommands(config.discord.botId, config.discord.guildId), { body: commands }) | |
.then(() => console.log('Successfully registered application commands.')) | |
.catch(console.error); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (interaction.targetType === 'MESSAGE' && interaction.commandName === 'Is user online?') { | |
console.log('INTERACTION user:', interaction.options?._hoistedOptions?.[0]?.message?.author); | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment