Skip to content

Instantly share code, notes, and snippets.

@100ze
Created November 6, 2020 01:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 100ze/6953bb6a90b13070eaf5f001bf37d786 to your computer and use it in GitHub Desktop.
Save 100ze/6953bb6a90b13070eaf5f001bf37d786 to your computer and use it in GitHub Desktop.
# 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