mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 08:33:30 +01:00
29 lines
848 B
JavaScript
29 lines
848 B
JavaScript
'use strict';
|
|
|
|
const { token } = require('./auth.js');
|
|
const { Client, Events, GatewayIntentBits } = require('../src/index.js');
|
|
|
|
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages] });
|
|
|
|
client
|
|
.on(Events.ClientReady, () => console.log('ready'))
|
|
.on(Events.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);
|