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.
293 lines
12 KiB
Python
293 lines
12 KiB
Python
5 years ago
|
import datetime
|
||
|
|
||
|
from discord import Embed, Colour
|
||
5 years ago
|
from discord.ext import commands, menus
|
||
5 years ago
|
from discord.ext.commands import command
|
||
|
|
||
|
|
||
5 years ago
|
# Function to allow the first page of the help commands (Fun Commands)
|
||
5 years ago
|
def fun_function(self, guild_icon, enso_name, enso_icon):
|
||
5 years ago
|
# Setting up the Embed for the Fun Commands
|
||
5 years ago
|
fun_commands = Embed(title="```(っ◔◡◔)っ Fun Commands (っ◔◡◔)っ```",
|
||
|
colour=Colour(0xFF69B4),
|
||
|
timestamp=datetime.datetime.utcnow())
|
||
|
|
||
5 years ago
|
# Setting thumbnail and author
|
||
5 years ago
|
fun_commands.set_thumbnail(url=guild_icon)
|
||
|
fun_commands.set_author(name=enso_name,
|
||
|
icon_url=enso_icon)
|
||
|
|
||
5 years ago
|
# Setting up the fields in a separate array
|
||
|
fun_fields = [
|
||
5 years ago
|
("\u200b", f"`{self.ctx.prefix}attack [person]`" +
|
||
5 years ago
|
"\n Allows the user to throw an insult to a person in the server" +
|
||
|
"\n *(Perms: Co-Owner)*", True),
|
||
5 years ago
|
("\u200b", f"`{self.ctx.prefix}comp [person]`" +
|
||
5 years ago
|
"\n Allows the user to compliment a person in the server" +
|
||
|
"\n *(Perms: Everyone)*", True),
|
||
5 years ago
|
("\u200b", f"`{self.ctx.prefix}8ball [text]`" +
|
||
5 years ago
|
"\n Allows the user to ask a question and 8ball will give a custom response" +
|
||
|
"\n *(Perms: everyone)*", True),
|
||
5 years ago
|
("\u200b", f"`{self.ctx.prefix}flip`" +
|
||
5 years ago
|
"\n Allows the user to 'throw a coin' and get a response with a 50/50 chance" +
|
||
|
"\n *(Perms: Everyone)*", True),
|
||
5 years ago
|
("\u200b", f"`{self.ctx.prefix}doggo`" +
|
||
5 years ago
|
"\n Allows the user to look at an image of a doggo (Over 20k Images Available" +
|
||
|
"\n *(Perms: Everyone)*", True)]
|
||
|
|
||
|
# Setting up the Embed for the Fun Commands
|
||
|
fun_commands_2 = Embed(title="```(っ◔◡◔)っ Fun Commands 2 (っ◔◡◔)っ```",
|
||
|
colour=Colour(0xFF69B4),
|
||
|
timestamp=datetime.datetime.utcnow())
|
||
|
|
||
|
# Setting thumbnail and author
|
||
|
fun_commands_2.set_thumbnail(url=guild_icon)
|
||
|
fun_commands_2.set_author(name=enso_name,
|
||
|
icon_url=enso_icon)
|
||
|
|
||
|
# Setting up the fields in a separate array
|
||
|
fun_fields_2 = [
|
||
5 years ago
|
("\u200b", f"`{self.ctx.prefix}lemon [person]`" +
|
||
5 years ago
|
"\n Allows the user to give a lemon to a person in the server" +
|
||
|
"\n *(Perms: Everyone)*", True),
|
||
5 years ago
|
("\u200b", f"`{self.ctx.prefix}slap [person]`" +
|
||
5 years ago
|
"\n Allows the user to slap a person in the server" +
|
||
|
"\n *(Perms: Everyone)*", True),
|
||
5 years ago
|
("\u200b", f"`{self.ctx.prefix}kill [person]`" +
|
||
5 years ago
|
"\n Allows the user to kill a person in the server" +
|
||
|
"\n *(Perms: Everyone)*", True),
|
||
5 years ago
|
("\u200b", f"`{self.ctx.prefix}pat [person]`" +
|
||
5 years ago
|
"\n Allows the user to pat a person in the server" +
|
||
|
"\n *(Perms: Everyone)*", True),
|
||
5 years ago
|
("\u200b", f"`{self.ctx.prefix}kiss [person]`" +
|
||
5 years ago
|
"\n Allows the user to kiss a person in the server" +
|
||
|
"\n *(Perms: Everyone)*", True),
|
||
5 years ago
|
("\u200b", f"`{self.ctx.prefix}cuddle [person]`" +
|
||
5 years ago
|
"\n Allows the user to cuddle a person in the server" +
|
||
|
"\n *(Perms: Everyone)*", True)]
|
||
5 years ago
|
|
||
|
# Add the fun_commands fields to the embed
|
||
|
for name, value, inline in fun_fields:
|
||
|
fun_commands.add_field(name=name, value=value, inline=inline)
|
||
|
|
||
5 years ago
|
# Add the fun_commands_2 fields to the embed
|
||
|
for name, value, inline in fun_fields_2:
|
||
|
fun_commands_2.add_field(name=name, value=value, inline=inline)
|
||
5 years ago
|
|
||
5 years ago
|
return fun_commands, fun_commands_2
|
||
5 years ago
|
|
||
5 years ago
|
|
||
|
# Function to allow the first page of the help commands (Waifu/Husbandos)
|
||
5 years ago
|
def waifu_husbando_function(self, guild_icon, enso_name, enso_icon):
|
||
5 years ago
|
# Setting up the Embed for the Waifu/Husbandos
|
||
5 years ago
|
waifu_husbando_commands = Embed(title="```(っ◔◡◔)っ Waifus/Husbando Commands (っ◔◡◔)っ```",
|
||
|
colour=Colour(0xFF69B4),
|
||
|
timestamp=datetime.datetime.utcnow())
|
||
|
|
||
5 years ago
|
# Setting thumbnail and author
|
||
5 years ago
|
waifu_husbando_commands.set_thumbnail(url=guild_icon)
|
||
|
waifu_husbando_commands.set_author(name=enso_name,
|
||
|
icon_url=enso_icon)
|
||
|
|
||
5 years ago
|
# Setting up the fields in a separate array
|
||
|
waifu_husbando_fields = [
|
||
5 years ago
|
("\u200b", f"`{self.ctx.prefix}[waifu]`" +
|
||
5 years ago
|
"\n Allows for a randomly generated image of a Waifu to be shown" +
|
||
|
"\n *(Perms: Everyone)*", True),
|
||
5 years ago
|
("\u200b", f"`{self.ctx.prefix}h [husbando]`" +
|
||
5 years ago
|
"\n Allows for a randomly generated image of a Husbando to be shown" +
|
||
|
"\n *(Perms: Everyone)*", True),
|
||
5 years ago
|
("\u200b", f"`{self.ctx.prefix}w list`" +
|
||
5 years ago
|
"\n Returns a list of Waifu's that are in the bot " +
|
||
|
"\n *(Perms: Everyone)*", True),
|
||
5 years ago
|
("\u200b", f"`{self.ctx.prefix}h list`" +
|
||
5 years ago
|
"\n Returns a list of Husbando's that are in the bot " +
|
||
|
"\n *(Perms: Everyone)*", True),
|
||
5 years ago
|
("\u200b", f"`{self.ctx.prefix}enso [person]`" +
|
||
5 years ago
|
"\n Allows for a randomly generated image of the member specified" +
|
||
|
"\n (Using ~enso by itself shall generate a random image of a person within all the server)" +
|
||
|
"\n *(Perms: Everyone)*", True),
|
||
5 years ago
|
("\u200b", f"`{self.ctx.prefix}enso list`" +
|
||
5 years ago
|
"\n Returns a list of the people's images currently in the bot" +
|
||
|
"\n *(Perms: Everyone)*", True)]
|
||
5 years ago
|
|
||
|
# Add the waifu_husbando_commands fields to the embed
|
||
|
for name, value, inline in waifu_husbando_fields:
|
||
|
waifu_husbando_commands.add_field(name=name, value=value, inline=inline)
|
||
|
|
||
|
return waifu_husbando_commands
|
||
|
|
||
|
|
||
5 years ago
|
# Function to allow the first page of the help commands (Miscellaneous)
|
||
5 years ago
|
def misc_function(self, guild_icon, enso_name, enso_icon):
|
||
5 years ago
|
# Setting up the Embed for the Miscellaneous commands
|
||
5 years ago
|
misc_commands = Embed(title="```(っ◔◡◔)っ Misc Commands (っ◔◡◔)っ```",
|
||
|
colour=Colour(0xFF69B4),
|
||
|
timestamp=datetime.datetime.utcnow())
|
||
|
|
||
5 years ago
|
# Setting thumbnail and author
|
||
5 years ago
|
misc_commands.set_thumbnail(url=guild_icon)
|
||
|
misc_commands.set_author(name=enso_name,
|
||
|
icon_url=enso_icon)
|
||
|
|
||
5 years ago
|
# Setting up the fields in a separate array
|
||
|
misc_fields = [
|
||
5 years ago
|
("\u200b", f"`{self.ctx.prefix}ping`" +
|
||
5 years ago
|
"\n Returns Pong! Along With The Latency in ms" +
|
||
|
"\n *(Perms: Co-Owner)*", True),
|
||
5 years ago
|
("\u200b", f"`{self.ctx.prefix}rolemenu`" +
|
||
5 years ago
|
"\n Allows for the users to get self ping-able roles" +
|
||
|
"\n *(Perms: Co-Owner)*", True),
|
||
5 years ago
|
("\u200b", f"`{self.ctx.prefix}dm [person]`" +
|
||
5 years ago
|
"\n Allows Hammy to dm anyone in the server through Enso~Chan!" +
|
||
|
"\n *(Perms: Co-Owner)*", True),
|
||
5 years ago
|
("\u200b", f"`{self.ctx.prefix}userinfo`" +
|
||
5 years ago
|
"\n Returns information about the user (Name, Roles, Joined Date, Created Date, etc)" +
|
||
|
"\n *(Perms: Everyone)*", True),
|
||
5 years ago
|
("\u200b", f"`{self.ctx.prefix}serverinfo`" +
|
||
5 years ago
|
"\n Returns information about the server (Owner, Members, Region, Bots etc etc)" +
|
||
|
"\n *(Perms: Everyone)*", True),
|
||
5 years ago
|
("\u200b", f"`{self.ctx.prefix}rules`" +
|
||
5 years ago
|
"\n Returns the entire ruleset for the server" +
|
||
|
"\n *(Perms: Everyone)*", True),
|
||
5 years ago
|
("\u200b", f"`{self.ctx.prefix}roles`" +
|
||
5 years ago
|
"\n Shows you how the leveling and xp system works, as well as displaying the order of leveled roles" +
|
||
|
"\n *(Perms: Everyone)*", True),
|
||
5 years ago
|
("\u200b", f"`{self.ctx.prefix}remindme [time] [text]`" +
|
||
5 years ago
|
"\n Allows the user to get Enso~Chan to remind them in dms of anything that they want" +
|
||
|
"\n *(Perms: Everyone)*", True),
|
||
5 years ago
|
("\u200b", f"`{self.ctx.prefix}help`" +
|
||
5 years ago
|
"\n Allows you to see every command in the bot so far" +
|
||
|
"\n *(Perms: Everyone)*", True)]
|
||
5 years ago
|
|
||
|
# Add the misc_commands fields to the embed
|
||
|
for name, value, inline in misc_fields:
|
||
|
misc_commands.add_field(name=name, value=value, inline=inline)
|
||
|
|
||
|
return misc_commands
|
||
|
|
||
|
|
||
5 years ago
|
def stop_embed(self):
|
||
|
# Define enso bot icon and enso bot name
|
||
|
enso_icon = self.bot.user.avatar_url
|
||
|
enso_name = self.bot.user.display_name
|
||
|
|
||
5 years ago
|
# Set up the Embed to display when the user reacts with the stop reaction
|
||
5 years ago
|
misc_commands = Embed(title="**help Commands Embed Closed!**",
|
||
5 years ago
|
colour=Colour(0xFF69B4),
|
||
|
timestamp=datetime.datetime.utcnow())
|
||
|
|
||
5 years ago
|
# Set the name and the icon for Enso~Chan
|
||
5 years ago
|
misc_commands.set_author(name=enso_name,
|
||
|
icon_url=enso_icon)
|
||
|
|
||
|
return misc_commands
|
||
|
|
||
|
|
||
|
def embeds(self):
|
||
5 years ago
|
# Define guild icon, enso bot icon and enso bot name
|
||
|
guild_icon = self.ctx.guild.icon_url
|
||
|
enso_icon = self.bot.user.avatar_url
|
||
|
enso_name = self.bot.user.display_name
|
||
5 years ago
|
|
||
5 years ago
|
# Set the different pages of the embed
|
||
5 years ago
|
page1, page2 = fun_function(self, guild_icon, enso_name, enso_icon)
|
||
|
page3 = waifu_husbando_function(self, guild_icon, enso_name, enso_icon)
|
||
|
page4 = misc_function(self, guild_icon, enso_name, enso_icon)
|
||
5 years ago
|
|
||
5 years ago
|
# Store all the categories of the menu to an array called pages
|
||
|
pages = [page1, page2, page3, page4]
|
||
5 years ago
|
|
||
5 years ago
|
return pages
|
||
5 years ago
|
|
||
|
|
||
5 years ago
|
class HelpMenu(menus.Menu):
|
||
5 years ago
|
def __init__(self, i, bot):
|
||
5 years ago
|
super().__init__()
|
||
|
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
|
# Send the stop embed which shows that the help commands embed is no longer accessible
|
||
5 years ago
|
stop = stop_embed(self)
|
||
5 years ago
|
await self.message.edit(embed=stop)
|
||
5 years ago
|
|
||
|
# Clear the reactions in the message and stop the function
|
||
5 years ago
|
await self.message.clear_reactions()
|
||
5 years ago
|
self.stop()
|
||
|
|
||
|
|
||
|
# Set up the cog
|
||
|
class ReactionMenu(commands.Cog):
|
||
|
def __init__(self, bot):
|
||
|
self.bot = bot
|
||
5 years ago
|
# Remove default help command
|
||
|
self.bot.remove_command("help")
|
||
5 years ago
|
|
||
5 years ago
|
# ~help command that returns a menu for help commands controlled by reactions
|
||
5 years ago
|
@command(name="help", aliases=["help"])
|
||
5 years ago
|
async def help(self, ctx):
|
||
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):
|
||
|
bot.add_cog(ReactionMenu(bot))
|