Skip to content

Instantly share code, notes, and snippets.

@100ze
Created November 6, 2020 02:31
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/e0aedee34e1f49011cb6850fe17dcd0d to your computer and use it in GitHub Desktop.
Save 100ze/e0aedee34e1f49011cb6850fe17dcd0d 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):
# marcando o usuário que fez a pergunta
await ctx.send('{} {}'.format(ctx.author.mention, pergunta))
# recebendo um número aleatório entre de 0 a 1
resposta = random.randint(0,1)
if resposta:
# adicionando um gif do tenor
await ctx.send('https://tenor.com/NHxx.gif')
# respondendo com SIM
await ctx.send('Pickle Rick! (Sim)')
else:
# adicionando um gif do tenor
await ctx.send('https://tenor.com/U7wJ.gif')
# respondendo com NÃO
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