Application Command Permission Update Event

I am trying to get the type of permission in the data of the event. Example: data.permissions.type This is returning as undefined when I update a app command's user/roles/channel permissions If you are confused, look at the type / ApplicationCommandPermissionType in the link below https://old.discordjs.dev/#/docs/discord.js/main/typedef/ApplicationCommandPermissions
4 Replies
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
PAdventures
PAdventuresOP2y ago
const { EmbedBuilder, Events } = require('discord.js');
require('dotenv').config();
const logsSchema = require('../../Models/Logs')

module.exports = {
name: Events.ApplicationCommandPermissionsUpdate,
on: true,
async execute(data, client){
//stuff here
function permissionType(number) {
--> console.log(data.permissions.type);
--> console.log(number);
const { EmbedBuilder, Events } = require('discord.js');
require('dotenv').config();
const logsSchema = require('../../Models/Logs')

module.exports = {
name: Events.ApplicationCommandPermissionsUpdate,
on: true,
async execute(data, client){
//stuff here
function permissionType(number) {
--> console.log(data.permissions.type);
--> console.log(number);
This is the code in the event file
console.log(data.permissions.type);
console.log(number);
console.log(data.permissions.type);
console.log(number);
Output
undefined
undefined
undefined
undefined
Number is coming from the following
.addFields(
{
name: "Permissions",
value: `${permissionType(data.permissions.type)}`
}
)
.addFields(
{
name: "Permissions",
value: `${permissionType(data.permissions.type)}`
}
)
same problem occurs when using data.permissions.permission when console.log(data.permissions) output is [ { type: 1, permission: true, id: '1047775679573409812' } ]
probablyraging
data.permissions returns an array of objects. You want to access the type property of the first object in the array
data.permissions[0].type
data.permissions[0].type
PAdventures
PAdventuresOP2y ago
ok, ill try this this works thank you. I just can't seem to understand arrays, ill look into them understood
Want results from more Discord servers?
Add your server