Skip to content

Commit

Permalink
add buttons on help command
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulMarisOUMary committed Aug 28, 2021
1 parent 812a2c6 commit 119730e
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 108 deletions.
45 changes: 24 additions & 21 deletions cogs/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,52 +19,55 @@ def help_custom(self):

@commands.command(name='help', aliases=['?', 'h', 'commands'])
async def help(self, ctx, *input):
"""Show help command, use : help {COMMAND/CATEGORY}"""
embed = discord.Embed(url='https://github.com/PaulMarisOUMary/Algosup-Discord')
remind = "\n**Remind** : Hooks such as {} must not be used when executing commands."
title, description, color = "Help · ", "", discord.Color.blue()
"""Show the help menu."""
if not input:
allowed = 5
close_in = round(datetime.timestamp(datetime.now() + timedelta(minutes=allowed)))
embed = discord.Embed(color=discord.Color.dark_grey(), title = "👋 Help · Home", description = "Welcome to the help page.\n\nUse `help command` for more info on a command.\nUse `help category` for more info on a category.\nUse the dropdown menu below to select a category.\n\u200b", url='https://github.com/PaulMarisOUMary/Algosup-Discord')
embed = discord.Embed(color=discord.Color.dark_grey(), title = "👋 Help · Home", description = "`Welcome to the help page.`\n\nUse `help command` for more info on a command.\nUse `help category` for more info on a category.\nUse the dropdown menu below to select a category.\n\u200b", url='https://github.com/PaulMarisOUMary/Algosup-Discord')
embed.add_field(name="Time remaining :", value="This help session will end <t:"+str(close_in)+":R>.\nType `help` to open a new session.\n\u200b", inline=False)
embed.add_field(name="Who am I ?", value="I'm a bot made by *WarriorMachine*. Made for Algosup in 2020.\nI have a lot of features such translator, events manager, utils, and more.\n\nI'm open source, you can see my code on [Github](https://github.com/PaulMarisOUMary/Algosup-Discord) !")

view = vhelp.View(bot=self.bot, ctx=ctx, homeembed=embed)
view = vhelp.View(bot=self.bot, ctx=ctx, homeembed=embed, ui=2)
message = await ctx.send(embed=embed, view=view)
try:
await asyncio.sleep(60*allowed)
view.stop()
await message.delete()
await ctx.message.add_reaction("<a:checkmark_a:842800730049871892>")
except: pass
return #end function

elif len(input) == 1:
search, search_command, search_cog = input[0].lower(), False, False
search, search_command, search_cog, embed = input[0].lower(), None, None, None
try:
search_command = self.bot.get_command(search)
search_cog = self.bot.cogs[search]
except: pass

title = "Help · " + str(search)
if search_cog:
description, command_list = str(search_cog.__doc__), ''
for command in search_cog.get_commands():
command_list += "__"+str(command.name)+"__\n"+str(command.help)+'\n'
embed.add_field(name="Commands :", value=command_list, inline=False)
if "help_custom" in dir(search_cog):
emoji, label, description = search_cog.help_custom()
embed = discord.Embed(title = str(emoji)+" Help · "+str(label),description='`'+str(search_cog.__doc__)+'`', url='https://github.com/PaulMarisOUMary/Algosup-Discord')
for command in search_cog.get_commands():
params = ""
for param in command.clean_params: params += " <"+str(param)+">"
embed.add_field(name=str(command.name)+str(params), value=str(command.help)+"\n\u200b", inline=False)
elif search_command:
description, color = '', discord.Color.green()
embed.add_field(name=str(search_command.name), value="__Aliases__ : `"+"`, `".join(search_command.aliases)+"`\n__Help__ : "+str(search_command.help), inline=False)
cog = search_command.cog
if "help_custom" in dir(cog):
emoji, label, description = cog.help_custom()
embed = discord.Embed(title = str(emoji)+" Help · "+str(label)+" : "+str(search_command.name), description="**Command** : "+str(search_command.name)+"\n"+str(search_command.help), url='https://github.com/PaulMarisOUMary/Algosup-Discord')
params = ""
for param in search_command.clean_params: params += " <"+str(param)+">"
embed.add_field(name="Usage", value=str(search_command.name)+str(params), inline=False)
embed.add_field(name="Aliases", value='`'+str(search_command.aliases)+'`')
else:
title, description, color = "Help · Error", "Nothing was found", discord.Color.orange()
raise commands.CommandError("Nothing found.")

embed.set_footer(text="Remind : Hooks such as <> must not be used when executing commands.", icon_url=ctx.message.author.display_avatar.url)
await ctx.send(embed=embed)

elif len(input) > 1:
title, description, color = "Help · Error", "Too many arguments", discord.Color.orange()

embed.title, embed.description, embed.color = title, remind + description, color
embed.set_footer(text="Requested by : "+str(ctx.message.author.name)+" at "+str(time.strftime('%H:%M:%S')), icon_url=ctx.message.author.display_avatar.url)
await ctx.send(embed=embed)
raise commands.CommandError("Too many arguments.")

@commands.command(name='ping', pass_context=True)
async def ping(self, ctx):
Expand Down
12 changes: 6 additions & 6 deletions cogs/fridaycake.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def getFriday(date, holiday, count):
date += timedelta(days=7)

class FridayCake(commands.Cog, name="fridaycake", command_attrs=dict(hidden=False)):
"""FridayCake's commands"""
"""FridayCake's event commands."""
def __init__(self, bot):
self.bot = bot

Expand All @@ -36,18 +36,18 @@ def help_custom(self):

@commands.command(name='cake', aliases=['fc'])
async def cake(self, ctx):
"""Show a random emoji of cake :)"""
"""Show a random emoji of cake <:bigsmile2:595317533104537601>."""
emoji_choices = [":cake:", ":moon_cake:", ":cupcake:", ":pancakes:"]
await ctx.send(random.choice(emoji_choices))

@commands.command(name='fridaycakeinfo', aliases=['fci'])
async def cake(self, ctx):
"""Explain how the order of participants is made"""
"""Explain how the order of participants is made."""
await ctx.send("FridayCake : *The order of the participants on the list has been generated randomly, your date is resulted of chaos.*")

@commands.command(name='all', aliases=['a'])
async def all_cake(self, ctx):
"""Show the complete order list for the FridayCake event"""
"""Show the complete order list for the FridayCake event."""
embed = discord.Embed(title="All ·", colour=0xf7346b)
embed.set_thumbnail(
url="https://cdn.discordapp.com/attachments/332696002144501760/800791318200188998/fridaycake.png")
Expand All @@ -61,7 +61,7 @@ async def all_cake(self, ctx):

@commands.command(name='when', aliases=['w'])
async def when_cake(self, ctx):
"""Show your specific date about the FridayCake event"""
"""Show your specific order of passage about the FridayCake event."""
name, pin = ctx.message.author.display_name.lower().replace(
'é', 'e').replace('-', ''), []
for _, (f, p) in enumerate(zip(getFriday(start, holidays, len(groups)), groups)):
Expand All @@ -81,7 +81,7 @@ async def when_cake(self, ctx):

@commands.command(name='next', aliases=['n'])
async def next_cake(self, ctx):
"""Show who are the next to make a cake for the FridayCake event"""
"""Show who are the next to make a cake for the FridayCake event."""
pin = []
for i, (f, p) in enumerate(zip(getFriday(start, holidays, len(groups)), groups)):
if not date.today() >= f and not pin:
Expand Down
4 changes: 2 additions & 2 deletions cogs/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def statServer(guild):
return status

class Info(commands.Cog, name="info", command_attrs=dict(hidden=False)):
"""Info & statistics"""
"""Info & statistics."""
def __init__(self, bot):
self.bot = bot

Expand All @@ -35,7 +35,7 @@ def help_custom(self):

@commands.command(name='stat', aliases=['status','graph','gs','sg'])
async def stat(self, ctx):
"""Show a graphic pie about the server's members"""
"""Show a graphic pie about the server's members."""
plt.clf()
ax, data, colors = plt.subplot(), statServer(ctx.guild.members), ["#747f8d","#f04747","#faa81a","#43b582"]
ax.pie([data['offline'], data['dnd'], data['idle'], data['online']], colors=colors, startangle=-40, wedgeprops=dict(width=0.5))
Expand Down
6 changes: 3 additions & 3 deletions cogs/privatetextual.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def help_custom(self):
@commands.command(name='addprivate', aliases=['create', 'add', '+', '>'], require_var_positional=True)
@commands.cooldown(1, 10, commands.BucketType.user)
async def create_private_channel(self, ctx, *members : discord.Member):
"""Create a private channel, use : addprivate {@USERNAME_1} {@USERNAME_2}"""
"""Create a private textual channel."""
users, mentions, down_role = [ctx.message.author], "", discord.utils.get(ctx.guild.roles, name="🎓Student")

for g in members:
Expand All @@ -59,7 +59,7 @@ async def create_private_channel(self, ctx, *members : discord.Member):

@commands.command(name='delprivate', aliases=['delete', 'del', '-', '<'])
async def delete_private_channel(self, ctx):
"""Delete your private channel"""
"""Delete your private textual channel."""
channel, roles = ctx.channel, get_created_roles(ctx)
if '_' in channel.name and roles:
await roles[0].delete()
Expand All @@ -69,7 +69,7 @@ async def delete_private_channel(self, ctx):

@commands.command(name='renprivate', aliases=['rename', 'ren', 'r', '_'], require_var_positional=True)
async def rename_private_channel(self, ctx, custom_name : str):
"""Rename your private channel, use : renprivate {NAME}"""
"""Rename your private textual channel."""
channel, roles = ctx.channel, get_created_roles(ctx)
normalize_cn, forbidden = text_to_allowed(custom_name)
if '_' in channel.name and roles and normalize_cn:
Expand Down
4 changes: 2 additions & 2 deletions cogs/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def processSchedule(self, events, startat = 9, endat = 17):

@commands.command(name='daycalendar', aliases=['dc'])
async def day_calendar(self, ctx, more = 0):
"""Get the schedule of the scolar day, use : daycalendar {NUMBER}"""
"""Get the schedule of the scolar day."""
today = datetime.now().date()
start = today + timedelta(days=more)
end = start + timedelta(days=1)
Expand All @@ -101,7 +101,7 @@ async def day_calendar(self, ctx, more = 0):

@commands.command(name='weekcalendar', aliases=['wc'])
async def week_calendar(self, ctx, more = 0):
"""Get the schedule of the scolar week, use : weekcalendar {NUMBER}"""
"""Get the schedule of the scolar week."""
today = datetime.now().date()
start = today + timedelta(days=today.weekday()+1+((more-1)*7))
end = start + timedelta(weeks=1)
Expand Down
2 changes: 1 addition & 1 deletion cogs/spotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def help_custom(self):

@commands.command(name='spotify', aliases=['sy', 'sp', 'spy', 'spot'])
async def actual_calendar(self, ctx, user: discord.Member = None):
"""Show the current Spotify song, or use : spotify {@USERNAME}"""
"""Show the current Spotify song."""
keeper = True
if not user: user = ctx.author
for activity in user.activities:
Expand Down
4 changes: 2 additions & 2 deletions cogs/usefull.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def help_custom(self):

@commands.command(name='strawpoll', aliases=['straw', 'stp', 'sond', 'sondage'], pass_context=True)
async def strawpool(self, ctx, *, context):
"""Ask a sondage, with 2 reactions, use : strawpoll {QUESTION}"""
"""Ask a sondage, and add 2 reactions to vote with your community."""
crossmark, checkmark = self.bot.get_emoji(842800737221607474), self.bot.get_emoji(842800730049871892)
await ctx.message.delete()
message = await ctx.send("__*" + ctx.message.author.mention + "*__ : " + context)
Expand All @@ -24,7 +24,7 @@ async def strawpool(self, ctx, *, context):

@commands.command(name='emojilist', aliases=['ce', 'el'], pass_context=True)
async def getcustomemojis(self, ctx):
"""Return a list of each cutom emojis of the server"""
"""Return a list of each cutom emojis from the current server."""
embed_list, embed = [], discord.Embed(title="Custom Emojis List ("+str(len(ctx.guild.emojis))+") :")
for i, emoji in enumerate(ctx.guild.emojis, start=1):
if i == 0 : i += 1
Expand Down
6 changes: 3 additions & 3 deletions cogs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ def help_custom(self):

@commands.command(name='bool')
async def boo(self, ctx):
"""Preview of buttons"""
"""Discover buttons feature with this command."""
view = bool.View(flabel="Agree", slabel="Disagree", sstyle=discord.ButtonStyle.red, emojis = True, source=ctx)
await ctx.send("Buttons demo right there !", view=view)

@commands.command(name='dropdown')
async def dro(self, ctx):
"""Preview of the Dropdown menu"""
"""Discover select menu feature with this command."""
options = [
{'label':"Mandarin", 'description':"你好", 'emoji':"🇨🇳"},
{'label':"Spanish", 'description':"Buenos dias", 'emoji':"🇪🇸"},
Expand Down Expand Up @@ -55,7 +55,7 @@ async def dro(self, ctx):

@commands.command(name='link')
async def lin(self, ctx):
"""Preview of link button"""
"""Discover button link with this feature."""
view = link.View(label="Source code on Github", url="https://github.com/PaulMarisOUMary/Algosup-Discord")
await ctx.send("Find out what is behind Algobot !", view=view)

Expand Down
Loading

0 comments on commit 119730e

Please sign in to comment.