async def revision(self, ctx): embed = discord.Embed(color=0xf54242, title="Revision") embed.add_field(name="Date", value=time.strftime("%d.%m.%Y"), inline=False) embed.add_field(name="Bor Version", value=default.config()["version"]) embed.add_field(name="Discord.py Version", value=discord.__version__) embed.add_field(name="Python Version", value=platform.python_version()) print(platform.version()) await ctx.send(embed=embed)
import os import discord from utils import default from utils.data import Bot, HelpFormat config = default.config() print("Logging in...") bot = Bot( command_prefix=config["prefix"], prefix=config["prefix"], owner_ids=config["owners"], command_attrs=dict(hidden=True), help_command=HelpFormat(), intents=discord.Intents( # kwargs found at https://discordpy.readthedocs.io/en/latest/api.html?highlight=intents#discord.Intents guilds=True, members=True, messages=True, reactions=True, presences=True ) ) for file in os.listdir("cogs"): if file.endswith(".py"): name = file[:-3] bot.load_extension(f"cogs.{name}") try: bot.run(config["token"]) except Exception as e: print(f'Error when logging in: {e}')
def __init__(self, bot): self.bot = bot self.config = default.config() self._last_result = None
def __init__(self, bot): self.bot = bot self.config = default.config() self.alex_api_token = self.config["alexflipnote_api"]
def __init__(self, bot): self.bot = bot self.config = default.config() self.content_fetch_api = self.config["content_fetch_api"]
def __init__(self, bot): self.bot = bot self.config = default.config() self.process = psutil.Process(os.getpid())
def __init__(self, bot): self.bot = bot self.config = default.config() self.executor = concurrent.futures.ThreadPoolExecutor(max_workers=1) self.log_dog = ValheimLogDog(self.bot) self.start_log_dog()
def __init__(self, bot): self.bot = bot self.config = default.config()
import discord from utils import default from discord.ext import commands owners = default.config()["owners"] def is_owner(ctx): """ Checks if the author is one of the owners """ return ctx.author.id in owners async def check_permissions(ctx, perms, *, check=all): """ Checks if author has permissions to a permission """ if ctx.author.id in owners: return True resolved = ctx.channel.permissions_for(ctx.author) return check( getattr(resolved, name, None) == value for name, value in perms.items()) def has_permissions(*, check=all, **perms): """ discord.Commands method to check if author has permissions """ async def pred(ctx): return await check_permissions(ctx, perms, check=check) return commands.check(pred)
def __init__(self): self.config = default.config() self._connection = self.connect()
def __init__(self): self.version = "1.1.0" config = default.config() # Calling func from Utils\deafault.py self.key = config[ "APIKey"] # Enter API key here (Without doing so you will 100% get a 401 or 404 error) if self.key == "": self.key = input( "Before continuing please type in your SteamAPI key") self.url = f"https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key={self.key}&steamids=" steamID = 0 # This loop catches the wrong type of steamID and stops the code from crashing if so. while True: try: steamID = int( input( "Please enter a valid Steam64 ID, (NOTE: any other form of ID will not work) \n" ) ) #Cause people may enter thr wrong type of steamID, this catches it except ValueError: print("Could not find user, returning to input\n\n\n\n") time.sleep(3) continue # The cycle continues (Bo2 references Ftw) else: break # Break cycle steamIDStr = str( steamID ) #Converts the variable int from the above test into a str so it registers in the url resp = requests.get(self.url + steamIDStr) # HTTP checking due to servers being inconsistant if resp.status_code == 200: print( "Successfully authorized by server/Key access is granted\n\n\n\n" ) time.sleep(3) if resp.status_code != 200: print( f"\n\n\n\nHTTP Error {resp.status_code}, please try again or contact the developer" ) time.sleep(3) Steam() # API Parser (Make into a function for better optimization upon next update) url = resp data = url.text parsed = json.loads(data) if not parsed['response'][ 'players']: # Catches wrong stem IDs and loops back to start to stop code from crashing lolol print("Invalid Steam64 ID, please try again\n") Steam() steamID = parsed["response"]["players"][0]["steamid"] pname = parsed["response"]["players"][0]["personaname"] avatar = parsed["response"]["players"][0]["avatarfull"] pfurl = parsed["response"]["players"][0]["profileurl"] # Due to certain areas of the API not returning any Dict when keyvalue is None, had to loop to see if a players "fullname" was there. fname = parsed.get("response", {}).get("players", [{}])[0].get("realname", None) onstatus = parsed["response"]["players"][0]["personastate"] acc_creation = parsed["response"]["players"][0]["timecreated"] lastlog = parsed["response"]["players"][0]["lastlogoff"] created = (datetime.fromtimestamp(acc_creation) - timedelta(hours=2)).strftime('%Y-%m-%d %H:%M:%S') logoff = ( datetime.fromtimestamp(lastlog) - timedelta(hours=2) ).strftime( '%Y-%m-%d %H:%M:%S' ) # By default, steam uses UNIX time to measure, making Vars to normalize to GMT # SteamAPI gives variable online status, this sorts the value of key into a response if onstatus == 1: bar = "Online" elif onstatus == [2, 3, 4]: bar = "Busy/Away/Snoozing" elif onstatus == [5, 6]: bar = "Looking to play/Trade" else: bar = "Offline/Private" print( f"Steam64 ID: {steamID} \n PersonaName: {pname} \n Link to full avatar:{avatar}\n Real-Name: {fname}\n Profile URL: {pfurl}\n Online Status: {bar}\n Account creation: {created}\n Last Steam Log off: {logoff}" ) foo = input("\nType 'yes' to input another users ID\n") if 'yes' in foo: Steam() else: print( f"\n\n\nThank you for using the SteamAPI console v{self.version} made by 5ifty" ) time.sleep(5) quit()
import discord import requests from discord.ext import commands from utils import default config_weather = default.config("weather") class Weather(commands.Cog): def __init__(self, bot): self.bot = bot # do u like to check weather??? @commands.command() async def weather(self, ctx, *, city="Анадырь"): api_key = config_weather["api_key"] base_url = config_weather["base_url"] city_name = city complete_url = base_url + "appid=" + api_key + "&q=" + city_name response = requests.get(complete_url) j_response = response.json() if j_response["cod"] != "404": response_main = j_response["main"] response_wind = j_response["wind"] response_clouds = j_response["clouds"]
import discord from discord.ext import commands from pymongo import MongoClient from utils import default, logging_tools as LOG config = default.config("database") cluster = MongoClient(config["mongo_cluster_url"]) db = cluster[config["mongo_database"]] class Schedule(commands.Cog): def __init__(self, bot): self.bot = bot @commands.command() async def schedule(self, ctx, *, group): async with ctx.channel.typing(): group = group.replace(" ", "_") group = group.lower() collection = db[group] embed = discord.Embed(color=0xf3d865, title=f"Schedule for {group[:2].upper()} !", description=f"Week: {group[7:]}") for day in range(6): day_schedule = str()