#Getting message content in a cmd

1 messages · Page 1 of 1 (latest)

charred cloud
velvet hill
#

ctx.message.content

#

there you go

charred cloud
#
    @commands.command()
    @commands.has_guild_permissions(ban_members=True)
    async def count(self, ctx, start_number: int):
        await ctx.message.delete()
        def check(m):
            return ctx.channel == m.channel
        counter = start_number + 1
        URL = "MY WBBHOOK"
        while not counting_state.STOPPED:
            try:
                msg = await self.bot.wait_for('message', check=check)
                # print(msg.content)
                if not msg.author.id == 943171320542269470:
                    if str(counter) in str(msg.content):
                        counter += 1
                        await msg.delete()
                        urls = re.findall(
                            'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', msg.content.lower())
                        if not urls:
                            async with aiohttp.ClientSession() as session:
                                webhook = Webhook.from_url(URL, session=session)
                                await webhook.send(content=msg.content,avatar_url=msg.author.avatar,username=msg.author.name,allowed_mentions=discord.AllowedMentions(everyone=False, users=False, roles=False, replied_user=False))
                        else:
                            async with aiohttp.ClientSession() as session:
                                webhook = Webhook.from_url(URL, session=session)
                                await webhook.send(content=int(counter)-1,avatar_url=msg.author.avatar, username=msg.author.name,allowed_mentions=discord.AllowedMentions(everyone=False, users=False, roles=False, replied_user=False))
                    else:
                        await msg.delete()
            except Exception as e:
                print(e)
                pass
        else:
            counting_state.STOPPED = False
            return```
#

msg = await self.bot.wait_for('message', check=check)
For some reasons i do not get every message with this method

quasi socket
#

be more precise please

charred cloud
velvet hill
#

but with a command

charred cloud
#

Yes

#

It is not gettin evry msgs as i said

#

@velvet hill

shut canyon
#

If I had to guess it would be because the previous message had not finished processing. By the time the next message is sent.

#

you could either use on_message or try to make the message listening async

charred cloud
shut canyon
#

No, Its a hard problem to solve. It just like you said, you are not catching all of the messages because they are coming in to fast for the wait_for to catch than finish the while loop again than wait_for again

charred cloud
#

@shut canyon I fixed thanks to a on_message function. Thanks for the idea :D

shut canyon
#

np

charred cloud
#

How do i close this chat? @shut canyon

shut canyon
#

You can do to the 3 dots at the top right of the screen and click archive post.

#

Im making a command for @strange swan that will just have to use /close in the future :)