Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

discord.js how to use subcommands

client.on('interactionCreate', async interaction => {
	if (!interaction.isCommand()) return;

	if (interaction.commandName === 'info') {
		if (interaction.options.getSubcommand() === 'user') {
			const user = interaction.options.getUser('target');

			if (user) {
				await interaction.reply(`Username: ${user.username}
ID: ${user.id}`);
			} else {
				await interaction.reply(`Your username: ${interaction.user.username}
Your ID: ${interaction.user.id}`);
			}
		} else if (interaction.options.getSubcommand() === 'server') {
			await interaction.reply(`Server name: ${interaction.guild.name}
Total members: ${interaction.guild.memberCount}`);
		}
	}
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: setinterval break 
Javascript :: create an array of size n in javascript 
Javascript :: min of an array javascript 
Javascript :: js find in array and remove 
Javascript :: get only one value from object array javascript 
Javascript :: import bootstrap css and js file in react 
Javascript :: loop key in object 
Javascript :: react native image source local file 
Javascript :: how do i remove all vowels from a string in javascript and return the result 
Javascript :: how to make stairs in javascript 
Javascript :: javascript switch statement multiple cases 
Javascript :: how to create public folder in node js 
Javascript :: deep copy object/array 
Javascript :: select add option js 
Javascript :: vue add script tags and link tags 
Javascript :: jquery unbind event 
Javascript :: compare NaN in javascript if condititon 
Javascript :: how to see chrome sync storage and local storage 
Javascript :: jquery data attribute 
Javascript :: get buffer from file javascript 
Javascript :: get current date + 1 js 
Javascript :: get express variable 
Javascript :: ip regex javascript 
Javascript :: moment day in range 
Javascript :: how to run different node app on server different domains 
Javascript :: how to copy to clipboard in react js 
Javascript :: seconds to degrees 
Javascript :: disable formcontrol angular 
Javascript :: remove a specific element from an array 
Javascript :: async storage get item 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =