async def on_ready(self): if not hasattr(self, 'startup_time'): self.startup_time = datetime.now() # add dblpy updater self.dblpy = dbl.Client(self, dbl_key) await self.update_dbl() log.info('Connected, starting setup') log.info('Connecting to database') self.db = await setup_db(db_bind, loop=self.loop) log.info('Initializing aiohttp') self.aiohttp = aiohttp.ClientSession( loop=self.loop, timeout=aiohttp.ClientTimeout(total=4)) self.remove_command('help') # load extensions for extension in extensions: log.info(f'Loading extension: {extension}') self.load_extension(extension) await self.change_presence(activity=discord.Game(name='.help')) log.info('Finished!')
def __init__(self, client=None): # set up parser to config through our .ini file with our discordbots.org api token config = configparser.ConfigParser() api_token_path = Path("tokens/token_dbo_api.ini" ) # use forward slash "/" for path directories # confirm the token is located in the above path, then setup DBL client and execute update_stats if api_token_path.is_file(): config.read(api_token_path) # we now have the client's token token = config.get('DBL_API', 'token') self.token = token # set this to your DBL token # only setup a loop to update server count to API when client is passed in constructor if client: self.client = client self.dblpy = dbl.Client(self.client, self.token, loop=client.loop) self.updating = client.loop.create_task(self.update_stats()) # if the file doesn't exist with the api token, do not attempt to use discordbots.org API else: print("\nWarning: discordbots.org token not found at: ", api_token_path) print( "client will continue to run without DiscordBotsOrgApi support." )
def __init__(self, bot): self.bot = bot self.base_url = f"https://bots.discord.pw/api/bots/{bot.user.id}/stats" self.headers = { "User-Agent": "Belphegor", "Authorization": token.DBOTS_TOKEN, "content-type": "application/json" } self.dbl = dbl.Client(self.bot, token.DBL_TOKEN)
def __init__(self, bot): super().__init__(bot) self.bot.server.add_listener(self.on_vote) self._token = self.bot.config.dbl_token self.update_task = None self.dbl = None if not self.bot.test_mode: self.dbl = dbl.Client(self.bot, self._token, loop=bot.loop) self.update_task = self.bot.loop.create_task(self.update_stats())
def __init__(self, bot): self.bot = bot self.statuses = { 'online': '<:dot_online:420205881200738314>', 'offline': '<:dot_invis:420205881272172544>', 'dnd': '<:dot_dnd:420205879883726858>', 'idle': '<:dot_idle:420205880508809218>' } self.dbl = dbl.Client(self.bot, self.bot._config.get("DBL", "value")) self.bot.loop.create_task(self.update_dbl()) self.bot.loop.create_task(self.expiry_check())
async def initialise(config, steam_api_key, db): await bot.login(token=config["token"], bot=True) asyncio.ensure_future(bot.connect(reconnect=True)) await bot.wait_until_ready() bot.db = db bot.steam_api_key = steam_api_key if config.get("dbl_token", ""): bot.dbl = dbl.Client(bot, config["dbl_token"]) bot.dbl.bot_id = bot.user.id await bot.dbl.post_server_count() else: bot.dbl = None await update_status() return bot
def init_discordbots(self): """Initialize stats posting to the bot lists and vote recognition. This also registers a webhook to track votes. If DiscordBot credentials are not set, then it will be disabled. """ if self.dbl_api_key: credentials = { "token": self.dbl_api_key, "bot": self.bot, "autopost": True, "webhook_auth": self.dbl_webhook_auth, "webhook_path": self.dbl_webhook_path, "webhook_port": self.dbl_webhook_port } self.dbl = dbl.Client(**credentials)
def __init__(self): super().__init__(self.getprefix) self.config = config self.init = INIT self.redis = None self.db = None self.dbl_client = dbl.Client(self, self.config.DBL) self.ipc = utils.IPC(self) self.prepared = asyncio.Event(loop=self.loop) self.process = psutil.Process() self.session = aiohttp.ClientSession() self.confirmation_invocation = [] self.in_tutorial = [] self.unload_complete = [] self.blacklist = {} self.prefixes = {} self.add_check(self.blacklist_check) self.prepare_extensions()
def __init__(self, bot): self.bot = bot self.token = config.dbl_token self.dblpy = dbl.Client(self.bot, self.token, loop=self.bot.loop) self.bot.loop.create_task(self.update_stats())
def __init__(self, bot): self.bot = bot self.token = os.getenv('DISCORDBOTSORG_TOKEN') # set this to your DBL token self.dblpy = dbl.Client(self.bot, self.token) self.bot.loop.create_task(self.update_stats())
def __init__(self, bot): self.bot = bot self.token = bot.myconfig["dbl_token"] # set this to your DBL token # print(self.token) self.dblpy = dbl.Client(self.bot, self.token) self.updating = self.bot.loop.create_task(self.update_stats())
def __init__(self, client): self.client = client self._token = os.environ["DISCORD_BOT_ORG_TOKEN"] self._dblpy = dbl.Client(self.client, self._token) self.client.loop.create_task(self.update_stats())
def __init__(self, bot: Red): self.bot = bot self.token = 'token' # set this to your DBL token self.dblpy = dbl.Client(self.bot, self.token) self.bot.loop.create_task(self.update_stats())
def __init__(self, client): self.client = client self.token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjI3MjI2MDA2Mjc5MjEyMjM2OCIsImJvdCI6dHJ1ZSwiaWF0IjoxNTY0MjQ5NjkzfQ.KHXeQJYvlm2OH9AvQ7RlIihwjfQnIsWr8q4hXK-JU6k' # set this to your DBL token self.dblpy = dbl.Client(self.client, self.token, webhook_path='/dblwebhook', webhook_auth='gryphticon123', webhook_port=5000) self.updating = self.client.loop.create_task(self.update_stats())
def __init__(self, bot): self.bot = bot self.token = dbexec("dbotsApiKey", log=True) self.dblpy = dbl.Client(self.bot, self.token) self.bot.loop.create_task(self.update_stats())
def __init__(self, bot): self.bot = bot self.token = self.bot.discordbotsapi # set this to your DBL token self.dblpy = dbl.Client(self.bot, self.token) self.bot.loop.create_task(self.update_stats())
def __init__(self, *args, **kwargs): super(Bot, self).__init__(*args, **kwargs) self.dbl = dbl.Client(bot=self, token=CONFIG['dbl_api_token']) self.loop.create_task(self._update_stats())
def __init__(self, bot, dbl_token): self.bot = bot self.dblpy = dbl.Client(self.bot, dbl_token) self.bot.loop.create_task(self.update_stats())
def __init__(self, bot): self.bot = bot self.token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjQ0OTIzNjU3MjQ5MjAwNTM5NiIsImJvdCI6dHJ1ZSwiaWF0IjoxNTMwMjA2Mzc4fQ.9NQP0w5Ze9zbuhPInXa1PFwNNDU8j7ARQ2qQK0urIRo' self.dblpy = dbl.Client(self.bot, self.token) self.bot.loop.create_task(self.update_stats())
def __init__(self, bot: Bot, token: str): self.bot = bot self.token = token self.dbl_client = dbl.Client(self.bot, self.token)
def __init__(self, client): self.client = client self.token = os.getenv('DBLT') # set this to your DBL token self.dblpy = dbl.Client(self.client, self.token) self.client.loop.create_task(self.update_stats())
def __init__(self, bot): self.bot = bot self.token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYyNDgyOTQ0NDk2MzY5NjY2MCIsImJvdCI6dHJ1ZSwiaWF0IjoxNTY5NDUwNzQzfQ.znNOAGSkl0dyExGwQpBXXle3bV7LO3w53-bNMoFnPZA' # set this to your DBL token self.dblpy = dbl.Client(self.bot, self.token) self.updating = self.bot.loop.create_task(self.update_stats())
def __init__(self, autochannel): self.autochannel = autochannel self.token = self.autochannel.dbl_token self.dblpy = dbl.Client(self.autochannel, self.token) self.updating = self.autochannel.loop.create_task(self.update_stats())
insultfile = open(sfwinsult_absPath) insultlist = insultfile.read().splitlines() insultCount = len(insultlist) insultfile.close() nsfwinsult_relPath = "Lists/nsfwinsults.list" nsfwinsult_absPath = os.path.join(root_dir, nsfwinsult_relPath) nsfwinsultfile = open(nsfwinsult_absPath) nsfwinsultlist = nsfwinsultfile.read().splitlines() nsfwInsultCount = len(nsfwinsultlist) nsfwinsultfile.close() # Instances client = discord.Client() translator = Translator() botlist = dbl.Client(client, config["bltoken"]) wolframClient = wolfram.Client(config["wolframapi"]) # Prefix things defaultPrefix = ";" # Trivia instantiation question_relPath = "Lists/trivia_questions.list" questionPath = os.path.join(root_dir, question_relPath) answer_relPath = "Lists/trivia_answers.list" answerPath = os.path.join(root_dir, answer_relPath) trivia = trivia.triviaGame(questionPath, answerPath) isSent = False # Eight ball instantiation eight = EightBall.eightBallGenerator()
time_zone_input, title_input, )) apollo.add_cog(HelpCommand(apollo, help_embed)) apollo.add_cog(PrefixCommand(apollo)) apollo.add_cog(RoleCommand(apollo)) apollo.add_cog(TimeZoneCommand(apollo, time_zone_embed, time_zone_input)) apollo.add_cog( EditCommand( apollo, sync_event_channels, event_selection_input, title_input, description_input, capacity_input, selection_input, start_time_input, update_event, events_for_user, )) # Add checks apollo.add_check(NotEventChannel(apollo)) # Add tasks if env == "production": apollo.add_cog( SyncDiscordBots(apollo, dbl.Client(apollo, os.getenv("DBL_TOKEN")))) apollo.run(os.getenv("BOT_TOKEN"), reconnect=True)
def __init__(self, bot): self.bot = bot self.token = config.dbots_key self.dblpy = dbl.Client(self.bot, self.token)
def __init__(self, bot): self.bot = bot self.token = config['dbl'] self.dblpy = dbl.Client(self.bot, self.token) self.bot.loop.create_task(self.update_stats())
#Directory stuff root_dir = os.path.dirname(__file__) #Auth tokens tokenfile = open("auth_token.txt", "r") rawtoken = tokenfile.read().splitlines() token = rawtoken[0] bltokenfile = open("dbl_token.txt", "r") rawbltoken = bltokenfile.read().splitlines() bltoken = rawbltoken[0] shardCount = 1 #Keeping it simple with 1 for now. client = discord.Client() translator = Translator() botlist = dbl.Client(client, bltoken) defaultPrefix = ";" def getServerPrefix(guild): #Returns the server prefix. #If there is no server prefix set, it returns the defaultPrefix. prefixFile = open("server_prefixes.txt", "r+") prefixList = prefixFile.read().splitlines() prefixFile.close() serverInList = False for line in prefixList: splitLine = line.split() if guild.id == int(splitLine[0]): serverInList = True
def __init__(self, bot): self.bot = bot self.token = os.environ['DBL_TOKEN'] self.dbl_py = dbl.Client(self.bot, self.token) self.bot.loop.create_task(self._update_stats())
def __init__(self, bot): self.bot = bot self.bot_id = None self.token = 'dbl_token' # set this to your DBL token self.dblpy = dbl.Client(self.bot, self.token)