✨ Fully converted to slash commands
This commit is contained in:
@@ -2,7 +2,6 @@ import discord, codecs, string, json
|
||||
from discord.ext import commands
|
||||
from discord_slash import cog_ext
|
||||
|
||||
from funcs import logThis, helloFunc, roll_dice, imageFunc, movieFunc, cap, findWikiPage
|
||||
from utils import Options
|
||||
|
||||
with open("resources/slashParameters.json", "r") as f:
|
||||
@@ -15,31 +14,31 @@ if options.testing:
|
||||
params[p]["guild_ids"] = options.guildIds
|
||||
|
||||
class MiscCog(commands.Cog):
|
||||
def __init__(self,client):
|
||||
def __init__(self, bot):
|
||||
"""Runs misc commands."""
|
||||
self.client = client
|
||||
self.client.remove_command("help")
|
||||
self.generator = client.generator
|
||||
self.bedreNetflix = client.bedreNetflix
|
||||
self.nerdShit = client.nerdShit
|
||||
self.bot = bot
|
||||
self.bot.remove_command("help")
|
||||
self.generators = bot.other.generators
|
||||
self.bedreNetflix = bot.other.bedreNetflix
|
||||
self.nerdShit = bot.other.nerdShit
|
||||
|
||||
# Sends the bot's latency
|
||||
@cog_ext.cog_slash(**params["ping"])
|
||||
async def ping(self, ctx):
|
||||
await ctx.send(f"Pong!\nLatency is {round(self.client.latency * 1000)}ms")
|
||||
await ctx.send(f"Pong!\nLatency is {round(self.bot.latency * 1000)}ms")
|
||||
|
||||
# Restarts the bot
|
||||
@cog_ext.cog_slash(**params["stop"])
|
||||
async def stop(self, ctx):
|
||||
if "#"+str(ctx.author.id) in self.client.options.admins:
|
||||
if "#"+str(ctx.author.id) in self.bot.options.admins:
|
||||
await ctx.send("Pulling git repo and restarting...")
|
||||
|
||||
self.client.funcs.stopServer()
|
||||
self.bot.databaseFuncs.stopServer()
|
||||
|
||||
logThis("Logging out.")
|
||||
await self.client.logout()
|
||||
self.bot.log("Logging out.")
|
||||
await self.bot.logout()
|
||||
else:
|
||||
logThis(f"{ctx.author.display_name} tried to stop me! (error code 201)",str(ctx.channel_id))
|
||||
self.bot.log(f"{ctx.author.display_name} tried to stop me! (error code 201)",str(ctx.channel_id))
|
||||
await ctx.send(f"I don't think I will, {ctx.author.display_name} (error code 201)")
|
||||
|
||||
# Gets help for specific command
|
||||
@@ -51,13 +50,13 @@ class MiscCog(commands.Cog):
|
||||
em = discord.Embed(title = "Help", description = text,colour = 0x59f442)
|
||||
await ctx.send(embed = em)
|
||||
else:
|
||||
logThis(f"Looking for help-{command}.txt",str(ctx.channel_id))
|
||||
self.bot.log(f"Looking for help-{command}.txt",str(ctx.channel_id))
|
||||
with codecs.open(f"resources/help/help-{command}.txt",encoding="utf-8") as f:
|
||||
text = f.read()
|
||||
em = discord.Embed(title = command.capitalize(), description = text,colour = 0x59f442)
|
||||
await ctx.send(embed = em)
|
||||
|
||||
# Let's you thank the bot
|
||||
# Lets you thank the bot
|
||||
@cog_ext.cog_slash(**params["thank"])
|
||||
async def thank(self, ctx):
|
||||
await ctx.send("You're welcome :blush:")
|
||||
@@ -65,61 +64,42 @@ class MiscCog(commands.Cog):
|
||||
# Sends a friendly message
|
||||
@cog_ext.cog_slash(**params["hello"])
|
||||
async def hello(self, ctx):
|
||||
await ctx.send(helloFunc(ctx.author.display_name))
|
||||
await ctx.send(self.bot.other.helloFunc(ctx.author.display_name))
|
||||
|
||||
# Rolls dice
|
||||
@cog_ext.cog_slash(**params["roll"])
|
||||
async def roll(self, ctx, dice = "1d20"):
|
||||
await ctx.send(roll_dice(ctx.author.display_name,dice))
|
||||
await ctx.send(self.bot.other.rollDice(ctx.author.display_name, dice))
|
||||
|
||||
# Sends a random image
|
||||
@cog_ext.cog_slash(**params["image"])
|
||||
async def image(self, ctx):
|
||||
randomImage = imageFunc()
|
||||
await ctx.send(randomImage)
|
||||
await ctx.defer()
|
||||
await ctx.send(self.bot.other.imageFunc())
|
||||
|
||||
# Finds a random movie
|
||||
@cog_ext.cog_slash(**params["movie"])
|
||||
async def movie(self,ctx):
|
||||
await ctx.defer()
|
||||
title, plot, cover, cast = movieFunc()
|
||||
if title == "error":
|
||||
await ctx.send("An error occurred. Try again (error code "+plot+")")
|
||||
else:
|
||||
try:
|
||||
embed = discord.Embed(title=title, description=plot, color=0x24ec19)
|
||||
embed.set_thumbnail(url=cover)
|
||||
embed.add_field(name="Cast", value=cast,inline = True)
|
||||
await ctx.send(embed = embed)
|
||||
except:
|
||||
logThis("Error embedding (error code 805)")
|
||||
await self.bot.other.movieFunc(ctx)
|
||||
|
||||
# Generates a random name
|
||||
@cog_ext.cog_slash(**params["name"])
|
||||
async def name(self, ctx):
|
||||
await ctx.send(self.generator.nameGen())
|
||||
await ctx.send(self.generators.nameGen())
|
||||
|
||||
# Generates a random tavern name
|
||||
@cog_ext.cog_slash(**params["tavern"])
|
||||
async def tavern(self, ctx):
|
||||
await ctx.send(self.generator.tavernGen())
|
||||
|
||||
# Sets the game Gwendolyn's playing
|
||||
@cog_ext.cog_slash(**params["game"])
|
||||
async def game(self, ctx, gameText):
|
||||
gamePlaying = cap(gameText)
|
||||
game = discord.Game(gamePlaying)
|
||||
await self.client.change_presence(activity=game)
|
||||
await ctx.send(f"Setting game to \"{gamePlaying}\"")
|
||||
await ctx.send(self.generators.tavernGen())
|
||||
|
||||
# Finds a page on the Senkulpa wiki
|
||||
@cog_ext.cog_slash(**params["wiki"])
|
||||
async def wiki(self, ctx, wikiPage):
|
||||
await ctx.defer()
|
||||
command = string.capwords(wikiPage)
|
||||
title, content, thumbnail = findWikiPage(command)
|
||||
title, content, thumbnail = self.bot.otherfindWikiPage(command)
|
||||
if title != "":
|
||||
logThis("Sending the embedded message",str(ctx.channel_id))
|
||||
self.bot.log("Sending the embedded message",str(ctx.channel_id))
|
||||
content += "\n[Læs mere](https://senkulpa.fandom.com/da/wiki/"+title.replace(" ","_")+")"
|
||||
embed = discord.Embed(title = title, description = content, colour=0xDEADBF)
|
||||
if thumbnail != "":
|
||||
@@ -152,5 +132,5 @@ class MiscCog(commands.Cog):
|
||||
async def wolf(self, ctx, query):
|
||||
await self.nerdShit.wolfSearch(ctx, query)
|
||||
|
||||
def setup(client):
|
||||
client.add_cog(MiscCog(client))
|
||||
def setup(bot):
|
||||
bot.add_cog(MiscCog(bot))
|
||||
|
||||
Reference in New Issue
Block a user