10 examples of 'discord js commands' in JavaScript

Every line of 'discord js commands' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
31async commando (message, [query]) {
32 await this.search(message, query, 'commando')
33}
9async run(client, message, args) {
10 try{
11 let info = client.emojis.get("655091815401127966") || "ℹ️"
12 let tierEmbed = new RichEmbed()
13 .setTitle(`${info} Info`)
14 .setDescription(`**Xenon Pro** and **Xenon Turbo** are the **paid versions** of Xenon. They extend the existing features of Xenon and add new ones.
15You can buy them [here](https://www.patreon.com/merlinfuchs) and find **more information** and a **detailed list of perks** [here](https://docs.discord.club/xenon/tiers)`)
16 .setColor("#5DBCD2")
17 message.channel.send(tierEmbed)
18 }catch(e) {
19 throw e;
20 }
21 }
23async main (message, [query, branch = 'stable']) {
24 await this.search(message, query, 'main', branch)
25}
8botEmbed(message, bot) {
9 const embed = new RichEmbed({ color: 0xF87000 })
10 .setFooter(bot.user.tag, bot.user.displayAvatarURL);
11 return message ? embed.setAuthor(message.author.tag, message.author.displayAvatarURL) : embed;
12}
81onCommand(sender, message, args) {
82 return app.database.getGuild(app.getGuildIdFrom(message)).then(transformer => {
83 let channel = transformer.getChannel(message.channel.id);
84 let fields = [];
85
86 for (let setting in this.channelSettings) {
87 let channelSetting = this.channelSettings[setting];
88 let value = channel.get(setting).enabled ? 'Enabled' : 'Disabled';
89
90 if (channelSetting.hasOwnProperty('format')) {
91 value = channelSetting.format(channel.get(setting));
92 }
93
94 fields.push({name: channelSetting.name, inline: true, value});
95 }
96
97 return app.envoyer.sendEmbededMessage(message, {
98 title: `#${message.channel.name} (${message.channel.id})`,
99 color: 0x3498DB, fields
100 });
101 });
102}
21run(msg) {
22 const langSet = msg.client.provider.getGuild(msg.guild.id, 'language');
23 const lang = require(`../../languages/${langSet}.json`);
24
25 const eventslist = ['Modlog', 'Messagedelete', 'Messageupdate', 'Channelupdate', 'Channelcreate', 'Channeldelete', 'Memberupdate', 'Presenceupdate', 'Rolecreate', 'Roledelete', 'Roleupdate', 'Userjoin', 'Userleft', 'Guildupdate', 'Chatfilter'];
26
27 const embed = new Discord.MessageEmbed()
28 .setColor('0066CC')
29 .setAuthor(lang.listevents_embed);
30
31 for (let i = 0; i < eventslist.length; i++) {
32 const x = eventslist[i].toLowerCase();
33 embed.addField(eventslist[i], lang[`listevents_${x}`]);
34 }
35
36 msg.channel.send({ embed });
37}
20async run(msg) {
21 const langSet = msg.client.provider.getGuild(msg.guild.id, 'language');
22 const lang = require(`../../languages/${langSet}.json`);
23 const args = msg.content.split(' ').slice(1);
24
25 const input = args.slice();
26 if (input.length !== 1) return msg.channel.send(lang.removechatfilter_error);
27
28 if (!msg.client.provider.getGuild(msg.guild.id, 'chatfilter')) {
29 await msg.client.provider.setGuild(msg.guild.id, 'chatfilter', {
30 chatfilter: 'false',
31 array: []
32 });
33 }
34
35 for (let i = 0; i < msg.client.provider.getGuild(msg.guild.id, 'chatfilter').array.length; i++) {
36 if (input.join(' ').toLowerCase() === msg.client.provider.getGuild(msg.guild.id, 'chatfilter').array[i]) {
37 const currentChatfilter = msg.client.provider.getGuild(msg.guild.id, 'chatfilter');
38 currentChatfilter.array.splice(i, 1);
39 await msg.client.provider.setGuild(msg.guild.id, 'chatfilter', currentChatfilter);
40
41 const removed = lang.removechatfilter_removed.replace('%input', input.join(' '));
42 msg.channel.send(removed);
43 }
44 }
45}
21async run(msg) {
22 const langSet = msg.client.provider.getGuild(msg.guild.id, 'language');
23 const lang = require(`../../languages/${langSet}.json`);
24 const args = msg.content.split(' ').slice(1);
25
26 const content = args.slice().join(' ');
27 if (!content) return msg.channel.send(lang.byemsg_noinput);
28
29 let currentByemsg = msg.client.provider.getGuild(msg.guild.id, 'byemsg');
30 currentByemsg = content;
31 await msg.client.provider.setGuild(msg.guild.id, 'byemsg', currentByemsg);
32
33 return msg.channel.send(lang.byemsg_goodbyemsgset);
34}
20async run(msg) {
21 const langSet = msg.client.provider.getGuild(msg.guild.id, 'language');
22 const lang = require(`../../languages/${langSet}.json`);
23 const args = msg.content.split(' ').slice(1);
24
25 const input = args.slice();
26
27 if (input.length !== 1) return msg.channel.send(lang.addchatfilter_error);
28
29 if (!msg.client.provider.getGuild(msg.guild.id, 'chatfilter')) {
30 await msg.client.provider.setGuild(msg.guild.id, 'chatfilter', {
31 chatfilter: 'false',
32 array: []
33 });
34 }
35
36 for (let i = 0; i < msg.client.provider.getGuild(msg.guild.id, 'chatfilter').array.length; i++) {
37 if (input.join(' ').toLowerCase() === msg.client.provider.getGuild(msg.guild.id, 'chatfilter').array[i].toLowerCase()) return msg.channel.send(lang.addchatfilter_already);
38 }
39
40 const currentChatfilter = msg.client.provider.getGuild(msg.guild.id, 'chatfilter');
41 currentChatfilter.array.push(input.join(' ').toLowerCase());
42 await msg.client.provider.setGuild(msg.guild.id, 'chatfilter', currentChatfilter);
43
44 const added = lang.addchatfilter_added.replace('%input', input.join(' '));
45 msg.channel.send(added);
46}
16async run(message) {
17 const settings = message.settings
18 const channel = message.channel
19 const embed = new RichEmbed()
20 .setAuthor(`#${channel.name}`, message.guild.iconURL)
21 .setColor(settings.embedColor)
22 .addField('Topic', `${channel.topic}`, false)
23 .addField('Position', `${channel.position}`, true)
24 .setTimestamp()
25 .setFooter(settings.embedFooter, settings.embedIcon)
26 return ({ embed }).catch(e => console.error(e))
27}

Related snippets