Created
November 15, 2017 20:06
-
-
Save ErikBoesen/e0e1bab5593662bfd7434eeed76a8d34 to your computer and use it in GitHub Desktop.
Given a file ./tokens.txt containing many Discord bot tokens, this script will attempt login with each, and write valid tokens (plus their names and how many servers they're in) to ./valid.csv.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import discord | |
import asyncio | |
class Bot(discord.Client): | |
def __init__(self, token): | |
super().__init__() | |
self.token = token | |
print('%s->' % token, end='') | |
async def on_ready(self): | |
"""Run when the bot is ready.""" | |
print('%s#%s' % (self.user.name, len(self.servers))) | |
with open('valid.csv', 'a+') as f: | |
f.write('%s,%s,%s\n' % (self.token, self.user.name, len(self.servers))) | |
await self.logout() | |
if __name__ == '__main__': | |
with open('tokens.txt') as f: | |
tokens = [token for token in f.read().split('\n') if token] | |
with open('valid.csv') as f: | |
f.write('token,name,servers') | |
loop = asyncio.get_event_loop() | |
bots = [] | |
for token in tokens: | |
bots.append(Bot(token)) | |
try: | |
loop.run_until_complete(bots[-1].start(token)) | |
except discord.errors.LoginFailure: | |
print('BAD TOKEN') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ok