Search code examples
pythonstringdiscord.pynew-operator

Discord.py/ Not all lines are written


I have a problem creating discord bots. The problem is when I use the .idea (idea text) command, only the first phrase of the idea is transferred to the outgoing embed.

Code:

@bot.command(pass_contxt=True)
async def идея(ctx,arg):
    await ctx.channel.purge(limit = 1)
    emb = discord.Embed(title=f'`Начато голосование на идею` 💡',
    description='Идея: ' + str(arg),
    colour=discord.Color.purple()
    )
    emb.set_footer(text = str(ctx.message.author))
    message = await ctx.send(embed=emb)
    await message.add_reaction('✅')
    await message.add_reaction('❌')
    print('>>Была отправлена идея: ' + str(arg))

Solution

  • First of all, it would be better sending your code using the code block formatting.

    code_block

    Then, related to your commands, arg should be a string - arg: str.

    Your new command:

    @bot.command()
    async def идея(ctx, *, arg: str): 
        await ctx.channel.purge(limit = 1)
        emb = discord.Embed(
            title=f'Начато голосование на идею 💡',
            description='Идея: ' + arg,
            colour=discord.Color.purple())
        emb.set_footer(text = str(ctx.message.author))
    
        message = await ctx.send(embed=emb)
        await message.add_reaction('✅')
        await message.add_reaction('❌')
        print('>>Была отправлена идея: ' + arg)
    

    Please check this question accepted to help other users (also upvoting would be great!)

    Have a great day! 👋