S
S
stepan-neretin72020-04-18 17:03:33
Python
stepan-neretin7, 2020-04-18 17:03:33

How to run discord.py without creating your own class?

5e9b07d4c0d17301664182.png
As we know, in order to work with the discord api in the discord.py library, we need to create a class and then run it

client = MyClient()
client.run('token')

But the question arises, is it possible to make a single request without creating a class?

I just need to get the id of all channel users
in the api.

async def on_message(self, message):
        print("Message from {0.author}: {0.content}".format(message))
        text = message.content.lower()
        if "!users" in text and message.author.bot is False:
            b = client.get_guild(699352136273887292)
            users = []
            for member in b.members:
                user = client.get_user(member.id)
                if user.bot:
                    continue
                users.append(str(member.id))
            print(users)


That is, I need to be able to do exactly the same code as I showed above without creating a class with methods where I catch events. I would be
grateful for any hints, thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew, 2020-04-18
@deepblack

create a class and then run it

client = MyClient()
client.run('token')

This is not creating a class and running it,
but creating an object of the class and calling the .
make a single request, I need to get the id of all users of the channel in the API

Look at the dock for the Discord API and write your own wrapper over it
for the necessary methods.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question