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 :: Display vowels in a string using for loop 
Python :: value_counts sort by index 
Python :: increase chart matplotlib 
Python :: Mixed Fractions in python 
Python :: one line try except python 
Python :: pyplot histogram labels in center 
Python :: City in ontario with cheapest houses 
Python :: utils/decorators.py", line 11, in __get__ raise AttributeError("This method is available only on the class, not on instances.") AttributeError: This method is available only on the class, not on instances. 
Python :: significant figures on axes plot matplotlib 
Python :: python web server oneliner 
Python :: load text file line in listbox python tkinter site:stackoverflow.com 
Python :: Convert the below Series to pandas datetime : DoB = pd.Series(["07Sep59","01Jan55","15Dec47","11Jul42"]) 
Python :: stackoverflow ocr,cropping letters 
Python :: 12 hour clock to 24 hour clock in python 
Python :: python force realod 
Shell :: gnupg, gnupg2 and gnupg1 do not seem to be installed, but one of them is required for this operation 
Shell :: stop nginx ubuntu 
Shell :: uninstall k3s 
Shell :: how to uninstall spacevim 
Shell :: Error starting daemon: error while opening volume store metadata database: timeout 
Shell :: mvn clean install skip tests 
Shell :: install shutil 
Shell :: how to check my ip address on wsl 
Shell :: undo git 
Shell :: windows kill port 
Shell :: install gparted ubuntu 
Shell :: Install xlrd = 1.0.0 for Excel support Use pip or conda to install xlrd 
Shell :: ERROR:uvicorn.error:[Errno 98] Address already in use 
Shell :: install tmux ubuntu 
Shell :: ps1 file not digitally signed 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =