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
- Generates random Truth or Dare questions
- Customizable questions
- Error handling
- Installation
- Install the required packages
- Discord Side
- Set up Heruko
- The command prefix is "~"
Tip
- Customization You can customize the Truth and Dare questions by modifying the truths and dares lists in the code.
intents = discord.Intents.default() intents.message_content = True bot = commands.Bot(command_prefix='~', intents=intents)
[ "Chkoun foulena?", "Chkoun akther wa7da ta7ki m3aha?", "Chloun 9alsounik?", "Taw inti rajil?", "Chkoun il crush mte3ik?", ]
[ "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.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 π.")
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)
Important
Install Python
Warning
Python libraries [pip/npm/etc]
Caution
In your Teminal/Console
pip install discord.py
pip install asyncio
- Create a new bot on the Discord Developer Portal
- Copy the bot token and replace
YOUR_BOT_TOKEN
in the code with it
bot.run('YOUR_BOT_TOKEN') import discord from discord.ext
import commands import random
Go to the Heroku CLI installation page. Download the installer for your Device.
heroku login
This will open a browser window asking you to log in to your Heroku account.
In your project directory, set the Heroku remote repository:
heroku git:remote -a YOU-APP-NAME
git add .
git commit -m "Initial commit"
git push heroku master Set Environment Variables on Heroku
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
License This project is licensed under the MIT License - see the LICENSE.md file for details.