-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathcommands.ts
152 lines (138 loc) · 4.29 KB
/
commands.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import type {
RESTGetAPIApplicationCommandResult,
RESTGetAPIApplicationCommandsResult,
RESTGetAPIApplicationGuildCommandResult,
RESTGetAPIApplicationGuildCommandsResult,
RESTPatchAPIApplicationCommandJSONBody,
RESTPatchAPIApplicationCommandResult,
RESTPatchAPIApplicationGuildCommandJSONBody,
RESTPatchAPIApplicationGuildCommandResult,
RESTPostAPIApplicationCommandsJSONBody,
RESTPostAPIApplicationCommandsResult,
RESTPostAPIApplicationGuildCommandsJSONBody,
RESTPostAPIApplicationGuildCommandsResult,
RESTPutAPIApplicationCommandsJSONBody,
RESTPutAPIApplicationCommandsResult,
RESTPutAPIApplicationGuildCommandsJSONBody,
RESTPutAPIApplicationGuildCommandsResult,
} from "discord-api-types/v10";
import { Routes } from "discord-api-types/v10";
import type { Snowflake } from "discord-snowflake";
import { client } from "../client";
/**
* Global Commands
*/
// TODO: Test, Document
export async function getGlobalApplicationCommands(applicationId: Snowflake) {
return client.get(
Routes.applicationCommands(applicationId)
) as Promise<RESTGetAPIApplicationCommandsResult>;
}
// TODO: Test, Document
export async function createGlobalApplicationCommand(
applicationId: Snowflake,
command: RESTPostAPIApplicationCommandsJSONBody
) {
return client.post(Routes.applicationCommands(applicationId), {
body: command,
}) as Promise<RESTPostAPIApplicationCommandsResult>;
}
// TODO: Test, Document
export async function getGlobalApplicationCommand(
applicationId: Snowflake,
commandId: Snowflake
) {
return client.get(
Routes.applicationCommand(applicationId, commandId)
) as Promise<RESTGetAPIApplicationCommandResult>;
}
// TODO: Test, Document
export async function editGlobalApplicationCommand(
applicationId: Snowflake,
command: RESTPatchAPIApplicationCommandJSONBody & { id: Snowflake }
) {
return client.patch(Routes.applicationCommand(applicationId, command.id), {
body: command,
}) as Promise<RESTPatchAPIApplicationCommandResult>;
}
// TODO: Test, Document
export async function deleteGlobalApplicationCommand(
applicationId: Snowflake,
commandId: Snowflake
) {
return client.delete(Routes.applicationCommand(applicationId, commandId));
}
// TODO: Test, Document
export async function bulkOverwriteGlobalApplicationCommands(
applicationId: Snowflake,
commands: RESTPutAPIApplicationCommandsJSONBody
) {
return client.put(Routes.applicationCommands(applicationId), {
body: commands,
}) as Promise<RESTPutAPIApplicationCommandsResult>;
}
/**
* Guild Commands
*/
// TODO: Test, Document
export async function getGuildApplicationCommands(
applicationId: Snowflake,
guildId: Snowflake
) {
return client.get(
Routes.applicationGuildCommands(applicationId, guildId)
) as Promise<RESTGetAPIApplicationGuildCommandsResult>;
}
// TODO: Test, Document
export async function createGuildApplicationCommand(
applicationId: Snowflake,
guildId: Snowflake,
command: RESTPostAPIApplicationGuildCommandsJSONBody
) {
return client.post(Routes.applicationGuildCommands(applicationId, guildId), {
body: command,
}) as Promise<RESTPostAPIApplicationGuildCommandsResult>;
}
// TODO: Test, Document
export async function getGuildApplicationCommand(
applicationId: Snowflake,
guildId: Snowflake,
commandId: Snowflake
) {
return client.get(
Routes.applicationGuildCommand(applicationId, guildId, commandId)
) as Promise<RESTGetAPIApplicationGuildCommandResult>;
}
// TODO: Test, Document
export async function editGuildApplicationCommands(
applicationId: Snowflake,
guildId: Snowflake,
commands: RESTPutAPIApplicationGuildCommandsJSONBody
) {
return client.put(Routes.applicationGuildCommands(applicationId, guildId), {
body: commands,
}) as Promise<RESTPutAPIApplicationGuildCommandsResult>;
}
// TODO: Test, Document
export async function deleteGuildApplicationCommand(
applicationId: Snowflake,
guildId: Snowflake,
commandId: Snowflake
) {
return client.delete(
Routes.applicationGuildCommand(applicationId, guildId, commandId)
);
}
// TODO: Test, Document
export async function bulkOverwriteGuildApplicationCommand(
applicationId: Snowflake,
guildId: Snowflake,
command: RESTPatchAPIApplicationGuildCommandJSONBody & { id: Snowflake }
) {
return client.patch(
Routes.applicationGuildCommand(applicationId, guildId, command.id),
{
body: command,
}
) as Promise<RESTPatchAPIApplicationGuildCommandResult>;
}