Files
discordeno/packages/bot/tests/e2e/resetguilds.spec.ts
T
Fleny 27808bea7d test(bot,gateway): Fix Bot E2E and Gateway Integration tests (#4084)
* Fix bot e2e, refactor gateway integration tests

* use debug for bot e2e log

* Discard changes to packages/bot/src/bot.ts
2025-01-06 04:04:12 -05:00

43 lines
1.1 KiB
TypeScript

import { Intents } from '@discordeno/types'
import { delay, logger } from '@discordeno/utils'
import { use as chaiUse } from 'chai'
import chaiAsPromised from 'chai-as-promised'
import { describe, it } from 'mocha'
import { createBot } from '../../src/bot.js'
import { token } from './constants.js'
chaiUse(chaiAsPromised)
describe('[Bot] Delete any guild owned guilds', () => {
it('Start the bot', async () => {
const bot = createBot({
token,
desiredProperties: {
guild: {
id: true,
joinedAt: true,
ownerId: true,
},
},
intents: Intents.Guilds,
events: {
async guildCreate(guild) {
if (guild.joinedAt && Date.now() - guild.joinedAt < 360000) {
return
}
if (bot.rest.applicationId === guild.ownerId) {
logger.debug(`Deleting one of the bot created guilds. ${guild.id}`)
await bot.rest.deleteGuild(guild.id)
}
},
},
})
await bot.start()
await delay(5000)
await bot.shutdown()
})
})