Skip to content

Commit

Permalink
Merge pull request #86 from starlightknown/re-write
Browse files Browse the repository at this point in the history
Re write
  • Loading branch information
starlightknown authored Jun 22, 2021
2 parents ee5085f + cd45a9d commit 89e3d86
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 102 deletions.
80 changes: 40 additions & 40 deletions cogs/Fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,29 @@ def __init__(self, bot):
@commands.command(name='8ball')
@cooldown(1,5,BucketType.channel)
async def eight_ball(self, ctx, *, question=None):
responses = ["It is certain.",
"It is decidedly so.",
"Without a doubt.",
"Yes - definitely.",
"You may rely on it.",
"As I see it, yes.",
"Most likely.",
"Outlook good.",
"Yes.",
"Signs point to yes.",
"Reply hazy, try again.",
"Ask again later.",
"Better not tell you now.",
"Cannot predict now.",
"Concentrate and ask again.",
"Don't count on it.",
"My reply is no.",
"My sources say no.",
"Outlook not so good.",
"Very doubtful."
]

if question is not None:
responses = ["It is certain.",
"It is decidedly so.",
"Without a doubt.",
"Yes - definitely.",
"You may rely on it.",
"As I see it, yes.",
"Most likely.",
"Outlook good.",
"Yes.",
"Signs point to yes.",
"Reply hazy, try again.",
"Ask again later.",
"Better not tell you now.",
"Cannot predict now.",
"Concentrate and ask again.",
"Don't count on it.",
"My reply is no.",
"My sources say no.",
"Outlook not so good.",
"Very doubtful."
]

embed = discord.Embed(title='*The 8ball*', description=f'**{ctx.message.author}** asked a question.\n\nThe question was: **{question}**\n\n\n{random.choice(responses)}', colour=0x0000ff)
await ctx.send(embed=embed)
else:
Expand Down Expand Up @@ -167,12 +167,10 @@ async def cat_picture_error(self, ctx, error):
@commands.command(name='fact', aliases=['facts'])
async def animal_facts(self, ctx, animal:str):

colour_choices= [0x400000,0x997379,0xeb96aa,0x4870a0,0x49a7c3,0x8b3a3a,0x1e747c,0x0000ff]

if animal.lower() in {'dog', 'cat', 'bird', 'birb', 'koala', 'panda'}:

fact_url = f"https://some-random-api.ml/facts/{'bird' if animal == 'birb' else animal}"

image_url=f"https://some-random-api.ml/img/{'bird' if animal == 'bird' else animal}"
async with request("GET", image_url, headers={}) as response:
if response.status == 200:
Expand All @@ -190,6 +188,8 @@ async def animal_facts(self, ctx, animal:str):
else:
description = data["fact"]

colour_choices= [0x400000,0x997379,0xeb96aa,0x4870a0,0x49a7c3,0x8b3a3a,0x1e747c,0x0000ff]

embed = discord.Embed(
title = f'Facts about {animal.lower()}',
description=description,
Expand Down Expand Up @@ -221,23 +221,23 @@ async def animal_facts_error(self, ctx, error):
@commands.command(name='asciify')
@cooldown(1, 1, BucketType.channel)
async def asciify_message(self, ctx, *, message=None):
if message is not None:
if len(message) <= 50:
if message[0] == '<' and (message[1] == '#'):
await ctx.send('im not doing that 😂')
elif message[0] == '<' and message[1] == '@':
await ctx.send('im not doing that 😂')
elif ctx.author.is_on_mobile and len(message) > 8:
await ctx.send('The output might look a bit weird on your phone! 😅\n Landscape mode might make it look Better')
msg = pyfiglet.figlet_format(message)
await ctx.send(f'```\n{msg}\n```')
else:
msg = pyfiglet.figlet_format(message)
await ctx.send(f'```\n{msg}\n```')
if message is None:
await ctx.send('Whats it you want to asciify?')

elif len(message) <= 50:
if message[0] == '<' and (message[1] == '#'):
await ctx.send('im not doing that 😂')
elif message[0] == '<' and message[1] == '@':
await ctx.send('im not doing that 😂')
elif ctx.author.is_on_mobile and len(message) > 8:
await ctx.send('The output might look a bit weird on your phone! 😅\n Landscape mode might make it look Better')
msg = pyfiglet.figlet_format(message)
await ctx.send(f'```\n{msg}\n```')
else:
await ctx.send(f"Your character length ({len(message)}) has exceeded a normal of 50.")
msg = pyfiglet.figlet_format(message)
await ctx.send(f'```\n{msg}\n```')
else:
await ctx.send('Whats it you want to asciify?')
await ctx.send(f"Your character length ({len(message)}) has exceeded a normal of 50.")


# ASCIIfy: Error handling
Expand Down
19 changes: 7 additions & 12 deletions cogs/Help.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async def help(self, ctx, argument=None, page = None):
mod_role = discord.utils.get(ctx.author.roles, name='Moderator')
admin_role = discord.utils.get(ctx.author.roles, name='Administrator')



fun_embed = discord.Embed(
title = 'Fun commands for Cyberon',
Expand All @@ -34,7 +34,7 @@ async def help(self, ctx, argument=None, page = None):
'**quotes**\nA random quote\n**Usage:** `cyb!quote`\n\n',
colour=0x01a901
)

utils_embed = discord.Embed(
title = 'Utility commands for cyberon',
description='**avatar** | **av**\nShows the avatar of the user mentioned\n**Usage:** `cyb!avatar <member_name | member_tag | member_id>`\nIf nothing is provided then it shows your avatar\n\n'
Expand All @@ -55,7 +55,7 @@ async def help(self, ctx, argument=None, page = None):
'**hackclub**\nShows the hack club\'s upcoming hackathons\n**Usage:** `cyb!hackclub`\n\n',
colour=0x01a901
)

mod_embed = discord.Embed(
title = 'Moderation commands for cyberon\nPage 1',
description='**kick**\nKicks the member out of the server\n**Usage:** `cyb!kick <member_name | member_id | member_tag> <reason>`, reason is not neccessary\n\n'
Expand Down Expand Up @@ -117,23 +117,18 @@ async def help(self, ctx, argument=None, page = None):
await ctx.send(embed=initial_help_dialogue)
elif argument.lower() == 'fun':
await ctx.send(embed=fun_embed)
elif argument.lower() == 'moderation' or argument.lower() == 'mod':
elif argument.lower() in ['moderation', 'mod']:

if page == '1' or page is None:
if page == '1' or page is None or page != '2':
await ctx.send(embed=mod_embed)
elif page == '2':
await ctx.send(embed=mod_embed_2)
else:
await ctx.send(embed=mod_embed)

elif argument.lower() == 'utils' or argument.lower() == 'util':
await ctx.send(embed=mod_embed_2)
elif argument.lower() in ['utils', 'util']:
await ctx.send(embed=utils_embed)
elif argument.lower() == 'config':
await ctx.send(embed=config_embed)
elif argument.lower() == 'support':
await ctx.send(embed=support_embed)
else:
pass


# Help console: Error handling
Expand Down
69 changes: 19 additions & 50 deletions cogs/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,21 @@ async def avatar(self, ctx, member, override=None):
member = await converter.convert(ctx, member)
elif member.isdigit():
member = int(member)
else:
pass

members = await ctx.guild.fetch_members().flatten()
multiple_member_array = []

if isinstance(member, discord.Member):
for members_list in members:
if member.name.lower() in members_list.name.lower():
multiple_member_array.append(members_list)
else:
pass
elif isinstance(member, int):
for member_list in members:
if member_list.id == member:
multiple_member_array.append(member_list)
else:
pass
else:
for members_list in members:
if member.lower() in members_list.name.lower():
multiple_member_array.append(members_list)
else:
pass

if member is discord.Member:
if member.isdigit() and member.lower() == 'me' and override == 'override':
embed = discord.Embed(colour=0x0000ff)
Expand All @@ -76,7 +66,7 @@ async def avatar(self, ctx, member, override=None):
if multiple_member_array[0].name == multiple_member_array[0].display_name:
embed = discord.Embed(title=f'{multiple_member_array[0]}',colour=0x0000ff)

elif multiple_member_array[0].name != multiple_member_array[0].display_name:
else:
embed = discord.Embed(title=f'{multiple_member_array[0]}({multiple_member_array[0].display_name})',colour=0x0000ff)

embed.set_image(url=f'{multiple_member_array[0].avatar_url}')
Expand Down Expand Up @@ -152,35 +142,23 @@ async def userinfo(self, ctx, member):

members = await ctx.guild.fetch_members().flatten()
multiple_member_array = []


if isinstance(member, discord.Member):
for members_list in members:
if member.name.lower() in members_list.name.lower():
multiple_member_array.append(members_list)
else:
pass

elif isinstance(member, int):
for member_list in members:
if member_list.id == member:
multiple_member_array.append(member_list)
else:
pass

else:
for members_list in members:
if member.lower() in members_list.name.lower():
multiple_member_array.append(members_list)
else:
pass

if len(multiple_member_array) == 1:

roles = []
for role in multiple_member_array[0].roles:
roles.append(role)

roles = [role for role in multiple_member_array[0].roles]
embed = discord.Embed(
colour = 0x0000ff,
)
Expand All @@ -198,7 +176,11 @@ async def userinfo(self, ctx, member):
if len(roles) == 1:
embed.add_field(name=f'Roles ({len(roles) - 1})', value='**NIL**')
else:
embed.add_field(name=f'Roles ({len(roles) - 1})', value=' '.join([role.mention for role in roles if role.name != '@everyone']))
embed.add_field(
name=f'Roles ({len(roles) - 1})',
value=' '.join(
role.mention for role in roles if role.name != '@everyone'),
)

embed.add_field(name='Bot?', value=multiple_member_array[0].bot)

Expand Down Expand Up @@ -245,16 +227,10 @@ async def userinfo_error(self, ctx, error):
@commands.command(aliases=['si'])
@cooldown(1, 4, BucketType.channel)
async def serverinfo(self, ctx):

count = 0

members = await ctx.guild.fetch_members().flatten()

for people in members:
if people.bot:
count = count + 1
else:
pass
count = sum(1 for people in members if people.bot)

embed = discord.Embed(
title = f'{ctx.guild.name} info',
Expand Down Expand Up @@ -288,10 +264,10 @@ async def serverinfo(self, ctx):
async def serverinfo_error(self, ctx, error):
if isinstance(error, commands.CommandOnCooldown):
await ctx.send(error)
raise error
else:
await ctx.send(f"An error occured \n```\n{error}\n```\nPlease check console for traceback, or raise an issue to cyberon.")
raise error

raise error


# Servercount
Expand All @@ -300,10 +276,7 @@ async def serverinfo_error(self, ctx, error):
@cooldown(1, 1, BucketType.channel)
async def servercount(self, ctx):

member_count = 0
for guild in self.bot.guilds:
member_count += guild.member_count

member_count = sum(guild.member_count for guild in self.bot.guilds)
await ctx.send(f'Present in `{len(self.bot.guilds)}` servers, moderating `{member_count}` members')


Expand Down Expand Up @@ -413,13 +386,8 @@ async def cypher(self, ctx, *, message):
'?':'..--..', '/':'-..-.', '-':'-....-',
'(':'-.--.', ')':'-.--.-'}

cipher = ''

for letter in message.upper():
if letter != ' ':
cipher += MORSE_DICT[letter] + ' '
else:
cipher += ' '
cipher = ''.join(MORSE_DICT[letter] + ' ' if letter != ' ' else ' '
for letter in message.upper())

await ctx.send(f'Here is your cyphered text:\n```\n{cipher}\n```')

Expand All @@ -446,7 +414,7 @@ async def base64(self, ctx, message, iterations=1):
if iterations <= 20:
message_bytecode = message.encode('ascii')

for i in range(iterations):
for _ in range(iterations):
message_bytecode = base64.b64encode(message_bytecode)
base64_message = message_bytecode.decode('ascii')

Expand Down Expand Up @@ -504,7 +472,7 @@ async def base64_decode_error(self, ctx, error):
await ctx.send('What are the arguments')
elif isinstance(error, commands.BadArgument):
await ctx.send("Please enter your text to be encode in quotes")
elif isinstance(error, base64.binascii.Error) or isinstance(error, binascii.Error):
elif isinstance(error, (base64.binascii.Error, binascii.Error)):
await ctx.send("Please enter a valid base64 encoded message to decrypt {ctx.author.display_name}")
elif isinstance(error, UnicodeDecodeError):
await ctx.send("Please enter a valid base64 encoded message to decrypt {ctx.author.display_name}")
Expand Down Expand Up @@ -604,5 +572,6 @@ async def about(self, ctx):
)
embed.add_field(name="Bug spray of my code", value="`Karuna#8722`")
await ctx.send(embed=embed)

def setup(bot):
bot.add_cog(GeneralCog(bot))

0 comments on commit 89e3d86

Please sign in to comment.