mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-11 13:56:15 +00:00
chore(bots/discord): reduce footprint of functions
This commit is contained in:
@@ -3,11 +3,11 @@ import { api } from '../../context'
|
||||
|
||||
const { client } = api
|
||||
|
||||
export function on<Event extends EventName>(event: Event, listener: ListenerOf<Event>) {
|
||||
export const on = <Event extends EventName>(event: Event, listener: ListenerOf<Event>) => {
|
||||
client.on(event, listener)
|
||||
}
|
||||
|
||||
export function once<Event extends EventName>(event: Event, listener: ListenerOf<Event>) {
|
||||
export const once = <Event extends EventName>(event: Event, listener: ListenerOf<Event>) => {
|
||||
client.once(event, listener)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,7 @@
|
||||
import type { Guild, GuildManager } from 'discord.js'
|
||||
import { config, logger } from '../../context'
|
||||
import type { Guild } from 'discord.js'
|
||||
import { logger } from '../../context'
|
||||
|
||||
export function leaveDisallowedGuild(guild: Guild) {
|
||||
export const leaveDisallowedGuild = (guild: Guild) => {
|
||||
logger.warn(`Server ${guild.name} (${guild.id}) is not allowed to use this bot.`)
|
||||
return guild.leave().then(() => logger.debug(`Left guild ${guild.name} (${guild.id})`))
|
||||
}
|
||||
|
||||
export async function leaveDisallowedGuilds(guildManager: GuildManager) {
|
||||
const guilds = await guildManager.fetch()
|
||||
for (const [id, guild] of guilds) {
|
||||
if (!config.allowedGuilds.includes(id)) await leaveDisallowedGuild(await guild.fetch())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user