'Convert a message into a list
I wanted to do a roll command on my discordbot and i wanted to convert the message into a list and wait x seconds before revealing the roll.
But when I split the message and print it, it returns <built-in method split of str object at 0x0000021B3AA202B0>.
@client.event
async def on_message(message):
if message.content.startswith('wroll'):
await message.channel.send(message.content.split)
start= int(message.content.split()[1])
end = int(message.content.split()[2])
txt = []
txt.append(message.content.split)
await message.channel.send(txt)
if len(txt) == 4:
print(True)
waiting = int(txt[3])
for i in range(waiting+1,0,-1):
await message.channel.send(i)
sleep(1)
await message.channel.send(randint(start,end))
client.run(TOKEN)
Solution 1:[1]
Typo, missing brackets on txt.append(message.content.split), should be txt.append(message.content.split())
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tzane |
