Bot refuses to send messages because of missing access.

Stack trace:
DiscordAPIError[50001]: Missing Access
at handleErrors (/home/jake/finnbot/node_modules/@discordjs/rest/dist/index.js:730:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (/home/jake/finnbot/node_modules/@discordjs/rest/dist/index.js:1133:23)
at async SequentialHandler.queueRequest (/home/jake/finnbot/node_modules/@discordjs/rest/dist/index.js:963:14)
at async _REST.request (/home/jake/finnbot/node_modules/@discordjs/rest/dist/index.js:1278:22)
at async TextChannel.send (/home/jake/finnbot/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:177:15)
at async publishRules (/home/jake/finnbot/src/commands/admin/rule.js:113:2)
at async Object.execute (/home/jake/finnbot/src/commands/admin/rule.js:220:5)
at async Object.execute (/home/jake/finnbot/src/events/interactionCreate.js:47:5) {
requestBody: {
files: [ [Object] ],
json: {
content: undefined,
tts: false,
nonce: undefined,
enforce_nonce: false,
embeds: [Array],
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: [Array],
sticker_ids: undefined,
thread_name: undefined,
applied_tags: undefined,
poll: undefined
}
},
rawError: { message: 'Missing Access', code: 50001 },
code: 50001,
status: 403,
method: 'POST',
url: 'https://discord.com/api/v10/channels/1267120761483821057/messages'
}
DiscordAPIError[50001]: Missing Access
at handleErrors (/home/jake/finnbot/node_modules/@discordjs/rest/dist/index.js:730:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (/home/jake/finnbot/node_modules/@discordjs/rest/dist/index.js:1133:23)
at async SequentialHandler.queueRequest (/home/jake/finnbot/node_modules/@discordjs/rest/dist/index.js:963:14)
at async _REST.request (/home/jake/finnbot/node_modules/@discordjs/rest/dist/index.js:1278:22)
at async TextChannel.send (/home/jake/finnbot/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:177:15)
at async publishRules (/home/jake/finnbot/src/commands/admin/rule.js:113:2)
at async Object.execute (/home/jake/finnbot/src/commands/admin/rule.js:220:5)
at async Object.execute (/home/jake/finnbot/src/events/interactionCreate.js:47:5) {
requestBody: {
files: [ [Object] ],
json: {
content: undefined,
tts: false,
nonce: undefined,
enforce_nonce: false,
embeds: [Array],
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: [Array],
sticker_ids: undefined,
thread_name: undefined,
applied_tags: undefined,
poll: undefined
}
},
rawError: { message: 'Missing Access', code: 50001 },
code: 50001,
status: 403,
method: 'POST',
url: 'https://discord.com/api/v10/channels/1267120761483821057/messages'
}
12 Replies
d.js toolkit
d.js toolkit4mo 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! - Marked as resolved by staff
Jake
JakeOP4mo ago
Code
sync function publishRules(interaction) {
await interaction.deferReply();
const files = {
config: path.join(process.env.APP_ROOT, 'data/config.yml'),
header: path.join(process.env.APP_ROOT, 'img/rules.png'),
}

const configFile = yaml.load(fs.readFileSync(files.config));
const ruleChannelID = configFile.rules.channelID;
const channel = interaction.client.channels.cache.find(channel => channel.id == ruleChannelID);

const rules = await ServerRule.findAll();
const embeds = rules.map(rule => {
return new EmbedBuilder()
.setTitle(`Rule ${rule.id}. - ${rule.title}`)
.setColor(Colour.PINK)
.setDescription(rule.description)
});

const sliceSize = 5;
await channel.send({
files: [{ attachment: files.header, }],
embeds: embeds.slice(0, sliceSize),
});

for (let i = sliceSize; i < embeds.length; i += sliceSize) {
await channel.send({ embeds: embeds.slice(i, i + sliceSize) });
}

await channel.send(`These rules are effective from ${new Date().toLocaleDateString('en-us')}.`)

await interaction.editReply('Replies have been published in the rules channel. You should delete the old rules.');
}
sync function publishRules(interaction) {
await interaction.deferReply();
const files = {
config: path.join(process.env.APP_ROOT, 'data/config.yml'),
header: path.join(process.env.APP_ROOT, 'img/rules.png'),
}

const configFile = yaml.load(fs.readFileSync(files.config));
const ruleChannelID = configFile.rules.channelID;
const channel = interaction.client.channels.cache.find(channel => channel.id == ruleChannelID);

const rules = await ServerRule.findAll();
const embeds = rules.map(rule => {
return new EmbedBuilder()
.setTitle(`Rule ${rule.id}. - ${rule.title}`)
.setColor(Colour.PINK)
.setDescription(rule.description)
});

const sliceSize = 5;
await channel.send({
files: [{ attachment: files.header, }],
embeds: embeds.slice(0, sliceSize),
});

for (let i = sliceSize; i < embeds.length; i += sliceSize) {
await channel.send({ embeds: embeds.slice(i, i + sliceSize) });
}

await channel.send(`These rules are effective from ${new Date().toLocaleDateString('en-us')}.`)

await interaction.editReply('Replies have been published in the rules channel. You should delete the old rules.');
}
Bot has application.commands and bot scopes and has permission to send messages.
Jake
JakeOP4mo ago
No description
d.js docs
d.js docs4mo ago
:guide: Popular Topics: Permissions (extended) - Implicit permissions Causes for "Missing Access": read more
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Jake
JakeOP4mo ago
It's fixed anyway now. Apparently needed to set explicit permission for the bot in the channel despite it having implied 'full' access to the channel.
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Jake
JakeOP4mo ago
Yeah I can only assume it was because this was set to / instead of ✓
No description
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Jake
JakeOP4mo ago
That stack trace is confusing as hell lol. But yeah all sorted now. Thanks.
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
d.js docs
d.js docs4mo ago
:guide: Popular Topics: Permissions (extended) - Implicit permissions Causes for "Missing Access": read more
Want results from more Discord servers?
Add your server