Ferklen
Ferklen
DIAdiscord.js - Imagine an app
Created by Ferklen on 9/10/2023 in #djs-questions
add role
hi so ive been trying a lot to make this work but it just wont
if (command === "addrole") {
if (!message.member.permissions.has(PermissionsBitField.Flags.ManageRoles)) {
return message.channel.send('no perms')
}
if (!message.guild.members.me.permissionsIn(message.channel).has(PermissionsBitField.Flags.ManageRoles)) {
return message.channel.send('no perms')
}
if (!args[0]) return message.channel.send("error reply")
let nombrea = args[0]
let user = message.mentions.users.first() || client.users.cache.get(args[0]) || client.users.cache.find(user => user.username === nombrea)
let role = message.mentions.roles.first() || message.guild.roles.cache.find(r => r.id == args[1])
if (!user) return message.channel.send("errpr reply")
if (!args[1]) return message.channel.send("error reply")
if (!role) return message.channel.send("error reply")
if (!role.editable) return message.channel.send("error reply")
// if (user.roles.cache.has(role.id)) return message.channel.send("reply")

if (role.comparePositionTo(message.member.roles.highest) >= 0) return message.channel.send("No puedes añadir un rol igual o superior al tuyo!")
// if (message.member.roles.highest.comparePositionTo(user.roles.highest) <= 0) return message.channel.send("reply")
try {
user.roles.add(role)
} catch (error){
console.log(error)
console.log(user)
console.log(role)
return message.channel.send('error reply')
}
return message.channel.send(`reply`)
}
if (command === "addrole") {
if (!message.member.permissions.has(PermissionsBitField.Flags.ManageRoles)) {
return message.channel.send('no perms')
}
if (!message.guild.members.me.permissionsIn(message.channel).has(PermissionsBitField.Flags.ManageRoles)) {
return message.channel.send('no perms')
}
if (!args[0]) return message.channel.send("error reply")
let nombrea = args[0]
let user = message.mentions.users.first() || client.users.cache.get(args[0]) || client.users.cache.find(user => user.username === nombrea)
let role = message.mentions.roles.first() || message.guild.roles.cache.find(r => r.id == args[1])
if (!user) return message.channel.send("errpr reply")
if (!args[1]) return message.channel.send("error reply")
if (!role) return message.channel.send("error reply")
if (!role.editable) return message.channel.send("error reply")
// if (user.roles.cache.has(role.id)) return message.channel.send("reply")

if (role.comparePositionTo(message.member.roles.highest) >= 0) return message.channel.send("No puedes añadir un rol igual o superior al tuyo!")
// if (message.member.roles.highest.comparePositionTo(user.roles.highest) <= 0) return message.channel.send("reply")
try {
user.roles.add(role)
} catch (error){
console.log(error)
console.log(user)
console.log(role)
return message.channel.send('error reply')
}
return message.channel.send(`reply`)
}
im updating my code from v12.3.1 to 14.13.0 and im trying to update this code but there are 3 errors first one, on the first // there is an error with the 'has' second one, on the second //there is an error with 'highest' and finally, on user.roles.add(role) there is always the error 'cannot read properties of undefined reading 'add'' and all of the console.log give me a real role and a real member, also im testing on a test server so i have perms, the bot has perms, the user is below the bot, the role is below the bot role idk what to do
17 replies
DIAdiscord.js - Imagine an app
Created by Ferklen on 9/7/2023 in #djs-questions
bot perms
anyone knows why is this not working? i don't have a handler, its on the start of the code right above the commands
if(!message.guild.me.permissions.has(PermissionsBitField.Flags.EmbedLinks)) return message.channel.send("reply")
if(!message.guild.me.permissions.has(PermissionsBitField.Flags.EmbedLinks)) return message.channel.send("reply")
i have this in client "PermissionsBitField" and other regular perms in commands work, for example
if (!message.member.permissions.has(PermissionsBitField.Flags.ManageMessages)) return message.channel.send('reply')
if (!message.member.permissions.has(PermissionsBitField.Flags.ManageMessages)) return message.channel.send('reply')
this works, and thats why i can't understand why the first line isn't working, they are in the same file and everything the exact error is TypeError: Cannot read properties of undefined (reading 'permissions')
12 replies
DIAdiscord.js - Imagine an app
Created by Ferklen on 9/3/2023 in #djs-questions
channel filter
so im updating to v14.13.0 and im having problem with the serverinfo command i had this
(`:speech_balloon: Channels (${server.channels.cache.size})`, `Categories: ${server.channels.cache.filter(x => x.type === "category").size} | Text: ${server.channels.cache.filter(x => x.type === "text").size} | Voice: ${server.channels.cache.filter(x => x.type === "voice").size}`, true)
(`:speech_balloon: Channels (${server.channels.cache.size})`, `Categories: ${server.channels.cache.filter(x => x.type === "category").size} | Text: ${server.channels.cache.filter(x => x.type === "text").size} | Voice: ${server.channels.cache.filter(x => x.type === "voice").size}`, true)
and it worked, but now that i updated i made this
const categories = channels.filter(x => x.type === "category").size
const text = channels.filter(x => x.type === "text").size
const voice = channels.filter(x => x.type === "voice").size
console.log(categories, text, voice)
const categories = channels.filter(x => x.type === "category").size
const text = channels.filter(x => x.type === "text").size
const voice = channels.filter(x => x.type === "voice").size
console.log(categories, text, voice)
and everything gives me '0' but
server.channels.cache.size
server.channels.cache.size
the total channel count works, its the channel filters that aint working
6 replies
DIAdiscord.js - Imagine an app
Created by Ferklen on 8/29/2023 in #djs-questions
timeout perms
im trying to make a timeout command but idk what perms are required if (!message.member.permissions.has('TIMEOUT_MEMBERS')) doesn't exist, as i made a role with the permission to timeout members, then i used roleinfo and it says the role has no perms like if it didn't exist
8 replies