Skip to content

Commit

Permalink
Delete Role Command
Browse files Browse the repository at this point in the history
  • Loading branch information
youngkidwarrior committed Aug 20, 2022
1 parent a8ceffc commit ca0970c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
5 changes: 1 addition & 4 deletions apps/bot/src/DeployCommands.mjs
Expand Up @@ -55,9 +55,7 @@ var rest = new Rest.REST({
version: 9
}).setToken(token);

var applicationGuildCommands = V9.Routes.applicationCommands(clientId);

$$Promise.$$catch(rest.put(applicationGuildCommands, {
$$Promise.$$catch(rest.put(V9.Routes.applicationCommands(clientId), {
body: commands
}).then(function (param) {
console.log("Successfully registered application commands.");
Expand Down Expand Up @@ -90,6 +88,5 @@ export {
guildCommand ,
commands ,
rest ,
applicationGuildCommands ,
}
/* Not a pure module */
21 changes: 18 additions & 3 deletions apps/bot/src/DeployCommands.res
Expand Up @@ -8,12 +8,17 @@ module Rest = {
@send external setToken: (t, string) => t = "setToken"
@send
external put: (t, string, {"body": array<SlashCommandBuilder.json>}) => Js.Promise.t<unit> = "put"
@send
external delete: (t, string) => Js.Promise.t<unit> = "delete"
}

module Routes = {
type t
@module("discord-api-types/v9") @scope("Routes")
external applicationCommands: (~clientId: string) => string = "applicationCommands"
@module("discord-api-types/v9") @scope("Routes")
external applicationCommand: (~clientId: string, ~commandId: string) => string =
"applicationCommand"
}

Env.createEnv()
Expand All @@ -37,10 +42,8 @@ let commands = [helpCommand, verifyCommand, inviteCommand, guildCommand]

let rest = Rest.make({"version": 9})->Rest.setToken(token)

let applicationGuildCommands = Routes.applicationCommands(~clientId)

rest
->Rest.put(applicationGuildCommands, {"body": commands})
->Rest.put(Routes.applicationCommands(~clientId), {"body": commands})
->thenResolve(() => Js.log("Successfully registered application commands."))
->catch(e => {
switch e {
Expand All @@ -55,3 +58,15 @@ rest
resolve()
})
->ignore

// delete role command
// rest
// ->Rest.delete(Routes.applicationCommand(~clientId, ~commandId="1010421714498359306"))
// ->then(_ => {
// Js.log("Successfully deleted role command.")->resolve
// })
// ->catch(e => {
// Js.log(e)
// resolve()
// })
// ->ignore

0 comments on commit ca0970c

Please sign in to comment.