Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help: Multi token support? #22

Closed
callihann opened this issue Jan 30, 2021 · 4 comments
Closed

Help: Multi token support? #22

callihann opened this issue Jan 30, 2021 · 4 comments

Comments

@callihann
Copy link

Hi! Are multiple tokens supported? If not that seems like a relatively simple thing to implement.

@callihann callihann changed the title Multi token support? Suggestion/Help: Multi token support? Jan 30, 2021
@callihann
Copy link
Author

callihann commented Jan 30, 2021

If it is possible could you provide an example with an implementation?


hey it's arandomnewaccount replying by editing (cause my acc is hidden):
Multiple tokens are supported. You'll just have to initialize multiple discum.Client objects:

bot0 = discum.Client(token='user0')
bot1 = discum.Client(token='user1')
bot2 = discum.Client(token='user2')

I suppose if you had a large list of tokens and you wanted to automatically initialize clients for all of them, you could like this:

clients = []
for token in tokenlist:
    clients.append(discum.Client(token=token))

and then do clients[some_index_idk].sendMessage(...) or whatever function you're using.

...
Another edit:
I'll be closing this issue in a few hours unless you have more questions/issues related to this.

@callihann
Copy link
Author

Sorry to reopen this, I don't really understand how to implement this. I am trying to import tokens from a json file and want to automatically initialize it. RIght now I have this:
`
with open ('tokens.json') as f:
data= json.load(f)

clients = []
for token in data:
clients.append(discum.Client(token=Tokens))
async def first():
clients.getGuilds()
print("initializing...")
`

When I run this I get the error Token is not defined. Sorry to bother you!

@callihann
Copy link
Author

callihann commented Feb 1, 2021

The formatting is a little messed up sorry.


arandomnewaccount:
no problem. Here's a "fixed" version:

with open('tokens.json') as f:
    data= json.load(f)

print("initializing...")
clients = []
for token in data:
    clients.append(discum.Client(token=token))

Now, I'm not entirely sure about your "clients.getGuilds()" line since clients is a list (see code above). If you'd like to get the guilds a client is in, you'll have to connect to the websocket and then do clients[some_index].gateway.session.guildIDs.

Lemme know if that helps.

@callihann
Copy link
Author

Thank you so much! That resolved it. Thank you for humoring me. Have a good day!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@callihann and others