mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 09:03:29 +01:00
fix(DataResolver): fix circular dependency error with GuildTemplate (#5622)
This commit is contained in:
27
test/templateCreateGuild.js
Normal file
27
test/templateCreateGuild.js
Normal file
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
const { token } = require('./auth');
|
||||
const { Client } = require('../src');
|
||||
|
||||
const client = new Client({ intents: ['GUILDS', 'GUILD_MESSAGES'] });
|
||||
client
|
||||
.on('ready', () => console.log('ready'))
|
||||
.on('message', async message => {
|
||||
try {
|
||||
const templates = await message.guild.fetchTemplates();
|
||||
if (!templates.size) {
|
||||
console.log('no templates');
|
||||
} else {
|
||||
const guild = await templates.first().createGuild('guild name');
|
||||
console.log(`created guild with ID ${guild.id}`);
|
||||
await guild.delete();
|
||||
console.log('deleted guild');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
} finally {
|
||||
client.destroy();
|
||||
}
|
||||
})
|
||||
.login(token)
|
||||
.catch(console.error);
|
||||
Reference in New Issue
Block a user