#get interaction name
64 messages · Page 1 of 1 (latest)
ContextMenuCommandInteraction#commandName
The invoked application command's name
GuildMember#ban()
Bans this guild member.
GuildMemberManager#ban()
Bans a user from the guild.
GuildBanManager#create()
Bans a user from the guild.
any of those 3 would do it
Okay
i will try it
thanks
to get the guildmember do i do targetMember or targetUser
forget it
targetMember
interaction.targetMember?
works!
thanks very much i will do the same for kick and other stuff!
ur epic @wild jay
another problem i am having that i just saw
with the permissions
i am getting TypeError: Cannot read properties of undefined (reading 'Flags')
in this line
if (!interaction.member.permissions.has(PermissionsBitField.Flags.KickMember)) {
PermissionsBitField.Flags
PermissionsBitField is undefined then
Okay
i think i might know why
i am using 14
just i think i forgot to change something in vs code
so turns out i updated incorrectly and i now updated and i get many errors like Interaction has already been acknowledged
and TypeError: command.execute is not a function
for the first one, you are replying twice
for the second one, command has no execute method.
i have these
client.on('interactionCreate', interaction => {
if (!interaction.isUserContextMenuCommand()) return;
const { username } = interaction.targetUser;
console.log(username);
if (!interaction.commandName == "Ban") {
return
}
if (!interaction.member.permissions.has(PermissionsBitField.Flags.BanMember)) {
interaction.reply({ content: 'No Permission!', ephemeral: true});
return;
}
interaction.targetMember.ban();
interaction.reply({ content: 'Done', ephemeral: true});
});
client.on('interactionCreate', interaction => {
if (!interaction.isUserContextMenuCommand()) return;
const { username } = interaction.targetUser;
console.log(username);
if (!interaction.commandName == "Kick") {
return
}
if (!interaction.member.permissions.has(PermissionsBitField.Flags.KickMember)) {
interaction.reply({ content: 'No Permission!', ephemeral: true});
return;
}
interaction.targetMember.kick();
interaction.reply({ content: 'Done', ephemeral: true});
});
is this incorrect?
Checking for things to not be equal in JavaScript:
- if (!yourVariable === yourOtherVariable) // !yourVariable is coerced to a boolean value
+ if (yourVariable !== yourOtherVariable) // checks that one is not equal to the other
• Comparison operators in JavaScript: learn more
so i just need to make it !==?
i now have this
if (!interaction.isUserContextMenuCommand()) return;
const { username } = interaction.targetUser;
console.log(username);
if (interaction.commandName !== "Ban") {
return
}
if (!interaction.member.permissions.has(PermissionsBitField.Flags.BanMember)) {
interaction.reply({ content: 'No Permission!', ephemeral: true});
return;
}
interaction.targetMember.ban();
interaction.reply({ content: 'Done', ephemeral: true});
});
client.on('interactionCreate', interaction => {
if (!interaction.isUserContextMenuCommand()) return;
const { username } = interaction.targetUser;
console.log(username);
if (interaction.commandName !== "Kick") {
return
}
if (!interaction.member.permissions.has(PermissionsBitField.Flags.KickMember)) {
interaction.reply({ content: 'No Permission!', ephemeral: true});
return;
}
interaction.targetMember.kick();
interaction.reply({ content: 'Done', ephemeral: true});
});```
still not fixed
is there a way to check if user has permission in 13v?
or i should just use 14v
and i am still getting Interaction has already been acknowledged.
i changed something its now this
if (!interaction.isUserContextMenuCommand()) return;
const { username } = interaction.targetUser;
console.log(username);
if (interaction.commandName === "Ban") {
if (!interaction.member.permissions.has(PermissionsBitField.Flags.BanMember)) {
interaction.reply({ content: 'No Permission!', ephemeral: true});
return;
}
interaction.targetMember.ban();
interaction.reply({ content: 'Done', ephemeral: true});
}
if (interaction.commandName === "Kick") {
if (!interaction.member.permissions.has(PermissionsBitField.Flags.KickMember)) {
interaction.reply({ content: 'No Permission!', ephemeral: true});
return;
}
interaction.targetMember.kick();
interaction.reply({ content: 'Done', ephemeral: true});
}
});```
you are replying twice
when am i replying twice
where in the code
all good!
fixed
and btw when the user dosent have perms he gets this error
RangeError [BitFieldInvalid]: Invalid bitfield flag or number: undefined.
lol