如何从 message.content 中删除一个字符?
How can I remove a character from message.content?
我目前正在尝试让我的机器人说出我所说的一切。因此,如果我的消息以“§”符号开头,机器人就会被激活。它应该删除我的消息,删除其中的“§”字符,然后 post 它在同一个聊天中没有那个符号。
我尝试了一些方法,包括减去符号或将其变成字符串,但没有任何效果。那么,我能做什么?
@client.event
@commands.has_permissions(manage_messages = True)
async def on_message(message):
if message.content.startswith('§'):
channel1 = message.channel
await message.delete()
await channel1.send(f'{message.content}' - '§')
在这里,我收到一条错误消息:
await channel1.send(f'{message.content}' - '§')
TypeError: unsupported operand type(s) for -: 'str' and 'str'
如何删除邮件中的“§”符号?
将前缀替换为空字符串
await channel1.send(f"{message.content.replace('§', '')}")
我目前正在尝试让我的机器人说出我所说的一切。因此,如果我的消息以“§”符号开头,机器人就会被激活。它应该删除我的消息,删除其中的“§”字符,然后 post 它在同一个聊天中没有那个符号。
我尝试了一些方法,包括减去符号或将其变成字符串,但没有任何效果。那么,我能做什么?
@client.event
@commands.has_permissions(manage_messages = True)
async def on_message(message):
if message.content.startswith('§'):
channel1 = message.channel
await message.delete()
await channel1.send(f'{message.content}' - '§')
在这里,我收到一条错误消息:
await channel1.send(f'{message.content}' - '§')
TypeError: unsupported operand type(s) for -: 'str' and 'str'
如何删除邮件中的“§”符号?
将前缀替换为空字符串
await channel1.send(f"{message.content.replace('§', '')}")