def execute(commands: list) -> int: my_token: str = '' # Your personal or bot token channel_id: str = '' # Channel to post into bot_id: str = '' # UnbelievaBoat # Login bot = discum.Client(token=my_token, log={ 'console': False, 'file': 'log.txt' }, user_agent='random') # Execute each command and wait five seconds for command in commands: bot.sendMessage(channel_id, f'<@!{bot_id}> {command}') time.sleep(5) return 0
'python', 'bots/misc/joinServer.py', email, password, inviteLink, useBrowser ], shell=True) p.wait() else: p = subprocess.Popen([ 'python', 'bots\misc\joinServer.py', email, password, inviteLink, useBrowser ], shell=False) p.wait() if (os.path.exists("proxies.txt")): # Checking root folder for proxies bot = discum.Client(email=email, password=password, token="none", proxy_host=pnp[0], proxy_port=pnp[1], log=discumLog) else: bot = discum.Client(email=email, password=password, token="none", log=discumLog) else: if autojoinServer == True: if sys.platform == "win32": p = subprocess.Popen([ pythonCommand, 'bots\misc\joinServer2.0.py', token, inviteLink, sys.argv[3] ], shell=True)
#not receiving messages from large guilds? simply run bot.gateway.subscribeToGuildEvents(wait=1) while #the gateway is running and then you'll get messages from those large guilds import discum bot = discum.Client(token='ur token', log=False) @bot.gateway.command def helloworld(resp): if resp.event.ready_supplemental: bot.gateway.subscribeToGuildEvents(wait=1) if resp.event.message: m = resp.parsed.auto() guildID = m[ 'guild_id'] if 'guild_id' in m else None #because DMs are technically channels too channelID = m['channel_id'] username = m['author']['username'] discriminator = m['author']['discriminator'] content = m['content'] print("> guild {} channel {} | {}#{}: {}".format( guildID, channelID, username, discriminator, content)) bot.gateway.run()
# Keep in mind that there's no actual api endpoint for users to get guild members. # So, to get guild members, we have to request for and read the member list. # This is all handled with the bot.gateway.fetchMembers(...) function :) . This function can either be run while the gateway is connected or before the gateway connects. # Note, you'll need to connect to the gateway to get the member list. # An example usage is below. The Guild and Channel ids used are from the fortnite server (652k members, around 150k of those are actually fetchable). # The number of fetchable members changes from time to time. # https://github.com/Merubokkusu/Discord-S.C.U.M/blob/master/docs/using.md#fetch-guild-members import discum bot = discum.Client(token='your token') def close_after_fetching(resp, guild_id): if bot.gateway.finishedMemberFetching(guild_id): lenmembersfetched = len(bot.gateway.session.guild( guild_id).members) #this line is optional print(str(lenmembersfetched) + ' members fetched') #this line is optional bot.gateway.removeCommand(close_after_fetching) bot.gateway.close() def get_members(guild_id, channel_id): bot.gateway.fetchMembers(guild_id, channel_id) bot.gateway.command({ 'function': close_after_fetching, 'params': { 'guild_id': guild_id } }) bot.gateway.run()
p = subprocess.Popen([ 'python', 'bots/misc/joinServer.py', email, password, inviteLink, useBrowser ], shell=True) p.wait() else: p = subprocess.Popen([ 'python', 'bots\misc\joinServer.py', email, password, inviteLink, useBrowser ], shell=False) p.wait() if (os.path.exists("proxies.txt")): # Checking root folder for proxies bot = discum.Client(email=email, password=password, token="none", proxy_host=sys.argv[3]) else: bot = discum.Client(email=email, password=password, token="none") else: if autojoinServer == True: if sys.platform == "win32": p = subprocess.Popen([ pythonCommand, 'bots\misc\joinServer2.0.py', token, inviteLink, sys.argv[3] ], shell=True) p.wait() else: p = subprocess.Popen([ pythonCommand, 'bots\misc\joinServer2.0.py', token, inviteLink,
''' working get-guild-members function This will get all the guild members that your client can see (from the members sidebar). This will eventually (maybe a few days, idk) be put into discum, made prettier (cause this code looks horrendous rn ngl), and get optimized, but I just wanted to upload this now cause I'm happy it works lol. ''' #notice how all these variables are bot.something #That's done so that the decorated getGuildChannelMembers function can access them while running. When I add a getGuildChannelMembers or getGuildMembers function it'll look a lot prettier ofc. import discum bot = discum.Client(token=token) bot.memberlist = [] bot.memberRanges = False bot.index = 0 #set guild and channel variables bot.guildID = "713308757529985086" bot.channelID = "713309316052156536" #you need to specify a channel ID @bot.gateway.command def getGuildChannelMembers(resp): if resp['t'] == 'READY_SUPPLEMENTAL': #tells the program when to start requesting for guild members bot.memberRanges = bot.gateway.guildcommands.rangeCalc( bot.gateway.session.guild(bot.guildID).memberCount) if bot.memberRanges != False: if bot.index == 0: bot.gateway.guildcommands.listen( bot.guildID, bot.channelID,
active_servers = set(active_servers.split(",")) cur = sqlite3.connect(cdb).cursor() r = list(cur.execute("select id, name from texts")) names = list(set([x[1] for x in r])) input_str = "\n".join(names) name_maps = {x[0]: x[1] for x in r} zh_cur = sqlite3.connect(zh_cdb).cursor() zh_names = list( set([str(x[0]) + ":" + x[1] for x in zh_cur.execute("select id, name from texts")]) ) zh_input_str = "\n".join(zh_names) bot = discum.Client( token=discord_token, log=False, ) my_guilds = bot.getGuilds().json() print(my_guilds) servs = [] for serv in active_servers: for guild in my_guilds: if serv == guild["id"]: print(f'active on \x1b[31;1m{guild["name"]}\x1b[0m') servs.append(serv) break if not servs: print("active_servers empty") sys.exit(1) active_servers = set(servs)
#login using remote authentication (install discum[ra] first) import discum bot = discum.Client(remoteAuth=True) #or login normally and run this: bot.initRA() #now you can use the remote authentication functions, for example: #this sends the qr code image in a message #note that qr codes expire after 5 mintues @bot.ra.command def test(response): if response["op"] == "pending_remote_init": bot.sendFile("channel id here", bot.ra.fingerprint + '.png') bot.ra.run() #if no filename is specified, {fingerprint}.png is assumed
def login(self, token): self.client = discum.Client(token=token, log=False) self.token = token print("Logging in")
import os try: os.system("pip3 install discum") import discum except: print("h") bot = discum.Client(token=os.getenv("TOKEN1")) def close_after_fetching(resp, guild_id): if bot.gateway.finishedMemberFetching(guild_id): lenmembersfetched = len(bot.gateway.session.guild( guild_id).members) #this line is optional print(str(lenmembersfetched) + ' members fetched') #this line is optional bot.gateway.removeCommand({ 'function': close_after_fetching, 'params': { 'guild_id': guild_id } }) bot.gateway.close() def get_members(guild_id, channel_id): bot.gateway.fetchMembers( guild_id, channel_id, keep="all", wait=1) #get all user attributes, wait 1 second between requests bot.gateway.command({ 'function': close_after_fetching, 'params': {
#we can pass in the bot object into the closeAfterReadySupp gateway function. import discum with open("tokenlist.txt") as f: tokenlist = f.read().splitlines() def closeAfterReadySupp(resp, bot): if resp.event.ready_supplemental: bot.gateway.close() clients = [] for i in range(len(tokenlist)): if i == 0: clients.append(discum.Client(token=tokenlist[0])) build_num = clients[0]._Client__super_properties['client_build_number'] else: clients.append(discum.Client(token=tokenlist[i], build_num=build_num)) clients[i].gateway.command({ "function": closeAfterReadySupp, "params": { "bot": clients[i] } }) #add closeAfterReadySupp to each bot #now for the fun part #we use threading to make it run fast. You can use multiprocessing or subprocess if you'd like to instead. This is just one implementation. import threading