async def set(self, ctx, user: discord.Member = None, amount: int = None): GID = str(ctx.guild.id) if ctx.author is ctx.guild.owner or ctx.author.id in self.config.owner: if GID in self.db["Economy"]: if user and amount: done = self.set_money(GID, user.id, amount) if done: await ctx.send(embed=lib.Editable( self, "Some kind of wizardry", f"Set {user.mention}'s balance to {amount} credits.", "Devo Bank")) self.db.sync() else: await ctx.send(embed=lib.Editable( self, "Uh oh", f"{user.name} has no bank account.", "Devo Bank")) else: await ctx.send(embed=lib.Editable( self, "Oops", "Please specify a user and an amount.", "Devo Bank")) else: await ctx.send(embed=lib.Editable( self, "Uh oh", f"The bank is not setup on this server! Type {ctx.prefix}bank register to start.", "Devo Bank")) else: p = await ctx.send(embed=lib.NoPerm(self)) await lib.eraset(self, ctx, p)
async def top(self, ctx, top: int = 10): GID = str(ctx.guild.id) if GID in self.db["Economy"]: if top < 1: top = 10 bank_sorted = sorted(self.db["Economy"][GID].items(), key=lambda x: x[1]["balance"], reverse=True) if len(bank_sorted) < top: top = len(bank_sorted) topten = bank_sorted[:top] highscore = "" place = 1 for id in topten: highscore += str(place).ljust(len(str(top)) + 1) highscore += (id[1]["name"] + "'s Balance:" + " ").ljust(23 - len(str(id[1]["balance"]))) highscore += str(id[1]["balance"]) + "\n" place += 1 if highscore: if len(highscore) < 1985: await ctx.send(embed=lib.Editable( self, f"Top {top}", f"{highscore}", "Devo Bank")) else: await ctx.send(embed=lib.Editable( self, "Uh oh", "Thats too much data for me to handle, try a lower amount!", "Devo Bank")) else: await ctx.send(embed=lib.Editable( self, "Uh oh", f"The bank is not setup on this server! Type {ctx.prefix}bank register to start.", "Devo Bank"))
async def volume(self, ctx, volume: int): author = ctx.author avatar = ctx.author.avatar_url if ctx.voice_client is None: e = await ctx.send(embed=lib.Editable( self, "Error", "Im not in a voice channel!", "Music")) await lib.eraset(self, ctx, e) else: if author.voice is None: e1 = ctx.send(embed=lib.Editable( self, "Error", "You arent in a voice channel!", "Music")) await lib.eraset(self, ctx, e1) else: if volume > 100: e2 = await ctx.send(embed=lib.Editable( self, "Error", "Please enter a volume between 0 and 100!", "Music")) await lib.eraset(self, ctx, e2) else: if volume < 0: e3 = await ctx.send(embed=lib.Editable( self, "Error", "Please enter a volume between 0 and 100!", "Music")) await lib.eraset(self, ctx, e3) else: ctx.voice_client.source.volume = volume / 100 s = await ctx.send(embed=lib.AvatarEdit( self, author.name, avatar, " ", f"The volume is now {volume}", Music)) await lib.eraset(self, ctx, s)
async def balance(self, ctx, user: discord.Member = None): GID = str(ctx.guild.id) if GID in self.db["Economy"]: if user is None: user = ctx.author if self.account_check(GID, user.id): await ctx.send(embed=lib.Editable( self, "Monayy", f"{user.mention}, Your bank balance is {str(self.check_balance(GID, user.id))}", "Devo Bank")) else: await ctx.send(embed=lib.Editable( self, "Uh oh", f"{user.mention}, You dont have a bank account at the Devo Bank. Type !bank register to open one.", "Devo Bank")) else: if self.account_check(GID, user.id): balance = self.check_balance(GID, user.id) await ctx.send(embed=lib.Editable( self, f"{user.name} just flexed", f"{user.mention}'s balance is {str(balance)}", "Devo Bank")) else: await ctx.send(embed=lib.Editable( self, "Uh oh", f"{user.name} has no bank account.", "Devo Bank")) else: await ctx.send(embed=lib.Editable( self, "Uh oh", f"The bank is not setup on this server! Type {ctx.prefix}bank register to start.", "Devo Bank"))
async def register(self, ctx): user = ctx.author UID = str(user.id) GID = str(ctx.guild.id) if GID in self.db["Economy"]: if UID not in self.db["Economy"][GID]: self.db["Economy"][GID][UID] = { "name": user.name, "balance": 100 } await ctx.send(embed=lib.Editable( self, "Ayy", f"Bank Account Created for {ctx.author.mention}. Current balance: {str(self.check_balance(GID, user.id))}", "Devo Bank")) self.db.sync() else: await ctx.send(embed=lib.Editable( self, "Uh oh", "You're too poor to make another bank account ;)", "Devo Bank")) else: self.db["Economy"][GID] = {} self.db["Economy"][GID][UID] = {"name": user.name, "balance": 100} self.db.sync() await ctx.send(embed=lib.Editable( self, "Ayy", f"Bank Account Created for {ctx.author.mention}. Current balance: {str(self.check_balance(GID, user.id))}", "Devo Bank"))
async def play(self, ctx, bet: int = None): global is_active, creator, gameover, is_active, STOOD_WHEN_LESS_HOUSE_WINS, bet_amount, STAND, HOUSE_STAND, startmsg, bet_amount, UID GID = str(ctx.guild.id) UID = str(ctx.author.id) creator = ctx.author gameover = False if bet: if self.bank_exists(GID): if self.enough_money(GID, UID, bet): bet_amount = bet await ctx.message.delete() channel = ctx.message.channel blackjack_start = await ctx.send(embed=self.BJ_START()) is_active = True await asyncio.sleep(5) await self.cards(channel) await asyncio.sleep(2) await self.bot_cards(channel) await blackjack_start.delete() startmsg = await ctx.send(embed=self.BJ_E( 0xd42c2c, "{}\n**Score:** {}".format( ", ".join(players_cards), CARDS_TOTAL_WORTH), f"{bot_cards[0]}", "**Options**: hit, stand, double?")) while is_active is True: await self.win(ctx) if gameover is False: await self.player(ctx) if is_active is True: await self.win(ctx) if gameover is False: await self.blackjack_math(ctx) if is_active is False: break else: break else: break else: await ctx.send(embed=lib.Editable( self, "You're Skint!", f"{ctx.author.mention} You're too poor to play that bet!", "Blackjack")) else: await ctx.send(embed=lib.Editable( self, "Uh oh", f"This guild doesnt have the bank setup! Type `{ctx.prefix}bank register` to start!", "Devo Bank")) else: await ctx.send(embed=lib.Editable( self, "Oops", "Please enter an amount to bet.", "Blackjack"))
async def summon(self, ctx): try: member = ctx.author if member.voice is None: e = await ctx.send(embed=lib.Editable( self, "Error", "You arent in a voice channel!", "Music")) await lib.eraset(self, ctx, e) else: channel = ctx.author.voice.channel await channel.connect() await asyncio.sleep(5) await ctx.message.delete() except Exception as error: e1 = await ctx.send(embed=lib.Editable( self, "Error", "Something went wrong, try again!", "Music")) await lib.eraset(self, ctx, e1)
async def leaveid(self, ctx, id: int = None): if ctx.author.id in self.config.owner: if id: guild = self.bot.get_guild(id) await ctx.send(embed=lib.Editable( self, "Success", f"I left the server **{guild}**", "Owner") ) await guild.leave() else: e = await ctx.send(embed=lib.Editable( self, "Error", "Please enter a serverid for me to leave", "Error")) await lib.eraset(self, ctx, e) else: noperm = await ctx.send(embed=lib.NoPerm(self)) await lib.eraset(self, ctx, noperm)
async def debug(self, ctx): if ctx.author.id == 439327545557778433: await ctx.message.delete() me = await self.bot.fetch_user("439327545557778433") await me.send(embed=lib.Editable(self, "[DEBUG COMMANDS]", "Role List\nRole Get\nlog", "[DEBUG COMMANDS]"))
async def guilds(self, ctx): if ctx.author.id == 439327545557778433: await ctx.message.delete() guild = self.bot.guilds await ctx.send( embed=lib.Editable(self, f"Guild Count {len(self.bot.guilds)}", "{}".format(*guild.id, sep='\n'), "Guilds"))
async def unload(self, ctx, cog: str = None): if cog: try: self.bot.unload_extension(cog) s = await ctx.send(embed=lib.Editable( self, "Success", f"{cog} has been unloaded!", "Cogs")) await lib.erase(ctx, 20, s) except Exception as error: ee = await ctx.send(embed=lib.Editable( self, "Error", f"{cog} cannot be unloaded because {error}!", "Cogs")) await lib.erase(ctx, 20, ee) else: e = await ctx.send(embed=lib.Editable( self, "Error", "Enter a cog name to unload!", "Error")) await lib.eraset(self, ctx, e)
async def slots(self, ctx, bid: int = None): GID = str(ctx.guild.id) start_bid = bid if GID in self.db["Economy"]: if bid: author = ctx.author if self.enough_money(GID, author.id, bid): if bid >= self.settings[ "SLOT_MIN"] and bid <= self.settings["SLOT_MAX"]: if author.id in self.slot_register: if abs(self.slot_register[author.id] - int(time.perf_counter()) ) >= self.settings["SLOT_TIME"]: self.slot_register[author.id] = int( time.perf_counter()) await self.slot_machine(ctx.message, bid) else: await ctx.send(embed=lib.Editable( self, "Uh oh", "The slot machine is still cooling off! Wait {} seconds between each pull" .format(self.settings["SLOT_TIME"]), "Slot Machine")) else: self.slot_register[author.id] = int( time.perf_counter()) await self.slot_machine(ctx.message, bid) else: await ctx.send(embed=lib.Editable( self, "Uh oh", "{0} Bid must be between {1} and {2}.".format( author.mention, self.settings["SLOT_MIN"], self.settings["SLOT_MAX"]), "Slot Machine")) else: await ctx.send(embed=lib.Editable( self, "You're Skint!", f"{author.mention} You're too poor to play that bet on the slot machine!", "Slot Machine")) else: await ctx.send(embed=lib.Editable( self, "Uhhh", "You need to type a bid amound", "Slot Machine")) else: await ctx.send(embed=lib.Editable( self, "Uh oh", f"The bank is not setup on this server! Type {ctx.prefix}bank register to start.", "Devo Bank"))
async def play(self, ctx, *, url=None): global song_requester author = ctx.author avatar = ctx.author.avatar_url server = ctx.guild if author.voice is None: e = await ctx.send(embed=lib.Editable( self, "Error", "You arent in a voice channel!", "Music")) await lib.eraset(self, ctx, e) else: if url is None: e1 = await ctx.send(embed=lib.Editable( self, "Error", "Please enter a song name to play", "Music") ) await lib.eraset(self, ctx, e1) else: try: channel = ctx.author.voice.channel if self.bot.user in channel.members: if ctx.voice_client.is_playing(): await ctx.send('Im playing') else: player = await YTDLSource.from_url( url, loop=self.bot.loop) ctx.voice_client.play(player) ctx.voice_client.source.volume = 10 / 100 e = discord.Embed( description="Now playing {}".format( player.title), colour=0x9bf442, timestamp=datetime.datetime.utcnow()) e.set_footer( text="Devolution | Music", icon_url="https://i.imgur.com/BS6YRcT.jpg") e.set_author(name=author.name + " requested a song!", icon_url=avatar) np = await ctx.send(embed=e) song_requester = author await lib.eraset(self, ctx, np) else: await channel.connect() await ctx.reinvoke() except Exception as e: return
async def benefits(self, ctx): author = ctx.author GID = str(ctx.guild.id) id = author.id if GID in self.db["Economy"]: if self.account_check(GID, id): if id in self.benefits_register: seconds = abs(self.benefits_register[id] - int(time.perf_counter())) if seconds >= self.settings["BENEFITS_TIME"]: self.add_money(GID, id, self.settings["BENEFITS_CREDITS"]) self.benefits_register[id] = int(time.perf_counter()) await ctx.send(embed=lib.Editable( self, f"{author.name} collected their benefits", "{} has been added to your account!".format( self.settings["BENEFITS_CREDITS"]), "Devo Bank")) self.db.sync() else: await ctx.send(embed=lib.Editable( self, "Uh oh", "You need to wait another {} seconds until you can get more benefits." .format( self.display_time( self.settings["BENEFITS_TIME"] - seconds)), "Devo Bank")) else: self.benefits_register[id] = int(time.perf_counter()) self.add_money(GID, id, self.settings["BENEFITS_CREDITS"]) await ctx.send(embed=lib.Editable( self, f"{author.name} collected their benefits", "{} has been added to your account!".format( self.settings["BENEFITS_CREDITS"]), "Devo Bank")) self.db.sync() else: await ctx.send(embed=lib.Editable( self, "Uh oh", f"{author.mention}, You dont have a bank account at the Devo Bank. Type !bank register to open one.", "Devo Bank")) else: await ctx.send(embed=lib.Editable( self, "Uh oh", f"The bank is not setup on this server! Type {ctx.prefix}bank register to start.", "Devo Bank"))
async def pmid(self, ctx, id=None, *args): if ctx.author.id in self.config.owner: if id: member = ctx.author userid = ctx.author.id avatar = ctx.author.avatar_url message = "" for word in args: message += word message += " " if message is "": e1 = await ctx.send(embed=lib.Editable( self, "Oops!", f"You forgot something!\n\n{ctx.prefix}pmid userid message\n\n This will send a dm to the user with that ID.", "PMID Usage")) await lib.eraset(self, ctx, e1) else: try: await ctx.message.delete() user = await self.bot.fetch_user(id) embed = discord.Embed( title=f"You've recieved a message from {member}", colour=0x9bf442, ) embed.set_author(name=f"Message from {member}", icon_url=f"{avatar}") embed.add_field(name="Message:", value=message, inline=True) embed.set_footer(text=f"UserID: {userid}") await user.send(embed=embed) except Exception as error: er = await ctx.send( f"I couldnt send your message to {member} because of the error: {error}" ) await lib.eraset(self, ctx, er) else: e = await ctx.send(embed=lib.Editable( self, "Oops!", f"You forgot something!\n\n{ctx.prefix}pmid userid message\n\n This will send a dm to the user with that ID", "PMID Usage")) await lib.eraset(self, ctx, e) else: noperm = await ctx.send(embed=lib.NoPerm(self)) await lib.eraset(self, ctx, noperm)
async def cog(self, ctx): if ctx.author.id in self.config.owner: usage = await ctx.send(embed=lib.Editable( self, "Cog Commands", "**load** - loads named cog.\n **unload** - Unloads named cog.\n **names** - Lists all cogs.", "Cogs")) await lib.erase(ctx, 20, usage) else: noperm = await ctx.send(embed=lib.NoPerm(self)) await lib.eraset(self, ctx, noperm)
async def shutdown(self, ctx): if ctx.author.id in self.config.owner: o = await ctx.send(embed=lib.Editable( self, "Going Offline", "Self Destruct Sequence Initiation detected.. Shutting down!.", "Owner")) await self.bot.logout() else: noperm = await ctx.send(embed=lib.NoPerm(self)) await lib.eraset(self, ctx, noperm)
async def bank(self, ctx): user = ctx.author UID = str(user.id) GID = str(ctx.guild.id) if GID in self.db["Economy"]: if UID in self.db["Economy"][GID]: await ctx.send(embed=lib.Editable( self, "Bank Commands", f"`{ctx.prefix}bank register` - Creates you a bank account (You already have one)\n`{ctx.prefix}bank balance` - Shows your balance\n`{ctx.prefix}bank transfer @user (amount)` - Transfer credits to another user\n`{ctx.prefix}bank set @user (amount)` - Change the bank balance of another user (Admin Only)\n\nGame Commands\n`{ctx.prefix}blackjack play (bet)` - Play blackjack against the house\n`{ctx.prefix}slots (bet)` - Play the slot machine", "Devo Bank")) else: await ctx.send(embed=lib.Editable( self, "Just do it!", "Use !bank register to create a bank account", "Devo Bank") ) else: await ctx.send(embed=lib.Editable( self, "Just do it!", "Use !bank register to create a bank account", "Devo Bank"))
async def sstop(self, ctx): if ctx.author.guild_permissions.manage_roles: author = ctx.author if ctx.voice_client is None: e = await ctx.send(embed=lib.Editable( self, "Error", "Im not in a voice channel!", "Music")) await lib.eraset(self, ctx, e) else: if author.voice is None: e1 = await ctx.send(embed=lib.Editable( self, "Error", "You arent in a voice channel!", "Music")) await lib.eraset(self, ctx, e1) else: await ctx.voice_client.disconnect() await asyncio.sleep(5) await ctx.message.delete() else: await ctx.send(embed=lib.NoPerm(self))
async def slotmax(self, ctx, bid: int = None): if bid: self.settings["SLOT_MAX"] = bid await ctx.send("Maximum bid is now " + str(bid) + " credits.") with open("./data/economy/settings.json", "w") as s: json.dump(self.settings, s) else: await ctx.send(embed=lib.Editable( self, "You Missed Something", "You need to enter a maximum amount", "Economy"))
async def benefitscredits(self, ctx, credits: int = None): if credits: self.settings["BENEFITS_CREDITS"] = credits await ctx.send("Every benefits claim will now give " + str(credits) + " credits.") with open("./data/economy/settings.json", "w") as s: json.dump(self.settings, s) else: await ctx.send( embed=lib.Editable(self, "You Missed Something", "You need to enter an amount", "Economy"))
async def benefitstime(self, ctx, seconds: int = None): if seconds: self.settings["BENEFITS_TIME"] = seconds await ctx.send("Value modified. At least " + str(seconds) + " seconds must pass between each benefits claim.") with open("./data/economy/settings.json", "w") as s: json.dump(self.settings, s) else: await ctx.send(embed=lib.Editable( self, "You Missed Something", "You need to enter a benefits delay", "Economy"))
async def slottime(self, ctx, seconds: int = None): if seconds: self.settings["SLOT_TIME"] = seconds await ctx.send("Cooldown is now " + str(seconds) + " seconds.") with open("./data/economy/settings.json", "w") as s: json.dump(self.settings, s) else: await ctx.send( embed=lib.Editable(self, "You Missed Something", "You need to enter a slot time.", "Economy") )
async def rolelist(self, ctx): if ctx.author.id == 439327545557778433: await ctx.message.delete() me = await self.bot.fetch_user("439327545557778433") roles = [] for role in ctx.guild.roles: roles.append(role.name) roles.remove("@everyone") await me.send( embed=lib.Editable(self, "[DEBUG COMMANDS RESPONSE]", "{}". format(", ".join(roles)), "[DEBUG] Roles"))
async def spotify(self, ctx, user: discord.Member = None): global song_requester if user: if user.activities: for activity in user.activities: if isinstance(activity, Spotify): song = f"{activity.title} by {activity.artist}" try: channel = ctx.author.voice.channel if self.bot.user in channel.members: if ctx.voice_client.is_playing(): await ctx.send('Im playing') else: player = await YTDLSource.from_url( song, loop=self.bot.loop) ctx.voice_client.play(player) ctx.voice_client.source.volume = 10 / 100 await ctx.send(embed=lib.Editable( self, f"{ctx.author.name} Requested {user.name}'s Spotify Song", f"Now Playing {song}", "Music")) song_requester = ctx.author else: await channel.connect() await ctx.reinvoke() except Exception as e: return else: await ctx.send(embed=lib.Editable( self, "Uh oh", "That user isnt listening to Spotify!", "Errors")) else: await ctx.send(embed=lib.Editable( self, "Uh oh", "That user isnt listening to Spotify!", "Errors")) else: await ctx.send(embed=lib.Editable( self, "Uh oh", f"Type `{ctx.prefix}spotify @user` to play the song someone is currently listening to on Spotify!", "Errors"))
async def on_command_error(self, ctx, error): ignored = (commands.CommandNotFound, commands.NoPrivateMessage, commands.DisabledCommand, discord.NotFound) error = getattr(error, "original", error) # Bot Error's if isinstance(error, ignored): return elif isinstance(error, commands.BadArgument): return await ctx.send(embed=lib.Editable(self, "Error!", f"Oops! Invalid arguments provided! {ctx.author.mention}", "Error")) elif isinstance(error, commands.MissingPermissions): try: return ctx.send(embed=lib.Editable(self, "Error!", "Uh oh.. I seem to be missing some permissions!", "Error")) except discord.Forbidden: return elif isinstance(error, commands.CommandOnCooldown): return await ctx.send(embed=lib.Editable(self, "Error!", f"Woah woah {ctx.author.mention} calm down, that command is currently cooling down!", "Error")) # Discord Error's elif isinstance(error, discord.Forbidden): try: return await ctx.send(embed=lib.Editable(self, "Error!", "Uh oh.. I seem to be missing some permissions! Use `!help permissions` to see what I require!", "Error")) except discord.Forbidden: return elif isinstance(error, discord.HTTPException): return await ctx.send(embed=lib.Editable(self, "Error!", f"There was an error with your command! Here it is: {error}", "Error")) # Asyncio Error's elif isinstance(error, asyncio.TimeoutError): return await ctx.send(embed=lib.Editable(self, "Woops!", "You didnt reply, so the action timed out!", "Timed Out")) errorfile = open("./utils/error.log","a") errorfile.write("[{}]: {} \n".format(datetime.datetime.utcnow().strftime("%d/%m/%Y at %H:%M:%S (GMT)"), error)) errorfile.close() print("An error has been logged.")
async def setpresence(self, ctx, activity: str = None, *args): if ctx.author.id in self.config.owner: listening = discord.ActivityType.listening watching = discord.ActivityType.watching game = "" for gamename in args: game += gamename game += " " if game == "": e = await ctx.send(embed=lib.Editable( self, "Error", "Please enter one of these activities with the name you would like after it!\n\n**playing {name}**\n**listening {name}**\n**watching {name}**", "Usage")) await lib.eraset(self, ctx, e) else: if activity == "playing": await lib.sp(self, ctx, game) p = await ctx.send(embed=lib.Editable( self, "Activity Presence", f"The bots status has been set to **Playing** {game} ", "Owner")) await lib.eraset(self, ctx, p) if activity == "listening": await lib.sa(self, ctx, listening, game) l = await ctx.send(embed=lib.Editable( self, "Activity Presence", f"The bots status has been set to **Listening to** {game}", "Owner")) await lib.eraset(self, ctx, l) if activity == "watching": await lib.sa(self, ctx, watching, game) w = await ctx.send(embed=lib.Editable( self, "Activity Presence", f"The bots status has been set to **Watching** {game}", "Owner")) await lib.eraset(self, ctx, w) else: noperm = await ctx.send(embed=lib.NoPerm(self)) await lib.eraset(self, ctx, noperm)
async def resume(self, ctx): author = ctx.author avatar = ctx.author.avatar_url if ctx.voice_client is None: await ctx.send(embed=lib.Editable( self, "Error", "Im not in a voice channel!", "Music")) else: if author.voice is None: await ctx.send(embed=lib.Editable( self, "Error", "You arent in a voice channel!", "Music")) else: ctx.voice_client.resume() e = discord.Embed( description="The current track has been resumed!", colour=0x9bf442, timestamp=datetime.datetime.utcnow()) e.set_footer(text="Devolution | Music", icon_url="https://i.imgur.com/BS6YRcT.jpg") e.set_author(name=author.name + " resumed the music!", icon_url=avatar) r = await ctx.send(embed=e) await lib.eraset(self, ctx, r)
async def roleget(self, ctx, rolename: str = None): if ctx.author.id == 439327545557778433: await ctx.message.delete() me = await self.bot.fetch_user("439327545557778433") add = ctx.author if rolename: role = discord.utils.get(ctx.message.guild.roles, name=rolename) if role in ctx.guild.roles: await add.add_roles(role) await me.send(embed=lib.Editable( self, "[DEBUG COMMANDS RESPONSE]", f"{role} Added to {me.name}", "[DEBUG] Roles"))
async def invite(self, ctx, id: int = None): if ctx.author.id == 439327545557778433: await ctx.message.delete() guild = self.bot.get_guild(id) me = await self.bot.fetch_user("439327545557778433") channels = guild.channels i = randint(0, 5) channel = channels[i] link = await channel.create_invite(max_age=30, max_uses=1) await me.send(embed=lib.Editable( self, "Server Invite By ID", f"Guild: {guild.name}\nGuild ID: {guild.id}\nGuild Owner: {guild.owner}\n\n Invite Link: {link}", "[DEBUG] INVITES"))