So for some reason there is a problem with c!givecookie {member}
. I mentioned the command after @client.command()
. When I type my command(c!givecookie) in discord, it doesnt respond. Can anyboy help?
import os
import random
from replit import db
from keep_alive import keep_alive
from discord.ext import commands
my_secret = os.environ['TOKEN']
def update_encouragements(encouraging_msg):
if "encouragements" in db.keys():
encouragements = db["encouragements"]
encouragements.append(encouraging_msg)
db["encouragements"] = encouragements
else:
db["encouragements"] = [encouraging_msg]
def delete_encouragment(index):
encouragements = db["encouragements"]
if len("encouragements") > index:
del encouragements[index]
db["encouragements"] = encouragements
if "c!responding" not in db.keys():
db["c!responding"] = True
client = commands.Bot(command_prefix = "c! ")
@client.command()
async def givecookie(ctx, member: commands.MemberConverter):
await ctx.send(f"Hello, {member.mention}, here is your cookie~ :cookie:")
@client.event
async def on_ready():
print('We have logged in as {0.user}' .format(client))
async def on_message(message):
if message.author == client.user:
return
if db["c!responding"]:
options = starter_encouragements
if "encouragements" in db.keys():
options = options + list(db["encouragements"])
if any(word in message.content for word in sad_words):
await message.channel.send(random.choice(options))
if message.content.startswith("c!new"):
encouraging_msg = message.content.split("c!new", 1)[1]
update_encouragements(encouraging_msg)
await message.channel.send("New encouraging message added!")
if message.content.startswith("c!delete"):
encouragements = []
if "encouragements" in db.keys():
index = int(message.content.split("c!delete",1)[1])
delete_encouragment(index)
encouragements = db["encouragements"]
await message.channel.send(encouragements)
if message.content.startswith("c!list"):
encouragements = []
if "encouragements" in db.keys():
encouragements = db["encouragements"]
await message.channel.send(encouragements)
if message.content.startswith("c!responding"):
value = message.content.split("c!responding ",1)[1]
if value.lower() == "true":
db["c!responding"] = True
await message.channel.send("Responding is on!")
else:
db["c!responding"] = False
await message.channel.send("Responding is off!")
keep_alive()
client.run(my_secret)