Reputation: 41
I have been creating a discord.py bot and have run into the issue of my discord bot not being able to send embeds there are no errors in the console the command was working before:
@client.command()
async def usercheck(ctx, username, number):
collection.update_one({"_id":ctx.guild.id},{"$set": {f'Userid{number}': username}})
for x in collection.find():
if x["_id"] == ctx.guild.id:
variable = x["Pop"]
variable2 = x[f'Userid{number}']
response = requests.get('https://api.battlemetrics.com/players/' + variable2 + '?fields[server]=name&filter[servers]=' + variable + '&include=server')
pass_times = response.json()
Player_id = pass_times['data']['attributes']['id']
Player_name = pass_times['data']['attributes']['name']
Server_name = pass_times['included'][0]['attributes']['name']
Player_online = pass_times['included'][0]['meta']['online']
Player_id = str(Player_id)
url = 'https://www.battlemetrics.com/players/' + Player_id
embed = discord.Embed(title=Player_name, description=url, color=0x1eff00)
embed.add_field(name="Status", value="Online: " + Player_online, inline=False)
embed.add_field(name="Server", value=Server_name, inline=False)
await ctx.send(embed=embed)
Upvotes: 0
Views: 593
Reputation: 1427
Since this line: Player_online = pass_times['included'][0]['meta']['online']
returns a boolean, you need to cast it to a string to send messages, this should fix your error:
embed.add_field(name="Status", value="Online: " + str(Player_online), inline=False)
or:
Player_online = str(pass_times['included'][0]['meta']['online'])
Upvotes: 1