mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
feat(GuildManager): add AFK and system channel options in create (#4837)
This commit adds support for the `afk_channel_id`, `afk_timeout`, and `system_channel_id` parameters in the [create guild](https://discord.com/developers/docs/resources/guild#create-guild-json-params) endpoint by adding the `afkChannelID`, `afkTimeout`, and `systemChannelID` options in `GuildManager#create`. This commit also fixes a minor bug in `create` when specifying types for the channels due to the channel types not being changed from `'text'`, `'voice'` etc to the corresponding numbers, so Discord would return an error.
This commit is contained in:
31
test/createGuild.js
Normal file
31
test/createGuild.js
Normal file
@@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const { token } = require('./auth');
|
||||
const { Client } = require('../src');
|
||||
|
||||
const client = new Client();
|
||||
|
||||
client.on('ready', async () => {
|
||||
try {
|
||||
const guild = await client.guilds.create('testing', {
|
||||
channels: [
|
||||
{ name: 'afk channel', type: 'voice', id: 0 },
|
||||
{ name: 'system-channel', id: 1 },
|
||||
],
|
||||
afkChannelID: 0,
|
||||
afkTimeout: 60,
|
||||
systemChannelID: 1,
|
||||
});
|
||||
console.log(guild.id);
|
||||
assert.strictEqual(guild.afkChannel.name, 'afk channel');
|
||||
assert.strictEqual(guild.afkTimeout, 60);
|
||||
assert.strictEqual(guild.systemChannel.name, 'system-channel');
|
||||
await guild.delete();
|
||||
client.destroy();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
|
||||
client.login(token).catch(console.error);
|
||||
Reference in New Issue
Block a user