Skip to content

Discord bot => Radom Truth or Dare questions in tunisian πŸ˜‡

Notifications You must be signed in to change notification settings

Ali-Cheikh/turth-ll-dare-DB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Discord Truth or Dare Bl Tounsi Bot


A simple Discord bot that generates random Truth or Dare questions in tunisian for you and your friends to enjoy action/verite bil tounsi! Radom Truth or Dare questions in tunisian

Features


Usage

Tip

  • To start a game, type ~help in a channel
    Type ~truth to receive a Truth question
    Type ~dare to receive a Dare question
  • Customization You can customize the Truth and Dare questions by modifying the truths and dares lists in the code.

Initialize the bot with intents

intents = discord.Intents.default() intents.message_content = True bot = commands.Bot(command_prefix='~', intents=intents)

Truth and Dare questions

truths

[ "Chkoun foulena?", "Chkoun akther wa7da ta7ki m3aha?", "Chloun 9alsounik?", "Taw inti rajil?", "Chkoun il crush mte3ik?", ]

dares

[ "Do 10 pushups.", "9oum 3ayit mich yo9tlouni", "8ani 8neya fi vocal ou ib3athha le5ir we7id 7kit m3ah 3la discord", "Do 30 pushups", "Hbat story fiha inti 7ra9t", ]

Bot events and commands

@bot.event async def on_ready():
    print(f'Bot is ready. Logged in as {bot.user}')

@bot.command(name='truth') async def truth(ctx):
    truth_question = random.choice(truths)
        await ctx.send({user},' ',truth_question)

@bot.command(name='dare') async def dare(ctx):
    dare_question = random.choice(dares)
        await ctx.send({user},' ',dare_question)

@bot.command(name='help')
    async def truth_or_dare(ctx):
        await ctx.send("{user} Type 'truth' or 'dare' to receive a challenge!") def check(m):
            return m.author == ctx.author and m.channel == ctx.channel and m.content.lower() in ['truth', 'dare']
            try: msg = await bot.wait_for('message', check=check, timeout=30) if msg.content.lower() == 'truth':
                await truth(ctx)
            elif msg.content.lower() == 'dare':
                await dare(ctx) 
            except asyncio.TimeoutError: # type: ignore
                await ctx.send("{user} You took too long to respond! Please try again πŸ˜‡.")

Error handling

The bot includes basic error handling for common errors such as invalid commands and timeouts.

@bot.event async def on_command_error(ctx, error):
    if isinstance(error, commands.CommandNotFound):
        await ctx.send("Invalid command. Please try again.")
    else:
        await ctx.send("An error occurred. Please try again later.") print(error)

Installation

Important

Install Python

Required Packages

Warning

Without the necessary packages and libraries nothing will work

Python libraries [pip/npm/etc]

Caution

In your Teminal/Console pip install discord.py
pip install asyncio

Discord side

The necessary :

  1. Create a new bot on the Discord Developer Portal
  2. Copy the bot token and replace YOUR_BOT_TOKEN in the code with it

3. Invite the bot to your server using the generated invite link

Run the bot with the token

bot.run('YOUR_BOT_TOKEN') import discord from discord.ext
import commands import random

Finale

Install the Heroku CLI

Go to the Heroku CLI installation page. Download the installer for your Device.

Log in to Heroku:

heroku login

This will open a browser window asking you to log in to your Heroku account.

Heroku Remote:

In your project directory, set the Heroku remote repository:

heroku git:remote -a YOU-APP-NAME

Stage Your Changes:

git add .

Commit Your Changes:

git commit -m "Initial commit"

Push to Heroku:

git push heroku master Set Environment Variables on Heroku

Set Your Bot Token:

heroku config:set DISCORD_TOKEN=your-bot-token

Code:

    git init
    heroku git:remote -a your-heroku-app-name
    git add .
    git commit -m "Initial commit"
    git push heroku master

Do you want me to make it in js next time ?

License This project is licensed under the MIT License - see the LICENSE.md file for details.