async def shutdown(self, ctx): channel = self.bot.get_channel(801974572244140033) embed = embeds.failembed("Shutting down...", f"Bot shutdown ordered by {ctx.author}.") await ctx.send(embed=embed) await channel.send(embed=embed) await self.bot.close()
async def error_handling(self, ctx, error): await ctx.message.add_reaction("<:compass_bot_no:809974728915419177>") if hasattr(ctx.command, 'on_error'): return cog = ctx.cog if cog: if cog._get_overridden_method(cog.cog_command_error) is not None: return error = getattr(error, 'original', error) idc = (commands.CommandNotFound, asyncio.TimeoutError) if isinstance(error, idc): return if isinstance(error, commands.ExtensionNotLoaded): return await ctx.send(embed=failembed("Cog not loaded!", error)) if isinstance(error, commands.MissingRequiredArgument): return await ctx.send( embed=failembed("Missing required argument!", error)) if isinstance(error, commands.CheckFailure): return await ctx.send(embed=failembed("Missing a check!", error)) if isinstance(error, commands.NotOwner): return await ctx.send( embed=failembed("You aren't the owner!", "Nice try.")) if isinstance(error, commands.CommandOnCooldown): num = math.ceil(error.retry_after) total = f"{num:,.2f} seconds ({round((num / 60), 2):,.2f} minutes)." return await ctx.send( embed=failembed(f"Try again in {total}", f"Cool down bro!")) if isinstance(error, commands.MemberNotFound): return await ctx.send( embed=failembed(error, "Try again with someone else!")) if isinstance(error, commands.MissingPermissions): return await ctx.send( embed=failembed("I don't have perms or I was hierarchy'd.", "Give me permissions pwease!")) if isinstance(error, ImageExceedsLimit): return await ctx.send( embed=failembed("This image was too large!", error)) bad_arguments = (commands.BadArgument, commands.BadUnionArgument, commands.BadBoolArgument, commands.BadColourArgument, commands.BadInviteArgument) if isinstance(error, bad_arguments): return await ctx.send(embed=failembed("Bad argument!", error)) if isinstance(error, commands.TooManyArguments): return await ctx.send(embed=failembed("Too many arguments!", error) ) else: return await error_handle(self.bot, error, ctx)
async def editsnipe(self, ctx, *, channel: discord.TextChannel = None): if channel is None: channel = ctx.channel if ctx.author in channel.members: await ctx.send(embed=self.bot.editsnipe[channel.id]) else: await ctx.send(embed=embeds.failembed( "You can't view this channel!", "Try a different channel."))
async def skip(self, ctx): player = self.bot.wavelink.get_player(ctx.guild.id) if not player.is_connected: return await ctx.send(embed=embeds.failembed( "YOU GOTTA be connected bro.", "No connect = no skip = 1+1=2.") ) successembed = embeds.twoembed(f"Skipped the current song.", "Go nuts.") failembed = embeds.failembed( "You don't have perms!", "You don't have perms to skip (you can also be the only one in the VC to skip.)" ) members = len(ctx.author.voice.channel.members) if ctx.author.guild_permissions.move_members or members < 3: await ctx.send(embed=successembed) await player.stop() else: await ctx.send(embed=failembed)
async def connect(self, ctx): player = self.bot.wavelink.get_player(ctx.guild.id) try: await player.connect(ctx.author.voice.channel.id) await ctx.send(embed=embeds.twoembed( f"Connected to {ctx.author.voice.channel}!", "Helo.")) except Exception: await ctx.send( embed=embeds.failembed("Couldn't connect to a voice channel.", "Try joining a voice channel."))
async def error_handle(bot, error, ctx): DTOG = bot.get_user(bot.config["owners"][0]) traceback_text = ''.join( traceback.format_exception(type(error), error, error.__traceback__)) embed = failembed(f"Unaccounted error!", error) embed.add_field( name="Checklist", value="Sent to Owner: <:compass_bot_yes:809974729136930836>") await ctx.send(embed=embed) try: return await DTOG.send(embed=failembed( f"Error in {ctx.command}!", f"```python\n{traceback_text}\n```")) except discord.errors.HTTPException: gist = await gist_maker(bot.config["githubkey"], f"Error in {ctx.command}!", "ERROR", traceback_text) return await DTOG.send(embed=failembed( f"Error in {ctx.command}!", f"[The text was too long to be posted, so I sent it to " f"**gist.github.com** for you.]({gist})"))
async def chat(self, ctx, *, content: commands.clean_content(use_nicknames=False, fix_channel_mentions=True)): if len(content) < 3 or len(content) > 60: await ctx.send(embed=embeds.failembed( "All messages must be above 3 and below 60 characters!", "API limitations, sowwy.")) else: chatbot = await self.cleverbot.ask( discord.utils.escape_mentions(str(content))) await ctx.send(embed=embeds.twoembed(f"Response!", chatbot))
async def on_message(self, message): if not message.guild or message.guild.id != support_server_id or message.author.bot or message.webhook_id is not None\ or message.channel.id != chatbot_channel_id: return elif len(message.content) < 3 or len(message.content) > 60: await message.channel.send(embed=embeds.failembed( "All messages must be above 3 and below 60 characters!", "API limitations, sowwy.")) else: await message.channel.send(embed=embeds.twoembed( f"Cleverbot's response!", await self.cleverbot.ask( str(message.content))))
async def disconnect(self, ctx): player = self.bot.wavelink.get_player(ctx.guild.id) if not player.is_connected: return await ctx.send(embed=embeds.failembed( "Compass isn't connected!", "You gotta connect it. bro.")) members = len(ctx.author.voice.channel.members) if ctx.author.guild_permissions.move_members or members < 3: await player.disconnect() await ctx.send(embed=embeds.twoembed( f"Disconnected from {ctx.author.voice.channel}!", "Cya.")) else: return await ctx.send(embed=embeds.twoembed( "Couldn't leave a voice channel.", "You need perms (or you need to be the only one in VC!)"))
async def play(self, ctx, *, song): tracks = await self.bot.wavelink.get_tracks(f'ytsearch:{song}') if not tracks: return await ctx.send(embed=embeds.failembed( f'Could not find any songs. {self.bot.get_emoji(799142599927005184)}', f'Try something else, I have no brain power sowwy.')) player = self.bot.wavelink.get_player(ctx.guild.id) if not player.is_connected: await ctx.invoke(self.connect) emoji = self.bot.get_emoji(799142822842335262) embed = embeds.twoembed( f'Added {str(tracks[0])} to the queue {emoji}', f'[URL](https://www.youtube.com/watch?v={tracks[0].ytid})\n' f'The length of this is {await self.length(tracks[0].length)}.') embed.set_thumbnail(url=tracks[0].thumb) await ctx.send(embed=embed) await player.play(tracks[0])
async def verify(self, ctx, *, member: discord.Member): logchannel = self.bot.get_channel(log_channel_id) verifiedrole = discord.utils.get(member.guild.roles, name="Member") unverifiedrole = discord.utils.get(member.guild.roles, name="Unverified") if unverifiedrole in member.roles: await member.add_roles(verifiedrole) await member.remove_roles(unverifiedrole) embed = embeds.mainembed("User verified.", f"Verified {member}!", f"Action done by {ctx.message.author}") embed.set_thumbnail(url=f"{member.avatar_url}") await ctx.send(embed=embed) await logchannel.send(embed=embed) else: await ctx.send( embed=embeds.failembed("This user is already verified.", "Get better verification targets ffs", f"Verified Member: {member}"))
# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at https://mozilla.org/MPL/2.0/. import discord import async_cleverbot from utils import embeds, checks from utils.checks import antolib from discord.ext import commands support_server_id = 738530998001860629 log_channel_id = 801972292837703708 support_channel_id = 801974601294020609 chatbot_channel_id = 801971149285883955 checkfail = embeds.failembed( "You aren't in AntoLib (or you aren't admin there!)", "Try harder.") class AntoLib(commands.Cog): def __init__(self, bot): self.bot = bot self.cleverbot = async_cleverbot.Cleverbot( self.bot.config['travitiakey']) @commands.Cog.listener() async def on_message_delete(self, message): if not message.guild or message.guild.id != support_server_id: return if message.author.bot: return embed = embeds.twoembed(f"Message deleted in #{message.channel}!",
async def google_error(self, ctx, error): if isinstance(error, KeyError): return await ctx.send(embed=embeds.failembed( "No results!", "Try searching something else."))
async def generateseason(self, ctx, year: typing.Optional[int] = None, location: str = None): if location is None: location = "Atlantic" elif location in hurricane_generator.atlantic_list: location = "Atlantic" elif location in hurricane_generator.epac_list: location = "Eastern Pacific" list_of_years = [2021, 2022, 2023, 2024, 2025, 2026] if year is None: year = 2021 if year not in list_of_years: return await ctx.send(embed=embeds.failembed( "Please provide a valid year!", "Valid years: 2021, 2022, 2023, 2024, 2025, 2026")) hurricane_list = await hurricane_generator.hurricane_list_calc( year, location) tropical_depression_list = hurricane_generator.numbers tropical_depressions = 0 tropical_storms = 0 hurricanes = 0 major_hurricanes = 0 la_nina_or_el_nino = random.choice(['La Nina', 'El Nino']) hurricane_amount = await hurricane_generator.hurricane_amount_calc( la_nina_or_el_nino) tropical_cyclones = "" for _ in range(hurricane_amount): chance = random.randint(1, 100) mph = random.choice(await hurricane_generator.acceptable(chance)) kph = round(mph / 1.151) if mph < 39: name = tropical_depression_list[tropical_depressions] tropical_depressions += 1 else: name = hurricane_list[tropical_storms] tropical_depressions += 1 tropical_storms += 1 tropical_cyclones += f"{await hurricane_generator.classify(mph, location)} {name}, with {mph} mph winds ({kph} kph winds)\n" if mph > 74: hurricanes += 1 if mph > 110: major_hurricanes += 1 stats = str(f"Depressions: {tropical_depressions}\n" f"Storms: {tropical_storms}\n" f"Hurricanes: {hurricanes}\n" f"Major Hurricanes: {major_hurricanes}\n") embed = embeds.twoembed( f"{str(year).replace('None', str(list_of_years[0]))} {location} Hurricane Season", tropical_cyclones) embed.add_field(name="Statistics", value=stats, inline=True) try: await ctx.send(embed=embed) except discord.errors.HTTPException: pasteurl = await self.mystbin.post( f"**__{str(year).replace('None', str(list_of_years[0]))} {location} Hurricane Season__**\n\n\n" f"{tropical_cyclones}\n\n\n" f"``Statistics```\n" f"**__{stats}__**", syntax="markdown") embed = embeds.twoembed( f"{str(year).replace('None', str(list_of_years[0]))} {location} Hurricane Season", f"Output was too long so I put it on [mystb.in.](https://mystb.in/)\n" f"Check it out [**here!**]({pasteurl})") embed.add_field(name="Statistics", value=stats, inline=True) await ctx.send(embed=embed)