0

First off, I'm only a few days into learning python, so my apologies if the answer is pretty simple. My goal is to return the message from the Minecraft server upon entering a command into discord via a bot. In this scenario it's whitelisting. However, when the message is returned, it looks like this..

"Player is already whitelisted" but that last "character" is a square with a X in it. It returns more, but I've added the [:-1][:-2] to remove the last two characters. Then tried seeing if adding a space would essentially replace it. Although it does not work with this because it's not really a character? Thoughts?

  if message.content.startswith('whitelist add'):
    channel = client.get_channel(<Channel ID>)
    await channel.send(rcon.command(message.content)[:-1][:-2]+" ", delete_after=3)
    await asyncio.sleep(3)
    await message.delete()
  • 4
    Does this answer your question? [Understanding slicing](https://stackoverflow.com/questions/509211/understanding-slicing) (Specifically, to remove the last two characters, you want just `[:-2]`, not `[:-1][:-2]`.) – CrazyChucky Jul 09 '22 at 02:54
  • Yeah.. thank you. I must have misread it, thinking it was a character in a specific position that was remove – s3skydance Jul 09 '22 at 08:11

0 Answers0