Reputation: 5
My question is very specific and i dont know if there is a right answer for it, but what im trying to adchieve is to retrieve a certain value from a message. For instance if the message is:
"Recovered 5 out of 10 messages".
I want to know how i can get both integers from this message in 2 different variables
Edit: My code at this moment is
import discord
class MyClient(discord.Client):
async def on_ready(self):
print('Logged in as {0}!'.format(self.user))
await self.send_message()
async def send_message(self):
channel = client.get_channel(CHANNELID)
content = (await channel.history(limit=1).flatten()[0]).content
await content
client = MyClient()
client.run('TOKEN')
Upvotes: 0
Views: 831
Reputation: 1047
You can use the history method of the channel object.
mychannel = client.get_channel(channelID)
content=(await mychannel.history(limit=1).flatten())[0].content
From there, you can do whatever you want with content. To extract the numbers, I'd use
content=...#see above
a,b=[int(i)for i in content.split()if i.isnumeric()]
Upvotes: 1