/friendly-discordly-watcher

A Simple discord bot that forwards all Links from an Input Text Channel to an Output Text Channel. Mainly for learning purposes

Primary LanguageTypeScriptMIT LicenseMIT

Banner

Building my own Discord Bot

This is part of my build-your-own-x weekly warmup and I've chosen to build a Discord bot based of this guide Node.js: Create a Discord bot

Progress

I plan on deploying the bot to fly.io.

I've also found a lot of my weaknesses from starting this project

Namely:

  • Using a different environment than what was written in the discord.js guide since I used Typescript instead of plain JavaScript for this project.
  • Lack of Typescript familiarity (I assumed that I could wing it with my JS experience.)
  • Lack of ESLint, Prettier and Husky Integration (I scoured through multiple sources just to get an environment that feels good enough to make this project which are listed below in the articles)
  • How Node and Typescript will have import issues. Due to configuring my tsconfig to use a baseUrl to ditch relative imports I expected that it would revert back to relative imports after transpilation. Turns out you need a path remapper for it.

Articles I've read to fix the environment issues

Discord and DiscordJS issues:

Missing Permissions and Intents are what caused friction when developing the bot. I've encountered the following:

  • Listening on messageCreate events. In order to enable this the client bot needs to have GatewayIntentBits.GuildMessages intent as well as permission to read messages from the Oauth 2 URL generator. Source

  • Replying on messageCreate events. To make this work two intent bits are required, namely GuildMessageTyping and MessageContent. You also have to enable Rich Presence for Message Content to prevent message.content from being null. Source

  • As of what I've tried you can't send messages to threads directly. You have to use a Webhook as described in this setup and giving the bot permission to Manage Webhooks in the Discord Developer Portal.

Additional Learning

  • Just found out that there is a collector object that listens for messages for a specified time. Source