From 54e0e41dc7e0fe8c56624390000b121cbed2e6d8 Mon Sep 17 00:00:00 2001 From: Helloyunho Date: Mon, 25 Jan 2021 23:02:43 +0900 Subject: [PATCH] just test thing --- src/test/index.ts | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/test/index.ts b/src/test/index.ts index aa30522..528982c 100644 --- a/src/test/index.ts +++ b/src/test/index.ts @@ -13,6 +13,7 @@ import { } from '../../mod.ts' import { Collector } from '../models/collectors.ts' import { MessageAttachment } from '../structures/message.ts' +import { Permissions } from '../utils/permissions.ts' import { TOKEN } from './config.ts' const client = new Client({ @@ -160,6 +161,37 @@ client.on('messageCreate', async (msg: Message) => { const vs = await msg.guild?.voiceStates.get(msg.member.id) if (typeof vs !== 'object') return vs.channel?.join() + } else if (msg.content === '!getOverwrites') { + if (msg.channel.type !== ChannelTypes.GUILD_TEXT) { + return msg.channel.send("This isn't a guild text channel!") + } + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + const overwrites = await (msg.channel as GuildTextChannel).overwritesFor( + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + msg.member as Member + ) + msg.channel.send( + `Your permission overwrites:\n${overwrites + .map( + (over) => + `ID: ${over.id}\nAllowed:\n${new Permissions(over.allow) + .toArray() + .join('\n')}\nDenied:\n${new Permissions(over.deny) + .toArray() + .join('\n')}` + ) + .join('\n\n')}` + ) + } else if (msg.content === '!getPermissions') { + if (msg.channel.type !== ChannelTypes.GUILD_TEXT) { + return msg.channel.send("This isn't a guild text channel!") + } + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + const permissions = await (msg.channel as GuildTextChannel).permissionsFor( + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + msg.member as Member + ) + msg.channel.send(`Your permissions:\n${permissions.toArray().join('\n')}`) } })