Created
November 6, 2020 01:37
-
-
Save 100ze/6953bb6a90b13070eaf5f001bf37d786 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# importando módulos | |
import os | |
# importando o módulo random | |
import random | |
from dotenv import load_dotenv | |
from discord.ext import commands | |
# pegando o token salvo no arquivo .env | |
load_dotenv() | |
TOKEN = os.getenv('DISCORD_TOKEN') | |
# definindo o prefixo do bot e armazenando o objeto 'bot' | |
bot = commands.Bot(command_prefix='!') | |
# mostrando algo no terminal quando o client se conectar | |
@bot.event | |
async def on_ready(): | |
print('{0.user} se conectou com sucesso :)'.format(bot)) | |
# criando comandos | |
@bot.command(name='r') | |
async def oracle_rick(ctx, *, pergunta): | |
# recebendo um número aleatório entre de 0 a 1 | |
resposta = random.randint(0,1) | |
# o if irá interpretar o 0 como False e o 1 como True | |
if resposta: | |
await ctx.send('Pickle Rick! (Sim)') | |
else: | |
await ctx.send('Buuuurrrpp! (Não)') | |
# conectando ao Discord | |
bot.run(TOKEN) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment