summaryrefslogtreecommitdiff
path: root/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'index.ts')
-rw-r--r--index.ts32
1 files changed, 27 insertions, 5 deletions
diff --git a/index.ts b/index.ts
index 9bf969d..fc65e3f 100644
--- a/index.ts
+++ b/index.ts
@@ -1,8 +1,8 @@
import {
Client,
- CommandInteraction,
Events,
GatewayIntentBits,
+ PermissionFlagsBits,
REST,
Routes,
} from "discord.js";
@@ -26,8 +26,30 @@ let client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.
let rest = new REST({ version: "10" }).setToken(token);
-client.once(Events.ClientReady, (readyClient) => {
- console.log(`Logged in as ${readyClient.user.tag}`);
+client.once(Events.ClientReady, (c) => {
+ console.log(`Logged in as ${c.user.tag}`);
+});
+
+client.on(Events.GuildAvailable, guild => {
+ console.log(`Available in Guild: ${guild.name}`);
+ let role = guild.roles.botRoleFor(guild.client.user);
+ if (!role) {
+ console.error(`Bot has no role in ${guild.name}`);
+ return;
+ }
+ for (let permission of [
+ PermissionFlagsBits.ViewChannel,
+ PermissionFlagsBits.ManageChannels,
+ PermissionFlagsBits.ManageRoles,
+ PermissionFlagsBits.SendMessages,
+ PermissionFlagsBits.SendMessagesInThreads,
+ PermissionFlagsBits.CreatePublicThreads,
+ PermissionFlagsBits.ManageThreads,
+ ]) {
+ if (!role.permissions.has(permission)) {
+ console.error(`Bot is missing permission ${permission} in ${guild.name}`);
+ }
+ }
});
client.on(Events.InteractionCreate, async (interaction) => {
@@ -50,8 +72,8 @@ client.on(Events.InteractionCreate, async (interaction) => {
}
} catch (error) {
if (error === "done") return;
- if (interaction instanceof CommandInteraction) {
- console.error("Error while handling interaction", error);
+ console.error("Error while handling interaction", error);
+ if (interaction.isChatInputCommand() || interaction.isButton()) {
if (interaction.deferred || interaction.replied) {
await interaction.followUp({
content: "Something went wrong! :(",