0
votes

So i am making a bot that waits for a int input from a user then changes a number in a embed description. My current code gives me the error in discord: Error: Command raised an exception: TypeError: can only concatenate str (not "int") to str

import discord
from discord.ext import commands, tasks
import os
import B
import wargaming

wot = wargaming.WoT('demo', region='na', language='en')

key=os.getenv('key')#just some things you might want inside the bot here.

wkey=os.getenv('wkey')

client = discord.Client()#declaring what the client is.

client = commands.Bot(command_prefix = ';;')
client.remove_command('help')

@client.event
async def on_ready():
    await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="Skirmish Tactics"))
    print("Bot is ready!")


def check(ctx):
  return lambda m: m.author == ctx.author and m.channel == ctx.channel

async def get_input_of_type(func, ctx):
  while True:
       try:
          msg = await client.wait_for('message', check=check(ctx))
          return func(msg.content)
       except ValueError:
          continue

@client.command()
async def skirmishstandings(ctx):
    await ctx.send('Enter skirmish tier(6,8,10):')
    tier = await get_input_of_type(int, ctx) 
    position = discord.Embed(title="Irish Rouge Ecelon's stronghold position", description="IRE's stronghold positon for tier" + int(tier) + "skirmishes")
    

    await ctx.send(embed=position)



@client.event
async def on_command_error(ctx, error):
  await ctx.send(f'Error: {error}')

I've looked around on stack overflow and changed my code a lot but no success unfortunately. I guess i'll ask my own question. any help is appreciated! Thanks!

1
Does this answer your question? How can I concatenate str and int objects?Nezuko

1 Answers

0
votes

Try this one.

description=f"IRE's stronghold positon for tier {tier} skirmishes"

You are trying to concatenate two objects of different type. Hence the error. So instead of doing int(tier), you should do str(tier) to get the desired output.