2021年5月6日星期四

No response when command is run

So, I'm making a discord bot but when I run the ;give command I made and I input a user, 1 chillcoin gets delivered perfectly fine to that user. However, when the parameter is a role, I get no response from my bot nor do I get an error. I have attached the code below

import discord, asyncio, time, random  from discord import message  from discord import colour  from discord.ext import commands  import random  import json  import os  from ChineseClassBotToken import token  import typing    # test    intents = discord.Intents.all()  client = commands.Bot(command_prefix=";", intents=intents)      @client.event  async def on_ready():      print("Chinese bot is up and ready!")      await client.change_presence(status=discord.Status.online,                                   activity=discord.Game(f"Watching over such bright students!"))      @client.command(pass_context=True)  async def nick(ctx, member: discord.Member, nick):      roles = member.roles      for role in roles:          if role.permissions.manage_nicknames:              await member.edit(nick=nick)              await ctx.send(f'Nickname was changed for {member}')              return      await ctx.send(f"{ctx.author.mention} Manage nickname permissions are required to use this command.")      @client.command()  async def question(ctx):      question_embed = discord.Embed(          title="What type of chinese do you need help with?",          colour=discord.Colour.red(),          description=None      )        await ctx.send(embed=question_embed)        def check(x):          return x.author == ctx.author        question_embed_response = await client.wait_for('message', check=check)        if question_embed_response.content.lower() == "chinese 2" or question_embed_response == "chin2" or question_embed_response.content.lower() == "chinese2":          channel = client.get_channel(832642317575258122)          await channel.send(f"{ctx.author.mention} needs help with **CHINESE 2** homework!")        if question_embed_response.content.lower() == "chinesecul" or question_embed_response.content.lower() == "chinese culture":          channel = client.get_channel(832643093987590214)          await channel.send(f"{ctx.author.mention} needs help with **CHINESE CULTURE** homework!")        if question_embed_response.content.lower() == "ap":          channel = client.get_channel(832642407282901000)          await channel.send(f"{ctx.author.mention} needs help with **AP CHINESE** homework!")        if question_embed_response.content.lower() == "convo" or question_embed_response.content.lower() == "chinese convo" or question_embed_response.content.lower() == "chineseconvo":          channel = client.get_channel(832643571441336340)          await channel.send(f"{ctx.author.mention} needs help with **CHINESE CONVERSATION** homework!")      @client.command()  async def stats(ctx, member: discord.Member = None):      member = member or ctx.author        await open_profile(member)        users = await get_student_data()        chillcoin_amount = users[str(member.id)]["chillcoins"]      homework_passes = users[str(member.id)]["Homework Passes"]        stats_embed = discord.Embed(          title=f"**{member}'s statistics**",          colour=discord.Colour.dark_gold(),        )      stats_embed.add_field(name="__chillcoins__", value=chillcoin_amount)      stats_embed.add_field(name="__Homework Passes__", value=homework_passes)      await ctx.send(embed=stats_embed)      async def open_profile(member):      users = await get_student_data()        if str(member.id) in users:          return False      else:          users[str(member.id)] = {}          users[str(member.id)]["chillcoins"] = 0          users[str(member.id)]["Homework Passes"] = 0        with open("Studentstats.json", "w") as f:          json.dump(users, f)      return True      async def get_student_data():      with open("Studentstats.json", "r") as f:          users = json.load(f)      return users    @client.command()  async def give(ctx, type_of_message : typing.Union[discord.Role, discord.Member], item, amount):         if isinstance(type_of_message, discord.Member):             await open_profile(type_of_message)             users = await get_student_data()             if ctx.author.id == 699991882465280031 or ctx.author.id == 709788125278502912:              if item.lower() == "chillcoins" or item.lower() == "chillcoin":                  users[str(type_of_message.id)]["chillcoins"] += int(amount)                  if int(amount) > 1:                      chillcoins_award = discord.Embed(                          title=f"{type_of_message} has been awarded %s chillcoins by Mr.Qiu!" % (amount),                          colour=discord.Colour.dark_purple(),                          description=None                      )                      await ctx.send(embed=chillcoins_award)                  if int(amount) == 1:                      chillcoin_award = discord.Embed(                          title=f"{type_of_message} has been awarded %s chillcoin by Mr.Qiu!" % (amount),                          colour=discord.Colour.dark_purple(),                          description=None                      )                      await ctx.send(embed=chillcoin_award)                 if item.lower() == "homework passes" or item.lower() == "homework pass":                  users[str(type_of_message.id)]["Homework Passes"] += int(amount)                  if int(amount) > 1:                      homework_passes = discord.Embed(                          title=f"{type_of_message} has been awarded %s homework passes" % (amount),                          colour=discord.Colour.dark_orange(),                          description=None                      )                      await ctx.send(embed=homework_passes)                     if int(amount) == 1:                      homework_pass = discord.Embed(                          title=f"{type_of_message} has been awarded %s homework pass" % (amount),                          colour=discord.Colour.dark_orange(),                          description=None                      )                      await ctx.send(embed=homework_pass)          if ctx.author.id != 699991882465280031 and ctx.author.id != 709788125278502912:              imposter_embed = discord.Embed(                  title="Only Mr.Qiu is allowed to hand out rewards!",                  colour=discord.Colour.red(),                  description=None              )              await ctx.send(embed=imposter_embed)             with open("Studentstats.json", "w") as f:              json.dump(users, f)          return True         if isinstance(type_of_message, discord.Role):             await open_profile(type_of_message)             users = await get_student_data()             for member in ctx.guild.members:              if type_of_message in member.roles:                  if item.lower() == "chillcoins" or item.lower() == "chillcoin":                      if int(amount) > 1:                          users[str(member.id)]["chillcoins"] += int(amount)                          role_coins_embed = discord.Embed(                              title=f"Members that have the {type_of_message} role have each been awarded {type_of_message} chillcoins!",                              colour=discord.Colour.teal()                          )                          await ctx.send(embed=role_coins_embed)                         if int(amount) == 1:                          users[str(member.id)]["chillcoins"] += int(amount)                          role_coin_embed = discord.Embed(                              title=f"Members that have the {type_of_message} role have each been awarded {amount} chillcoin!",                              colour=discord.Colour.teal()                          )                          await ctx.send(embed=role_coin_embed)                     if item.lower() == "homework passes" or item.lower() == "homework pass":                      if str(amount) > 1:                          users[str(member.id)]["Homework Passes"] += int(amount)                          role_pass_embed = discord.Embed(                              title=f"Members that have the {type_of_message} role have each been awarded {amount} homework passes!",                              colour=discord.Colour.teal()                          )                          await ctx.send(embed=role_pass_embed)                         if str(amount) == 1:                          users[str(member.id)]["Homework Passes"] += int(amount)                          role_passes_embed = discord.Embed(                              title=f"Members that have the {type_of_message} role have each been awarded {amount} homework pass!",                              colour=discord.Colour.teal()                          )                          await ctx.send(embed=role_passes_embed)                 with open("Studentstats.json", "w") as f:                  json.dump(users, f)              return True      #          client.run(token)  

Greatly appreciated if you can help!

https://stackoverflow.com/questions/67428501/no-response-when-command-is-run May 07, 2021 at 11:05AM

没有评论:

发表评论