Files
discord.js/packages/discord.js/test/templateCreateGuild.js
Mogyuchi 75308f2669 fix(WebSocketManager): await WebSocket destroy (#9519)
fix(WebSocketManager): await ws destroy

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-06-09 09:59:18 +00:00

28 lines
811 B
JavaScript

'use strict';
const { token } = require('./auth');
const { Client, GatewayIntentBits } = require('../src');
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages] });
client
.on('ready', () => console.log('ready'))
.on('messageCreate', 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 {
await client.destroy();
}
})
.login(token)
.catch(console.error);