Started work on converting all commands to slash-commands

This commit is contained in:
NikolajDanger
2021-03-29 00:55:31 +02:00
parent e6e6b9b9b9
commit 232f97d0c8
11 changed files with 363 additions and 179 deletions

View File

@ -1,10 +1,10 @@
import discord, os, finnhub, platform, asyncio, traceback import discord, os, finnhub, platform, asyncio, traceback
from discord.ext import commands from discord.ext import commands
from discord_slash import SlashCommand
from pymongo import MongoClient from pymongo import MongoClient
from funcs import logThis, makeFiles, Money, Funcs, SwChar, SwDestiny, SwRoll, Games, Generators, BedreNetflix, NerdShit from funcs import logThis, makeFiles, Money, Funcs, SwChar, SwDestiny, SwRoll, Games, Generators, BedreNetflix, NerdShit
from utils import Options
commandPrefix = "!"
if platform.system() == "Windows": if platform.system() == "Windows":
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
@ -23,14 +23,6 @@ class Credentials():
self.radarrKey = data[6][15:].replace(" ","") self.radarrKey = data[6][15:].replace(" ","")
self.sonarrKey = data[7][15:].replace(" ","") self.sonarrKey = data[7][15:].replace(" ","")
class Options():
def __init__(self):
with open("options.txt","r") as f:
data = f.read().splitlines()
self.prefix = data[0][7:].replace(" ","")
self.testing = (data[1][8:].replace(" ","").lower() == "true")
class Gwendolyn(commands.Bot): class Gwendolyn(commands.Bot):
def __init__(self): def __init__(self):
self.options = Options() self.options = Options()
@ -57,13 +49,15 @@ class Gwendolyn(commands.Bot):
self.money = Money(self) self.money = Money(self)
self.funcs = Funcs(self) self.funcs = Funcs(self)
super().__init__(command_prefix=commandPrefix, case_insensitive=True) super().__init__(command_prefix=" ", case_insensitive=True)
# Creates the required files # Creates the required files
makeFiles() makeFiles()
# Creates the Bot # Creates the Bot
client = Gwendolyn() client = Gwendolyn()
slash = SlashCommand(client, sync_commands=True, sync_on_cog_reload=True, override_type=True)
# Logs in # Logs in
@client.event @client.event
@ -74,16 +68,16 @@ async def on_ready():
# Logs when user sends a command # Logs when user sends a command
@client.event @client.event
async def on_command(ctx): async def on_slash_command(ctx):
logThis(f"{ctx.message.author.display_name} ran {ctx.message.content}") logThis(f"{ctx.author.display_name} ran {ctx.name}")
# Logs if a command experiences an error # Logs if a command experiences an error
@client.event @client.event
async def on_command_error(ctx, error): async def on_slash_command_error(ctx, error):
if isinstance(error, commands.CommandNotFound): if isinstance(error, commands.CommandNotFound):
await ctx.send("That's not a command (error code 001)") await ctx.send("That's not a command (error code 001)")
elif isinstance(error,commands.errors.MissingRequiredArgument): elif isinstance(error,commands.errors.MissingRequiredArgument):
logThis(f"{error}",str(ctx.message.channel.id)) logThis(f"{error}",str(ctx.channel_id))
await ctx.send("Missing command parameters (error code 002). Try using `!help [command]` to find out how to use the command.") await ctx.send("Missing command parameters (error code 002). Try using `!help [command]` to find out how to use the command.")
else: else:
exception = traceback.format_exception(type(error), error, error.__traceback__) exception = traceback.format_exception(type(error), error, error.__traceback__)
@ -93,7 +87,7 @@ async def on_command_error(ctx, error):
exception = exception[:index] exception = exception[:index]
exceptionString = "".join(exception) exceptionString = "".join(exception)
logThis([f"exception in command !{ctx.command}", f"{exceptionString}"],str(ctx.message.channel.id), 40) logThis([f"exception in {ctx.name} command", f"{exceptionString}"],str(ctx.channel_id), 40)
await ctx.send("Something went wrong (error code 000)") await ctx.send("Something went wrong (error code 000)")
#Loads cogs #Loads cogs

View File

@ -1,5 +1,7 @@
import discord, asyncio import discord, asyncio
from discord.ext import commands from discord.ext import commands
from discord_slash import cog_ext
from discord_slash import SlashCommandOptionType as scot
from funcs import logThis from funcs import logThis

View File

@ -1,7 +1,19 @@
import discord import discord, json
from discord.ext import commands from discord.ext import commands
from discord_slash import cog_ext
from discord_slash import SlashCommandOptionType as scot
from funcs import spellFunc, monsterFunc, cap from funcs import spellFunc, monsterFunc, cap
from utils import Options
with open("resources/slashParameters.json", "r") as f:
params = json.load(f)
options = Options()
if options.testing:
for p in params:
params[p]["guild_ids"] = options.guildIds
class LookupCog(commands.Cog): class LookupCog(commands.Cog):
@ -10,9 +22,9 @@ class LookupCog(commands.Cog):
self.client = client self.client = client
# Looks up a spell # Looks up a spell
@commands.command() @cog_ext.cog_slash(**params["spell"])
async def spell(self, ctx, *, content): async def spell(self, ctx, query):
spell = spellFunc(cap(content)) spell = spellFunc(cap(query))
if len(spell) > 2000: if len(spell) > 2000:
await ctx.send(spell[:2000]) await ctx.send(spell[:2000])
await ctx.send(spell[2000:]) await ctx.send(spell[2000:])
@ -20,12 +32,12 @@ class LookupCog(commands.Cog):
await ctx.send(spell) await ctx.send(spell)
# Looks up a monster # Looks up a monster
@commands.command() @cog_ext.cog_slash(**params["monster"])
async def monster(self, ctx, *, content): async def monster(self, ctx, query):
title, text1, text2, text3, text4, text5 = monsterFunc(cap(content)) title, text1, text2, text3, text4, text5 = monsterFunc(cap(query))
em1 = discord.Embed(title = title, description = text1, colour=0xDEADBF) em1 = discord.Embed(title = title, description = text1, colour=0xDEADBF)
# Sends the received information. Seperates into seperate messages if # Sends the received information. Separates into separate messages if
# there is too much text # there is too much text
await ctx.send(embed = em1) await ctx.send(embed = em1)
if text2 != "": if text2 != "":

View File

@ -1,10 +1,20 @@
import discord, codecs, string import discord, codecs, string, json
from discord.ext import commands from discord.ext import commands
from discord_slash import cog_ext
from funcs import logThis, helloFunc, roll_dice, imageFunc, movieFunc, cap, findWikiPage from funcs import logThis, helloFunc, roll_dice, imageFunc, movieFunc, cap, findWikiPage
from utils import Options
with open("resources/slashParameters.json", "r") as f:
params = json.load(f)
options = Options()
if options.testing:
for p in params:
params[p]["guild_ids"] = options.guildIds
class MiscCog(commands.Cog): class MiscCog(commands.Cog):
def __init__(self,client): def __init__(self,client):
"""Runs misc commands.""" """Runs misc commands."""
self.client = client self.client = client
@ -13,34 +23,15 @@ class MiscCog(commands.Cog):
self.bedreNetflix = client.bedreNetflix self.bedreNetflix = client.bedreNetflix
self.nerdShit = client.nerdShit self.nerdShit = client.nerdShit
@commands.command(name = "help")
async def helpCommand(self, ctx, *, content = ""):
if content == "":
with codecs.open("resources/help/help.txt",encoding="utf-8") as f:
text = f.read()
em = discord.Embed(title = "Help", description = text,colour = 0x59f442)
await ctx.send(embed = em)
else:
logThis(f"Looking for help-{content}.txt",str(ctx.message.channel.id))
with codecs.open(f"resources/help/help-{content}.txt",encoding="utf-8") as f:
text = f.read()
em = discord.Embed(title = content.capitalize(), description = text,colour = 0x59f442)
await ctx.send(embed = em)
# Sends the bot's latency # Sends the bot's latency
@commands.command() @cog_ext.cog_slash(**params["ping"])
async def ping(self, ctx): 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.client.latency * 1000)}ms")
# Logs whatever is written
@commands.command(hidden = True)
async def log(self, ctx, *, content):
logThis(content,str("Logged by "+ctx.message.author.display_name))
# Restarts the bot # Restarts the bot
@commands.command(hidden = True,aliases=["stop"]) @cog_ext.cog_slash(**params["stop"])
async def restart(self, ctx): async def stop(self, ctx):
if "#"+str(ctx.message.author.id) in ["#266269899859427329", "#380732645602230272"]: if "#"+str(ctx.author.id) in self.client.options.admins:
await ctx.send("Pulling git repo and restarting...") await ctx.send("Pulling git repo and restarting...")
self.client.funcs.stopServer() self.client.funcs.stopServer()
@ -48,103 +39,118 @@ class MiscCog(commands.Cog):
logThis("Logging out.") logThis("Logging out.")
await self.client.logout() await self.client.logout()
else: else:
logThis(f"{ctx.message.author.display_name} tried to stop me! (error code 201)",str(ctx.message.channel.id)) logThis(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.message.author.display_name} (error code 201)") await ctx.send(f"I don't think I will, {ctx.author.display_name} (error code 201)")
@commands.command(aliases = ["thankyou", "thanku", "thanks"]) # Gets help for specific command
@cog_ext.cog_slash(**params["help"])
async def helpCommand(self, ctx, command = ""):
if command == "":
with codecs.open("resources/help/help.txt",encoding="utf-8") as f:
text = f.read()
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))
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
@cog_ext.cog_slash(**params["thank"])
async def thank(self, ctx): async def thank(self, ctx):
await ctx.send("You're welcome :blush:") await ctx.send("You're welcome :blush:")
# Sends a friendly message # Sends a friendly message
@commands.command(aliases = ["hi","howdy"]) @cog_ext.cog_slash(**params["hello"])
async def hello(self, ctx): async def hello(self, ctx):
await ctx.send(helloFunc(ctx.message.author.display_name)) await ctx.send(helloFunc(ctx.author.display_name))
# Rolls dice # Rolls dice
@commands.command() @cog_ext.cog_slash(**params["roll"])
async def roll(self, ctx, *, content = "1d20"): async def roll(self, ctx, dice = "1d20"):
await ctx.send(roll_dice(ctx.message.author.display_name,content)) await ctx.send(roll_dice(ctx.author.display_name,dice))
# Sends an image of the Senkulpa map
@commands.command(name="map")
async def mapCommand(self, ctx):
await ctx.send("https://i.imgur.com/diMXXJs.jpg")
# Sends a random image # Sends a random image
@commands.command(aliases = ["img"]) @cog_ext.cog_slash(**params["image"])
async def image(self, ctx): async def image(self, ctx):
randomImage = imageFunc() randomImage = imageFunc()
await ctx.send(randomImage) await ctx.send(randomImage)
# Finds a random movie # Finds a random movie
@commands.command() @cog_ext.cog_slash(**params["movie"])
async def movie(self,ctx): async def movie(self,ctx):
async with ctx.typing(): await ctx.defer()
title, plot, cover, cast = movieFunc() title, plot, cover, cast = movieFunc()
if title == "error": if title == "error":
await ctx.send("An error occurred. Try again (error code "+plot+")") await ctx.send("An error occurred. Try again (error code "+plot+")")
else: else:
try: try:
embed = discord.Embed(title=title, description=plot, color=0x24ec19) embed = discord.Embed(title=title, description=plot, color=0x24ec19)
embed.set_thumbnail(url=cover) embed.set_thumbnail(url=cover)
embed.add_field(name="Cast", value=cast,inline = True) embed.add_field(name="Cast", value=cast,inline = True)
await ctx.send(embed = embed) await ctx.send(embed = embed)
except: except:
logThis("Error embedding (error code 805)") logThis("Error embedding (error code 805)")
# Generates a random name # Generates a random name
@commands.command() @cog_ext.cog_slash(**params["name"])
async def name(self, ctx): async def name(self, ctx):
await ctx.send(self.generator.nameGen()) await ctx.send(self.generator.nameGen())
# Generates a random tavern name # Generates a random tavern name
@commands.command() @cog_ext.cog_slash(**params["tavern"])
async def tavern(self, ctx): async def tavern(self, ctx):
await ctx.send(self.generator.tavernGen()) await ctx.send(self.generator.tavernGen())
# Sets the game Gwendolyn's playing # Sets the game Gwendolyn's playing
@commands.command() @cog_ext.cog_slash(**params["game"])
async def game(self, ctx, *, content): async def game(self, ctx, gameText):
gamePlaying = cap(content) gamePlaying = cap(gameText)
game = discord.Game(gamePlaying) game = discord.Game(gamePlaying)
await self.client.change_presence(activity=game) await self.client.change_presence(activity=game)
await ctx.send(f"Setting game to \"{gamePlaying}\"")
# Finds a page on the Senkulpa wiki # Finds a page on the Senkulpa wiki
@commands.command(aliases = ["wikia"]) @cog_ext.cog_slash(**params["wiki"])
async def wiki(self, ctx, *, content): async def wiki(self, ctx, wikiPage):
async with ctx.message.channel.typing(): await ctx.defer()
command = string.capwords(content) command = string.capwords(wikiPage)
title, content, thumbnail = findWikiPage(command) title, content, thumbnail = findWikiPage(command)
if title != "": if title != "":
logThis("Sending the embedded message",str(ctx.message.channel.id)) logThis("Sending the embedded message",str(ctx.channel_id))
content += "\n[Læs mere](https://senkulpa.fandom.com/da/wiki/"+title.replace(" ","_")+")" content += "\n[Læs mere](https://senkulpa.fandom.com/da/wiki/"+title.replace(" ","_")+")"
embed = discord.Embed(title = title, description = content, colour=0xDEADBF) embed = discord.Embed(title = title, description = content, colour=0xDEADBF)
if thumbnail != "": if thumbnail != "":
embed.set_thumbnail(url=thumbnail) embed.set_thumbnail(url=thumbnail)
await ctx.send(embed = embed) await ctx.send(embed = embed)
else: else:
await ctx.send(content) await ctx.send(content)
#Searches for movie and adds it to Bedre Netflix #Searches for movie and adds it to Bedre Netflix
@commands.command(aliases = ["rm","addmovie","am"]) @cog_ext.cog_slash(**params["addMovie"])
async def requestmovie(self, ctx, *, content): async def addMovie(self, ctx, movie):
await self.bedreNetflix.requestMovie(ctx,content) await ctx.defer()
await self.bedreNetflix.requestMovie(ctx, movie)
#Searches for show and adds it to Bedre Netflix #Searches for show and adds it to Bedre Netflix
@commands.command(aliases = ["rs","addshow","as","addseries"]) @cog_ext.cog_slash(**params["addShow"])
async def requestshow(self, ctx, *, content): async def addShow(self, ctx, show):
await self.bedreNetflix.requestShow(ctx,content) await ctx.defer()
await self.bedreNetflix.requestShow(ctx, show)
#Returns currently downloading torrents #Returns currently downloading torrents
@commands.command(aliases = ["downloads"]) @cog_ext.cog_slash(**params["downloading"])
async def downloading(self, ctx, *, content = "-d"): async def downloading(self, ctx, parameters = "-d"):
await self.bedreNetflix.downloading(ctx, content) await ctx.defer()
await self.bedreNetflix.downloading(ctx, parameters)
#Looks up on Wolfram Alpha #Looks up on Wolfram Alpha
@commands.command() @cog_ext.cog_slash(**params["wolf"])
async def wolf(self, ctx, *, content): async def wolf(self, ctx, query):
await self.nerdShit.wolfSearch(ctx,content) await self.nerdShit.wolfSearch(ctx, query)
def setup(client): def setup(client):
client.add_cog(MiscCog(client)) client.add_cog(MiscCog(client))

View File

@ -1,5 +1,6 @@
import discord, string import discord, string
from discord.ext import commands from discord.ext import commands
from discord_slash import cog_ext
from funcs import cap from funcs import cap
@ -10,16 +11,16 @@ class SwCog(commands.Cog):
self.client = client self.client = client
# Rolls star wars dice # Rolls star wars dice
@commands.command() @cog_ext.cog_slash()
async def swroll(self, ctx, *, content = ""): async def swroll(self, ctx, dice = ""):
command = cap(content) command = cap(dice)
newMessage = self.client.swroll.parseRoll("#"+str(ctx.message.author.id),command) newMessage = self.client.swroll.parseRoll("#"+str(ctx.message.author.id),command)
messageList = newMessage.split("\n") messageList = newMessage.split("\n")
for messageItem in messageList: for messageItem in messageList:
await ctx.send(messageItem) await ctx.send(messageItem)
# Controls destiny points # Controls destiny points
@commands.command() @cog_ext.cog_slash()
async def swd(self, ctx, *, content): async def swd(self, ctx, *, content):
newMessage = self.client.swdestiny.parseDestiny("#"+str(ctx.message.author.id),content) newMessage = self.client.swdestiny.parseDestiny("#"+str(ctx.message.author.id),content)
messageList = newMessage.split("\n") messageList = newMessage.split("\n")
@ -27,7 +28,7 @@ class SwCog(commands.Cog):
await ctx.send(messageItem) await ctx.send(messageItem)
# Rolls for critical injuries # Rolls for critical injuries
@commands.command() @cog_ext.cog_slash()
async def swcrit(self, ctx, arg : int = 0): async def swcrit(self, ctx, arg : int = 0):
newMessage = self.client.swroll.critRoll(int(arg)) newMessage = self.client.swroll.critRoll(int(arg))
@ -37,7 +38,7 @@ class SwCog(commands.Cog):
# Accesses and changes character sheet data with the parseChar function # Accesses and changes character sheet data with the parseChar function
# from funcs/swfuncs/swchar.py # from funcs/swfuncs/swchar.py
@commands.command(aliases=["sw"]) @cog_ext.cog_slash()
async def swchar(self, ctx, *, content = ""): async def swchar(self, ctx, *, content = ""):
command = string.capwords(content.replace("+","+ ").replace("-","- ").replace(",",", ")) command = string.capwords(content.replace("+","+ ").replace("-","- ").replace(",",", "))
title, desc = self.client.swchar.parseChar("#"+str(ctx.message.author.id),command) title, desc = self.client.swchar.parseChar("#"+str(ctx.message.author.id),command)

View File

@ -83,7 +83,7 @@ class BedreNetflix():
await channel.send(postData["title"]+" successfully added to Bedre Netflix") await channel.send(postData["title"]+" successfully added to Bedre Netflix")
logThis("Added "+postData["title"]+" to Bedre Netflix") logThis("Added "+postData["title"]+" to Bedre Netflix")
elif r.status_code == 400: elif r.status_code == 400:
await channel.send("The movie is already requested for Bedre Netflix") await channel.send("The movie is already requested for or added to Bedre Netflix")
else: else:
await channel.send("Something went wrong") await channel.send("Something went wrong")
logThis(str(r.status_code)+" "+r.reason) logThis(str(r.status_code)+" "+r.reason)
@ -159,7 +159,7 @@ class BedreNetflix():
await channel.send(postData["title"]+" successfully added to Bedre Netflix") await channel.send(postData["title"]+" successfully added to Bedre Netflix")
logThis("Added a "+postData["title"]+" to Bedre Netflix") logThis("Added a "+postData["title"]+" to Bedre Netflix")
elif r.status_code == 400: elif r.status_code == 400:
await channel.send("The show is already requested for Bedre Netflix") await channel.send("The show is already requested for or added to Bedre Netflix")
else: else:
await channel.send("Something went wrong") await channel.send("Something went wrong")
logThis(str(r.status_code)+" "+r.reason) logThis(str(r.status_code)+" "+r.reason)

View File

@ -9,73 +9,74 @@ class NerdShit():
async def wolfSearch(self,ctx,content): async def wolfSearch(self,ctx,content):
fnt = ImageFont.truetype('resources/times-new-roman.ttf', 20) fnt = ImageFont.truetype('resources/times-new-roman.ttf', 20)
async with ctx.message.channel.typing(): await ctx.defer()
logThis("Requesting data") logThis("Requesting data")
client = wolframalpha.Client(self.client.credentials.wolfKey) client = wolframalpha.Client(self.client.credentials.wolfKey)
res = client.query(content) res = client.query(content)
logThis("Processing data") logThis("Processing data")
titles = [] titles = []
pods = [] pods = []
if int(res.numpods) > 0: if int(res.numpods) > 0:
for pod in res.pods: for pod in res.pods:
titles += [pod.title] titles += [pod.title]
for x, sub in enumerate(pod.subpods): for x, sub in enumerate(pod.subpods):
pods += [sub] pods += [sub]
if x > 0: if x > 0:
titles += [""] titles += [""]
podChunks = [pods[x:x+2] for x in range(0, len(pods), 2)] podChunks = [pods[x:x+2] for x in range(0, len(pods), 2)]
titleChucks = [titles[x:x+2] for x in range(0, len(titles), 2)] titleChucks = [titles[x:x+2] for x in range(0, len(titles), 2)]
await ctx.send(f"Response for \"{content}\"")
for x, chunk in enumerate(podChunks): for x, chunk in enumerate(podChunks):
width = 0 width = 0
for title in titleChucks[x]: for title in titleChucks[x]:
width = max(width,fnt.getsize(title)[0]) width = max(width,fnt.getsize(title)[0])
height = 5 height = 5
heights = [] heights = []
for count, pod in enumerate(chunk): for count, pod in enumerate(chunk):
heights += [height] heights += [height]
width = max(width,int(list(pod.img)[0]["@width"])) width = max(width,int(list(pod.img)[0]["@width"]))
if titleChucks[x][count] == "": if titleChucks[x][count] == "":
placeForText = 0 placeForText = 0
else: else:
placeForText = 30 placeForText = 30
height += int(list(pod.img)[0]["@height"]) + 10 + placeForText height += int(list(pod.img)[0]["@height"]) + 10 + placeForText
width += 10 width += 10
height += 5 height += 5
wolfImage = Image.new("RGB",(width,height),color=(255,255,255)) wolfImage = Image.new("RGB",(width,height),color=(255,255,255))
for count, pod in enumerate(chunk): for count, pod in enumerate(chunk):
response = requests.get(list(pod.img)[0]["@src"]) response = requests.get(list(pod.img)[0]["@src"])
file = open("resources/wolfTemp.png", "wb") file = open("resources/wolfTemp.png", "wb")
file.write(response.content) file.write(response.content)
file.close() file.close()
oldImage = Image.open("resources/wolfTemp.png") oldImage = Image.open("resources/wolfTemp.png")
oldSize = oldImage.size oldSize = oldImage.size
if titleChucks[x][count] == "": if titleChucks[x][count] == "":
placeForText = 0 placeForText = 0
else: else:
placeForText = 30 placeForText = 30
newSize = (width,int(oldSize[1]+10+placeForText)) newSize = (width,int(oldSize[1]+10+placeForText))
newImage = Image.new("RGB",newSize,color=(255,255,255)) newImage = Image.new("RGB",newSize,color=(255,255,255))
newImage.paste(oldImage, (int((int(oldSize[0]+10)-oldSize[0])/2),int(((newSize[1]-placeForText)-oldSize[1])/2)+placeForText)) newImage.paste(oldImage, (int((int(oldSize[0]+10)-oldSize[0])/2),int(((newSize[1]-placeForText)-oldSize[1])/2)+placeForText))
if titleChucks[x][count] != "": if titleChucks[x][count] != "":
d = ImageDraw.Draw(newImage,"RGB") d = ImageDraw.Draw(newImage,"RGB")
d.text((5,7),titleChucks[x][count],font=fnt,fill=(150,150,150)) d.text((5,7),titleChucks[x][count],font=fnt,fill=(150,150,150))
wolfImage.paste(newImage,(0,heights[count])) wolfImage.paste(newImage,(0,heights[count]))
newImage.close() newImage.close()
oldImage.close() oldImage.close()
count += 1 count += 1
wolfImage.save("resources/wolf.png") wolfImage.save("resources/wolf.png")
wolfImage.close() wolfImage.close()
await ctx.message.channel.send(file = discord.File("resources/wolf.png")) await ctx.send(file = discord.File("resources/wolf.png"))
os.remove("resources/wolf.png") os.remove("resources/wolf.png")
os.remove("resources/wolfTemp.png") os.remove("resources/wolfTemp.png")
else: else:
logThis("No returned data") logThis("No returned data")
await ctx.message.channel.send("Could not find anything relating to your search") await ctx.send("Could not find anything relating to your search")

View File

@ -0,0 +1,154 @@
{
"addMovie" : {
"name" : "addMovie",
"description" : "Request a movie for Bedre Netflix",
"options" : [
{
"name" : "movie",
"description" : "The movie to request",
"type" : 3,
"required" : "true"
}
]
},
"addShow" : {
"name" : "addShow",
"description" : "Request a show for Bedre Netflix",
"options" : [
{
"name" : "show",
"description" : "The show to request",
"type" : 3,
"required" : "true"
}
]
},
"downloading" : {
"name" : "downloading",
"description" : "See current downloads for Bedre Netflix",
"options" : [
{
"name" : "parameters",
"description" : "Parameters for the command",
"type" : 3,
"required" : "false"
}
]
},
"game" : {
"name" : "game",
"description" : "Set the 'playing' text for Gwendolyn",
"options" : [
{
"name" : "gameText",
"description" : "The game to set the 'playing' text to",
"type" : 3,
"required" : "true"
}
]
},
"hello" : {
"name" : "hello",
"description" : "Greet Gwendolyn"
},
"help" : {
"name" : "help",
"description" : "Get help with a command",
"options" : [
{
"name" : "command",
"description" : "The command you want help with",
"type" : 3,
"required" : "false"
}
]
},
"image" : {
"name" : "image",
"description" : "Get a random image from Bing"
},
"monster" : {
"name" : "monster",
"description" : "Look up a monster",
"options" : [
{
"name" : "query",
"description" : "The monster to look up",
"type" : 3,
"required" : "true"
}
]
},
"movie" : {
"name" : "movie",
"description" : "Get the name and information of a random movie"
},
"name" : {
"name" : "name",
"description" : "Generate a random name"
},
"ping" : {
"name" : "ping",
"description" : "Get the Gwendolyn's latency to the server"
},
"roll" : {
"name" : "roll",
"description" : "Roll rpg dice",
"options" : [
{
"name" : "dice",
"description" : "The dice to roll",
"type" : 3,
"required" : "false"
}
]
},
"spell" : {
"name" : "spell",
"description" : "Look up a spell",
"options" : [
{
"name" : "query",
"description" : "The spell to look up",
"type" : 3,
"required" : "true"
}
]
},
"stop" : {
"name" : "stop",
"description" : "Restart Gwendolyn"
},
"tavern" : {
"name" : "tavern",
"description" : "Generate a random tavern"
},
"thank" : {
"name" : "thank",
"description" : "Thank Gwendolyn for her service"
},
"wiki" : {
"name" : "wiki",
"description" : "Searches for and gets the info for a wiki page",
"options" : [
{
"name" : "wikiPage",
"description" : "The page to find",
"type" : 3,
"required" : "true"
}
]
},
"wolf" : {
"name" : "wolf",
"description" : "Performs a search on Wolfram Alpha",
"options" : [
{
"name" : "query",
"description" : "What to search for on Wolfram Alpha",
"type" : 3,
"required" : "true"
}
]
}
}

View File

@ -60,7 +60,7 @@
"resources/movies.txt": "The Room", "resources/movies.txt": "The Room",
"resources/names.txt": "Gandalf", "resources/names.txt": "Gandalf",
"credentials.txt" : "Bot token: TOKEN\nFinnhub API key: KEY\nWordnik API Key: KEY\nMongoDB user: USERNAME\nMongoDB password: PASSWORD\nWolframAlpha AppID: APPID\nRadarr API key: KEY\nSonarr API key: KEY", "credentials.txt" : "Bot token: TOKEN\nFinnhub API key: KEY\nWordnik API Key: KEY\nMongoDB user: USERNAME\nMongoDB password: PASSWORD\nWolframAlpha AppID: APPID\nRadarr API key: KEY\nSonarr API key: KEY",
"options.txt" : "Prefix: !\nTesting: True" "options.txt" : "Testing: True"
}, },
"folder" : [ "folder" : [
"resources/games/blackjackTables", "resources/games/blackjackTables",

5
utils/__init__.py Normal file
View File

@ -0,0 +1,5 @@
"""A collections of utilities used by Gwendolyn and her functions"""
__all__ = ["Options"]
from .options import Options

9
utils/options.py Normal file
View File

@ -0,0 +1,9 @@
class Options():
def __init__(self):
with open("options.txt","r") as f:
data = f.read().splitlines()
self.testing = (data[0][8:].replace(" ","").lower() == "true")
guildIds = data[1][17:].replace(" ","").split(",")
self.guildIds = [int(i) for i in guildIds]
self.admins = data[2][7:].replace(" ","").split(",")