#rest permissions

1 messages · Page 1 of 1 (latest)

warm lark
#

no, you need to make a second put request to that route

broken gazelle
#

Right, but how do i select the commands that are put in via adminCommands array/

warm lark
#

the first request returns RESTPutAPIApplicationGuildCommandsResult

#

type from discord-api-types btw

broken gazelle
#

So this wouldnt work?

warm lark
#

no, Routes.guildApplicationCommandsPermissions is a route builder, same as Routes.applicationGuildCommands

#

you need to call it with your application id and guild id

broken gazelle
#

Ok so how do I make it affect only adminCommands?

warm lark
#

by putting something of type RESTPutAPIGuildApplicationCommandsPermissionsJSONBody to this route

broken gazelle
#

hmm...

#

so if the first one was assigned to aCommands var, I could then do aCommands.applicationGuildCommandsPermissions?

warm lark
#

no, aCommands will be an object

broken gazelle
#

hmm

warm lark
#

using rest you work with the "raw" discord API

#

^ and you want to do this request

broken gazelle
#

right... but how am I to get the ID of the commands from this?

warm lark
#

that would be from "aCommands" in your example

broken gazelle
#

Right

#

via a for each?

warm lark
#

yeah, for each works

broken gazelle
#

ok let me quickly script something

#

How do I select the command?

warm lark
warm lark
#

your request body will look similar but with number types instead of "USER"

broken gazelle
#

I have this, how do I do it?

warm lark
#

how did you define permissions?

broken gazelle
warm lark
#

it needs to be an array of { id, permissions }

broken gazelle
#

That’s the issue… can I just put permissions into the array per command?

warm lark
#

all of those will have the same permissions, right?

broken gazelle
#

Yes

warm lark
#

if so, you can simply map aCommands to the above objects

broken gazelle
#

Yeah… ok

#

Wait how?

#

I found this...

earnest streamBOT
#

<:_:818272565419573308> Array.prototype.map()
The map() method creates a new array populated with the results of calling a provided function on every element in the calling array.

broken gazelle
#

Or this?

#

I am not sure I did this right...

#

@warm lark

#

Would this work?

#

why am I doing this... only admin commands are listed as guild... I could literally just pull all guild commands and set the permissions...

#

This should work better right @warm lark?