Skip to content

PoldekPL/AskBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AskBot (or, The Asker)

A dead simple Discord bot with one purpose - to ask newcomers in a server a simple choice question, randomly generated from a list of options.

AskBot is a single-purpose Discord bot written in Python 3 with the latest (v2.5.2 at the time of writing this) discord.py library, meant to fulfill one goal - ask new server member questions.

Born out of the oldest question to ask new people about their tastes or preferences, the idea quickly evolved into generating random questions out of a predefined list of options.

It is a functional bot and can be easily used as a reference for people wanting to write their own Discord bots in Python. Written and tested under Python 3.10, ran without issues under Python 3.8.

Features

  • Simple, concise code - AskBot subclasses discord.ext.commands.Bot and thus inherits everything needed to be a functional bot.
  • Code organization via OOP and Cogs - whatever bot needs to do internally is implemented via methods inside AskBot class. Commands have their own Cog loaded at startup, events to handle have their own Cog.
  • /slash commands - no need for any permissions to read member messages - bot only needs a greet_channel to be set once, and after that it will fire messages into that channel when new members join the server.
  • Transparent configuration - bot uses data from and saves data to plaintext files. They're as secure as the machine you want to run the bot on.

Requirements

AskBot relies solely on discord.py, and whatever discord.py requires.

Only server permissions that AskBot needs are:

  • Send Messages

Additionally the bot also requires one privileged intent:

  • Server Members

Running it yourself

Easiest way to replicate the environment in which the bot was created and is used is to clone the repository to a local directory on your PC and create a virtual Python environment right next to it. Make sure you've got Python 3 (3.8+) and pip3 installed first. After creating the virtual environment and activating it, run pip3 install -r requirements.txt.

Next you'll need to provide bot token (which you obtain from Discord Developer portal after creating your "application") in a token or token.txt file in the same directory as bot.py.

Additionally bot needs wordlist or wordlist.txt file. You can create one youself, with each option for bot to choose from in separate lines, or you can rename the provided example_wordlist file.

Once all that is done, you've got the virtual environment activated and you navigated in the console/terminal to the main directory of the bot, launch it using python .\bot.py or python3 .\bot.py, depending on what's your OS and how you installed Python.

To add the bot to your server, it's best to look up an up-to-date guide online. Once the bot is in your server, use /greet_channel command to set a "greet channel" where new members will be "greeted" by the bot with the questions. Each new member should receive new randomly generated question.

Note: AskBot can work in multiple servers at once, but it will use the same wordlist for each of them. If you want it to ask different questions in different servers, you will need to run multiple instances (register multiple "apps" on Developer Portal and obtain separate token for each of the instances).

About

Discord bot asking new server members one question: "x, y or z?"

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Languages