This commit is contained in:
Mael G 2019-07-28 18:35:03 -04:00
commit e473128c21
2 changed files with 11 additions and 17 deletions

View file

@ -174,7 +174,7 @@ class Admin(commands.Cog):
except Exception: except Exception:
print(f"Impossible de supprimer le message " print(f"Impossible de supprimer le message "
f"\"{str(ctx.message.content)}\"") f"\"{str(ctx.message.content)}\"")
toedit = await ctx.channel.get_message(message_id) toedit = await ctx.channel.fetch_message(message_id)
except discord.errors.NotFound: except discord.errors.NotFound:
await ctx.send(f"Impossible de trouver le message avec l'id " await ctx.send(f"Impossible de trouver le message avec l'id "
f"`{message_id}` sur ce salon") f"`{message_id}` sur ce salon")
@ -196,7 +196,7 @@ class Admin(commands.Cog):
except Exception: except Exception:
print(f"Impossible de supprimer le message " print(f"Impossible de supprimer le message "
f"\"{str(ctx.message.content)}\"") f"\"{str(ctx.message.content)}\"")
toadd = await ctx.channel.get_message(message_id) toadd = await ctx.channel.fetch_message(message_id)
except discord.errors.NotFound: except discord.errors.NotFound:
await ctx.send(f"Impossible de trouver le message avec l'id " await ctx.send(f"Impossible de trouver le message avec l'id "
f"`{message_id}` sur ce salon") f"`{message_id}` sur ce salon")
@ -218,7 +218,7 @@ class Admin(commands.Cog):
except Exception: except Exception:
print(f"Impossible de supprimer le message " print(f"Impossible de supprimer le message "
f"\"{str(ctx.message.content)}\"") f"\"{str(ctx.message.content)}\"")
todelete = await ctx.channel.get_message(message_id) todelete = await ctx.channel.fetch_message(message_id)
except discord.errors.NotFound: except discord.errors.NotFound:
await ctx.send(f"Impossible de trouver le message avec l'id " await ctx.send(f"Impossible de trouver le message avec l'id "
f"`{message_id}` sur ce salon") f"`{message_id}` sur ce salon")
@ -241,7 +241,7 @@ class Admin(commands.Cog):
except Exception: except Exception:
print(f"Impossible de supprimer le message " print(f"Impossible de supprimer le message "
f"\"{str(ctx.message.content)}\"") f"\"{str(ctx.message.content)}\"")
todelete = await chan.get_message(message_id) todelete = await chan.fetch_message(message_id)
except discord.errors.NotFound: except discord.errors.NotFound:
await ctx.send(f"Impossible de trouver le message avec l'id " await ctx.send(f"Impossible de trouver le message avec l'id "
f"`{id}` sur le salon") f"`{id}` sur le salon")

View file

@ -1,3 +1,6 @@
# Help paginator by Rapptz
# Edited by F4stZ4p
import asyncio import asyncio
import discord import discord
@ -7,12 +10,9 @@ class CannotPaginate(Exception):
class Pages: class Pages:
"""Implements a paginator that queries the user for the """Implements a paginator that queries the user for the
pagination interface. pagination interface.
Pages are 1-index based, not 0-index based. Pages are 1-index based, not 0-index based.
If the user does not reply within 2 minutes then the pagination If the user does not reply within 2 minutes then the pagination
interface exits automatically. interface exits automatically.
Parameters Parameters
------------ ------------
ctx: Context ctx: Context
@ -23,7 +23,6 @@ class Pages:
How many entries show up per page. How many entries show up per page.
show_entry_count: bool show_entry_count: bool
Whether to show an entry count in the footer. Whether to show an entry count in the footer.
Attributes Attributes
----------- -----------
embed: discord.Embed embed: discord.Embed
@ -44,7 +43,7 @@ class Pages:
if left_over: if left_over:
pages += 1 pages += 1
self.maximum_pages = pages self.maximum_pages = pages
self.embed = discord.Embed(colour=discord.Colour.blurple()) self.embed = discord.Embed(colour=discord.Color.green())
self.paginating = len(entries) > per_page self.paginating = len(entries) > per_page
self.show_entry_count = show_entry_count self.show_entry_count = show_entry_count
self.reaction_emojis = [ self.reaction_emojis = [
@ -340,7 +339,7 @@ class HelpPaginator(Pages):
cog_name = cog.__class__.__name__ cog_name = cog.__class__.__name__
# get the commands # get the commands
entries = sorted(ctx.bot.get_cog_commands(cog_name), key=lambda c: c.name) entries = sorted(ctx.bot.get_cog(cog_name).get_commands(), key=lambda c: c.name)
# remove the ones we can't run # remove the ones we can't run
entries = [cmd for cmd in entries if (await _can_run(cmd, ctx)) and not cmd.hidden] entries = [cmd for cmd in entries if (await _can_run(cmd, ctx)) and not cmd.hidden]
@ -350,9 +349,6 @@ class HelpPaginator(Pages):
self.description = inspect.getdoc(cog) self.description = inspect.getdoc(cog)
self.prefix = cleanup_prefix(ctx.bot, ctx.prefix) self.prefix = cleanup_prefix(ctx.bot, ctx.prefix)
# no longer need the database
#await ctx.release()
return self return self
@classmethod @classmethod
@ -373,7 +369,6 @@ class HelpPaginator(Pages):
self.description = command.help or 'No help given.' self.description = command.help or 'No help given.'
self.prefix = cleanup_prefix(ctx.bot, ctx.prefix) self.prefix = cleanup_prefix(ctx.bot, ctx.prefix)
#await ctx.release()
return self return self
@classmethod @classmethod
@ -404,7 +399,6 @@ class HelpPaginator(Pages):
self = cls(ctx, nested_pages, per_page=1) # this forces the pagination session self = cls(ctx, nested_pages, per_page=1) # this forces the pagination session
self.prefix = cleanup_prefix(ctx.bot, ctx.prefix) self.prefix = cleanup_prefix(ctx.bot, ctx.prefix)
#await ctx.release()
# swap the get_page implementation with one that supports our style of pagination # swap the get_page implementation with one that supports our style of pagination
self.get_page = self.get_bot_page self.get_page = self.get_bot_page
@ -429,8 +423,8 @@ class HelpPaginator(Pages):
self.embed.title = self.title self.embed.title = self.title
if hasattr(self, '_is_bot'): if hasattr(self, '_is_bot'):
value ='For more help, join the official bot support server: https://discord.gg/pYuKF2Z' value ='Check the bot source: **[GitHub Link](https://github.com/F4stZ4p/DJ5n4k3/)**'
self.embed.add_field(name='Support', value=value, inline=False) self.embed.add_field(name='**GitHub**', value=value, inline=False)
self.embed.set_footer(text=f'Use "{self.prefix}help command" for more info on a command.') self.embed.set_footer(text=f'Use "{self.prefix}help command" for more info on a command.')