mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-19 04:38:17 +00:00
feat(handlers/guild): change createGuildChannel() to use guild ID (#528)
* guild > guildID * fix(test): createGuildChannel test * Update test/mod.test.ts * Update test/mod.test.ts * fmt Co-authored-by: ayntee <ayyantee@gmail.com>
This commit is contained in:
@@ -112,20 +112,19 @@ export function guildBannerURL(
|
|||||||
|
|
||||||
/** Create a channel in your server. Bot needs MANAGE_CHANNEL permissions in the server. */
|
/** Create a channel in your server. Bot needs MANAGE_CHANNEL permissions in the server. */
|
||||||
export async function createGuildChannel(
|
export async function createGuildChannel(
|
||||||
guild: Guild,
|
guildID: string,
|
||||||
name: string,
|
name: string,
|
||||||
options?: ChannelCreateOptions,
|
options?: ChannelCreateOptions,
|
||||||
) {
|
) {
|
||||||
const hasPerm = await botHasPermission(
|
const hasPerm = await botHasPermission(
|
||||||
guild.id,
|
guildID,
|
||||||
["MANAGE_CHANNELS"],
|
["MANAGE_CHANNELS"],
|
||||||
);
|
);
|
||||||
if (!hasPerm) {
|
if (!hasPerm) {
|
||||||
throw new Error(Errors.MISSING_MANAGE_CHANNELS);
|
throw new Error(Errors.MISSING_MANAGE_CHANNELS);
|
||||||
}
|
}
|
||||||
|
|
||||||
const result =
|
const result = (await RequestManager.post(endpoints.GUILD_CHANNELS(guildID), {
|
||||||
(await RequestManager.post(endpoints.GUILD_CHANNELS(guild.id), {
|
|
||||||
...options,
|
...options,
|
||||||
name,
|
name,
|
||||||
permission_overwrites: options?.permissionOverwrites?.map((perm) => ({
|
permission_overwrites: options?.permissionOverwrites?.map((perm) => ({
|
||||||
|
|||||||
+1
-4
@@ -138,10 +138,7 @@ Deno.test({
|
|||||||
Deno.test({
|
Deno.test({
|
||||||
name: "[channel] create a channel in a guild",
|
name: "[channel] create a channel in a guild",
|
||||||
async fn() {
|
async fn() {
|
||||||
const guild = cache.guilds.get(tempData.guildID);
|
const channel = await createGuildChannel(tempData.guildID, "test");
|
||||||
if (!guild) throw new Error("Guild not found");
|
|
||||||
|
|
||||||
const channel = await createGuildChannel(guild, "test");
|
|
||||||
|
|
||||||
// Assertions
|
// Assertions
|
||||||
assertExists(channel);
|
assertExists(channel);
|
||||||
|
|||||||
Reference in New Issue
Block a user