Skip to content

Installation

Follow these steps to correctly install the script on your bot.

  1. Download the module & unzip the folder

    Retrieve the module folder (often in .zip or .rar format) from the official source. Use a tool like WinRAR or 7-Zip to extract the script folder to your computer.

  2. Creating your Twitter Bearer Token keys

    • Logging in to the Twitter developer platform
      Go to: Dasboard to log in or create an account to access the dashboard.
      If this is your first time, you will need to choose a subscription or click on Sign up for Free Account.
      Write a description of how their API is used. Here is an example in English for our case:

      Retrieving a user’s ID allows us to access their recent tweets, analyze updates in real time, and automatically share them on our Discord server. This keeps the community informed of the latest messages and activities. All while linking back to Twitter so they can comment on the messages.


      Check the boxes to validate your request and then click Submit.

    • Retrieve your bearer token for your application
      Go to the following page: Projects and apps


      You already have a project created with an auto-generated name, bearing in mind that you are only entitled to one application as part of your free subscription.


      On the project visible on the page, click on the App Settings gear icon, then on Keys and tokens.
      In the Authentication Tokens section, click Generate for the Bearer Token.
      The bearer token will be displayed so that you can put it in the .env file.


    • ⚠️ If you do not wish to pay, you have a quota per 15-minute period to respect. You can enter up to 1 Twitter account via the module. If you want more, you will need to adjust this on the Quotas page.

  3. Configure the environment variables

    Open the .env file provided with the script and add & modify the necessary environment variables for the proper functioning of the module.

    • twitterChannelID: ID of the channel where tweet notifications will be sent.
    • twitterRoleID: ID of the role of the people who want to receive notifications (usually the member role to notify the entire server, or a role you create so that members can choose this role to be notified of new tweets!).
    • twitterTokenBearer: The Twitter API bearer token (see step 2)
    • twitterChannelFollowerID: ID of the voice channel that will be updated with the number of followers (configure the account in the code, see next step)
  4. Copy/move the files/codes into your project

    Copy the following files into the appropriate folders of your Discord bot project:

    • commands/notification/notification-add.js : in your commands folder
    • commands/notification/notification-list.js : in your commands folder
    • commands/notification/notification-remove.js : in your commands folder
    • utils/notification/twitter.js : in your utilities folder
    • utils/utils.js : in your utilities folder

    Also copy the module’s index code into your main index.js file. In this file, we have added prisma directly linked to the “client” object. Put this code in yours or adjust it according to how you use prisma.

    ❗ If you wish, you can modify PSEUDO_UPDATE_CHANNEL_STAT to update the statistics channel or comment out this line. The username must be the same as the one encoded in the database.

    Twitter notification stat image
  5. Update the database schema

    Add the data model for retrieving notifications of new YouTube videos in your prisma/schema.prisma file and run the necessary migrations to apply the changes to your database. Execute the following command:

    Terminal window
    npx prisma generate
    npx prisma migrate dev --name add_twitter_notification
  6. Install the dependencies

    Make sure the necessary dependencies are installed by checking your package.json and running:

    Terminal window
    npm install
  7. Restart the bot

    Restart your bot for the script to be taken into account.


  • For the /notification-add command, you must enter the name of the Twitter account indicated in the page URL. Example: https://x.com/JoycaOff => The name to enter when using the command is JoycaOff (without the @ in the username).