import os
import discord
import requests
import json
from replit import db
from keep_alive import keep_alive
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('$hello'):
await message.channel.send('Hello!')
my_secret = os.environ['encourage']
client.run(my_secret)
my_secret = os.environ['Demon']
# set the apikey and limit
# Demon = "notnotnotnotsecret"
lmt=8
search_term = "$nezuko"
# get random results using default locale of EN_US
r = requests.get("https://g.tenor.com/v1/random?q=%s&key=%s&limit=%s" % (search_term, my_secret, lmt))
if r.status_code == 200:
gifs = json.loads(r.content)
print(gifs)
else:
gifs = None
keep_alive()
Because nowhere in your code you are checking for a message starting with $nezuko
and doing something in response
https://replit.com/@wyi/encourage-bot-discord#main.py
I understand, thanks.
I edited the code, still not working. I know there are many mistakes
The client event needs to go before client.run
Also, I would not use my_secret
for both your environment variables
And double check that your environment variables are actually correct
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.