diff --git a/apps/bot/src/DeployCommands.mjs b/apps/bot/src/DeployCommands.mjs index 1e93168..76ef212 100644 --- a/apps/bot/src/DeployCommands.mjs +++ b/apps/bot/src/DeployCommands.mjs @@ -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."); @@ -90,6 +88,5 @@ export { guildCommand , commands , rest , - applicationGuildCommands , } /* Not a pure module */ diff --git a/apps/bot/src/DeployCommands.res b/apps/bot/src/DeployCommands.res index e69425b..a770159 100644 --- a/apps/bot/src/DeployCommands.res +++ b/apps/bot/src/DeployCommands.res @@ -8,12 +8,17 @@ module Rest = { @send external setToken: (t, string) => t = "setToken" @send external put: (t, string, {"body": array}) => Js.Promise.t = "put" + @send + external delete: (t, string) => Js.Promise.t = "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() @@ -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 { @@ -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