From 6c1a1cf62625aafa0675ad19bfe0d5ee26a6e88d Mon Sep 17 00:00:00 2001 From: NikolajDanger Date: Wed, 31 Mar 2021 01:02:32 +0200 Subject: [PATCH] :broom: Last bit of cleaning up before pushing --- Gwendolyn.py | 9 +++-- cogs/EventCog.py | 4 +- cogs/GameCogs.py | 6 +-- cogs/ReactionCog.py | 2 +- funcs/games/blackjack.py | 30 +++++++------- funcs/games/blackjackDraw.py | 6 +-- funcs/games/connectFour.py | 16 ++++---- funcs/games/connectFourDraw.py | 2 +- funcs/games/gameLoops.py | 18 ++++----- funcs/games/hangman.py | 2 +- funcs/games/hangmanDraw.py | 2 +- funcs/games/hex.py | 24 ++++++------ funcs/games/invest.py | 4 +- funcs/games/money.py | 4 +- funcs/lookup/lookupFuncs.py | 2 +- funcs/other/bedreNetflix.py | 6 +-- funcs/other/other.py | 2 +- funcs/starWarsFuncs/starWarsChar.py | 2 +- funcs/starWarsFuncs/starWarsRoll.py | 2 +- project-guidelines.md | 2 +- resources/help/help-addmovie.txt | 2 +- resources/help/help-addshow.txt | 2 +- resources/help/help-blackjack.txt | 2 +- resources/help/help-connectfour.txt | 2 +- resources/help/help-give.txt | 2 +- resources/help/help-hangman.txt | 2 +- resources/help/help-hello.txt | 2 +- resources/help/help-hex.txt | 2 +- resources/help/help-invest.txt | 6 +-- resources/help/help-monster.txt | 2 +- resources/help/help-spell.txt | 2 +- resources/help/help-starwarscharacter.txt | 2 +- resources/help/help-starwarsroll.txt | 2 +- resources/help/help-trivia.txt | 4 +- resources/help/help.txt | 48 +++++++++++------------ resources/slashParameters.json | 12 ++++-- utils/helperClasses.py | 4 +- 37 files changed, 125 insertions(+), 118 deletions(-) diff --git a/Gwendolyn.py b/Gwendolyn.py index 6f81b1e..5e72481 100644 --- a/Gwendolyn.py +++ b/Gwendolyn.py @@ -1,4 +1,4 @@ -import os, finnhub, platform, asyncio +import os, finnhub, platform, asyncio, discord from discord.ext import commands from discord_slash import SlashCommand @@ -26,9 +26,12 @@ class Gwendolyn(commands.Bot): self.money = Money(self) self.databaseFuncs = databaseFuncs(self) - super().__init__(command_prefix=" ", case_insensitive=True) + intents = discord.Intents.default() + intents.members = True - def log(self, messages, channel : str = "", level : int = 20): + super().__init__(command_prefix=" ", case_insensitive=True, intents = intents) + + def log(self, messages, channel : str = "", level : int = 10): logThis(messages, channel, level) diff --git a/cogs/EventCog.py b/cogs/EventCog.py index 1332886..c220968 100644 --- a/cogs/EventCog.py +++ b/cogs/EventCog.py @@ -8,14 +8,14 @@ class EventCog(commands.Cog): # Sets the game and logs when the bot logs in @commands.Cog.listener() async def on_ready(self): - self.bot.log("Logged in as "+self.bot.user.name+", "+str(self.bot.user.id)) + self.bot.log("Logged in as "+self.bot.user.name+", "+str(self.bot.user.id), level = 20) game = discord.Game("Use /help for commands") await self.bot.change_presence(activity=game) # Logs when user sends a command @commands.Cog.listener() async def on_slash_command(self, ctx): - self.bot.log(f"{ctx.author.display_name} ran /{ctx.name}") + self.bot.log(f"{ctx.author.display_name} ran /{ctx.name}", str(ctx.channel_id), level = 20) # Logs if a command experiences an error @commands.Cog.listener() diff --git a/cogs/GameCogs.py b/cogs/GameCogs.py index 4e48881..ed0ca78 100644 --- a/cogs/GameCogs.py +++ b/cogs/GameCogs.py @@ -25,11 +25,9 @@ class GamesCog(commands.Cog): # Gives another user an amount of GwendoBucks @cog_ext.cog_slash(**params["give"]) - async def give(self, ctx, parameters): + async def give(self, ctx, user, amount): await ctx.defer() - commands = parameters.split(" ") - amount = int(commands[-1]) - username = " ".join(commands[:-1]) + username = user.display_name if self.bot.databaseFuncs.getID(username) == None: async for member in ctx.guild.fetch_members(limit=None): if member.display_name.lower() == username.lower(): diff --git a/cogs/ReactionCog.py b/cogs/ReactionCog.py index c791a89..14b4cc0 100644 --- a/cogs/ReactionCog.py +++ b/cogs/ReactionCog.py @@ -12,7 +12,7 @@ class ReactionCog(commands.Cog): if user.bot == False: message = reaction.message channel = message.channel - self.bot.log(f"{user.display_name} reacted to a message",str(channel.id), level = 10) + self.bot.log(f"{user.display_name} reacted to a message",str(channel.id)) try: connectFourTheirTurn, piece = self.bot.databaseFuncs.connectFourReactionTest(channel,message,"#"+str(user.id)) except: diff --git a/funcs/games/blackjack.py b/funcs/games/blackjack.py index 5f60609..7fb9c02 100644 --- a/funcs/games/blackjack.py +++ b/funcs/games/blackjack.py @@ -35,7 +35,7 @@ class Blackjack(): # Calculates the value of a blackjack hand def calcHandValue(self, hand : list): - self.bot.log("Calculating hand value", level = 10) + self.bot.log("Calculating hand value") values = [] values.append(0) @@ -58,13 +58,13 @@ class Blackjack(): if value <= 21: handValue = value - self.bot.log("Calculated "+str(hand)+" to be "+str(handValue), level = 10) + self.bot.log("Calculated "+str(hand)+" to be "+str(handValue)) return handValue # Draws a card from the deck def drawCard(self, channel): - self.bot.log("drawing a card", level = 10) + self.bot.log("drawing a card") drawnCard = self.bot.database["blackjack cards"].find_one({"_id":channel})["cards"][0] self.bot.database["blackjack cards"].update_one({"_id":channel},{"$pop":{"cards":-1}}) @@ -97,7 +97,7 @@ class Blackjack(): # Goes to the next round and calculates some stuff def blackjackContinue(self, channel): - self.bot.log("Continuing blackjack game", level = 10) + self.bot.log("Continuing blackjack game") game = self.bot.database["blackjack games"].find_one({"_id":channel}) done = False @@ -116,7 +116,7 @@ class Blackjack(): game = self.bot.database["blackjack games"].find_one({"_id":channel}) - self.bot.log("Testing if all are standing", level = 10) + self.bot.log("Testing if all are standing") for user in game["user hands"]: try: newUser, allStanding, preAllStanding = self.testIfStanding(game["user hands"][user],allStanding,preAllStanding,True) @@ -141,10 +141,10 @@ class Blackjack(): return "", True, done else: if game["round"] == 1: - firstRoundMessage = ". You can also double down with \"!blackjack double\" or split with \"!blackjack split\"" + firstRoundMessage = ". You can also double down with \"/blackjack double\" or split with \"/blackjack split\"" else: firstRoundMessage = "" - return "You have 2 minutes to either hit or stand with \"!blackjack hit\" or \"!blackjack stand\""+firstRoundMessage+". It's assumed you're standing if you don't make a choice.", False, done + return "You have 2 minutes to either hit or stand with \"/blackjack hit\" or \"/blackjack stand\""+firstRoundMessage+". It's assumed you're standing if you don't make a choice.", False, done def testIfStanding(self, hand,allStanding,preAllStanding,topLevel): if hand["hit"] == False: @@ -430,7 +430,7 @@ class Blackjack(): roundDone = self.isRoundDone(self.bot.database["blackjack games"].find_one({"_id":channel})) - return "Splitting "+self.bot.databaseFuncs.getName(user)+"'s hand into 2. Adding their original bet to the second hand. You can use \"!Blackjack hit/stand/double 1\" and \"!Blackjack hit/stand/double 2\" to play the different hands.",str(roundDone)[0] + str(game["round"]) + return "Splitting "+self.bot.databaseFuncs.getName(user)+"'s hand into 2. Adding their original bet to the second hand. You can use \"/blackjack hit/stand/double 1\" and \"/blackjack hit/stand/double 2\" to play the different hands.",str(roundDone)[0] + str(game["round"]) else: self.bot.log(user+" doesn't have enough GwendoBucks") return "You don't have enough GwendoBucks","" @@ -564,7 +564,7 @@ class Blackjack(): def calcWinnings(self,hand, dealerValue, topLevel, dealerBlackjack, dealerBusted): - self.bot.log("Calculating winnings", level = 10) + self.bot.log("Calculating winnings") reason = "" bet = hand["bet"] winnings = -1 * bet @@ -659,14 +659,14 @@ class Blackjack(): # Loop of blackjack game rounds async def blackjackLoop(self,channel,gameRound,gameID): - self.bot.log("Loop "+str(gameRound),str(channel.id), level = 10) + self.bot.log("Loop "+str(gameRound),str(channel.id)) with open("resources/games/oldImages/blackjack"+str(channel.id), "r") as f: oldImage = await channel.fetch_message(int(f.read())) new_message, allStanding, gamedone = self.blackjackContinue(str(channel.id)) if new_message != "": - self.bot.log(new_message,str(channel.id), level = 10) + self.bot.log(new_message,str(channel.id)) await channel.send(new_message) if gamedone == False: await oldImage.delete() @@ -699,9 +699,9 @@ class Blackjack(): self.bot.log("Something fucked up (error code 1310)") await channel.send(new_message) else: - self.bot.log("Ending loop on round "+str(gameRound),str(channel.id), level = 10) + self.bot.log("Ending loop on round "+str(gameRound),str(channel.id)) else: - self.bot.log("Ending loop on round "+str(gameRound),str(channel.id), level = 10) + self.bot.log("Ending loop on round "+str(gameRound),str(channel.id)) async def parseBlackjack(self,content, ctx): # Blackjack shuffle variables @@ -726,7 +726,7 @@ class Blackjack(): new_message = self.blackjackStart(str(channel)) if new_message == "started": - new_message = "Blackjack game started. Use \"!blackjack bet [amount]\" to enter the game within the next 30 seconds." + new_message = "Blackjack game started. Use \"/blackjack bet [amount]\" to enter the game within the next 30 seconds." await ctx.channel.send(new_message) oldImage = await ctx.channel.send(file = discord.File("resources/games/blackjackTables/blackjackTable"+str(channel)+".png")) @@ -746,7 +746,7 @@ class Blackjack(): # Loop of game rounds if gamedone == False: - self.bot.log("!blackjack calling self.blackjackLoop()",str(channel)) + self.bot.log("/blackjack calling self.blackjackLoop()",str(channel)) await self.blackjackLoop(ctx.channel,1,gameID) else: new_message = self.blackjackFinish(str(channel)) diff --git a/funcs/games/blackjackDraw.py b/funcs/games/blackjackDraw.py index 7c5b870..23aae9e 100644 --- a/funcs/games/blackjackDraw.py +++ b/funcs/games/blackjackDraw.py @@ -9,7 +9,7 @@ class DrawBlackjack(): self.bot = bot def drawImage(self,channel): - self.bot.log("Drawing blackjack table",channel, level = 10) + self.bot.log("Drawing blackjack table",channel) game = self.bot.database["blackjack games"].find_one({"_id":channel}) fnt = ImageFont.truetype('resources/fonts/futura-bold.ttf', 50) @@ -78,13 +78,13 @@ class DrawBlackjack(): textImage.text((32+(384*placement[x])+117-int(textWidth/2)+2,1020+2),key,fill=(0,0,0), font=fntSmol) textImage.text((32+(384*placement[x])+117-int(textWidth/2),1015),key,fill=(255,255,255), font=fntSmol) - self.bot.log("Saving table image", level = 10) + self.bot.log("Saving table image") table.save("resources/games/blackjackTables/blackjackTable"+channel+".png") return def drawHand(self, hand, dealer, busted, blackjack): - self.bot.log("Drawing hand "+str(hand)+", "+str(busted)+", "+str(blackjack), level = 10) + self.bot.log("Drawing hand "+str(hand)+", "+str(busted)+", "+str(blackjack)) fnt = ImageFont.truetype('resources/fonts/futura-bold.ttf', 200) fnt2 = ImageFont.truetype('resources/fonts/futura-bold.ttf', 120) length = len(hand) diff --git a/funcs/games/connectFour.py b/funcs/games/connectFour.py index d5d7cff..d655c62 100644 --- a/funcs/games/connectFour.py +++ b/funcs/games/connectFour.py @@ -88,7 +88,7 @@ class connectFour(): turn = (game["turn"]+1)%2 self.bot.database["connect 4 games"].update_one({"_id":channel},{"$set":{"turn":turn}}) - self.bot.log("Checking for win", level = 10) + self.bot.log("Checking for win") won, winDirection, winCoordinates = self.isWon(board) if won != 0: @@ -112,7 +112,7 @@ class connectFour(): gwendoTurn = False if game["players"][turn] == "Gwendolyn": - self.bot.log("It's Gwendolyn's turn", level = 10) + self.bot.log("It's Gwendolyn's turn") gwendoTurn = True self.draw.drawImage(channel) @@ -141,10 +141,10 @@ class connectFour(): def parseconnectFour(self, command, channel, user): commands = command.split() if command == "" or command == " ": - return "I didn't get that. Use \"!connectFour start [opponent]\" to start a game. To play against the computer, use difficulty 1 through 5 as the [opponent].", False, False, False, False + return "I didn't get that. Use \"/connectFour start [opponent]\" to start a game. To play against the computer, use difficulty 1 through 5 as the [opponent].", False, False, False, False elif commands[0] == "start": # Starting a game - if len(commands) == 1: # if the commands is "!connectFour start", the opponent is Gwendolyn + if len(commands) == 1: # if the commands is "/connectFour start", the opponent is Gwendolyn commands.append("3") return self.connectFourStart(channel,user,commands[1]) # commands[1] is the opponent @@ -165,7 +165,7 @@ class connectFour(): if user == game["players"][turn]: piece = turn + 1 else: - self.bot.log("It wasn't their turn", level = 10) + self.bot.log("It wasn't their turn") return "It's not your turn!", False, False, False, False column = int(commands[1])-1 else: @@ -173,7 +173,7 @@ class connectFour(): piece = int(commands[1]) return self.placePiece(channel, piece, column) else: - return "I didn't get that. Use \"!connectFour start [opponent]\" to start a game. To play against the computer, use difficulty 1 through 5 as the [opponent].", False, False, False, False + return "I didn't get that. Use \"/connectFour start [opponent]\" to start a game. To play against the computer, use difficulty 1 through 5 as the [opponent].", False, False, False, False # Checks if someone has won the game and returns the winner def isWon(self, board): @@ -235,7 +235,7 @@ class connectFour(): # Plays as the AI async def connectFourAI(self, channel): - self.bot.log("Figuring out best move", level = 10) + self.bot.log("Figuring out best move") game = self.bot.database["connect 4 games"].find_one({"_id":channel}) board = game["board"] @@ -248,7 +248,7 @@ class connectFour(): testBoard = self.placeOnBoard(testBoard,player,column) if testBoard != None: scores[column] = await self.minimax(testBoard,difficulty,player%2+1,player,-math.inf,math.inf,False) - self.bot.log("Best score for column "+str(column)+" is "+str(scores[column]), level = 10) + self.bot.log("Best score for column "+str(column)+" is "+str(scores[column])) possibleScores = scores.copy() diff --git a/funcs/games/connectFourDraw.py b/funcs/games/connectFourDraw.py index 0c52491..340bb2f 100644 --- a/funcs/games/connectFourDraw.py +++ b/funcs/games/connectFourDraw.py @@ -8,7 +8,7 @@ class drawConnectFour(): # Draws the whole thing def drawImage(self, channel): - self.bot.log("Drawing connect four board", level = 10) + self.bot.log("Drawing connect four board") game = self.bot.database["connect 4 games"].find_one({"_id":channel}) board = game["board"] diff --git a/funcs/games/gameLoops.py b/funcs/games/gameLoops.py index 8096726..f680558 100644 --- a/funcs/games/gameLoops.py +++ b/funcs/games/gameLoops.py @@ -14,7 +14,7 @@ class GameLoops(): for message in messages: oldMessage = await channel.fetch_message(int(message)) - self.bot.log("Deleting old message", level = 10) + self.bot.log("Deleting old message") await oldMessage.delete() except: oldMessage = "" @@ -35,7 +35,7 @@ class GameLoops(): await ctx.send(response) else: await ctx.channel.send(response) - self.bot.log(response, channelId, level = 10) + self.bot.log(response, channelId) if showImage: if deleteImage: oldImage = await self.deleteMessage("connectFour"+channelId,ctx.channel) @@ -44,7 +44,7 @@ class GameLoops(): if gwendoTurn: response, showImage, deleteImage, gameDone, gwendoTurn = await self.bot.games.connectFour.connectFourAI(channelId) await ctx.channel.send(response) - self.bot.log(response,channelId, level = 10) + self.bot.log(response,channelId) if showImage: if deleteImage: await oldImage.delete() @@ -58,7 +58,7 @@ class GameLoops(): await oldImage.add_reaction(reaction) except: - self.bot.log("Image deleted before I could react to all of them", level = 10) + self.bot.log("Image deleted before I could react to all of them") else: with open("resources/games/oldImages/connectFour"+channelId, "w") as f: @@ -68,7 +68,7 @@ class GameLoops(): for reaction in reactions: await oldImage.add_reaction(reaction) except: - self.bot.log("Image deleted before I could react to all of them", level = 10) + self.bot.log("Image deleted before I could react to all of them") if gameDone: game = self.bot.database["connect 4 games"].find_one({"_id":channelId}) @@ -100,7 +100,7 @@ class GameLoops(): await channel.send(response) else: await ctx.send(response) - self.bot.log(response,str(channel.id), level = 10) + self.bot.log(response,str(channel.id)) if showImage: if deleteImage: await self.deleteMessage("hangman"+str(channel.id),channel) @@ -125,7 +125,7 @@ class GameLoops(): emoji = chr(ord(letter)+127397) await message.add_reaction(emoji) except: - self.bot.log("Image deleted before adding all reactions", level = 10) + self.bot.log("Image deleted before adding all reactions") # Runs Hex async def runHex(self,ctx,command,user): @@ -137,7 +137,7 @@ class GameLoops(): await ctx.send(response) - self.bot.log(response,str(channelId), level = 10) + self.bot.log(response,str(channelId)) if showImage: if deleteImage: try: @@ -152,7 +152,7 @@ class GameLoops(): response, showImage, deleteImage, gameDone, gwendoTurn = "An AI error ocurred",False,False,False,False self.bot.log("AI error (error code 1520)") await ctx.channel.send(response) - self.bot.log(response,str(channelId), level = 10) + self.bot.log(response,str(channelId)) if showImage: if deleteImage: await oldImage.delete() diff --git a/funcs/games/hangman.py b/funcs/games/hangman.py index 2dcac9b..dcd50df 100644 --- a/funcs/games/hangman.py +++ b/funcs/games/hangman.py @@ -18,7 +18,7 @@ class Hangman(): while "-" in word or "." in word: with urllib.request.urlopen(apiUrl+apiKey) as p: word = list(json.load(p)[0]["word"].upper()) - self.bot.log("Found the word \""+"".join(word)+"\"", level = 10) + self.bot.log("Found the word \""+"".join(word)+"\"") guessed = [False] * len(word) gameID = datetime.datetime.now().strftime('%Y%m%d%H%M%S') newGame = {"_id":channel,"player" : user,"guessed letters" : [],"word" : word,"game ID" : gameID,"misses" : 0,"guessed" : guessed} diff --git a/funcs/games/hangmanDraw.py b/funcs/games/hangmanDraw.py index 23b7a9c..c955fee 100644 --- a/funcs/games/hangmanDraw.py +++ b/funcs/games/hangmanDraw.py @@ -212,7 +212,7 @@ class DrawHangman(): return background def drawImage(self,channel): - self.bot.log("Drawing hangman image", channel, level = 10) + self.bot.log("Drawing hangman image", channel) game = self.bot.database["hangman games"].find_one({"_id":channel}) random.seed(game["game ID"]) diff --git a/funcs/games/hex.py b/funcs/games/hex.py index d173390..3af263f 100644 --- a/funcs/games/hex.py +++ b/funcs/games/hex.py @@ -22,13 +22,13 @@ class HexGame(): commands = command.lower().split() game = self.bot.database["hex games"].find_one({"_id":channel}) if command == "" or command == " ": - return "I didn't get that. Use \"!hex start [opponent]\" to start a game.", False, False, False, False + return "I didn't get that. Use \"/hex start [opponent]\" to start a game.", False, False, False, False elif commands[0] == "start": # Starting a game - if len(commands) == 1: # if the commands is "!hex start", the opponent is Gwendolyn at difficulty 2 + if len(commands) == 1: # if the commands is "/hex start", the opponent is Gwendolyn at difficulty 2 commands.append("2") - self.bot.log("Starting a hex game with hexStart(). "+str(user)+" challenged "+commands[1], level = 10) + self.bot.log("Starting a hex game with hexStart(). "+str(user)+" challenged "+commands[1]) return self.hexStart(channel,user,commands[1]) # commands[1] is the opponent # If using a command with no game, return error @@ -47,7 +47,7 @@ class HexGame(): try: return self.placeHex(channel,commands[1], user) except: - return "I didn't get that. To place a piece use \"!hex place [position]\". A valid position is e.g. \"E2\".", False, False, False, False + return "I didn't get that. To place a piece use \"/hex place [position]\". A valid position is e.g. \"E2\".", False, False, False, False # Undo elif commands[0] == "undo": @@ -78,7 +78,7 @@ class HexGame(): return "You can only swap as the second player after the very first move.", False, False, False, False else: - return "I didn't get that. Use \"!hex start [opponent]\" to start a game, \"!hex place [position]\" to place a piece, \"!hex undo\" to undo your last move or \"!hex stop\" to stop a current game.", False, False, False, False + return "I didn't get that. Use \"/hex start [opponent]\" to start a game, \"/hex place [position]\" to place a piece, \"/hex undo\" to undo your last move or \"/hex stop\" to stop a current game.", False, False, False, False # Starts the game def hexStart(self, channel, user, opponent): @@ -142,7 +142,7 @@ class HexGame(): if player == turn: board = game["board"] - self.bot.log("Placing a piece on the board with placeHex()", level = 10) + self.bot.log("Placing a piece on the board with placeHex()") # Places on board board = self.placeOnHexBoard(board,player,position) @@ -153,7 +153,7 @@ class HexGame(): self.bot.database["hex games"].update_one({"_id":channel},{"$set":{"turn":turn}}) # Checking for a win - self.bot.log("Checking for win", level = 10) + self.bot.log("Checking for win") winner = self.evaluateBoard(game["board"])[1] if winner == 0: # Continue with the game. @@ -174,7 +174,7 @@ class HexGame(): # Is it now Gwendolyn's turn? gwendoTurn = False if game["players"][turn-1] == "Gwendolyn": - self.bot.log("It's Gwendolyn's turn", level = 10) + self.bot.log("It's Gwendolyn's turn") gwendoTurn = True # Update the board @@ -226,7 +226,7 @@ class HexGame(): turn = game["turn"] # You can only undo after your turn, which is the opponent's turn. if user == game["players"][(turn % 2)]: # If it's not your turn - self.bot.log("Undoing {}'s last move".format(self.bot.databaseFuncs.getName(user)), level = 10) + self.bot.log("Undoing {}'s last move".format(self.bot.databaseFuncs.getName(user))) lastMove = game["gameHistory"].pop() game["board"][lastMove[0]][lastMove[1]] = 0 @@ -251,7 +251,7 @@ class HexGame(): # Plays as the AI def hexAI(self, channel): - self.bot.log("Figuring out best move", level = 10) + self.bot.log("Figuring out best move") game = self.bot.database["hex games"].find_one({"_id":channel}) board = game["board"] @@ -293,7 +293,7 @@ class HexGame(): chosenMove = (i // BOARDWIDTH , i % BOARDWIDTH) """ placement = "abcdefghijk"[chosenMove[1]]+str(chosenMove[0]+1) - self.bot.log("ChosenMove is {} at {}".format(chosenMove,placement), level = 10) + self.bot.log("ChosenMove is {} at {}".format(chosenMove,placement)) return self.placeHex(channel,placement, "Gwendolyn") @@ -327,7 +327,7 @@ class HexGame(): scores[player] = Distance[u] # A player's score is the shortest distance to goal. Which equals the number of remaining moves they need to win if unblocked by the opponent. break else: - self.bot.log("For some reason, no path to the goal was found. ", level = 10) + self.bot.log("For some reason, no path to the goal was found. ") if scores[player] == 0: winner = player break # We don't need to check the other player's score, if player1 won. diff --git a/funcs/games/invest.py b/funcs/games/invest.py index 65c1cc0..04a80dc 100644 --- a/funcs/games/invest.py +++ b/funcs/games/invest.py @@ -122,7 +122,7 @@ class Invest(): #try: return self.buyStock(user,commands[1],int(commands[2])) #except: - # return "The command must be given as \"!invest buy [stock] [amount of GwendoBucks to purchase with]\"" + # return "The command must be given as \"/invest buy [stock] [amount of GwendoBucks to purchase with]\"" else: return "You must give both a stock name and an amount of gwendobucks you wish to spend." @@ -132,6 +132,6 @@ class Invest(): try: return self.sellStock(user,commands[1],int(commands[2])) except: - return "The command must be given as \"!invest sell [stock] [amount of GwendoBucks to sell stocks for]\"" + return "The command must be given as \"/invest sell [stock] [amount of GwendoBucks to sell stocks for]\"" else: return "You must give both a stock name and an amount of GwendoBucks you wish to sell stocks for." diff --git a/funcs/games/money.py b/funcs/games/money.py index 20aadd2..f4d28e3 100644 --- a/funcs/games/money.py +++ b/funcs/games/money.py @@ -6,7 +6,7 @@ class Money(): # Returns the account balance for a user def checkBalance(self, user): - self.bot.log("checking "+user+"'s account balance", level = 10) + self.bot.log("checking "+user+"'s account balance") userData = self.database["users"].find_one({"_id":user}) @@ -16,7 +16,7 @@ class Money(): # Adds money to the account of a user def addMoney(self,user,amount): - self.bot.log("adding "+str(amount)+" to "+user+"'s account", level = 10) + self.bot.log("adding "+str(amount)+" to "+user+"'s account") userData = self.database["users"].find_one({"_id":user}) diff --git a/funcs/lookup/lookupFuncs.py b/funcs/lookup/lookupFuncs.py index a9091a2..3cfe9aa 100644 --- a/funcs/lookup/lookupFuncs.py +++ b/funcs/lookup/lookupFuncs.py @@ -135,5 +135,5 @@ class LookupFuncs(): else: self.bot.log("I don't know that spell (error code 501)") spell_output = "I don't think that's a spell (error code 501)" - self.bot.log("Successfully ran !spell") + self.bot.log("Successfully ran /spell") return(spell_output) diff --git a/funcs/other/bedreNetflix.py b/funcs/other/bedreNetflix.py index eab30ce..7c98520 100644 --- a/funcs/other/bedreNetflix.py +++ b/funcs/other/bedreNetflix.py @@ -40,7 +40,7 @@ class BedreNetflix(): messageText += "Error" imdbIds.append(movie.movieID) - self.bot.log("Returning a list of "+str(len(movies))+" possible movies: "+str(imdbIds), level = 10) + self.bot.log("Returning a list of "+str(len(movies))+" possible movies: "+str(imdbIds)) em = discord.Embed(title=messageTitle,description=messageText,colour=0x00FF00) @@ -116,7 +116,7 @@ class BedreNetflix(): messageText += "Error" imdbNames.append(show["title"]) - self.bot.log("Returning a list of "+str(len(shows))+" possible shows: "+str(imdbNames), level = 10) + self.bot.log("Returning a list of "+str(len(shows))+" possible shows: "+str(imdbNames)) em = discord.Embed(title=messageTitle,description=messageText,colour=0x00FF00) @@ -380,5 +380,5 @@ class BedreNetflix(): else: await ctx.send(messageText) else: - await ctx.send("Invalid or repeated parameters. Use '!help downloading' to see valid parameters.") + await ctx.send("Invalid or repeated parameters. Use '/help downloading' to see valid parameters.") diff --git a/funcs/other/other.py b/funcs/other/other.py index c8c98ac..90bff31 100644 --- a/funcs/other/other.py +++ b/funcs/other/other.py @@ -45,7 +45,7 @@ class Other(): movie = searchResult[0] imdbClient.update(movie) - self.bot.log("Successfully ran !movie") + self.bot.log("Successfully ran /movie") title = movie["title"] plot = movie['plot'][0].split("::")[0] diff --git a/funcs/starWarsFuncs/starWarsChar.py b/funcs/starWarsFuncs/starWarsChar.py index 95caa17..71f56c9 100644 --- a/funcs/starWarsFuncs/starWarsChar.py +++ b/funcs/starWarsFuncs/starWarsChar.py @@ -450,7 +450,7 @@ class StarWarsChar(): return "Couldn't find that data. Are you sure you spelled it correctly? (error code 944)" else: self.bot.log(user+" doesn't have a character (error code 943)") - return "You don't have a character. You can make one with !starwarscharacter (error code 943)" + return "You don't have a character. You can make one with /starwarscharacter (error code 943)" def replaceSpaces(self,cmd : str): withSpaces = ["Specialization Trees","Wound Threshold","Strain Threshold","Defense - Ranged","Defense - Melee","Force Rating","Core Worlds","Outer Rim","Piloting - Planetary","Piloting - Space","Ranged - Heavy","Ranged - Light","Lightsaber Characteristic","Critical Injuries","Force Powers"] diff --git a/funcs/starWarsFuncs/starWarsRoll.py b/funcs/starWarsFuncs/starWarsRoll.py index cc24a92..0cd045d 100644 --- a/funcs/starWarsFuncs/starWarsRoll.py +++ b/funcs/starWarsFuncs/starWarsRoll.py @@ -328,7 +328,7 @@ class StarWarsRoll(): self.bot.log("Converted skill to dice") else: self.bot.log("Okay, no they don't i guess (error code 912)") - return "You don't have a user. You can make one with !starwarscharacter (error code 912)" + return "You don't have a user. You can make one with /starwarscharacter (error code 912)" elif string.capwords(commands[0]) in ["Ranged","Piloting"]: self.bot.log("They fucked up writing the name of a ranged or piloting skill") diff --git a/project-guidelines.md b/project-guidelines.md index 2befabb..c351765 100644 --- a/project-guidelines.md +++ b/project-guidelines.md @@ -108,5 +108,5 @@ Things you should know about the logging: ### Logging rules 1. Never call the `logThis()` function from `/utils/utilFuncs/`. Always call `bot.log`. -1. There should be at most 3 `INFO` level logs while executing a single command. This includes the log created in the `on_command()` function in `Gwendolyn.py`, so your code for a command can at most make 2 logs of level `INFO`. `DEBUG` level logs should be used for all other logging. +1. The `on_slash_command()` and `on_ready()` events are the only times log should be called at level 20.`DEBUG` level logs should be used for all other logging. 1. Always provide the channel id if available. Although you shouldn't pass the channel id to a function purely to use it in logs. diff --git a/resources/help/help-addmovie.txt b/resources/help/help-addmovie.txt index 5d28180..daa1ac6 100644 --- a/resources/help/help-addmovie.txt +++ b/resources/help/help-addmovie.txt @@ -1 +1 @@ -Du kan søge efter en film ved at skrive `!addmovie [søgning]`. Gwendolyn vil derefter vise dig resultater baseret på din søgning. Du kan derfra reagere på Gwendolyns besked for at downloade en specifik film. \ No newline at end of file +Du kan søge efter en film ved at skrive `/addmovie [søgning]`. Gwendolyn vil derefter vise dig resultater baseret på din søgning. Du kan derfra reagere på Gwendolyns besked for at downloade en specifik film. \ No newline at end of file diff --git a/resources/help/help-addshow.txt b/resources/help/help-addshow.txt index 746f5e9..9d35d5c 100644 --- a/resources/help/help-addshow.txt +++ b/resources/help/help-addshow.txt @@ -1 +1 @@ -Du kan søge efter et show ved at skrive `!addshow [søgning]`. Gwendolyn vil derefter vise dig resultater baseret på din søgning. Du kan derfra reagere på Gwendolyns besked for at downloade et specifikt show. \ No newline at end of file +Du kan søge efter et show ved at skrive `/addshow [søgning]`. Gwendolyn vil derefter vise dig resultater baseret på din søgning. Du kan derfra reagere på Gwendolyns besked for at downloade et specifikt show. \ No newline at end of file diff --git a/resources/help/help-blackjack.txt b/resources/help/help-blackjack.txt index 45f5c43..49464d1 100644 --- a/resources/help/help-blackjack.txt +++ b/resources/help/help-blackjack.txt @@ -1 +1 @@ -Kommandoen `!blackjack` starter et spil blackjack. `!blackjack bet [beløb]` lader dig vædde en mængde af dine GwendoBucks. Du bruger `!blackjack hit`, `!blackjack stand`, `!blackjack split` og `!blackjack double` i løbet af spillet. \ No newline at end of file +Kommandoen `/blackjack` starter et spil blackjack. `/blackjack bet [beløb]` lader dig vædde en mængde af dine GwendoBucks. Du bruger `/blackjack hit`, `/blackjack stand`, `/blackjack split` og `/blackjack double` i løbet af spillet. \ No newline at end of file diff --git a/resources/help/help-connectfour.txt b/resources/help/help-connectfour.txt index 073324c..ee48f68 100644 --- a/resources/help/help-connectfour.txt +++ b/resources/help/help-connectfour.txt @@ -1 +1 @@ -Brug `!connectFour start` til at starte et spil imod Gwendolyn. Brug `!connectFour start [modstander]` for at spille imod en anden person. Du kan også bruge `!connectFour start [1-5]`, hvor tallet er sværhedsgraden af Gwendolyn du gerne vil spille imod. \ No newline at end of file +Brug `/connectFour start` til at starte et spil imod Gwendolyn. Brug `/connectFour start [modstander]` for at spille imod en anden person. Du kan også bruge `/connectFour start [1-5]`, hvor tallet er sværhedsgraden af Gwendolyn du gerne vil spille imod. \ No newline at end of file diff --git a/resources/help/help-give.txt b/resources/help/help-give.txt index 5fbb27f..8c2803c 100644 --- a/resources/help/help-give.txt +++ b/resources/help/help-give.txt @@ -1 +1 @@ -Du kan give GwendoBucks til andre med `!give [modtager] [antal]`, hvor [modtager] er den der skal modtage GwendoBucks og [antal] er hvor mange GwendoBucks du giver dem. \ No newline at end of file +Du kan give GwendoBucks til andre med `/give [modtager] [antal]`, hvor [modtager] er den der skal modtage GwendoBucks og [antal] er hvor mange GwendoBucks du giver dem. \ No newline at end of file diff --git a/resources/help/help-hangman.txt b/resources/help/help-hangman.txt index eeff703..1d3741e 100644 --- a/resources/help/help-hangman.txt +++ b/resources/help/help-hangman.txt @@ -1 +1 @@ -Brug `!hangman` til at starte et spil hangman. Brug derefter reaktionerne til at gætte bogstaver. Du har 6 gæt. \ No newline at end of file +Brug `/hangman` til at starte et spil hangman. Brug derefter reaktionerne til at gætte bogstaver. Du har 6 gæt. \ No newline at end of file diff --git a/resources/help/help-hello.txt b/resources/help/help-hello.txt index deee19f..6aa55c9 100644 --- a/resources/help/help-hello.txt +++ b/resources/help/help-hello.txt @@ -1 +1 @@ -Hvis du bruger kommandoen `!hello`, sender Gwendolyn en venlig hilsen. \ No newline at end of file +Hvis du bruger kommandoen `/hello`, sender Gwendolyn en venlig hilsen. \ No newline at end of file diff --git a/resources/help/help-hex.txt b/resources/help/help-hex.txt index 99d5b96..9d1e14b 100644 --- a/resources/help/help-hex.txt +++ b/resources/help/help-hex.txt @@ -1 +1 @@ -Brug `!hex start` til at starte et spil imod Gwendolyn. Brug "!hex start [modstander]" for at spille imod en anden person. \ No newline at end of file +Brug `/hex start` til at starte et spil imod Gwendolyn. Brug "/hex start [modstander]" for at spille imod en anden person. \ No newline at end of file diff --git a/resources/help/help-invest.txt b/resources/help/help-invest.txt index b5ceae5..4228ab0 100644 --- a/resources/help/help-invest.txt +++ b/resources/help/help-invest.txt @@ -1,3 +1,3 @@ -`!invest` vil vise dig hvilke aktier du har. `!invest check [symbol]` viser dig en akties nuværende pris, hvor [symbol] er forkortelsen for firmaet. GwendoBucks er lig med 1 amerikans cent. -`!invest buy [symbol] [pris]` lader dig købe aktier. [pris] er mængden af GwendoBucks du bruger på at købe. Du kan købe for færre GwendoBucks end en enkelt akties pris, men ikke for mindre end 100 GwendoBucks. -`!invest buy [symbol] [pris]` lader dig sælge dine aktier. Du kan godt sælge for mindre end 100 GwendoBucks. \ No newline at end of file +`/invest` vil vise dig hvilke aktier du har. `/invest check [symbol]` viser dig en akties nuværende pris, hvor [symbol] er forkortelsen for firmaet. GwendoBucks er lig med 1 amerikans cent. +`/invest buy [symbol] [pris]` lader dig købe aktier. [pris] er mængden af GwendoBucks du bruger på at købe. Du kan købe for færre GwendoBucks end en enkelt akties pris, men ikke for mindre end 100 GwendoBucks. +`/invest buy [symbol] [pris]` lader dig sælge dine aktier. Du kan godt sælge for mindre end 100 GwendoBucks. \ No newline at end of file diff --git a/resources/help/help-monster.txt b/resources/help/help-monster.txt index 4c7a22f..957043d 100644 --- a/resources/help/help-monster.txt +++ b/resources/help/help-monster.txt @@ -1,2 +1,2 @@ -Søg efter et monster i D&D med `!monster [monster]`, hvor [monster] er navnet på det monster du søger efter. +Søg efter et monster i D&D med `/monster [monster]`, hvor [monster] er navnet på det monster du søger efter. Hvis Gwendolyn ikke kan finde det, er det ofte fordi du har skrevet navnet forkert. \ No newline at end of file diff --git a/resources/help/help-spell.txt b/resources/help/help-spell.txt index 16d9eb4..606b9ea 100644 --- a/resources/help/help-spell.txt +++ b/resources/help/help-spell.txt @@ -1,2 +1,2 @@ -Søg efter en spell i D&D med `!spell [spell]`, hvor [spell] er navnet på den spell du søger efter. +Søg efter en spell i D&D med `/spell [spell]`, hvor [spell] er navnet på den spell du søger efter. Hvis Gwendolyn ikke kan finde den, er det ofte fordi du har skrevet navnet forkert. \ No newline at end of file diff --git a/resources/help/help-starwarscharacter.txt b/resources/help/help-starwarscharacter.txt index ef610ad..794add6 100644 --- a/resources/help/help-starwarscharacter.txt +++ b/resources/help/help-starwarscharacter.txt @@ -1 +1 @@ - Du kan bruge kommandoer som `!starWarsCharacter name Jared` eller `!starWarsCharacter skills astrogation 3` til at ændre din karakters info. Kommandoen `!starWarsCharacter` vil give dig et character sheet for din karakter. \ No newline at end of file + Du kan bruge kommandoer som `/starWarsCharacter name Jared` eller `/starWarsCharacter skills astrogation 3` til at ændre din karakters info. Kommandoen `/starWarsCharacter` vil give dig et character sheet for din karakter. \ No newline at end of file diff --git a/resources/help/help-starwarsroll.txt b/resources/help/help-starwarsroll.txt index 13b059f..4876bf2 100644 --- a/resources/help/help-starwarsroll.txt +++ b/resources/help/help-starwarsroll.txt @@ -1 +1 @@ -Lader dig rulle Star Wars terninger. Du kan skrive tal der repræsenterer antallet af hver terning i rækkefølgen: ability, proficiency, difficulty, challenge, boost, setback og force. Du behøver ikke skrive et tal til alle terningerne. Du kan også skrive forbogstavet for terningen du vil rulle før antallet, såsom "!starWarsRoll f2", der ruller 2 force terninger. \ No newline at end of file +Lader dig rulle Star Wars terninger. Du kan skrive tal der repræsenterer antallet af hver terning i rækkefølgen: ability, proficiency, difficulty, challenge, boost, setback og force. Du behøver ikke skrive et tal til alle terningerne. Du kan også skrive forbogstavet for terningen du vil rulle før antallet, såsom "/starWarsRoll f2", der ruller 2 force terninger. \ No newline at end of file diff --git a/resources/help/help-trivia.txt b/resources/help/help-trivia.txt index 305b0ba..a5da454 100644 --- a/resources/help/help-trivia.txt +++ b/resources/help/help-trivia.txt @@ -1,4 +1,4 @@ -Lader dig spille et spil trivia. `!trivia` starter spillet. +Lader dig spille et spil trivia. `/trivia` starter spillet. Hvert spil trivia varer i 1 minut, og der kan kun være et enkelt spil i hver kanal ad gangen. -`!trivia [svar]` lader dig svare på det nuværende spørgsmål, hvor [svar] er a, b, c eller d. +`/trivia [svar]` lader dig svare på det nuværende spørgsmål, hvor [svar] er a, b, c eller d. Hvis du svarer rigtigt får du 1 GwendoBuck. \ No newline at end of file diff --git a/resources/help/help.txt b/resources/help/help.txt index 9066015..9501046 100644 --- a/resources/help/help.txt +++ b/resources/help/help.txt @@ -1,24 +1,24 @@ -`!hello` - En venlig hilsen. -`!roll` - Rul terninger i xdy format. -`!spell` - Slå en besværgelse op. -`!monster` - Slå et monster op. -`!image` - Finder et tilfældigt billede fra internettet. -`!movie` - Giver titlen på en tilfældig film fra Bedre Netflix -`!name` - Genererer et tilfældigt navn. -`!tavern` - Genererer en tilfældig tavern. -`!give` - Lader dig give GwendoBucks til andre. -`!starWarsCharacter` - Lader dig lave en Star Wars karakter. -`!starWarsRoll` - Lader dig rulle Star Wars terninger. -`!balance` - Viser dig hvor mange GwendoBucks du har. -`!invest` - Lader dig investere dine GwendoBucks i aktiemarkedet. -`!blackjack` - Lader dig spille et spil blackjack. -`!trivia` - Lader dig spille et spil trivia, hvor du kan tjene GwendoBucks. -`!connectFour` - Lader dig spille et spil fire på stribe. -`!hex` - Lader dig spille et spil Hex. -`!hangman` - Lader dig spille et spil hangman. -`!wolf` - Lader dig slå ting op på Wolfram Alpha. -`!addmovie` - Lader dig tilføje film til Bedre Netflix. -`!addshow` - Lader dig tilføje tv shows til Bedre Netflix. -`!downloading` - Viser dig hvor langt de torrents der er ved at downloade er kommet. -`!thank` - Lader dig takke Gwendolyn. -Du kan få ekstra information om kommandoerne med "!help [kommando]". +`/hello` - En venlig hilsen. +`/roll` - Rul terninger i xdy format. +`/spell` - Slå en besværgelse op. +`/monster` - Slå et monster op. +`/image` - Finder et tilfældigt billede fra internettet. +`/movie` - Giver titlen på en tilfældig film fra Bedre Netflix +`/name` - Genererer et tilfældigt navn. +`/tavern` - Genererer en tilfældig tavern. +`/give` - Lader dig give GwendoBucks til andre. +`/starWarsCharacter` - Lader dig lave en Star Wars karakter. +`/starWarsRoll` - Lader dig rulle Star Wars terninger. +`/balance` - Viser dig hvor mange GwendoBucks du har. +`/invest` - Lader dig investere dine GwendoBucks i aktiemarkedet. +`/blackjack` - Lader dig spille et spil blackjack. +`/trivia` - Lader dig spille et spil trivia, hvor du kan tjene GwendoBucks. +`/connectFour` - Lader dig spille et spil fire på stribe. +`/hex` - Lader dig spille et spil Hex. +`/hangman` - Lader dig spille et spil hangman. +`/wolf` - Lader dig slå ting op på Wolfram Alpha. +`/addmovie` - Lader dig tilføje film til Bedre Netflix. +`/addshow` - Lader dig tilføje tv shows til Bedre Netflix. +`/downloading` - Viser dig hvor langt de torrents der er ved at downloade er kommet. +`/thank` - Lader dig takke Gwendolyn. +Du kan få ekstra information om kommandoerne med "/help [kommando]". diff --git a/resources/slashParameters.json b/resources/slashParameters.json index d398d8b..84dab46 100644 --- a/resources/slashParameters.json +++ b/resources/slashParameters.json @@ -146,9 +146,15 @@ "description" : "Give GwendoBucks to another user", "options" : [ { - "name" : "parameters", - "description" : "The user and amount of GwendoBucks you're sending", - "type" : 3, + "name" : "user", + "description" : "The user you're sending GwendoBucks to", + "type" : 6, + "required" : "true" + }, + { + "name" : "amount", + "description" : "The number of GwendoBucks you're sending", + "type" : 4, "required" : "true" } ] diff --git a/utils/helperClasses.py b/utils/helperClasses.py index bc4846a..74b4cc1 100644 --- a/utils/helperClasses.py +++ b/utils/helperClasses.py @@ -90,7 +90,7 @@ class databaseFuncs(): oldImage = int(f.read()) if message.id == oldImage: - self.bot.log("They reacted to the connectFour game", level = 10) + self.bot.log("They reacted to the connectFour game") turn = game["turn"] if user == game["players"][turn]: return True, turn+1 @@ -111,7 +111,7 @@ class databaseFuncs(): for oldMessage in oldMessages: oldMessageID = int(oldMessage) if message.id == oldMessageID: - self.bot.log("They reacted to the hangman game", level = 10) + self.bot.log("They reacted to the hangman game") gameMessage = True return gameMessage