Table of Contents

Stickybot

Stickybot, sometimes known as Imaginifer, is the bot we use to send automatic announcement messages that are always at the bottom of a channel.

Built by: Spooker#0378
If you have any issues with this guide or feedback please contact dustojnikhummerCZ#6262

This guide assumes you are working without a GUI, most likely connected over SSH. If you are working with a Linux Desktop environment some of these steps can be done that way, like unzipping the archive.

Requirements

Download

Download here: CDN

Unzip the archive and copy its contents to your Linux server. Alternatively, run:

wget https://cdn.laptopwiki.eu/public/laptopwiki/sticky-message.zip

Then unzip the archive with:

unzip ./sticky-message.zip -d ./sticky-message

If you want to move the folder somewhere else (or what to rename the folder) make sure to move the entire folder, not all of its contents. Linux's mv ./* does not move files hidden files (file starting with a .) and you might forget your .env file (which is very important).

For example, you can move/rename the folder with the following command:

mv ./sticky-message ./imaginifer

Bot Setup - Discord

  1. In the top right create a New Application and give it a name.
  2. In the left panel select the Bot section. On the right click Add Bot.
  3. Click the Reset Token button. Copy that token and do not lose it. Also make sure nobody else has that token.
  4. In the left panel select OAuth2-URL Generator and select the bot scope. Below that a permission list will appear.
  5. Select the permissions you want. Read Message History, Manage Messages, Send Messages at least. Add more if you want.

Bot Setup - Host

In the bot folder should be an .env file. If there isn't, create it:

touch .env

Open it in Nano text editor:

nano .env

The file should contain the following content (DO NOT USE CTRL+V in nano, type it manually):

DISCORD_BOT_TOKEN=

Now add the token you generated in a previous section on this line, so it looks like the following example:

DISCORD_BOT_TOKEN=MTAxMjYzMjA3NzM2RESTOFTHETOKEN

Press Ctrl+O and Enter to save changes and Ctrl+X to exit Nano.

Installation

Enter the bot folder

 cd /path/to/unpackaged/

Now install dependencies for the bot:

Fedora/AlmaLinux or other RHEL derivatives

sudo dnf install npm

Debian/Ubuntu or other Debian derivatives

sudo apt install npm

Install NPM dependencies

npm install

You will most likely get a message talking about vulnerabilities. You can fix that with:

npm audit fix
npm fund

Install dotenv

npm install dotenv

Now run the bot with:

npm start

If you get the following error, it probably means your bot token is incorrect:

(node:133979) UnhandledPromiseRejectionWarning: ReferenceError: c is not defined
    at /path/to/stickybot/src/main.js:10:15
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async  /path/to/stickybot/src/src/main.js:9:2

Check your .env file and make sure the correct token is in the file.

Now you should see your bot online in your server and ready to send messages!

Messages.json

In the bot folder is a file messages.json. The bot takes messages from this file and prints them into a Discord message. These messages can be edited while the bot is running.

Copy the following template to your messages.json:

{
    "928291939244195882": "This is a text field",
    "comment": "Test channel"
}

The number on the first line is the channel ID. You can get it by activating developer mode in the Discord Client, right clicking on a channel and selecting Copy ID.
You can find that toggle in Discord Settings - Advanced - Developer Mode

After the channel ID comes the text. This can have basic formatting like bold and code block:

{
    "928291939244195882": "`This is a text field`",
    "comment": "Test channel"
}



The comment line is just for you to say what channel belongs that message to.

If you want to add another message to a different channel just replicate this syntax, but add a , at the end of a line:

{
    "928291939244195882": "`This is a text field`",
    "comment": "Test channel",
    "928291939244195883": "`This is a text field 2`",
    "comment": "Test channel 2"
}

Do not add , to the very last line, that won't work.

Run stickybot in the background manually

Unless you want to keep the SSH connection active all the time to keep the bot running you will need to run it in the background. To do that we will use a Linux terminal application called Screen

To install it run:

sudo apt install screen

Then create a session with:

screen -S stickybot

Now you are in a Screen session. Now you can start the bot:

npm start

To properly exit it press CTRL+A and then D. To get back into the session (or Attach it) use:

screen -r session-name

Basic GNU Screen commands

Create a session:

screen -S stickybot

List all sessions:

screen -ls

Kill a particular session :

screen -XS sessionid/name quit

Kill all Screen sessions:

pkill screen

Running Stickybot as a systemd service

Running "npm start" App As a Systemd Service

dustojnikhummer 2022/12/30 08:01