This is the current code that I have, I would like to make it where if you have a certain role then you can bypass the cooldown, also if anyone knows how to make a command that restricts a certain command to a certain channel, instead of having this really long message.channel.id.
JavaScript
x
48
48
1
const Discord = require('discord.js');
2
const fetch = require('node-fetch');
3
const talkedRecently = new Set();
4
module.exports.run = async(client, message, args, queue, searcher, ) => {
5
6
if (talkedRecently.has(message.author.id)) {
7
message.channel.send("Wait 1 minute before getting typing this again. " +'<@'+ message.author.id + '>');
8
} else {
9
10
11
switch(args[0].toLowerCase()){
12
case 'neko':
13
if(message.channel.id === '739002385531404288'||
14
message.channel.id === '646849145289834506'||
15
message.channel.id === '785079847763574794'||
16
message.channel.id === '782891383361896469'||
17
message.channel.id === '784417039425994772'){
18
fetch('https://nekos.life/api/v2/img/lewd')
19
.then(res => res.json())
20
.then(json => {
21
let nekoEmbed = new Discord.MessageEmbed()
22
.setTitle('Lewd Nekos! (=^・ω・^=)')
23
.setImage(json.url)
24
message.channel.send(nekoEmbed)
25
26
})
27
}else{
28
return}}
29
30
talkedRecently.add(message.author.id);
31
setTimeout(() => {
32
33
talkedRecently.delete(message.author.id);
34
}, 60000);
35
}
36
37
38
39
40
}
41
42
module.exports.config = {
43
name: "hentai",
44
aliases: ['ht']
45
}
46
```
47
48
Advertisement
Answer
Answering Your First Question:
Simply check if the member has a certain role. If they do, construct your if statement so that it will not fire if they have that role
Make sure to use message.member
when checking roles
JavaScript
1
4
1
if (talkedRecently.has(message.author.id) && !message.member.roles.cache.has('bypass role id here')) {
2
// Your cooldown message
3
}
4
Learn more about Roles#has
Answering your 2nd question:
You can have an array of channel id’s then use includes
to check if any of the id’s in the array match the current channel id
JavaScript
1
6
1
const ids = ['id1', 'id2', 'id3', 'id4'] // And so on
2
3
if (ids.includes(message.channel.id)) {
4
// Your Code
5
}
6
Learn more about Array.prototype.includes