issue with finding a role

I haven't worked on this bot in a long time as well as forgot how to code a little bit and having issue with finding a role that has already been created in the server. ERROR:
Cannot read properties of undefined (reading 'roles')
Cannot read properties of undefined (reading 'roles')
CODE:
const supportRole = this.guild.roles.cache.find(r => r.name === "Ticket Support");
const supportRole = this.guild.roles.cache.find(r => r.name === "Ticket Support");
any help would be really appreciated
6 Replies
d.js toolkit
d.js toolkit13mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Danial
Danial13mo ago
What is this? It doesn't have a guild property
j
jOP13mo ago
its basically defining the guild without its id
Danial
Danial13mo ago
Can you show more code
j
jOP13mo ago
/**
* The guild's ticket category and support role
* @typedef {Object} BaseObjects
* @property {CategoryChannel} ticketCategory
* @property {Role} supportRole
* @property {Role} botRole The role managed by the bot
*/
/**
* Gets the guild's ticketing system categories and roles
* @param {boolean} [force] Whether the channel and role managers should be force fetched. Defaults to true.
* @returns {Promise<BaseObjects>}
*/

const supportRole = this.guild.roles.cache.find(r => r.name === "Ticket Support");

await channel.send({
content: `${supportRole}`,
embeds: [embed],
components: [actionRow],
});
/**
* The guild's ticket category and support role
* @typedef {Object} BaseObjects
* @property {CategoryChannel} ticketCategory
* @property {Role} supportRole
* @property {Role} botRole The role managed by the bot
*/
/**
* Gets the guild's ticketing system categories and roles
* @param {boolean} [force] Whether the channel and role managers should be force fetched. Defaults to true.
* @returns {Promise<BaseObjects>}
*/

const supportRole = this.guild.roles.cache.find(r => r.name === "Ticket Support");

await channel.send({
content: `${supportRole}`,
embeds: [embed],
components: [actionRow],
});
Danial
Danial13mo ago
That doesn't really help me help you, of what type is this?
Want results from more Discord servers?
Add your server