Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

create 8ball command in discord.py

import discord, random
from discord.ext import commands

bot = commands.Bot(command_prefix='?')

@bot.event
def on_ready():
  print('Bot is online!')

@bot.command(aliases=['8ball'])
async def _8ball(ctx, *, q):
  responses = ['yes', 'no', 'maybe', '...', 'problably not', 'ok']
  await ctx.send(f'Question: {q}
 Answer: {random.choice(responses)}')

bot.token("your bot's token here")
Comment

discord.py 8ball

"""
Put the ball object under the bot object
"""
@bot.command()
async def ball(ctx, *, question):
 await ctx.send(bot.ball.response(question)
Comment

PREVIOUS NEXT
Code Example
Python :: seed python 
Python :: how to convert python input to int 
Python :: group by, aggregate multiple column -pandas 
Python :: python install minio 
Python :: heroku django procfile 
Python :: xticks and yticks matplotlib 
Python :: python datetime compare date 
Python :: Support Vector Machine (SVM) classifier 
Python :: python variable 
Python :: python trim whitespace from end of string 
Python :: pie plot in python 
Python :: how return the data timestamp after some days in python 
Python :: turn characters to alpgabetic numper python 
Python :: how to merge two pandas dataframes on a column 
Python :: python distilled 
Python :: add metadata png PIL 
Python :: Python RegEx Findall – re.findall() 
Python :: group by 2 unique attributes pandas 
Python :: python arrays 
Python :: get function in dictionary 
Python :: .describe() python 
Python :: python list add element to front 
Python :: how to take float input upto 2 decimal points in python 
Python :: how to log errors while debug is false in django 
Python :: python word starts with 
Python :: log loss python 
Python :: circumference of a circle python 
Python :: add a list in python 
Python :: sending email with django 
Python :: flask print request headers 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =