.setNickname returning Missing Privileges error

Hey there, I'm writing a simply change nickname command and for some reason, I'm getting an error of Missing Permissions. Now I have my bot set as an Administrator, it's role above everyone else. And the account I'm running the command on is a test account with no special permissions or roles. The test account is below the bot in hierarchy. Yet I'm still getting this error. And I just too tired to see the error I've made? Steps I've taken to resolve the issue: * Test account has no roles * Bot role hierarchy is top most * Bot has Administrator privileges * Confirmed member object is being returned correctly * Confirmed all Intents required are added Command code
const { EmbedBuilder, SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('nickname')
.setDescription('Change your name')
.addStringOption(option =>
option.setName('name')
.setDescription('Enter your new nickname')
.setRequired(true)),
async execute(client,interaction) {
const name = interaction.options.getString('name');
const userid = interaction.user.id;

const guild = client.guilds.cache.get(`${process.env.guildID}`);
await guild.members.fetch(`${userid}`).then(async member => {
return member.setNickname(`${name}`).catch(async err => {
return console.log(err);
});
}).catch(async err => {
return console.log(err);
});
},
};
const { EmbedBuilder, SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('nickname')
.setDescription('Change your name')
.addStringOption(option =>
option.setName('name')
.setDescription('Enter your new nickname')
.setRequired(true)),
async execute(client,interaction) {
const name = interaction.options.getString('name');
const userid = interaction.user.id;

const guild = client.guilds.cache.get(`${process.env.guildID}`);
await guild.members.fetch(`${userid}`).then(async member => {
return member.setNickname(`${name}`).catch(async err => {
return console.log(err);
});
}).catch(async err => {
return console.log(err);
});
},
};
Have all my intents in place
const { Client, Collection, GatewayIntentBits, Partials } = require('discord.js');
const client = new Client({ intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildIntegrations,
GatewayIntentBits.GuildBans,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.DirectMessageReactions,
GatewayIntentBits.MessageContent,
], partials: [
Partials.Message,
Partials.Channel,
Partials.Reaction
] });
const { Client, Collection, GatewayIntentBits, Partials } = require('discord.js');
const client = new Client({ intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildIntegrations,
GatewayIntentBits.GuildBans,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.DirectMessageReactions,
GatewayIntentBits.MessageContent,
], partials: [
Partials.Message,
Partials.Channel,
Partials.Reaction
] });
I'm pretty sure the issue is just me being blind, but I am at a loss right now as to why it's erroring out.
2 Replies
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Gravvy
GravvyOP2y ago
Yes I use it from the test account, also the test account is not the server owner. Forgot to include that. Will give that a shot. Had to go into work so it'll be a bit. Found the issue, turns out it was me that was blind. I was attempting to call process.env.guildID but I forgot I was storing the guildid elsewhere.
Want results from more Discord servers?
Add your server