I want my bot to be able to check...
- If a channel my bot made matches a certain name... OR
- If a role my bot made matches a certain name...
THEN
The bot would return the action with the message Mod mail is already activated here!
Here's my code
var mg = message.guild
const mythings = mg.channels.filter(chane => chane.client.user.id === `595840576386236437` && chane.name === 'modmail' &&chane.type === `text`);
const mythings2 = mg.channels.filter(chane => chane.client.user.id === `595840576386236437` && chane.name === 'qanda' &&chane.type === `text`);
const mythings3 = mg.roles.filter(role => role.client.user.id === `595840576386236437` && role.name === 'ModMail');
console.log(mythings)
if(mythings) return message.channel.send(`Rejected! There's possible fragments of modmail already set up here!`)
if(mythings2) return message.channel.send(`Rejected! There's possible fragments of modmail already set up here!`)
if(!mythings3) return message.channel.send(`Rejected! There's possible fragments of modmail already set up here!`)
NOTE
I am doing in this in discord.js-commando, not discord.js so this is not in my index.js file so my only limitation is I can't refer to the client variable. Directory is ~/commands/extras/modmail.js/ instead of ~/index.js/ What I mean by this is I cannot start with the client
variable because it will return to me as undefined, but something like channel.client
would be allowed because it's defining the creator of the channel the messgae was sent in.
What went wrong
Here's what went wrong.
- Bot doesn't find the channel channel
- Bot returns
OR
- Bot finds channel
- Bot continues to make all the channels and roles.
I expect: Bot can search the guild for a channel that meets client.id AND name expectations and then return. Also, Bot can search the guild for a role that meets the owner (my(Referring to me being the bot)) id AND name and then return also.
The actual result is the bot returning when it's not supposed to, e.g. Bot returns when it doesn't find a channel when it is supposed to create one. (I cut out the code for it though)
client
in the code snippet? – slothifulbot.login
and other actions the bot does in theindex.js
file. It means that I can't start withclient
because it is undefined butchane.client
isn't. – SomePerson