mirror of https://github.com/sgoudham/Enso-Bot.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
322 lines
12 KiB
Python
322 lines
12 KiB
Python
4 years ago
|
import datetime
|
||
|
|
||
4 years ago
|
from discord import Embed
|
||
4 years ago
|
from discord.ext import commands, menus
|
||
4 years ago
|
from discord.ext.commands import command
|
||
|
|
||
4 years ago
|
from settings import enso_embedmod_colours
|
||
4 years ago
|
|
||
4 years ago
|
|
||
4 years ago
|
# Pages of the help embed
|
||
|
def help_menu(self, guild_icon):
|
||
|
# Setting up the embed for the Fun Commands
|
||
|
fun = Embed(title="(っ◔◡◔)っ Fun (っ◔◡◔)っ",
|
||
|
colour=enso_embedmod_colours,
|
||
|
timestamp=datetime.datetime.utcnow())
|
||
4 years ago
|
|
||
4 years ago
|
# Setting thumbnail and author
|
||
4 years ago
|
fun.set_thumbnail(url=guild_icon)
|
||
4 years ago
|
|
||
4 years ago
|
# Setting up the fields in a separate array
|
||
|
fun_fields = [
|
||
4 years ago
|
(f"**{self.ctx.prefix}comp `<person>`**",
|
||
4 years ago
|
"\nCompliment a person in the server", True),
|
||
4 years ago
|
(f"**{self.ctx.prefix}8ball `<text>`**",
|
||
4 years ago
|
"\nAsk a question and 8ball will give a custom response", True),
|
||
4 years ago
|
(f"**{self.ctx.prefix}homies `<text>`**",
|
||
4 years ago
|
"\nGenerates homies meme with given text", True),
|
||
4 years ago
|
(f"**{self.ctx.prefix}owo `<text>`**",
|
||
4 years ago
|
"\nTranslates given text to 'owo' format", True),
|
||
|
(f"**{self.ctx.prefix}flip**",
|
||
|
"\nDoes a coinflip with big pp Or smol pp", True),
|
||
|
(f"**{self.ctx.prefix}doggo**",
|
||
|
"\nLook at images of Doggos", True)]
|
||
4 years ago
|
|
||
4 years ago
|
# Setting up the embed for the Fun Commands
|
||
|
interactive = Embed(title="(っ◔◡◔)っ Interactive (っ◔◡◔)っ",
|
||
|
colour=enso_embedmod_colours,
|
||
|
timestamp=datetime.datetime.utcnow())
|
||
4 years ago
|
|
||
|
# Setting thumbnail and author
|
||
4 years ago
|
interactive.set_thumbnail(url=guild_icon)
|
||
4 years ago
|
|
||
|
# Setting up the fields in a separate array
|
||
4 years ago
|
interactive_fields = [
|
||
4 years ago
|
(f"**{self.ctx.prefix}hug `<person>`**",
|
||
4 years ago
|
"\nHug a User Within The Server", True),
|
||
4 years ago
|
(f"**{self.ctx.prefix}cuddle `<person>`**",
|
||
4 years ago
|
"\nCuddle a User Within The Server", True),
|
||
4 years ago
|
(f"**{self.ctx.prefix}pat `<person>`**",
|
||
4 years ago
|
"\nPat a User Within The Server", True),
|
||
4 years ago
|
(f"**{self.ctx.prefix}kiss `<person>`**",
|
||
4 years ago
|
"\nKiss a User Within The Server", True),
|
||
4 years ago
|
(f"**{self.ctx.prefix}lemon `<person>`**",
|
||
4 years ago
|
"\nGive lemon to a User Within The Server", True)]
|
||
4 years ago
|
|
||
4 years ago
|
# Setting up the embed for the Fun Commands
|
||
|
interactive_2 = Embed(title="(っ◔◡◔)っ Interactive 2 (っ◔◡◔)っ",
|
||
|
colour=enso_embedmod_colours,
|
||
|
timestamp=datetime.datetime.utcnow())
|
||
4 years ago
|
|
||
|
# Setting thumbnail and author
|
||
4 years ago
|
interactive_2.set_thumbnail(url=guild_icon)
|
||
4 years ago
|
|
||
|
# Setting up the fields in a separate array
|
||
4 years ago
|
interactive_fields_2 = [
|
||
4 years ago
|
(f"**{self.ctx.prefix}slap `<person>`**",
|
||
4 years ago
|
"\nSlap a User Within The Server", True),
|
||
4 years ago
|
(f"**{self.ctx.prefix}kill `<person>`**",
|
||
4 years ago
|
"\nKill a User Within The Server", True),
|
||
4 years ago
|
(f"**{self.ctx.prefix}choke `<person>`**",
|
||
4 years ago
|
"\nChoke a User Within The Server", True)]
|
||
4 years ago
|
|
||
4 years ago
|
# Setting up the embed for Relationship commands
|
||
|
relationship = Embed(title="(っ◔◡◔)っ Relationship (っ◔◡◔)っ",
|
||
|
colour=enso_embedmod_colours,
|
||
|
timestamp=datetime.datetime.utcnow())
|
||
4 years ago
|
|
||
|
# Setting thumbnail and author
|
||
4 years ago
|
relationship.set_thumbnail(url=guild_icon)
|
||
4 years ago
|
|
||
|
# Setting up the fields in a separate array
|
||
4 years ago
|
relationship_fields = [
|
||
4 years ago
|
(f"**{self.ctx.prefix}marry `<person>`**",
|
||
|
"\nMarry a User Within The Server", True),
|
||
|
(f"**{self.ctx.prefix}divorce `<person>`**",
|
||
4 years ago
|
"\nDivorce The Person You Are Married To", False),
|
||
4 years ago
|
(f"**{self.ctx.prefix}minfo `<person>`**",
|
||
|
"\nDisplays information about the user's current marriage" +
|
||
4 years ago
|
f"\nUsing **{self.ctx.prefix}minfo** by itself will retrieve your marriage information", True)]
|
||
4 years ago
|
|
||
4 years ago
|
# Setting up the Embed for the Enso commands
|
||
|
enso = Embed(title="(っ◔◡◔)っ Enso (っ◔◡◔)っ",
|
||
|
colour=enso_embedmod_colours,
|
||
|
timestamp=datetime.datetime.utcnow())
|
||
4 years ago
|
|
||
4 years ago
|
# Setting thumbnail and author
|
||
|
enso.set_thumbnail(url=guild_icon)
|
||
4 years ago
|
|
||
4 years ago
|
# Setting up the fields in a separate array
|
||
|
enso_fields = [
|
||
|
(f"**{self.ctx.prefix}enso `<person>`**",
|
||
|
"\nShows Specified Image of User" +
|
||
4 years ago
|
f"\n(Using **{self.ctx.prefix}enso** by itself shows random image of users in the server)",
|
||
4 years ago
|
True),
|
||
|
(f"**{self.ctx.prefix}enso `list`**",
|
||
|
"\nReturns all Users", False),
|
||
|
(f"**{self.ctx.prefix}rules**",
|
||
|
"\nFull ruleset for Enso", True),
|
||
|
(f"**{self.ctx.prefix}roles**",
|
||
|
"\nLeveling and xp system in Enso", True),
|
||
|
]
|
||
4 years ago
|
|
||
4 years ago
|
# Setting up the embed for the Waifu/Husbandos
|
||
|
waifu_and_husbando = Embed(title="(っ◔◡◔)っ Waifu/Husbando Commands (っ◔◡◔)っ",
|
||
|
colour=enso_embedmod_colours,
|
||
|
timestamp=datetime.datetime.utcnow())
|
||
4 years ago
|
|
||
4 years ago
|
# Setting thumbnail and author
|
||
4 years ago
|
waifu_and_husbando.set_thumbnail(url=guild_icon)
|
||
4 years ago
|
|
||
4 years ago
|
# Setting up the fields in a separate array
|
||
4 years ago
|
waifu_and_husbando_fields = [
|
||
4 years ago
|
(f"**{self.ctx.prefix}w `<waifu>`**",
|
||
4 years ago
|
"\nShows Specified Image of Waifu" +
|
||
4 years ago
|
f"\n(Using **{self.ctx.prefix}w** shows random image of Waifu)", True),
|
||
4 years ago
|
(f"**{self.ctx.prefix}h `<husbando>`**",
|
||
4 years ago
|
"\nShows Specified Image of Husbando" +
|
||
4 years ago
|
f"\n(Using **{self.ctx.prefix}h** shows random image of Husbando)", False),
|
||
|
(f"**{self.ctx.prefix}w `list`**",
|
||
|
"\nReturns all Waifus", True),
|
||
|
(f"**{self.ctx.prefix}h `list`**",
|
||
|
"\nReturns all Husbandos", True)]
|
||
4 years ago
|
|
||
4 years ago
|
# Setting up the embed for the Important Commands
|
||
|
important = Embed(title="(っ◔◡◔)っ Important (っ◔◡◔)っ",
|
||
|
colour=enso_embedmod_colours,
|
||
|
timestamp=datetime.datetime.utcnow())
|
||
4 years ago
|
|
||
4 years ago
|
# Setting thumbnail and author
|
||
|
important.set_thumbnail(url=guild_icon)
|
||
4 years ago
|
|
||
4 years ago
|
# Setting up the fields in a separate array
|
||
|
important_fields = [
|
||
|
(f"**{self.ctx.prefix}userinfo**",
|
||
|
"\nReturns information about the user", True),
|
||
|
(f"**{self.ctx.prefix}serverinfo**",
|
||
|
"\nReturns information about the server", True),
|
||
4 years ago
|
(f"**{self.ctx.prefix}prefix `<new_prefix>`**",
|
||
|
"\nView current prefix/Update current prefix", True),
|
||
4 years ago
|
(f"**{self.ctx.prefix}help**",
|
||
|
"\nSee every command in the bot", True)]
|
||
4 years ago
|
|
||
4 years ago
|
# Setting up the embed for modmail
|
||
|
modmail = Embed(title="(っ◔◡◔)っ ModMail (っ◔◡◔)っ",
|
||
|
colour=enso_embedmod_colours,
|
||
|
timestamp=datetime.datetime.utcnow())
|
||
4 years ago
|
|
||
|
# Setting thumbnail and author
|
||
4 years ago
|
modmail.set_thumbnail(url=guild_icon)
|
||
4 years ago
|
|
||
|
# Setting up the fields in a separate array
|
||
4 years ago
|
modmail_fields = [(f"**{self.ctx.prefix}modmail setup `<channelID>`**",
|
||
4 years ago
|
"Sets up the modmail system in the guild,"
|
||
|
"channelID given will be the channel that the user will interact with", False),
|
||
4 years ago
|
(f"**{self.ctx.prefix}modmail update `<channelID>`**",
|
||
4 years ago
|
"Updates the channel that the modmail will be sent to", False),
|
||
4 years ago
|
(f"**{self.ctx.prefix}modmail delete modmail**",
|
||
4 years ago
|
"Existing modmail system will be deleted", False)]
|
||
|
|
||
4 years ago
|
# Setting up the Embed for the Miscellaneous commands
|
||
|
msc = Embed(title="(っ◔◡◔)っ Misc (っ◔◡◔)っ",
|
||
|
colour=enso_embedmod_colours,
|
||
|
timestamp=datetime.datetime.utcnow())
|
||
|
|
||
|
# Setting thumbnail and author
|
||
|
msc.set_thumbnail(url=guild_icon)
|
||
|
|
||
|
# Setting up the fields in a separate array
|
||
4 years ago
|
msc_fields = [(f"**{self.ctx.prefix}dm `<person>`**",
|
||
4 years ago
|
f"\nFor admins to DM Users" +
|
||
|
"\n**(Perms: Co-Owner)**", True),
|
||
|
(f"**{self.ctx.prefix}remindme `<time>` `<text>`**",
|
||
4 years ago
|
"\nGet Enso~Chan to remind you in DMs", True),
|
||
|
(f"**{self.ctx.prefix}stats**",
|
||
|
"\nView bot statistics (CPU/Mem Usage etc)", True),
|
||
|
(f"**{self.ctx.prefix}ping**", "\nReturns latency in ms", True)]
|
||
4 years ago
|
|
||
4 years ago
|
# Defining dictionary of embeds as keys, list of fields as values
|
||
|
help_dict = {
|
||
|
fun: fun_fields,
|
||
|
interactive: interactive_fields,
|
||
|
interactive_2: interactive_fields_2,
|
||
|
relationship: relationship_fields,
|
||
|
enso: enso_fields,
|
||
|
waifu_and_husbando: waifu_and_husbando_fields,
|
||
|
important: important_fields,
|
||
4 years ago
|
modmail: modmail_fields,
|
||
|
msc: msc_fields
|
||
4 years ago
|
}
|
||
|
|
||
|
# Iterating through the dictionary and adding fields to the embeds
|
||
|
for embed, field in help_dict.items():
|
||
|
for name, value, inline in field:
|
||
|
embed.add_field(name=name, value=value, inline=inline)
|
||
|
|
||
|
# Return all the embeds
|
||
4 years ago
|
return fun, interactive, interactive_2, relationship, enso, waifu_and_husbando, important, modmail, msc
|
||
4 years ago
|
|
||
|
|
||
4 years ago
|
def embeds(self):
|
||
4 years ago
|
# Define guild icon
|
||
4 years ago
|
guild_icon = self.ctx.guild.icon_url
|
||
4 years ago
|
|
||
4 years ago
|
# Set the different pages of the embed
|
||
4 years ago
|
page1, page2, page3, page4, page5, page6, page7, page8, page9 = help_menu(self, guild_icon)
|
||
4 years ago
|
|
||
4 years ago
|
# Store all the categories of the menu to an array called pages
|
||
4 years ago
|
pages = [page1, page2, page3,
|
||
|
page4, page5, page6,
|
||
|
page7, page8, page9]
|
||
4 years ago
|
|
||
4 years ago
|
return pages
|
||
4 years ago
|
|
||
|
|
||
4 years ago
|
# Set up the Cog
|
||
4 years ago
|
class HelpMenu(menus.Menu):
|
||
4 years ago
|
def __init__(self, i, bot):
|
||
4 years ago
|
super().__init__(timeout=125.0, delete_message_after=True)
|
||
4 years ago
|
self.i = i
|
||
4 years ago
|
self.bot = bot
|
||
4 years ago
|
|
||
4 years ago
|
# Message to be sent on the initial command ~help
|
||
4 years ago
|
async def send_initial_message(self, ctx, channel):
|
||
4 years ago
|
# Set the first embed to the first element in the pages[]
|
||
4 years ago
|
initial = embeds(self)[self.i]
|
||
4 years ago
|
|
||
|
# Send embed
|
||
4 years ago
|
return await channel.send(embed=initial)
|
||
|
|
||
4 years ago
|
# Reaction to allow user to go to the previous page in the embed
|
||
4 years ago
|
@menus.button('\N{LEFTWARDS BLACK ARROW}')
|
||
4 years ago
|
async def on_left_arrow(self, payload):
|
||
4 years ago
|
|
||
|
# Simple check to make sure that the reaction is performed by the user
|
||
4 years ago
|
def check(m):
|
||
|
return m.author == payload.member
|
||
|
|
||
4 years ago
|
# Do nothing if the check does not return true
|
||
|
if not check(self.ctx):
|
||
|
return
|
||
|
# Allow the page number to be decreased
|
||
|
else:
|
||
|
|
||
|
# Set self.i to (i - 1) remainder length of the array
|
||
4 years ago
|
self.i = (self.i - 1) % len(embeds(self))
|
||
|
prev_page = embeds(self)[self.i]
|
||
|
|
||
4 years ago
|
# Send the embed and remove the reaction of the user
|
||
4 years ago
|
await self.message.edit(embed=prev_page)
|
||
|
await self.message.remove_reaction("⬅", self.ctx.author)
|
||
|
|
||
4 years ago
|
# Reaction to allow user to go to the next page in the embed
|
||
4 years ago
|
@menus.button('\N{BLACK RIGHTWARDS ARROW}')
|
||
4 years ago
|
async def on_right_arrow(self, payload):
|
||
4 years ago
|
|
||
|
# Simple check to make sure that the reaction is performed by the user
|
||
4 years ago
|
def check(m):
|
||
|
return m.author == payload.member
|
||
|
|
||
4 years ago
|
# Do nothing if the check does not return true
|
||
|
if not check(self.ctx):
|
||
|
return
|
||
4 years ago
|
# Allow the page number to be increased
|
||
4 years ago
|
else:
|
||
|
|
||
|
# Set self.i to (i + 1) remainder length of the array
|
||
4 years ago
|
self.i = (self.i + 1) % len(embeds(self))
|
||
|
next_page = embeds(self)[self.i]
|
||
|
|
||
4 years ago
|
# Send the embed and remove the reaction of the user
|
||
4 years ago
|
await self.message.edit(embed=next_page)
|
||
|
await self.message.remove_reaction("➡", self.ctx.author)
|
||
|
|
||
4 years ago
|
@menus.button('\N{BLACK SQUARE FOR STOP}\ufe0f')
|
||
4 years ago
|
async def on_stop(self, payload):
|
||
4 years ago
|
|
||
4 years ago
|
# Simple check to make sure that the reaction is performed by the user
|
||
|
def check(m):
|
||
|
return m.author == payload.member
|
||
|
|
||
4 years ago
|
# Do nothing if the check does not return true
|
||
4 years ago
|
if not check(self.ctx):
|
||
|
return
|
||
4 years ago
|
# Allow the embed to be deleted
|
||
4 years ago
|
else:
|
||
|
|
||
4 years ago
|
# Delete the embed and stop the function from running
|
||
|
await self.message.delete()
|
||
4 years ago
|
self.stop()
|
||
4 years ago
|
|
||
|
|
||
|
# Set up the cog
|
||
4 years ago
|
class CustomHelp(commands.Cog):
|
||
4 years ago
|
def __init__(self, bot):
|
||
|
self.bot = bot
|
||
4 years ago
|
self.bot.remove_command("help")
|
||
4 years ago
|
|
||
4 years ago
|
@command(name="help", aliases=["Help"])
|
||
4 years ago
|
async def help(self, ctx):
|
||
4 years ago
|
"""Returns a menu for help commands controlled by reactions"""
|
||
|
|
||
4 years ago
|
# Local Variable i to allow the index of the pages[] to be modified
|
||
4 years ago
|
i = 0
|
||
4 years ago
|
|
||
|
# Send the menu to the display
|
||
|
menu = HelpMenu(i, self)
|
||
|
await menu.start(ctx)
|
||
4 years ago
|
|
||
|
|
||
|
def setup(bot):
|
||
4 years ago
|
bot.add_cog(CustomHelp(bot))
|