def __init__(self, bot): self.bot = bot self.channelDb = md.mongoConnection("127.0.0.1", "Channels", "JoinedChannels") self.openDotaDb = md.mongoConnection("127.0.0.1", "OpenDota", "OpenDotaServices") self.open_dota_task.start()
def __init__(self, bot): self.bot = bot self.channelDb = md.mongoConnection("127.0.0.1", "Channels", "PoeChannels") self.pathDB = md.mongoConnection('127.0.0.1', 'Pathofexile', 'Pathdatabase') self.pathAccount = md.mongoConnection("127.0.0.1", 'Pathofexile', 'Account') self.lastActive = md.mongoConnection("127.0.0.1", 'Pathofexile', 'lastActive')
def return_guild_db(self): return md.mongoConnection("127.0.0.1", 'Pathofexile', 'Account')
from discord.ext import commands import mongoDriver as md from twitch import TwitchClient import config twitchDb = md.mongoConnection('127.0.0.1', 'TwitchInfo', 'Twitchusers') class AddTwitch(commands.Cog): def __init__(self, bot): self.bot = bot @commands.command() async def live(self, ctx, arg): vars = twitchDb.getAllDocuments() twitch_name = None for item in vars: if arg == item['username']: twitch_name = item twitch_id = twitch_name['user_id'] client = TwitchClient(config.twitch_client) channel = client.streams.get_stream_by_user(twitch_id) if channel == None: await ctx.send(twitch_name['username'] + " is not live right now") else: await ctx.send(twitch_name['username'] + " is live right now!") @commands.command()
from discord.ext import commands import time import json import requests import mongoDriver as md acctIdDb = md.mongoConnection("127.0.0.1", "matchDatabase", "Users") lastMatchDb = md.mongoConnection("127.0.0.1", "matchDatabase", "lastMatches") twitchDb = md.mongoConnection('127.0.0.1', 'TwitchInfo', 'Twitchusers') class OpenDota(commands.Cog): def __init__(self, bot): self.bot = bot @commands.command() async def getrecent(self, ctx, arg): isAccountId = False try: input = int(arg) isAccountId = True except: pass if isAccountId: recent = requests.get("https://api.opendota.com/api/players/" + str(arg) + "/recentMatches") await ctx.send("getting recent matches...") time.sleep(2) json_data = json.loads(recent.text) match_id = json_data[0]['match_id']
def return_guild_db(self, guild_id): return md.mongoConnection("127.0.0.1", "OpenDotaGuildDatabases", str(guild_id))
import botMain from discord.ext import commands import time import mongoDriver as md import discord guildDb = md.mongoConnection("127.0.0.1", "Channels", "JoinedChannels") class Utilities(commands.Cog): def __init__(self, bot): self.bot = bot @commands.command() async def runtime(self, ctx): """ Usage !runtime """ current_time = (time.time() - botMain.Bot.start_time) / 3600 print('Bot has been running for: {0:.2f} hours'.format(current_time)) await ctx.send( 'Bot has been running for: **{0:.2f}** hours'.format(current_time)) @commands.Cog.listener() async def on_guild_join(self, guild): temp = {} temp['guild_id'] = guild.id temp['guild_name'] = guild.name temp['guild_owner_id'] = guild.owner_id temp['base_text_channel'] = guild.text_channels[0].id temp['join_time'] = time.time() guildDb.insertOne(temp)
from discord.ext import commands import mongoDriver as md import json acctIdDb = md.mongoConnection("127.0.0.1", "matchDatabase", "Users") lastMatchDb = md.mongoConnection("127.0.0.1", "matchDatabase", "lastMatches") servicesDb = md.mongoConnection("127.0.0.1", "OpenDota", "OpenDotaServices") class AddDota(commands.Cog): def __init__(self, bot): self.bot = bot @commands.command() async def enableOpenDotaApi(self, ctx): empty_follows_account = {'accounts': []} empty_account_string = json.dumps(empty_follows_account) guild_obj = {} guild_obj['guild_id'] = ctx.guild.id guild_obj['followed_accounts'] = empty_account_string servicesDb.insertOne(guild_obj) @commands.command() async def test(self, ctx): steve_guild = self.bot.get_guild(584036142295285794) jorge_guild = self.bot.get_guild(547669771450187776) @commands.command() async def adduser(self, ctx, user, acct_id): acct_id = acct_id