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
5 years ago
|
import datetime
|
||
|
|
||
5 years ago
|
from discord import Embed
|
||
5 years ago
|
from discord.ext import commands, menus
|
||
5 years ago
|
from discord.ext.commands import command
|
||
|
|
||
5 years ago
|
from settings import enso_embedmod_colours
|
||
5 years ago
|
|
||
5 years ago
|
|
||
5 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())
|
||
5 years ago
|
|
||
5 years ago
|
# Setting thumbnail and author
|
||
5 years ago
|
fun.set_thumbnail(url=guild_icon)
|
||
5 years ago
|
|
||
5 years ago
|
# Setting up the fields in a separate array
|
||
|
fun_fields = [
|
||
5 years ago
|
(f"**{self.ctx.prefix}comp `<person>`**",
|
||
5 years ago
|
"\nCompliment a person in the server", True),
|
||
5 years ago
|
(f"**{self.ctx.prefix}8ball `<text>`**",
|
||
5 years ago
|
"\nAsk a question and 8ball will give a custom response", True),
|
||
5 years ago
|
(f"**{self.ctx.prefix}homies `<text>`**",
|
||
5 years ago
|
"\nGenerates homies meme with given text", True),
|
||
5 years ago
|
(f"**{self.ctx.prefix}owo `<text>`**",
|
||
5 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)]
|
||
5 years ago
|
|
||
5 years ago
|
# Setting up the embed for the Fun Commands
|
||
|
interactive = Embed(title="(っ◔◡◔)っ Interactive (っ◔◡◔)っ",
|
||
|
colour=enso_embedmod_colours,
|
||
|
timestamp=datetime.datetime.utcnow())
|
||
5 years ago
|
|
||
|
# Setting thumbnail and author
|
||
5 years ago
|
interactive.set_thumbnail(url=guild_icon)
|
||
5 years ago
|
|
||
|
# Setting up the fields in a separate array
|
||
5 years ago
|
interactive_fields = [
|
||
5 years ago
|
(f"**{self.ctx.prefix}hug `<person>`**",
|
||
5 years ago
|
"\nHug a User Within The Server", True),
|
||
5 years ago
|
(f"**{self.ctx.prefix}cuddle `<person>`**",
|
||
5 years ago
|
"\nCuddle a User Within The Server", True),
|
||
5 years ago
|
(f"**{self.ctx.prefix}pat `<person>`**",
|
||
5 years ago
|
"\nPat a User Within The Server", True),
|
||
5 years ago
|
(f"**{self.ctx.prefix}kiss `<person>`**",
|
||
5 years ago
|
"\nKiss a User Within The Server", True),
|
||
5 years ago
|
(f"**{self.ctx.prefix}lemon `<person>`**",
|
||
5 years ago
|
"\nGive lemon to a User Within The Server", True)]
|
||
5 years ago
|
|
||
5 years ago
|
# Setting up the embed for the Fun Commands
|
||
|
interactive_2 = Embed(title="(っ◔◡◔)っ Interactive 2 (っ◔◡◔)っ",
|
||
|
colour=enso_embedmod_colours,
|
||
|
timestamp=datetime.datetime.utcnow())
|
||
5 years ago
|
|
||
|
# Setting thumbnail and author
|
||
5 years ago
|
interactive_2.set_thumbnail(url=guild_icon)
|
||
5 years ago
|
|
||
|
# Setting up the fields in a separate array
|
||
5 years ago
|
interactive_fields_2 = [
|
||
5 years ago
|
(f"**{self.ctx.prefix}slap `<person>`**",
|
||
5 years ago
|
"\nSlap a User Within The Server", True),
|
||
5 years ago
|
(f"**{self.ctx.prefix}kill `<person>`**",
|
||
5 years ago
|
"\nKill a User Within The Server", True),
|
||
5 years ago
|
(f"**{self.ctx.prefix}choke `<person>`**",
|
||
5 years ago
|
"\nChoke a User Within The Server", True)]
|
||
5 years ago
|
|
||
5 years ago
|
# Setting up the embed for Relationship commands
|
||
|
relationship = Embed(title="(っ◔◡◔)っ Relationship (っ◔◡◔)っ",
|
||
|
colour=enso_embedmod_colours,
|
||
|
timestamp=datetime.datetime.utcnow())
|
||
5 years ago
|
|
||
|
# Setting thumbnail and author
|
||
5 years ago
|
relationship.set_thumbnail(url=guild_icon)
|
||
5 years ago
|
|
||
|
# Setting up the fields in a separate array
|
||
5 years ago
|
relationship_fields = [
|
||
5 years ago
|
(f"**{self.ctx.prefix}marry `<person>`**",
|
||
|
"\nMarry a User Within The Server", True),
|
||
|
(f"**{self.ctx.prefix}divorce `<person>`**",
|
||
5 years ago
|
"\nDivorce The Person You Are Married To", False),
|
||
5 years ago
|
(f"**{self.ctx.prefix}minfo `<person>`**",
|
||
|
"\nDisplays information about the user's current marriage" +
|
||
5 years ago
|
f"\nUsing **{self.ctx.prefix}minfo** by itself will retrieve your marriage information", True)]
|
||
5 years ago
|
|
||
5 years ago
|
# Setting up the Embed for the Enso commands
|
||
|
enso = Embed(title="(っ◔◡◔)っ Enso (っ◔◡◔)っ",
|
||
|
colour=enso_embedmod_colours,
|
||
|
timestamp=datetime.datetime.utcnow())
|
||
5 years ago
|
|
||
5 years ago
|
# Setting thumbnail and author
|
||
|
enso.set_thumbnail(url=guild_icon)
|
||
5 years ago
|
|
||
5 years ago
|
# Setting up the fields in a separate array
|
||
|
enso_fields = [
|
||
|
(f"**{self.ctx.prefix}enso `<person>`**",
|
||
|
"\nShows Specified Image of User" +
|
||
5 years ago
|
f"\n(Using **{self.ctx.prefix}enso** by itself shows random image of users in the server)",
|
||
5 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),
|
||
|
]
|
||
5 years ago
|
|
||
5 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())
|
||
5 years ago
|
|
||
5 years ago
|
# Setting thumbnail and author
|
||
5 years ago
|
waifu_and_husbando.set_thumbnail(url=guild_icon)
|
||
5 years ago
|
|
||
5 years ago
|
# Setting up the fields in a separate array
|
||
5 years ago
|
waifu_and_husbando_fields = [
|
||
5 years ago
|
(f"**{self.ctx.prefix}w `<waifu>`**",
|
||
5 years ago
|
"\nShows Specified Image of Waifu" +
|
||
5 years ago
|
f"\n(Using **{self.ctx.prefix}w** shows random image of Waifu)", True),
|
||
5 years ago
|
(f"**{self.ctx.prefix}h `<husbando>`**",
|
||
5 years ago
|
"\nShows Specified Image of Husbando" +
|
||
5 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)]
|
||
5 years ago
|
|
||
5 years ago
|
# Setting up the embed for the Important Commands
|
||
|
important = Embed(title="(っ◔◡◔)っ Important (っ◔◡◔)っ",
|
||
|
colour=enso_embedmod_colours,
|
||
|
timestamp=datetime.datetime.utcnow())
|
||
5 years ago
|
|
||
5 years ago
|
# Setting thumbnail and author
|
||
|
important.set_thumbnail(url=guild_icon)
|
||
5 years ago
|
|
||
5 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),
|
||
5 years ago
|
(f"**{self.ctx.prefix}prefix `<new_prefix>`**",
|
||
|
"\nView current prefix/Update current prefix", True),
|
||
5 years ago
|
(f"**{self.ctx.prefix}help**",
|
||
|
"\nSee every command in the bot", True)]
|
||
5 years ago
|
|
||
5 years ago
|
# Setting up the embed for modmail
|
||
|
modmail = Embed(title="(っ◔◡◔)っ ModMail (っ◔◡◔)っ",
|
||
|
colour=enso_embedmod_colours,
|
||
|
timestamp=datetime.datetime.utcnow())
|
||
5 years ago
|
|
||
|
# Setting thumbnail and author
|
||
5 years ago
|
modmail.set_thumbnail(url=guild_icon)
|
||
5 years ago
|
|
||
|
# Setting up the fields in a separate array
|
||
4 years ago
|
modmail_fields = [(f"**{self.ctx.prefix}modmail setup `<channelID>`**",
|
||
5 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>`**",
|
||
5 years ago
|
"Updates the channel that the modmail will be sent to", False),
|
||
4 years ago
|
(f"**{self.ctx.prefix}modmail delete modmail**",
|
||
5 years ago
|
"Existing modmail system will be deleted", False)]
|
||
|
|
||
5 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
|
||
5 years ago
|
msc_fields = [(f"**{self.ctx.prefix}dm `<person>`**",
|
||
5 years ago
|
f"\nFor admins to DM Users" +
|
||
|
"\n**(Perms: Co-Owner)**", True),
|
||
|
(f"**{self.ctx.prefix}remindme `<time>` `<text>`**",
|
||
5 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)]
|
||
5 years ago
|
|
||
5 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,
|
||
5 years ago
|
modmail: modmail_fields,
|
||
|
msc: msc_fields
|
||
5 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
|
||
5 years ago
|
return fun, interactive, interactive_2, relationship, enso, waifu_and_husbando, important, modmail, msc
|
||
5 years ago
|
|
||
|
|
||
5 years ago
|
def embeds(self):
|
||
5 years ago
|
# Define guild icon
|
||
5 years ago
|
guild_icon = self.ctx.guild.icon_url
|
||
5 years ago
|
|
||
5 years ago
|
# Set the different pages of the embed
|
||
5 years ago
|
page1, page2, page3, page4, page5, page6, page7, page8, page9 = help_menu(self, guild_icon)
|
||
5 years ago
|
|
||
5 years ago
|
# Store all the categories of the menu to an array called pages
|
||
5 years ago
|
pages = [page1, page2, page3,
|
||
|
page4, page5, page6,
|
||
|
page7, page8, page9]
|
||
5 years ago
|
|
||
5 years ago
|
return pages
|
||
5 years ago
|
|
||
|
|
||
5 years ago
|
# Set up the Cog
|
||
5 years ago
|
class HelpMenu(menus.Menu):
|
||
5 years ago
|
def __init__(self, i, bot):
|
||
5 years ago
|
super().__init__(timeout=125.0, delete_message_after=True)
|
||
5 years ago
|
self.i = i
|
||
5 years ago
|
self.bot = bot
|
||
5 years ago
|
|
||
5 years ago
|
# Message to be sent on the initial command ~help
|
||
5 years ago
|
async def send_initial_message(self, ctx, channel):
|
||
5 years ago
|
# Set the first embed to the first element in the pages[]
|
||
5 years ago
|
initial = embeds(self)[self.i]
|
||
5 years ago
|
|
||
|
# Send embed
|
||
5 years ago
|
return await channel.send(embed=initial)
|
||
|
|
||
5 years ago
|
# Reaction to allow user to go to the previous page in the embed
|
||
5 years ago
|
@menus.button('\N{LEFTWARDS BLACK ARROW}')
|
||
5 years ago
|
async def on_left_arrow(self, payload):
|
||
5 years ago
|
|
||
|
# Simple check to make sure that the reaction is performed by the user
|
||
5 years ago
|
def check(m):
|
||
|
return m.author == payload.member
|
||
|
|
||
5 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
|
||
5 years ago
|
self.i = (self.i - 1) % len(embeds(self))
|
||
|
prev_page = embeds(self)[self.i]
|
||
|
|
||
5 years ago
|
# Send the embed and remove the reaction of the user
|
||
5 years ago
|
await self.message.edit(embed=prev_page)
|
||
|
await self.message.remove_reaction("⬅", self.ctx.author)
|
||
|
|
||
5 years ago
|
# Reaction to allow user to go to the next page in the embed
|
||
5 years ago
|
@menus.button('\N{BLACK RIGHTWARDS ARROW}')
|
||
5 years ago
|
async def on_right_arrow(self, payload):
|
||
5 years ago
|
|
||
|
# Simple check to make sure that the reaction is performed by the user
|
||
5 years ago
|
def check(m):
|
||
|
return m.author == payload.member
|
||
|
|
||
5 years ago
|
# Do nothing if the check does not return true
|
||
|
if not check(self.ctx):
|
||
|
return
|
||
5 years ago
|
# Allow the page number to be increased
|
||
5 years ago
|
else:
|
||
|
|
||
|
# Set self.i to (i + 1) remainder length of the array
|
||
5 years ago
|
self.i = (self.i + 1) % len(embeds(self))
|
||
|
next_page = embeds(self)[self.i]
|
||
|
|
||
5 years ago
|
# Send the embed and remove the reaction of the user
|
||
5 years ago
|
await self.message.edit(embed=next_page)
|
||
|
await self.message.remove_reaction("➡", self.ctx.author)
|
||
|
|
||
5 years ago
|
@menus.button('\N{BLACK SQUARE FOR STOP}\ufe0f')
|
||
5 years ago
|
async def on_stop(self, payload):
|
||
5 years ago
|
|
||
5 years ago
|
# Simple check to make sure that the reaction is performed by the user
|
||
|
def check(m):
|
||
|
return m.author == payload.member
|
||
|
|
||
5 years ago
|
# Do nothing if the check does not return true
|
||
5 years ago
|
if not check(self.ctx):
|
||
|
return
|
||
5 years ago
|
# Allow the embed to be deleted
|
||
5 years ago
|
else:
|
||
|
|
||
5 years ago
|
# Delete the embed and stop the function from running
|
||
|
await self.message.delete()
|
||
5 years ago
|
self.stop()
|
||
5 years ago
|
|
||
|
|
||
|
# Set up the cog
|
||
4 years ago
|
class CustomHelp(commands.Cog):
|
||
5 years ago
|
def __init__(self, bot):
|
||
|
self.bot = bot
|
||
5 years ago
|
self.bot.remove_command("help")
|
||
5 years ago
|
|
||
5 years ago
|
@command(name="help", aliases=["Help"])
|
||
5 years ago
|
async def help(self, ctx):
|
||
5 years ago
|
"""Returns a menu for help commands controlled by reactions"""
|
||
|
|
||
5 years ago
|
# Local Variable i to allow the index of the pages[] to be modified
|
||
5 years ago
|
i = 0
|
||
5 years ago
|
|
||
|
# Send the menu to the display
|
||
|
menu = HelpMenu(i, self)
|
||
|
await menu.start(ctx)
|
||
5 years ago
|
|
||
|
|
||
|
def setup(bot):
|
||
4 years ago
|
bot.add_cog(CustomHelp(bot))
|