Arguments Issue

. So looks like inside the if the user is null because sapphire is taking it like the third argument I think, how can I fix this?
13 Replies
Favna
Favna•16mo ago
Please share the full command code as well as the command message used
-Carlos👑
-Carlos👑OP•16mo ago
that's the full code, the things I didn't show are stuff like the command name, description, aliases, etc wdym command message
Ben
Ben•16mo ago
It looks like you are picking the first argument as a user, then later picking the second argument as a member. My guess is you should pick a member first and then use args.rest to get the reson. That sould give you a command stucture like prefix command targetedMember reason with spaces
-Carlos👑
-Carlos👑OP•16mo ago
wdym pick a member first
Ben
Ben•16mo ago
Use args.pick("member") right after your args.finished check and use the result of that for determining if they have manageMessages privileges in the perms check
-Carlos👑
-Carlos👑OP•16mo ago
now the if(!user) will always get returned since im currently testing with a guildmember
Favna
Favna•16mo ago
!command arg1 arg2 arg3 thing, what you sent in Discord
Ben
Ben•16mo ago
Are you trying to make it so you can ban someone who's not in the guild?
-Carlos👑
-Carlos👑OP•16mo ago
>b userid testing ban command yes this code should detect if the user that is getting banned is in the guild, if it is, it will check his permissions
Ben
Ben•16mo ago
ah I didn't realize that. In that case, keep it as picking a user at the top and then in the perms check, instead of picking a member, you should fetch the member from the guild's members cache. Whenever you call args.pick it advances to read the next argument. Since your calling it twice, its expecting you to have specified the same user twice, once as a user, and again as a member.
-Carlos👑
-Carlos👑OP•16mo ago
yeah I think that worked, gonna test a little bit more looks like it worked, ty
Favna
Favna•16mo ago
@_carlos123 FWIW I was under the impression there would be more code above the args.finished because I didnt think that would be at the top ergo my initial question
-Carlos👑
-Carlos👑OP•16mo ago
oh alright
Want results from more Discord servers?
Add your server