From 20809aa39c40fc56733294a02be14a92cd1092cd Mon Sep 17 00:00:00 2001 From: Ang Jun Ray Date: Tue, 20 Jul 2021 11:19:08 +0800 Subject: [PATCH 01/19] Update hangman.py --- cogs/hangman.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cogs/hangman.py b/cogs/hangman.py index 69d4b31..b3b7f20 100644 --- a/cogs/hangman.py +++ b/cogs/hangman.py @@ -86,7 +86,7 @@ def check(msg): while True: try: message = await self.client.wait_for('message', timeout=120, check=check) - if message.content == "m!hangmanList" or message.content != "!hangmanList": + if message.content == "m!hangmanList" or message.content == "!hangmanList": continue elif message.content in myList: chosenTopic = message.content From d0ae093e60c30b26af535a29003b2aee1f60b74b Mon Sep 17 00:00:00 2001 From: neon_paradox Date: Tue, 20 Jul 2021 11:31:53 +0800 Subject: [PATCH 02/19] Fixed some hangman issues with repeating guessing same letter also fixed guessed correctly but no finish game issue :D --- cogs/hangman.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/cogs/hangman.py b/cogs/hangman.py index b3b7f20..4754fd1 100644 --- a/cogs/hangman.py +++ b/cogs/hangman.py @@ -144,13 +144,26 @@ def check(msg): lives = 5 word_guessed = 0 await ctx.reply(embed=embed) - + guessed_letter = [] while answer != wordChoice and lives > 0: + + if currentGuess == correctWord: + break try: message = await self.client.wait_for('message', timeout=45, check=check) messageanswer = message.content.lower() if len(str(messageanswer)) == 1: + if str(messageanswer) in guessed_letter: + embed=discord.Embed( + title="You already guessed that letter!", + description="Try again!", + color=0xff0000 + ) + await message.reply(embed=embed) + continue ok = 0 + guessed_letter.append(str(messageanswer)) + answer = "" for i in range(len(correctWord)): if messageanswer == correctWord[i]: From 01898ef99a93f2d4449a08bbae66a7d32c44e355 Mon Sep 17 00:00:00 2001 From: Ang Jun Ray Date: Tue, 20 Jul 2021 11:46:44 +0800 Subject: [PATCH 03/19] added firebase to hangman --- cogs/eastereggs.py | 17 +---------------- cogs/hangman.py | 43 +++++++++++++++++++++++++++++++++---------- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/cogs/eastereggs.py b/cogs/eastereggs.py index 165f2e4..9206899 100644 --- a/cogs/eastereggs.py +++ b/cogs/eastereggs.py @@ -8,7 +8,7 @@ def __init__(self, client): self.client = client self.hidden = True - @commands.command(hidden=True) + @commands.command(hidden=True, aliases=["whoareu"]) async def whoru(self, ctx): embed = discord.Embed(title = "Hey! Looks like you found this easter egg!",description = "Nice.",color = self.client.primary_colour) embed.add_field( @@ -22,21 +22,6 @@ async def whoru(self, ctx): inline = False ) await ctx.author.send(embed=embed) - @commands.command(hidden=True) - async def whoareu(self, ctx): - embed = discord.Embed(title = "Hey! Looks like you found this easter egg!",description = "Nice.",color = self.client.primary_colour) - embed.add_field( - name = "Whoami?", - value = "I am Maxigames! The creation of amateur bot devs <@!712942935129456671>, <@!676748194956181505> and <@!782247763542016010>", - inline = False - ) - embed.add_field( - name = "Are there more easter eggs?", - value = "Yes ofc.", - inline = False - ) - await ctx.author.send(embed=embed) - def setup(client): client.add_cog(EasterEggs(client)) diff --git a/cogs/hangman.py b/cogs/hangman.py index 4754fd1..bdca98a 100644 --- a/cogs/hangman.py +++ b/cogs/hangman.py @@ -11,14 +11,17 @@ import asyncio import time from utils.paginator import Paginator +import firebase_admin +from firebase_admin import firestore alpha = "abcdefghijklmnopqrstuvwxyz" - class Hangman(commands.Cog): def __init__(self, client): self.client = client self.hidden = False + self.db = firestore.client() + self.initiation = self.client.get_cog("Initiation") @commands.command() async def hangmanList(self, ctx): @@ -71,6 +74,14 @@ async def hangmanList(self, ctx): @commands.command() async def hangman(self, ctx): + #! Hangman Firebase Initalisation + self.initiation = self.client.get_cog("Initiation") + await self.initiation.checkserver(ctx) + doc_ref = self.db.collection(u'users').document(str(ctx.author.id)) + doc = doc_ref.get() + data = doc.to_dict() + + #! Retriving data def check(msg): return msg.author == ctx.author and msg.channel == ctx.channel @@ -82,6 +93,7 @@ def check(msg): words.close() await ctx.reply(embed=discord.Embed(title="You have **2 minutes** to choose one topic. Do `m!hangmanList` to check all the topics.", colour=0x00ff00)) + #! Waiting for a reply chosenTopic = "" while True: try: @@ -145,6 +157,8 @@ def check(msg): word_guessed = 0 await ctx.reply(embed=embed) guessed_letter = [] + + #! Main Hangman Portion while answer != wordChoice and lives > 0: if currentGuess == correctWord: @@ -187,15 +201,16 @@ def check(msg): else: if messageanswer == wordChoice: + add = random.randint(1, 10) + data["money"] += add embed = discord.Embed( - title="Your guess was correct!", - description="You win! The word was " + wordChoice, - color=self.client.primary_colour + title="You won!", + description=f"Congratulations, you guessed the word {wordChoice} correctly! You have {data['money']} money now!", + color=0x00ff00 ) - answer = wordChoice - word_guessed = 1 - await message.reply(embed=embed) - + await ctx.reply(embed=embed) + doc_ref.set(data) + return else: lives -= 1 embed = discord.Embed( @@ -208,19 +223,27 @@ def check(msg): await ctx.reply(embed=discord.Embed(title="Hangman game aborted due to Timeout", description="", colour=0x00ff00)) return if lives == 0: + deduct = random.randint(1, 10) + data["money"] -= deduct + if data["money"] < 0: + data["money"] = 0 embed = discord.Embed( title="You lost!", - description="The word was " + wordChoice, + description=f"The word was {wordChoice}, {deduct} money was subtracted off your account :(. You currently have f{data['money']} money", color=0xff0000 ) await ctx.reply(embed=embed) + doc_ref.set(data) elif word_guessed == 0: + add = random.randint(1, 10) + data["money"] += add embed = discord.Embed( title="You won!", - description="The word was " + wordChoice, + description=f"Congratulations, you guessed the word {wordChoice} correctly! You have {data['money']} money now!", color=0x00ff00 ) await ctx.reply(embed=embed) + doc_ref.set(data) def setup(client): From 0654253e105c1ef1c104671a0235f7986344da50 Mon Sep 17 00:00:00 2001 From: neon_paradox Date: Tue, 20 Jul 2021 14:25:12 +0800 Subject: [PATCH 04/19] hangman live system balacned :D --- app.py | 3 ++- cogs/hangman.py | 14 ++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app.py b/app.py index a3ace80..9cefd1e 100644 --- a/app.py +++ b/app.py @@ -2,6 +2,7 @@ import discord from discord.ext import commands import os +import time from client import Client # from start import keep_alive import firebase_admin @@ -35,5 +36,5 @@ async def on_ready(): with open('config.json', 'r') as file: data = json.load(file) client.run(data["tokenIdBeta"]) - #test! + diff --git a/cogs/hangman.py b/cogs/hangman.py index 4754fd1..6e18de8 100644 --- a/cogs/hangman.py +++ b/cogs/hangman.py @@ -5,6 +5,7 @@ import random import discord from discord.ext import commands +import math from urllib.request import urlopen as uReq from bs4 import BeautifulSoup as soup import sys @@ -141,7 +142,12 @@ def check(msg): description=answer, color=0xffff00 ) - lives = 5 + def maxi(a,b): + if a > b: + return a + else: + return b + lives = maxi(5,math.floor(len(wordChoice)*2/3)) word_guessed = 0 await ctx.reply(embed=embed) guessed_letter = [] @@ -183,7 +189,7 @@ def check(msg): description=f"The word now is {' '.join(currentGuess)}! You have {lives} lives left", color=self.client.primary_colour ) - await ctx.reply(embed=embed) + await message.reply(embed=embed) else: if messageanswer == wordChoice: @@ -213,14 +219,14 @@ def check(msg): description="The word was " + wordChoice, color=0xff0000 ) - await ctx.reply(embed=embed) + await message.reply(embed=embed) elif word_guessed == 0: embed = discord.Embed( title="You won!", description="The word was " + wordChoice, color=0x00ff00 ) - await ctx.reply(embed=embed) + await message.reply(embed=embed) def setup(client): From 7dd6b0cce18030daf1c053fe2f29fbda3a37807c Mon Sep 17 00:00:00 2001 From: Isaac Date: Tue, 20 Jul 2021 14:27:50 +0800 Subject: [PATCH 05/19] reindented starboard lol --- cogs/starboard.py | 94 +++++++++++++++++++++++------------------------ 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/cogs/starboard.py b/cogs/starboard.py index 0a33fbb..1bd007d 100644 --- a/cogs/starboard.py +++ b/cogs/starboard.py @@ -5,57 +5,57 @@ from utils import check class Starboard(commands.Cog): - def __init__(self, client): - self.client = client - self.hidden = True - self.db = firestore.client() - self.initiation = self.client.get_cog("Initiation") + def __init__(self, client): + self.client = client + self.hidden = True + self.db = firestore.client() + self.initiation = self.client.get_cog("Initiation") - @check.is_admin() - @commands.command(name="starboard", description="Starts a starboard", usage="m!starboard #starboard") - async def starboard(self, ctx, channel: discord.TextChannel = None): - if channel == None: - await ctx.reply("You need to specify a channel") - return - try: - self.initation = self.client.get_cog("Initiation") - await self.initation.checkserver(ctx) - doc_ref = self.db.collection(u'servers').document(str(ctx.guild.id)) - doc = doc_ref.get() - data = doc.to_dict() - data["starboard"] = {"channel": channel.id} - doc_ref.set(data) - await ctx.reply(f"Starboard channel has been set to {channel}!") - except: - await ctx.reply("That channel does not exist") + @check.is_admin() + @commands.command(name="starboard", description="Starts a starboard", usage="m!starboard #starboard") + async def starboard(self, ctx, channel: discord.TextChannel = None): + if channel == None: + await ctx.reply("You need to specify a channel") + return + try: + self.initation = self.client.get_cog("Initiation") + await self.initation.checkserver(ctx) + doc_ref = self.db.collection(u'servers').document(str(ctx.guild.id)) + doc = doc_ref.get() + data = doc.to_dict() + data["starboard"] = {"channel": channel.id} + doc_ref.set(data) + await ctx.reply(f"Starboard channel has been set to {channel}!") + except: + await ctx.reply("That channel does not exist") - @commands.Cog.listener() - async def on_reaction_add(self, reaction, user): - print("WORKING") - self.initiation = self.client.get_cog("Initiation") - doc_ref = self.db.collection(u'servers').document(str(reaction.message.guild.id)) - doc = doc_ref.get() - data = doc.to_dict() - channel = self.client.get_channel(int(data["starboard"]["channel"])) - await self.initiation.checkserver(reaction.message) + @commands.Cog.listener() + async def on_reaction_add(self, reaction, user): + print("WORKING") + self.initiation = self.client.get_cog("Initiation") + doc_ref = self.db.collection(u'servers').document(str(reaction.message.guild.id)) + doc = doc_ref.get() + data = doc.to_dict() + channel = self.client.get_channel(int(data["starboard"]["channel"])) + await self.initiation.checkserver(reaction.message) - if "starboard" not in data: - print('b') - return - if channel is None: - print("a") - return + if "starboard" not in data: + print('b') + return + if channel is None: + print("a") + return - if reaction.count > 1: - if reaction.emoji == "⭐": - try: - msg = await channel.fetch_message(data["starboard"][str(reaction.message.id)]) - await msg.edit(embed=discord.Embed(title=f"Starboard: {reaction.count}", description=reaction.message.content, color=0x00ff00).set_footer(text=f"React with {'🌟'} to star this message").set_author(name=reaction.message.author.name, icon_url=reaction.message.author.avatar_url)) - doc_ref.set(data) - except KeyError: - message = await channel.send(embed=discord.Embed(title=f"Starboard: {reaction.count}", description=reaction.message.content, color=0x00ff00).set_footer(text=f"React with {'🌟'} to star this message").set_author(name=reaction.message.author.name, icon_url=reaction.message.author.avatar_url)) - data["starboard"][str(reaction.message.id)] = message.id - doc_ref.set(data) + if reaction.count > 1: + if reaction.emoji == "⭐": + try: + msg = await channel.fetch_message(data["starboard"][str(reaction.message.id)]) + await msg.edit(embed=discord.Embed(title=f"Starboard: {reaction.count}", description=reaction.message.content, color=0x00ff00).set_footer(text=f"React with {'🌟'} to star this message").set_author(name=reaction.message.author.name, icon_url=reaction.message.author.avatar_url)) + doc_ref.set(data) + except KeyError: + message = await channel.send(embed=discord.Embed(title=f"Starboard: {reaction.count}", description=reaction.message.content, color=0x00ff00).set_footer(text=f"React with {'🌟'} to star this message").set_author(name=reaction.message.author.name, icon_url=reaction.message.author.avatar_url)) + data["starboard"][str(reaction.message.id)] = message.id + doc_ref.set(data) def setup(client): From 81b8d8a4127bbce63804c66d8e12da6c54cca5a2 Mon Sep 17 00:00:00 2001 From: Isaac Date: Tue, 20 Jul 2021 14:29:45 +0800 Subject: [PATCH 06/19] black! --- app.py | 27 +-- client.py | 12 +- cogs/connect4.py | 190 +++++++++++++++------ cogs/counting.py | 178 +++++++++++++------- cogs/eastereggs.py | 21 ++- cogs/economy.py | 290 ++++++++++++++++++-------------- cogs/errors.py | 47 +++--- cogs/general.py | 393 +++++++++++++++++++++++++------------------- cogs/hangman.py | 106 ++++++++---- cogs/initiation.py | 75 +++++---- cogs/quiz.py | 257 +++++++++++++++++------------ cogs/starboard.py | 45 ++++- cogs/suggestions.py | 25 ++- cogs/tickets.py | 178 +++++++++++++------- cogs/tictactoe.py | 138 +++++++++++----- cogs/todo.py | 26 +-- config.py | 2 +- start.py | 11 +- utils/check.py | 33 ++-- utils/paginator.py | 95 +++++++---- 20 files changed, 1349 insertions(+), 800 deletions(-) diff --git a/app.py b/app.py index 9cefd1e..0ab0f64 100644 --- a/app.py +++ b/app.py @@ -2,8 +2,9 @@ import discord from discord.ext import commands import os -import time +import time from client import Client + # from start import keep_alive import firebase_admin from firebase_admin import firestore @@ -11,7 +12,7 @@ from discord_components import * from discord_slash import SlashCommand, SlashContext -with open('config.json', 'r') as file: +with open("config.json", "r") as file: data = json.load(file) client = Client(command_prefix=[data["prefixBeta"]], help_command=None) @@ -20,21 +21,27 @@ db = firestore.client() DiscordComponents(client) -slash = SlashCommand(client, sync_commands=True, sync_on_cog_reload=True, override_type=True) -for filename in os.listdir('./cogs'): - if filename.endswith('.py'): - client.load_extension(f'cogs.{filename[:-3]}') +slash = SlashCommand( + client, sync_commands=True, sync_on_cog_reload=True, override_type=True +) +for filename in os.listdir("./cogs"): + if filename.endswith(".py"): + client.load_extension(f"cogs.{filename[:-3]}") @client.event async def on_ready(): - await client.change_presence(status=discord.Status.online, activity=discord.Game(name="m!help on " + str(len(client.guilds)) + " servers", type=0)) + await client.change_presence( + status=discord.Status.online, + activity=discord.Game( + name="m!help on " + str(len(client.guilds)) + " servers", type=0 + ), + ) print("We have logged in as {0.user}".format(client)) + # keep_alive() -with open('config.json', 'r') as file: +with open("config.json", "r") as file: data = json.load(file) client.run(data["tokenIdBeta"]) - - diff --git a/client.py b/client.py index 0e2c347..b52c9bb 100644 --- a/client.py +++ b/client.py @@ -1,16 +1,16 @@ - import discord from discord.ext import commands import datetime import json import config + class Client(commands.Bot): def __init__(self, **kwargs): super().__init__(**kwargs) self.help_command = None self.start_time = datetime.datetime.utcnow() - + @property def uptime(self): return datetime.datetime.utcnow() - self.start_time @@ -18,15 +18,15 @@ def uptime(self): @property def config(self): return config - + @property def primary_colour(self): return self.config.primary_colour - + @property def error_colour(self): return self.config.error_colour - + @property def icon_url(self): - return self.config.icon_url \ No newline at end of file + return self.config.icon_url diff --git a/cogs/connect4.py b/cogs/connect4.py index f5be90f..bdeac96 100644 --- a/cogs/connect4.py +++ b/cogs/connect4.py @@ -4,6 +4,7 @@ import sys import asyncio import time + alpha = "abcdefghijklmnopqrstuvwxyz" @@ -12,10 +13,16 @@ def __init__(self, client): self.client = client self.hidden = False - @commands.command(name="connect4", description="play connect4 with another player", usage="connect4") + @commands.command( + name="connect4", + description="play connect4 with another player", + usage="connect4", + ) async def connect4(self, ctx): player1 = ctx.author - message = await ctx.reply("React on this message to start a Connect 4 game. Another person is needed to start the game!") + message = await ctx.reply( + "React on this message to start a Connect 4 game. Another person is needed to start the game!" + ) await message.add_reaction("✅") def check(reaction, user): @@ -26,13 +33,15 @@ def check(reaction, user): while True: try: - reaction1, user1 = await self.client.wait_for('reaction_add', timeout=45, check=check) + reaction1, user1 = await self.client.wait_for( + "reaction_add", timeout=45, check=check + ) if user1.id == ctx.author.id: embed = discord.Embed( title="You already joined the game!", description="Wait for another player.", - color=0xff0000 + color=0xFF0000, ) await ctx.reply(embed=embed) else: @@ -44,10 +53,19 @@ def check(reaction, user): await ctx.reply("No one joined, please try again later!") return - await ctx.reply(f"2 players have joined, connect4 game starting... <@{player1.id}>, <@{player2.id}>") + await ctx.reply( + f"2 players have joined, connect4 game starting... <@{player1.id}>, <@{player2.id}>" + ) time.sleep(0.5) - board = [["□", "□", "□", "□", "□", "□"], ["□", "□", "□", "□", "□", "□"], ["□", "□", "□", "□", "□", "□"], [ - "□", "□", "□", "□", "□", "□"], ["□", "□", "□", "□", "□", "□"], ["□", "□", "□", "□", "□", "□"], ["□", "□", "□", "□", "□", "□"]] + board = [ + ["□", "□", "□", "□", "□", "□"], + ["□", "□", "□", "□", "□", "□"], + ["□", "□", "□", "□", "□", "□"], + ["□", "□", "□", "□", "□", "□"], + ["□", "□", "□", "□", "□", "□"], + ["□", "□", "□", "□", "□", "□"], + ["□", "□", "□", "□", "□", "□"], + ] print(board) curmax = [0, 0, 0, 0, 0, 0, 0] turn = 0 @@ -55,28 +73,32 @@ def check(reaction, user): while True: print(number_of_counter_left) if number_of_counter_left == 0: - embed=discord.Embed( - title = "Draw", - description = "No one wins!", - color =0xffff00 + embed = discord.Embed( + title="Draw", description="No one wins!", color=0xFFFF00 ) await message.reply(embed=embed) return if turn == 0: turn = 1 success = 0 - await ctx.send(f"{player1.mention}'s turn! Type a number from 1 to 7, the column you want to place a marker on!") + await ctx.send( + f"{player1.mention}'s turn! Type a number from 1 to 7, the column you want to place a marker on!" + ) while True: try: - message = await self.client.wait_for('message', timeout=30, check=lambda m: m.author == player1) + message = await self.client.wait_for( + "message", timeout=30, check=lambda m: m.author == player1 + ) try: - selected = int(message.content)-1 + selected = int(message.content) - 1 # restrict number to 1-9 if selected < 0 or selected > 6: await message.reply("Invalid number, please try again") continue if curmax[selected] > 5: - await message.reply("That column is already full! Please try again.") + await message.reply( + "That column is already full! Please try again." + ) continue board[selected][curmax[selected]] = "o" curmax[selected] += 1 @@ -86,7 +108,7 @@ def check(reaction, user): for i in range(6): board_display += "|\n|" for j in range(7): - board_display += board[j][5-i] + board_display += board[j][5 - i] board_display += " " board_display += "|```" number_of_counter_left -= 1 @@ -94,45 +116,69 @@ def check(reaction, user): for i in range(7): for j in range(3): - if board[i][j] == board[i][j+1] == board[i][j+2] == board[i][j+3] == "o": + if ( + board[i][j] + == board[i][j + 1] + == board[i][j + 2] + == board[i][j + 3] + == "o" + ): embed = discord.Embed( title="Game over!", description=f"{player1.mention} wins!", - color=self.client.primary_colour + color=self.client.primary_colour, ) await message.reply(embed=embed) return for i in range(6): for j in range(4): - if board[j][i] == board[j+1][i] == board[j+2][i] == board[j+3][i] == "o": + if ( + board[j][i] + == board[j + 1][i] + == board[j + 2][i] + == board[j + 3][i] + == "o" + ): embed = discord.Embed( title="Game over!", description=f"{player1.mention} wins!", - color=self.client.primary_colour + color=self.client.primary_colour, ) await message.reply(embed=embed) return for i in range(4): for j in range(3): - if board[i][j] == board[i+1][j+1] == board[i+2][j+2] == board[i+3][j+3] == "o": + if ( + board[i][j] + == board[i + 1][j + 1] + == board[i + 2][j + 2] + == board[i + 3][j + 3] + == "o" + ): embed = discord.Embed( title="Game over!", description=f"{player1.mention} wins!", - color=self.client.primary_colour + color=self.client.primary_colour, ) await message.reply(embed=embed) return for i in range(4): - for j in range(3,6): - if board[i][j] == board[i+1][j-1] == board[i+2][j-2] == board[i+3][j-3] == "o": + for j in range(3, 6): + if ( + board[i][j] + == board[i + 1][j - 1] + == board[i + 2][j - 2] + == board[i + 3][j - 3] + == "o" + ): embed = discord.Embed( title="Game over!", description=f"{player1.mention} wins!", - color=self.client.primary_colour + color=self.client.primary_colour, ) await message.reply(embed=embed) - return + return break except ValueError: await message.reply("Please enter a number from 1 to 7") @@ -147,25 +193,29 @@ def check(reaction, user): success = 0 print(number_of_counter_left) if number_of_counter_left == 0: - embed=discord.Embed( - title = "Draw", - description = "No one wins!", - color =0xffff00 + embed = discord.Embed( + title="Draw", description="No one wins!", color=0xFFFF00 ) await message.reply(embed=embed) return - await ctx.send(f"{player2.mention}'s turn! Type a number from 1 to 7, the column you want to place a marker on!") + await ctx.send( + f"{player2.mention}'s turn! Type a number from 1 to 7, the column you want to place a marker on!" + ) while True: try: - message = await self.client.wait_for('message', timeout=30, check=lambda m: m.author == player2) + message = await self.client.wait_for( + "message", timeout=30, check=lambda m: m.author == player2 + ) try: - selected = int(message.content)-1 + selected = int(message.content) - 1 # restrict number to 1-9 if selected < 0 or selected > 6: await message.reply("Invalid number, please try again") continue if curmax[selected] > 5: - await message.reply("That column is already full! Please try again.") + await message.reply( + "That column is already full! Please try again." + ) continue board[selected][curmax[selected]] = "x" curmax[selected] += 1 @@ -176,30 +226,42 @@ def check(reaction, user): for i in range(6): board_display += "|\n| " for j in range(7): - board_display += board[j][5-i] + board_display += board[j][5 - i] board_display += " " print(board_display) board_display += "|```" await message.reply(board_display) - + for i in range(4): - for j in range(3,6): - if board[i][j] == board[i+1][j-1] == board[i+2][j-2] == board[i+3][j-3] == "x": + for j in range(3, 6): + if ( + board[i][j] + == board[i + 1][j - 1] + == board[i + 2][j - 2] + == board[i + 3][j - 3] + == "x" + ): embed = discord.Embed( title="Game over!", description=f"{player2.mention} wins!", - color=self.client.primary_colour + color=self.client.primary_colour, ) await message.reply(embed=embed) - return + return break for i in range(4): for j in range(3): - if board[i][j] == board[i+1][j+1] == board[i+2][j+2] == board[i+3][j+3] == "x": + if ( + board[i][j] + == board[i + 1][j + 1] + == board[i + 2][j + 2] + == board[i + 3][j + 3] + == "x" + ): embed = discord.Embed( title="Game over!", description=f"{player2.mention} wins!", - color=self.client.primary_colour + color=self.client.primary_colour, ) await message.reply(embed=embed) return @@ -207,11 +269,17 @@ def check(reaction, user): # horizontal for i in range(7): for j in range(3): - if board[i][j] == board[i][j+1] == board[i][j+2] == board[i][j+3] == "x": + if ( + board[i][j] + == board[i][j + 1] + == board[i][j + 2] + == board[i][j + 3] + == "x" + ): embed = discord.Embed( title="Game over!", description=f"{player2.mention} wins!", - color=self.client.primary_colour + color=self.client.primary_colour, ) await message.reply(embed=embed) @@ -219,35 +287,53 @@ def check(reaction, user): # vertical for i in range(6): for j in range(4): - if board[j][i] == board[j+1][i] == board[j+2][i] == board[j+3][i] == "x": + if ( + board[j][i] + == board[j + 1][i] + == board[j + 2][i] + == board[j + 3][i] + == "x" + ): embed = discord.Embed( title="Game over!", description=f"{player2.mention} wins!", - color=self.client.primary_colour + color=self.client.primary_colour, ) await message.reply(embed=embed) return # diagonal bottomleft to topright for i in range(4): for j in range(3): - if board[i][j] == board[i+1][j+1] == board[i+2][j+2] == board[i+3][j+3] == "x": + if ( + board[i][j] + == board[i + 1][j + 1] + == board[i + 2][j + 2] + == board[i + 3][j + 3] + == "x" + ): embed = discord.Embed( title="Game over!", description=f"{player2.mention} wins!", - color=self.client.primary_colour + color=self.client.primary_colour, ) await message.reply(embed=embed) return for i in range(4): - for j in range(3,6): - if board[i][j] == board[i+1][j-1] == board[i+2][j-2] == board[i+3][j-3] == "x": + for j in range(3, 6): + if ( + board[i][j] + == board[i + 1][j - 1] + == board[i + 2][j - 2] + == board[i + 3][j - 3] + == "x" + ): embed = discord.Embed( title="Game over!", description=f"{player2.mention} wins!", - color=self.client.primary_colour + color=self.client.primary_colour, ) await message.reply(embed=embed) - return + return break except ValueError: diff --git a/cogs/counting.py b/cogs/counting.py index 7565558..269f389 100644 --- a/cogs/counting.py +++ b/cogs/counting.py @@ -6,40 +6,41 @@ class Counting(commands.Cog): - def __init__(self, client): self.client = client self.db = firestore.client() self.data = {} self.cooldown = {} self.initation = self.client.get_cog("Initiation") - docs = self.db.collection(u'servers').stream() + docs = self.db.collection("servers").stream() for doc in docs: self.data[doc.id] = doc.to_dict() self.cooldown[doc.id] = {} for channel in self.data[doc.id]["countingChannels"]: - self.cooldown[doc.id][channel] = time.time()-5 + self.cooldown[doc.id][channel] = time.time() - 5 self.hidden = False - @commands.Cog.listener() async def on_message(self, message): self.initation = self.client.get_cog("Initiation") if message.author == self.client.user: return - if(message.author.bot): + if message.author.bot: return self.initation = self.client.get_cog("Initiation") self.data = await self.initation.checkserver(message, self.data) # print(self.data) - if message.channel.name.lower() in self.data[str(message.guild.id)]["countingChannels"]: + if ( + message.channel.name.lower() + in self.data[str(message.guild.id)]["countingChannels"] + ): string = message.content.lower() string = string.split(" ")[0] string = string.split("_")[0] # string = string.split("*")[0] - string = string.replace('x', '*').replace('÷', '/').replace('^', '**') - try: + string = string.replace("x", "*").replace("÷", "/").replace("^", "**") + try: string = str(int(eval(string))) except: pass @@ -47,54 +48,96 @@ async def on_message(self, message): dict2 = self.data[(str(message.guild.id))] num = int(string) # print(dict2) - if not (num == dict2["countingChannels"][message.channel.name.lower()]["count"]+1) or (message.author.id == dict2["countingChannels"][message.channel.name.lower()]["last_user"]): + if not ( + num + == dict2["countingChannels"][message.channel.name.lower()]["count"] + + 1 + ) or ( + message.author.id + == dict2["countingChannels"][message.channel.name.lower()][ + "last_user" + ] + ): wrongCount = not ( - num == dict2["countingChannels"][message.channel.name.lower()]["count"]+1) - previous = dict2["countingChannels"][message.channel.name.lower()]["count"] + num + == dict2["countingChannels"][message.channel.name.lower()][ + "count" + ] + + 1 + ) + previous = dict2["countingChannels"][message.channel.name.lower()][ + "count" + ] dict2["countingChannels"][message.channel.name.lower()]["count"] = 0 - dict2["countingChannels"][message.channel.name.lower()]["last_user"] = None + dict2["countingChannels"][message.channel.name.lower()][ + "last_user" + ] = None self.data[str(message.guild.id)] = dict2 await message.add_reaction("❌") - embed="No embed" + embed = "No embed" if wrongCount: embed = discord.Embed( title="Wrong Count", description=f"{message.author.mention} messed up the count at **{previous}**. The next count for this server is **1**.", - colour=self.client.primary_colour + colour=self.client.primary_colour, ) else: embed = discord.Embed( title="You cannot count twice in a row", description=f"{message.author.mention} messed up the count at **{previous}**. The next count for this server is **1**.", - colour=self.client.primary_colour + colour=self.client.primary_colour, ) await message.channel.send(embed=embed) - self.cooldown[str(message.guild.id)][message.channel.name.lower()] = time.time() + self.cooldown[str(message.guild.id)][ + message.channel.name.lower() + ] = time.time() # await message.channel.edit(topic=f"Count: {dict2['count']}") else: - if ((time.time()-self.cooldown[str(message.guild.id)][message.channel.name.lower()]) < 2): + if ( + time.time() + - self.cooldown[str(message.guild.id)][ + message.channel.name.lower() + ] + ) < 2: return - if (num > dict2["countingChannels"][message.channel.name.lower()]["highest_count"]): - dict2["countingChannels"][message.channel.name.lower()]["highest_count"] = num - dict2["countingChannels"][message.channel.name.lower()]["count"] = num - dict2["countingChannels"][message.channel.name.lower()]["last_user"] = message.author.id + if ( + num + > dict2["countingChannels"][message.channel.name.lower()][ + "highest_count" + ] + ): + dict2["countingChannels"][message.channel.name.lower()][ + "highest_count" + ] = num + dict2["countingChannels"][message.channel.name.lower()][ + "count" + ] = num + dict2["countingChannels"][message.channel.name.lower()][ + "last_user" + ] = message.author.id self.data[str(message.guild.id)] = dict2 await message.add_reaction("☑️") # await message.channel.edit(topic=f"Count: {dict2['count']}") else: - dict2["countingChannels"][message.channel.name.lower() - ]["count"] = num - dict2["countingChannels"][message.channel.name.lower( - )]["last_user"] = message.author.id + dict2["countingChannels"][message.channel.name.lower()][ + "count" + ] = num + dict2["countingChannels"][message.channel.name.lower()][ + "last_user" + ] = message.author.id self.data[str(message.guild.id)] = dict2 await message.add_reaction("✅") - self.db.collection(u'servers').document( - str(message.guild.id)).set(dict2) + self.db.collection("servers").document(str(message.guild.id)).set(dict2) @check.is_admin() - @commands.command(name="addchannel", description="Adds a counting channel, from which counts will be recorded :D", usage="addchannel ", aliases=["addc"]) + @commands.command( + name="addchannel", + description="Adds a counting channel, from which counts will be recorded :D", + usage="addchannel ", + aliases=["addc"], + ) async def add_counting_channel(self, ctx, name: str = None): self.initation = self.client.get_cog("Initiation") self.data = await self.initation.checkserver(ctx, self.data) @@ -106,17 +149,16 @@ async def add_counting_channel(self, ctx, name: str = None): "name": name, "count": 0, "highest_count": 0, - "last_user": None + "last_user": None, } self.data[str(ctx.guild.id)] = dict1 - self.cooldown[str(ctx.guild.id) - ][ctx.channel.name.lower()] = time.time()-5 - self.db.collection(u'servers').document(str(ctx.guild.id)).set(dict1) + self.cooldown[str(ctx.guild.id)][ctx.channel.name.lower()] = time.time() - 5 + self.db.collection("servers").document(str(ctx.guild.id)).set(dict1) embed = discord.Embed( title="Counting Channel Added", description=f"The channel **{name}** has been added as a counting channel.", - colour=self.client.primary_colour + colour=self.client.primary_colour, ) await ctx.send(embed=embed) print("add counting channel") @@ -134,25 +176,29 @@ async def remove_counting_channel(self, ctx, name: str = None): embed = discord.Embed( title="Command not in list", description="This channel is not originally a counting channel.", - colour=self.client.error_colour + colour=self.client.error_colour, ) await ctx.send(embed=embed) return dict1["countingChannels"].pop(name) self.data[str(ctx.guild.id)] = dict1 - self.db.collection(u'servers').document(str(ctx.guild.id)).set(dict1) + self.db.collection("servers").document(str(ctx.guild.id)).set(dict1) embed = discord.Embed( title="Counting Channel Removed", description=f"The channel **{name}** has been removed from being as a counting channel.", - colour=self.client.primary_colour + colour=self.client.primary_colour, ) await ctx.send(embed=embed) print("remove counting channel") @check.is_staff() @commands.command( - name="Set Count", aliases=["setcount"], description="Sets the current count in the current channel.", usage="setcount ", hidden=True + name="Set Count", + aliases=["setcount"], + description="Sets the current count in the current channel.", + usage="setcount ", + hidden=True, ) async def setcurrentcount(self, ctx, num: int): self.initation = self.client.get_cog("Initiation") @@ -163,65 +209,79 @@ async def setcurrentcount(self, ctx, num: int): embed = discord.Embed( title="Channel not a counting channel", description="The channel you are in now is not a counting channel. If you want to make this a counting channel, please use the add-counting-channel command.", - colour=self.client.primary_colour + colour=self.client.primary_colour, ) await ctx.send(embed=embed) print("channel not counting channel") return - dict2["countingChannels"][ctx.channel.name.lower()]["highest_count"] = max(dict2["countingChannels"][ctx.channel.name.lower()]["highest_count"], num) + dict2["countingChannels"][ctx.channel.name.lower()]["highest_count"] = max( + dict2["countingChannels"][ctx.channel.name.lower()]["highest_count"], num + ) dict2["countingChannels"][ctx.channel.name.lower()]["count"] = num dict2["countingChannels"][ctx.channel.name.lower()]["last_user"] = None self.data[str(ctx.guild.id)] = dict2 - self.db.collection(u'servers').document(str(ctx.guild.id)).set(dict2) + self.db.collection("servers").document(str(ctx.guild.id)).set(dict2) embed = discord.Embed( title="Current Count Set", description=f"The count in this server has been set by {ctx.author.name} to **{num}**. The next count is **{num+1}**.", - colour=self.client.primary_colour + colour=self.client.primary_colour, ) await ctx.send(embed=embed) print("setcount") - @commands.command(name="channelinfo", - description="Returns info about the current channel and counting statistics.", - usage="countingchannel", aliases=["csi", "cs", "countingchannel"] - ) + @commands.command( + name="channelinfo", + description="Returns info about the current channel and counting statistics.", + usage="countingchannel", + aliases=["csi", "cs", "countingchannel"], + ) async def channelcountinginfo(self, ctx): embed = discord.Embed( title=f"Info about the **{ctx.channel.name}** channel", description=f"Find all the info you need about this channel you are currently in :D", - colour=self.client.primary_colour + colour=self.client.primary_colour, ) - embed.add_field(name="Statistics", value=f""" + embed.add_field( + name="Statistics", + value=f""" Current Count: {self.data[str(ctx.guild.id)]['countingChannels'][ctx.channel.name.lower()]['count']} Highest Score: {self.data[str(ctx.guild.id)]['countingChannels'][ctx.channel.name.lower()]['highest_count']} Last counted by <@{self.data[str(ctx.guild.id)]['countingChannels'][ctx.channel.name.lower()]['last_user']}> - """, inline=False) + """, + inline=False, + ) await ctx.send(embed=embed) print("counting channel info") @commands.command( name="countinginfo", description="Shows the statistics of all counting channels in the current server.", - usage="countinfo", aliases=["ci", "countinfo"] + usage="countinfo", + aliases=["ci", "countinfo"], ) async def countinginfo(self, ctx): embed = discord.Embed( title="Shows the respective counts of the channels :D", description="Ever wondered where you could easily keep track of how other counting channels are doing?", - colour=self.client.primary_colour + colour=self.client.primary_colour, ) leaderboard = {} for i in self.data[str(ctx.guild.id)]["countingChannels"]: - leaderboard[i] = [self.data[str(ctx.guild.id)]["countingChannels"][i]["count"], self.data[str( - ctx.guild.id)]["countingChannels"][i]["highest_count"]] + leaderboard[i] = [ + self.data[str(ctx.guild.id)]["countingChannels"][i]["count"], + self.data[str(ctx.guild.id)]["countingChannels"][i]["highest_count"], + ] count = 0 description = "" for i in sorted(leaderboard.items(), key=lambda kv: (kv[1]), reverse=True): # embed.add_field(name=) embed.add_field( - name=i[0], value=f"Highest Count: {i[1][1]}\nCount: {i[1][0]}", inline=False) + name=i[0], + value=f"Highest Count: {i[1][1]}\nCount: {i[1][0]}", + inline=False, + ) count += 1 if count > 10: break @@ -232,7 +292,7 @@ async def countinginfo(self, ctx): name="countingleaderboards", description="The very best of all counting channels from all servers.", usage="countingl", - aliases=["cl", "countingl", "cleaderb", "cleaderboards"] + aliases=["cl", "countingl", "cleaderb", "cleaderboards"], ) async def countingleader(self, ctx): leaderboard = {} @@ -241,13 +301,14 @@ async def countingleader(self, ctx): highest = 0 for p in self.data[i]["countingChannels"]: highest = max( - highest, self.data[i]["countingChannels"][p]["highest_count"]) + highest, self.data[i]["countingChannels"][p]["highest_count"] + ) guild = self.client.get_guild(int(i)) leaderboard[guild.name] = highest count = 1 description = "" for i in sorted(leaderboard.items(), key=lambda kv: (kv[1]), reverse=True): - description += (f"{count}. **{i[0]}** - *{i[1]}*" + '\n') + description += f"{count}. **{i[0]}** - *{i[1]}*" + "\n" count += 1 if count > 10: break @@ -255,10 +316,11 @@ async def countingleader(self, ctx): embed = discord.Embed( title="Global leaderboard :D", description=description, - colour=self.client.primary_colour + colour=self.client.primary_colour, ) embed.set_footer( - text="Find out about the highest and most dedicated servers!!!") + text="Find out about the highest and most dedicated servers!!!" + ) await ctx.send(embed=embed) diff --git a/cogs/eastereggs.py b/cogs/eastereggs.py index 9206899..97fbd8a 100644 --- a/cogs/eastereggs.py +++ b/cogs/eastereggs.py @@ -1,27 +1,32 @@ import discord from discord.ext import commands from discord.ext.commands.core import has_guild_permissions + # import tictactoe + class EasterEggs(commands.Cog): def __init__(self, client): self.client = client self.hidden = True - + @commands.command(hidden=True, aliases=["whoareu"]) async def whoru(self, ctx): - embed = discord.Embed(title = "Hey! Looks like you found this easter egg!",description = "Nice.",color = self.client.primary_colour) + embed = discord.Embed( + title="Hey! Looks like you found this easter egg!", + description="Nice.", + color=self.client.primary_colour, + ) embed.add_field( - name = "Whoami?", - value = "I am Maxigames! The creation of amateur bot devs <@!712942935129456671>, <@!676748194956181505> and <@!782247763542016010>", - inline = False + name="Whoami?", + value="I am Maxigames! The creation of amateur bot devs <@!712942935129456671>, <@!676748194956181505> and <@!782247763542016010>", + inline=False, ) embed.add_field( - name = "Are there more easter eggs?", - value = "Yes ofc.", - inline = False + name="Are there more easter eggs?", value="Yes ofc.", inline=False ) await ctx.author.send(embed=embed) + def setup(client): client.add_cog(EasterEggs(client)) diff --git a/cogs/economy.py b/cogs/economy.py index a4b61e4..5c8983a 100644 --- a/cogs/economy.py +++ b/cogs/economy.py @@ -24,36 +24,38 @@ def __init__(self, client): async def _coinflip(self, ctx, choice: str, amount: int = 1): self.initation = self.client.get_cog("Initiation") await self.initation.checkserver(ctx) - doc_ref = self.db.collection(u'users').document( - u'{}'.format(str(ctx.author.id))) + doc_ref = self.db.collection("users").document("{}".format(str(ctx.author.id))) doc = doc_ref.get() if doc.exists: dict1 = doc.to_dict() - if dict1['money'] < amount: + if dict1["money"] < amount: embed = discord.Embed( title="Amount in bank too low", description="The amount that you want to gamble is more than what you have in your bank.", - color=self.client.primary_colour + color=self.client.primary_colour, + ) + embed.set_author( + name=ctx.author.display_name, icon_url=ctx.author.avatar_url ) - embed.set_author(name=ctx.author.display_name, - icon_url=ctx.author.avatar_url) await ctx.reply(embed=embed) return if amount <= 0: - doc_ref = self.db.collection(u'users').document( - u'{}'.format(str(ctx.author.id))) + doc_ref = self.db.collection("users").document( + "{}".format(str(ctx.author.id)) + ) doc = doc_ref.get() if doc.exists: dict1 = doc.to_dict() - dict1['money'] = -1 + dict1["money"] = -1 doc_ref.set(dict1) embed = discord.Embed( title="Amount gambled unacceptable", description="It appears that you have been attempting to exploit the system and this is very bad!!! Therefore, your balance will be set to negative 1.", - color=self.client.primary_colour + color=self.client.primary_colour, + ) + embed.set_author( + name=ctx.author.display_name, icon_url=ctx.author.avatar_url ) - embed.set_author(name=ctx.author.display_name, - icon_url=ctx.author.avatar_url) await ctx.reply(embed=embed) side = 0 @@ -64,114 +66,144 @@ async def _coinflip(self, ctx, choice: str, amount: int = 1): else: raise discord.ext.commands.errors.MissingRequiredArgument - result = (random.randint(0, 100) >= 40) + result = random.randint(0, 100) >= 40 if result: embed = discord.Embed( title="Coinflip results", description=f"Welp, the coin flipped to **{'tails' if not side else 'heads'}**. You lost {amount} points to coinflipping :(", - colour=self.client.primary_colour + colour=self.client.primary_colour, + ) + embed.set_author( + name=ctx.author.display_name, icon_url=ctx.author.avatar_url ) - embed.set_author(name=ctx.author.display_name, - icon_url=ctx.author.avatar_url) await ctx.reply(embed=embed) - dict1['money'] -= amount + dict1["money"] -= amount # await ctx.send(f"Welp you lost {amount} points to coinflipping :(") ctx.send else: - dict1['money'] += amount + dict1["money"] += amount # await ctx.send(f"Oh wow, you won {amount} points to coinflipping :O") embed = discord.Embed( title="Coinflip results", description=f"Oh wow, the coin flipped to **{'tails' if side else 'heads'}**. You won {amount} points from the coin flip :O", - colour=self.client.primary_colour + colour=self.client.primary_colour, + ) + embed.set_author( + name=ctx.author.display_name, icon_url=ctx.author.avatar_url ) - embed.set_author(name=ctx.author.display_name, - icon_url=ctx.author.avatar_url) await ctx.reply(embed=embed) doc_ref.set(dict1) else: await self.initation.initiate(ctx) - @commands.command(name="Gamble", description="Gamble all the money you want until you're happy. Remember, theres a jackpot :D", aliases=['g', 'gamble', 'gg'], usage="gamble ") + @commands.command( + name="Gamble", + description="Gamble all the money you want until you're happy. Remember, theres a jackpot :D", + aliases=["g", "gamble", "gg"], + usage="gamble ", + ) async def _gamble(self, ctx, amount: int = 5): self.initation = self.client.get_cog("Initiation") await self.initation.checkserver(ctx) - doc_ref = self.db.collection(u'users').document( - u'{}'.format(str(ctx.author.id))) + doc_ref = self.db.collection("users").document("{}".format(str(ctx.author.id))) doc = doc_ref.get() if doc.exists: dict1 = doc.to_dict() - if dict1['money'] < amount: + if dict1["money"] < amount: embed = discord.Embed( title="Amount in bank too low", description="The amount that you want to gamble is more than what you have in your bank.", - color=self.client.primary_colour + color=self.client.primary_colour, + ) + embed.set_author( + name=ctx.author.display_name, icon_url=ctx.author.avatar_url ) - embed.set_author(name=ctx.author.display_name, - icon_url=ctx.author.avatar_url) await ctx.reply(embed=embed) return if amount <= 0: - doc_ref = self.db.collection(u'users').document( - u'{}'.format(str(ctx.author.id))) + doc_ref = self.db.collection("users").document( + "{}".format(str(ctx.author.id)) + ) doc = doc_ref.get() if doc.exists: dict1 = doc.to_dict() - dict1['money'] = -1 + dict1["money"] = -1 doc_ref.set(dict1) embed = discord.Embed( title="Amount gambled unacceptable", description="It appears that you have been attempting to exploit the system and this is very bad!!! Therefore, your balance will be set to negative 1.", - color=self.client.primary_colour + color=self.client.primary_colour, + ) + embed.set_author( + name=ctx.author.display_name, icon_url=ctx.author.avatar_url ) - embed.set_author(name=ctx.author.display_name, - icon_url=ctx.author.avatar_url) await ctx.reply(embed=embed) return - #chance = (math.log10(amount)-0.95) / \ - #(100+100*max(10, math.log2(amount))) - #print(chance) - botnum = random.randint(1,12) - yournum = random.randint(1,14) + # chance = (math.log10(amount)-0.95) / \ + # (100+100*max(10, math.log2(amount))) + # print(chance) + botnum = random.randint(1, 12) + yournum = random.randint(1, 14) if yournum >= 13: - yournum = random.randint(1,6) + yournum = random.randint(1, 6) if yournum > botnum: - dict1['money'] += amount + dict1["money"] += amount embed = discord.Embed( title="Gambling results", - description="Bot rolled: " + str(botnum) + "\nYou rolled: " + str(yournum) + - "\nYou won! Congrats. You now have " + str(dict1['money']) + " money", - colour=self.client.primary_colour + description="Bot rolled: " + + str(botnum) + + "\nYou rolled: " + + str(yournum) + + "\nYou won! Congrats. You now have " + + str(dict1["money"]) + + " money", + colour=self.client.primary_colour, + ) + embed.set_author( + name=ctx.author.display_name, icon_url=ctx.author.avatar_url ) - embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url) - - await ctx.reply(embed=embed, allowed_mentions=discord.AllowedMentions.none()) + await ctx.reply( + embed=embed, allowed_mentions=discord.AllowedMentions.none() + ) doc_ref.set(dict1) elif yournum == botnum: - dict1['money'] -= math.ceil(amount/2) + dict1["money"] -= math.ceil(amount / 2) embed = discord.Embed( title="Gambling results", - description="Bot rolled: " + str(botnum) + "\nYou rolled: " + str(yournum) + - "\nYou drawed and lost half of your bet.\nYou now have " + str(dict1['money']) + " money.", - - colour=0xffff00 + description="Bot rolled: " + + str(botnum) + + "\nYou rolled: " + + str(yournum) + + "\nYou drawed and lost half of your bet.\nYou now have " + + str(dict1["money"]) + + " money.", + colour=0xFFFF00, + ) + embed.set_author( + name=ctx.author.display_name, icon_url=ctx.author.avatar_url ) - embed.set_author(name=ctx.author.display_name, - icon_url=ctx.author.avatar_url) - - await ctx.reply(embed=embed, allowed_mentions=discord.AllowedMentions.none()) + await ctx.reply( + embed=embed, allowed_mentions=discord.AllowedMentions.none() + ) doc_ref.set(dict1) else: - dict1['money'] -= amount + dict1["money"] -= amount embed = discord.Embed( - title = "Gambling results", - description="Bot rolled: " + str(botnum) + "\nYou rolled: " + str(yournum) + - "\nYou lost your whole bet.\nYou now have " + str(dict1['money']) + " money.", - colour=0xff0000 + title="Gambling results", + description="Bot rolled: " + + str(botnum) + + "\nYou rolled: " + + str(yournum) + + "\nYou lost your whole bet.\nYou now have " + + str(dict1["money"]) + + " money.", + colour=0xFF0000, + ) + await ctx.reply( + embed=embed, allowed_mentions=discord.AllowedMentions.none() ) - await ctx.reply(embed=embed, allowed_mentions=discord.AllowedMentions.none()) else: await check.initiate(ctx) @@ -180,14 +212,13 @@ async def _gamble(self, ctx, amount: int = 5): name="Money", description="Allows you to get a source of unlimited points :O", usage="money", - aliases=["money", "m"] + aliases=["money", "m"], ) @cooldown(1, 5, BucketType.user) async def _money(self, ctx): self.initation = self.client.get_cog("Initiation") await self.initation.checkserver(ctx) - doc_ref = self.db.collection(u'users').document( - u'{}'.format(str(ctx.author.id))) + doc_ref = self.db.collection("users").document("{}".format(str(ctx.author.id))) doc = doc_ref.get() if doc.exists: dict1 = doc.to_dict() @@ -196,15 +227,20 @@ async def _money(self, ctx): embed = discord.Embed( title="Money added", description="Money has been added to your bank. ", - colour=self.client.primary_colour + colour=self.client.primary_colour, ) - embed.set_author(name=ctx.author.display_name, - url="https://google.com", icon_url=ctx.author.avatar_url) - embed.add_field(name="New Balance", - value=f'{dict1["money"]}', inline=True) + embed.set_author( + name=ctx.author.display_name, + url="https://google.com", + icon_url=ctx.author.avatar_url, + ) + embed.add_field(name="New Balance", value=f'{dict1["money"]}', inline=True) embed.set_footer( - text="Find our more about how to use other currency functions by typing 'n!help currency' :D") - await ctx.reply(embed=embed, allowed_mentions=discord.AllowedMentions.none()) + text="Find our more about how to use other currency functions by typing 'n!help currency' :D" + ) + await ctx.reply( + embed=embed, allowed_mentions=discord.AllowedMentions.none() + ) else: await self.initation.initiate(ctx) # await ctx.send("Now you can start running currency commands :D") @@ -214,20 +250,25 @@ async def _money(self, ctx): async def bal(self, ctx): self.initation = self.client.get_cog("Initiation") await self.initation.checkserver(ctx) - doc_ref = self.db.collection(u'users').document( - u'{}'.format(str(ctx.author.id))) + doc_ref = self.db.collection("users").document("{}".format(str(ctx.author.id))) doc = doc_ref.get() if doc.exists: embed = discord.Embed( title="Current Amount", description="How much money do you have in your bank?", - colour=self.client.primary_colour + colour=self.client.primary_colour, + ) + embed.set_author( + name=ctx.author.display_name, + url="https://google.com", + icon_url=ctx.author.avatar_url, ) - embed.set_author(name=ctx.author.display_name, - url="https://google.com", icon_url=ctx.author.avatar_url) embed.add_field( - name="Balance", value=f'{doc.to_dict()["money"]}', inline=True) - await ctx.reply(embed=embed, allowed_mentions=discord.AllowedMentions.none()) + name="Balance", value=f'{doc.to_dict()["money"]}', inline=True + ) + await ctx.reply( + embed=embed, allowed_mentions=discord.AllowedMentions.none() + ) else: await self.initation.initiate(ctx) # return False @@ -236,88 +277,103 @@ async def bal(self, ctx): name="Leaderboard", description="Shows you the richest and most wealthy people in the server you are in :O", usage="leaderboard", - aliases=["leaderboard", "l", "rich", "r", " l"] + aliases=["leaderboard", "l", "rich", "r", " l"], ) async def _leaderboard(self, ctx): self.initation = self.client.get_cog("Initiation") await self.initation.checkserver(ctx) - doc_ref = self.db.collection(u'servers').document( - u'{}'.format(str(ctx.guild.id))) + doc_ref = self.db.collection("servers").document("{}".format(str(ctx.guild.id))) doc = doc_ref.get() dict2 = doc.to_dict()["users"] dict3 = {} for i in dict2.keys(): - doc_ref = self.db.collection(u'users').document(u'{}'.format(i)) + doc_ref = self.db.collection("users").document("{}".format(i)) doc = doc_ref.get() dict1 = doc.to_dict() - dict3[i] = dict1['money'] + dict3[i] = dict1["money"] description = "" count = 1 for i in sorted(dict3.items(), key=lambda kv: (kv[1]), reverse=True): user = self.client.get_user(int(i[0])) - descriptio += f'{count}) {user.mention} - {i[1]} points\n' + descriptio += f"{count}) {user.mention} - {i[1]} points\n" count += 1 if count > 10: break embed = discord.Embed( title=f"Leaderboard in {ctx.message.guild.name}:", description=description, - colour=self.client.primary_colour + colour=self.client.primary_colour, + ) + embed.set_author( + name="Hallo Bot", + icon_url="https://cdn.discordapp.com/attachments/797393542251151380/839131666483511336/476ffc83637891f004e1ba6e1ca63e6c.jpg", ) - embed.set_author(name="Hallo Bot", - icon_url='https://cdn.discordapp.com/attachments/797393542251151380/839131666483511336/476ffc83637891f004e1ba6e1ca63e6c.jpg') await ctx.send(embed=embed, allowed_mentions=discord.AllowedMentions.none()) - @commands.command(name="Hourly", description="Hourly points :D", usage="hourly", aliases=["h", "hourly"]) + @commands.command( + name="Hourly", + description="Hourly points :D", + usage="hourly", + aliases=["h", "hourly"], + ) @cooldown(1, 3600, BucketType.user) async def hourly(self, ctx): await self.initation.checkserver(ctx) - doc_ref = self.db.collection(u'users').document( - u'{}'.format(str(ctx.author.id))) + doc_ref = self.db.collection("users").document("{}".format(str(ctx.author.id))) doc = doc_ref.get() booster = 1 if doc.exists: dict1 = doc.to_dict() # value = int(doc.to_dict()['money']) - dict1["money"] = dict1["money"] + \ - booster * (random.randint(20, 50)) + dict1["money"] = dict1["money"] + booster * (random.randint(20, 50)) doc_ref.set(dict1) embed = discord.Embed( title="Hourly claimed :D", description="Money gained from saying hourly!", - colour=self.client.primary_colour + colour=self.client.primary_colour, + ) + embed.set_author( + name=ctx.author.display_name, + url="https://google.com", + icon_url=ctx.author.avatar_url, ) - embed.set_author(name=ctx.author.display_name, - url="https://google.com", icon_url=ctx.author.avatar_url) - embed.add_field(name="New Balance", - value=f'{dict1["money"]}', inline=True) - await ctx.reply(embed=embed, allowed_mentions=discord.AllowedMentions.none()) - - @commands.command(name="Daily", description="Daily points :D", usage="daily", aliases=["d", "daily"]) + embed.add_field(name="New Balance", value=f'{dict1["money"]}', inline=True) + await ctx.reply( + embed=embed, allowed_mentions=discord.AllowedMentions.none() + ) + + @commands.command( + name="Daily", + description="Daily points :D", + usage="daily", + aliases=["d", "daily"], + ) @cooldown(1, 86400, BucketType.user) async def daily(self, ctx): await self.initation.checkserver(ctx) - doc_ref = self.db.collection(u'users').document( - u'{}'.format(str(ctx.author.id))) + doc_ref = self.db.collection("users").document("{}".format(str(ctx.author.id))) doc = doc_ref.get() booster = 1 if doc.exists: dict1 = doc.to_dict() # value = int(doc.to_dict()['money']) - dict1["money"] = dict1["money"] + \ - booster * (random.randint(20, 200)) + dict1["money"] = dict1["money"] + booster * (random.randint(20, 200)) doc_ref.set(dict1) embed = discord.Embed( title="Daily claimed :D", description="Money gained from saying daily!", - colour=self.client.primary_colour + colour=self.client.primary_colour, + ) + embed.set_author( + name=ctx.author.display_name, + url="https://google.com", + icon_url=ctx.author.avatar_url, + ) + embed.add_field(name="New Balance", value=f'{dict1["money"]}', inline=True) + await ctx.reply( + embed=embed, allowed_mentions=discord.AllowedMentions.none() ) - embed.set_author(name=ctx.author.display_name, - url="https://google.com", icon_url=ctx.author.avatar_url) - embed.add_field(name="New Balance", - value=f'{dict1["money"]}', inline=True) - await ctx.reply(embed=embed, allowed_mentions=discord.AllowedMentions.none()) @cog_ext.cog_slash(name="hour", description="Claim your hourly money here :D") async def _hourly_cog(self, ctx): @@ -329,7 +385,7 @@ async def _hourly_cog(self, ctx): description="Sets the amount of money of a person.", usage="setmoney ", aliases=["sm", "setmoney", "setm"], - hidden=True + hidden=True, ) async def _setmoney(self, ctx, amount: int, name: discord.Member = None): if name == None: @@ -337,7 +393,7 @@ async def _setmoney(self, ctx, amount: int, name: discord.Member = None): else: uid = str(name.id) - doc_ref = self.db.collection(u'users').document(u'{}'.format(uid)) + doc_ref = self.db.collection("users").document("{}".format(uid)) doc = doc_ref.get() if doc.exists: dict2 = doc.to_dict() @@ -346,7 +402,7 @@ async def _setmoney(self, ctx, amount: int, name: discord.Member = None): embed = discord.Embed( title="User amount set", description=f"Amount of <@{uid}> has been set to {amount}.", - colour=self.client.primary_colour + colour=self.client.primary_colour, ) await ctx.send(embed=embed) @@ -354,14 +410,10 @@ async def _setmoney(self, ctx, amount: int, name: discord.Member = None): embed = discord.Embed( title="User not initiated", description="This user is not initiated. Please make sure that the person has used hallo bot before :D", - color=self.client.primary_colour + color=self.client.primary_colour, ) await ctx.send(embed=embed) - - - - def setup(client): client.add_cog(Economy(client)) diff --git a/cogs/errors.py b/cogs/errors.py index 1871e4b..6ce2da3 100644 --- a/cogs/errors.py +++ b/cogs/errors.py @@ -2,54 +2,63 @@ from discord.ext import commands import traceback + class Errors(commands.Cog): def __init__(self, client): self.client = client self.hidden = True - + @commands.Cog.listener() async def on_command_error(self, ctx, error, bypass=False): if isinstance(error, commands.CommandNotFound): pass elif isinstance(error, commands.NotOwner): embed = discord.Embed( - title = "Unauthorised Access", + title="Unauthorised Access", description="You are not authorised to use this command.", - colour = self.client.error_colour + colour=self.client.error_colour, ) channel = self.client.get_channel(866526918484164668) - embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url) - await channel.send(embed = embed) - + embed.set_author( + name=ctx.author.display_name, icon_url=ctx.author.avatar_url + ) + await channel.send(embed=embed) + elif isinstance(error, commands.MissingPermissions): embed = discord.Embed( - title = "Missing Permissions", + title="Missing Permissions", description="You do not have permission to run this command. It might be because it is a command only for admins, or because you have been banned.", - colour = self.client.error_colour + colour=self.client.error_colour, ) channel = self.client.get_channel(866526918484164668) - embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url) - await channel.send(embed = embed) - + embed.set_author( + name=ctx.author.display_name, icon_url=ctx.author.avatar_url + ) + await channel.send(embed=embed) + elif isinstance(error, commands.CommandOnCooldown): embed = discord.Embed( - title = "Command on Cooldown", + title="Command on Cooldown", description=f"This command is on cooldown. Try again in {error.retry_after:,.1f} seconds.", - colour = self.client.primary_colour + colour=self.client.primary_colour, ) channel = self.client.get_channel(866526918484164668) - embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url) - await channel.send(embed = embed) + embed.set_author( + name=ctx.author.display_name, icon_url=ctx.author.avatar_url + ) + await channel.send(embed=embed) elif isinstance(error, commands.BadArgument): embed = discord.Embed( title="Incorrect Argument", description="There is an error with your command statement. Please check your command syntax through `n!help `.", - colour=self.client.primary_colour + colour=self.client.primary_colour, ) channel = self.client.get_channel(866526918484164668) - embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url) - await channel.send(embed = embed) + embed.set_author( + name=ctx.author.display_name, icon_url=ctx.author.avatar_url + ) + await channel.send(embed=embed) else: channel = self.client.get_channel(866526918484164668) @@ -59,4 +68,4 @@ async def on_command_error(self, ctx, error, bypass=False): def setup(client): # client.add_cog(Errors(client)) - pass \ No newline at end of file + pass diff --git a/cogs/general.py b/cogs/general.py index 7509ddd..9993dab 100644 --- a/cogs/general.py +++ b/cogs/general.py @@ -19,11 +19,10 @@ def __init__(self, client): 3: "Thursday", 4: "Friday", 5: "Saturday", - 6: "Sunday" + 6: "Sunday", } self.hidden = False - @commands.command() async def hallo(self, ctx): await ctx.send("Hallo") @@ -33,21 +32,28 @@ async def current(self, ctx): result = time.localtime(time.time()) embed = discord.Embed( title="Current Date and Time", - description=f'Find the current date and time below :D', - colour=self.client.primary_colour + description=f"Find the current date and time below :D", + colour=self.client.primary_colour, ) embed.add_field( - name="Date", value=f'{result.tm_mday}/{result.tm_mon}/{result.tm_year}', inline=True) - embed.add_field( - name="Day", value=self.dates[result.tm_wday], inline=True) + name="Date", + value=f"{result.tm_mday}/{result.tm_mon}/{result.tm_year}", + inline=True, + ) + embed.add_field(name="Day", value=self.dates[result.tm_wday], inline=True) embed.add_field( - name="Time", value=f'{result.tm_hour}:{result.tm_min}:{result.tm_sec}', inline=True) + name="Time", + value=f"{result.tm_hour}:{result.tm_min}:{result.tm_sec}", + inline=True, + ) await ctx.send(embed=embed) @commands.command() async def seconds(self, ctx): - await ctx.send(str(round(time.time())) + " seconds have passed since the epoch!") + await ctx.send( + str(round(time.time())) + " seconds have passed since the epoch!" + ) @commands.command() async def ns(self, ctx, num: int): @@ -69,8 +75,11 @@ async def ns(self, ctx, num: int): @commands.command() async def invite(self, ctx): - embed = discord.Embed(title="Invite Link to invite the bot", - description="https://discord.com/api/oauth2/authorize?client_id=863419048041381920&permissions=8&scope=bot", color=self.client.primary_colour) + embed = discord.Embed( + title="Invite Link to invite the bot", + description="https://discord.com/api/oauth2/authorize?client_id=863419048041381920&permissions=8&scope=bot", + color=self.client.primary_colour, + ) await ctx.send(embed=embed) @commands.command() @@ -78,7 +87,8 @@ async def official(self, ctx): embed = discord.Embed( title="Join our official server today!", description="https://discord.gg/nGWhxNG2sf", - colour=self.client.primary_colour) + colour=self.client.primary_colour, + ) await ctx.send(embed=embed) @commands.command() @@ -86,36 +96,47 @@ async def whoami(self, ctx): embed = discord.Embed( title="You are " + str(ctx.author) + " :D", description="What a pog name!!!", - color=self.client.primary_colour + color=self.client.primary_colour, ) role = "" # theres probably some way to optimise this... for i in ctx.author.roles[::-1]: if i.name != "@everyone": - role += f'{i.mention} ' + role += f"{i.mention} " embed.add_field(name="Roles", value=role, inline=True) embed.add_field( - name="Created On", value=f'{ctx.author.created_at.strftime("%A, %d %b %Y")} \n {ctx.author.created_at.strftime("%I:%M %p")}', inline=True) + name="Created On", + value=f'{ctx.author.created_at.strftime("%A, %d %b %Y")} \n {ctx.author.created_at.strftime("%I:%M %p")}', + inline=True, + ) embed.add_field( - name="Joined On", value=f'{ctx.author.joined_at.strftime("%A, %d %b %Y")} \n {ctx.author.joined_at.strftime("%I:%M %p")}', inline=True) + name="Joined On", + value=f'{ctx.author.joined_at.strftime("%A, %d %b %Y")} \n {ctx.author.joined_at.strftime("%I:%M %p")}', + inline=True, + ) embed.set_author(name=ctx.author.name, icon_url=ctx.author.avatar_url) await ctx.send(embed=embed) @commands.command() - async def hallolong(self, ctx, num: int): await ctx.send(f'Hall{"o"*num}') + async def hallolong(self, ctx, num: int): + await ctx.send(f'Hall{"o"*num}') @commands.command() async def servercount(self, ctx): embed = discord.Embed( title="I'm in " + str(len(self.client.guilds)) + " servers", description="Invite the bot to your server today using the link from s!invite!", - color=0xBB2277 + color=0xBB2277, ) await ctx.send(embed=embed) - @commands.command(name="help", description="Shows this help menu or information about a specific command if specified", usage="help") + @commands.command( + name="help", + description="Shows this help menu or information about a specific command if specified", + usage="help", + ) async def help(self, ctx, *cmd): - if len(cmd)>0: + if len(cmd) > 0: command = " ".join(cmd) command = self.client.get_command(command.lower()) if not command: @@ -123,21 +144,23 @@ async def help(self, ctx, *cmd): embed=discord.Embed( title="Non-existant command", description="This command cannot be found. Please make sure that everything is spelled correctly :D", - colour=self.client.primary_colour + colour=self.client.primary_colour, ) ) return embed = discord.Embed( - title=f'Command `{command.name}`', + title=f"Command `{command.name}`", description=command.description, colour=self.client.primary_colour, ) - usage = "\n".join([ctx.prefix + x.strip() - for x in command.usage.split('\n')]) + usage = "\n".join( + [ctx.prefix + x.strip() for x in command.usage.split("\n")] + ) embed.add_field(name="Usage", value=f"```{usage}```", inline=False) if len(command.aliases) > 1: embed.add_field( - name="Aliases", value=f"`{'`, `'.join(command.aliases)}`") + name="Aliases", value=f"`{'`, `'.join(command.aliases)}`" + ) elif len(command.aliases) > 0: embed.add_field(name="Alias", value=f"`{command.aliases[0]}`") await ctx.send(embed=embed) @@ -148,9 +171,11 @@ async def help(self, ctx, *cmd): description="""Halloooo and thank you for using Maxigames, a fun, random, cheerful and gambling-addiction-curbing bot developed as part of an initiative to curb gambling addiction and fill everyones' lives with bad puns, minigames and happiness!!! Feel free to invite this bot to your own server from the link below, or even join our support server, if you have any questions or suggestions :D""", - colour=self.client.primary_colour + colour=self.client.primary_colour, + ) + page.set_author( + name=self.client.user.name, icon_url=self.client.user.avatar_url ) - page.set_author(name=self.client.user.name, icon_url=self.client.user.avatar_url) page.set_footer(text="Press Next to see the commands :D") pages.append(page) @@ -183,283 +208,307 @@ async def help(self, ctx, *cmd): msg = await ctx.send( embed=pages[page_num], ) - buttons = [[Button(style=ButtonStyle.URL, label="Invite :D", url="https://discord.com/api/oauth2/authorize?client_id=863419048041381920&permissions=8&scope=bot%20applications.commands"), Button(style=ButtonStyle.URL, label="Support Server!!!", url="https://discord.gg/BNm87Cvdx3"), Button(style=ButtonStyle.URL, label="Vote :)", url="https://top.gg/bot/863419048041381920")]] - page = Paginator(self.client, ctx, msg, pages, buttons=buttons,timeout=60) + buttons = [ + [ + Button( + style=ButtonStyle.URL, + label="Invite :D", + url="https://discord.com/api/oauth2/authorize?client_id=863419048041381920&permissions=8&scope=bot%20applications.commands", + ), + Button( + style=ButtonStyle.URL, + label="Support Server!!!", + url="https://discord.gg/BNm87Cvdx3", + ), + Button( + style=ButtonStyle.URL, + label="Vote :)", + url="https://top.gg/bot/863419048041381920", + ), + ] + ] + page = Paginator(self.client, ctx, msg, pages, buttons=buttons, timeout=60) await page.start() - + @cog_ext.cog_slash(name="help", description="Shows the help menu :D") async def help_command(self, ctx: SlashContext): await self.help(ctx) - @commands.command(name="randnum", description="Gives you a random number between the two numbers you specified.", usage="randnum ") + @commands.command( + name="randnum", + description="Gives you a random number between the two numbers you specified.", + usage="randnum ", + ) async def randnum(self, ctx, start: int, end: int): answer = random.randint(start, end) await ctx.reply("Your number was " + str(answer)) + @commands.command() - async def empty(self,ctx): + async def empty(self, ctx): await ctx.reply("‎") - @commands.command(name="fibo",description="Returns the nth fibonacci number, where n is the number you input.", usage="fibo ") - async def fibo(self,ctx,num:int): + + @commands.command( + name="fibo", + description="Returns the nth fibonacci number, where n is the number you input.", + usage="fibo ", + ) + async def fibo(self, ctx, num: int): if num <= 0: - embed=discord.Embed( - title = "Bruh. Don't be stupid.", - description = "", - color = 0xff0000 + embed = discord.Embed( + title="Bruh. Don't be stupid.", description="", color=0xFF0000 ) await ctx.reply(embed=embed) elif num == 1: - embed=discord.Embed( - title = "The 1st fibonacci number is 1!", - description = "", - color = self.client.primary_colour + embed = discord.Embed( + title="The 1st fibonacci number is 1!", + description="", + color=self.client.primary_colour, ) await ctx.reply(embed=embed) elif num == 2: - embed=discord.Embed( - title = "The 2nd fibonacci number is 1!", - description = "", - color = self.client.primary_colour + embed = discord.Embed( + title="The 2nd fibonacci number is 1!", + description="", + color=self.client.primary_colour, ) await ctx.reply(embed=embed) elif num <= 1000: fibo1 = 1 fibo2 = 2 - for i in range(num-3): + for i in range(num - 3): currfibo1 = fibo1 fibo1 = fibo2 fibo2 += currfibo1 - embed=discord.Embed( - title = "The " + str(num) + "th fibonacci number is " + str(fibo2) + "!", - description = "", - color = self.client.primary_colour + embed = discord.Embed( + title="The " + str(num) + "th fibonacci number is " + str(fibo2) + "!", + description="", + color=self.client.primary_colour, ) await ctx.reply(embed=embed) else: - embed=discord.Embed( - title = "Make it smaller, stop trying to break me.", - description = "", - color = 0xff0000 + embed = discord.Embed( + title="Make it smaller, stop trying to break me.", + description="", + color=0xFF0000, ) await ctx.reply(embed=embed) - @commands.command(name="bigdice",description="rolls a specified number of dice with a specified number of faces that you can specify.",usage="bigdice ") - async def bigdice(self,ctx,sides:int,num:int): + + @commands.command( + name="bigdice", + description="rolls a specified number of dice with a specified number of faces that you can specify.", + usage="bigdice ", + ) + async def bigdice(self, ctx, sides: int, num: int): curr = "" if sides <= 0: embed = discord.Embed( - title = "What kind of dice is this?", - description="", - color = 0xff0000 + title="What kind of dice is this?", description="", color=0xFF0000 ) await ctx.reply(embed=embed) elif sides == 1: embed = discord.Embed( - title = "What's the point of rolling a die if it's always gonna come out on the same side?", - description = "", - color = 0xff0000 + title="What's the point of rolling a die if it's always gonna come out on the same side?", + description="", + color=0xFF0000, ) await ctx.reply(embed=embed) elif sides >= 1000: embed = discord.Embed( - title = str(sides) + " sides?!?! Come back to me when you make this die. Seriously why.", - description = "Bruh", - color = 0xff0000 + title=str(sides) + + " sides?!?! Come back to me when you make this die. Seriously why.", + description="Bruh", + color=0xFF0000, ) await ctx.reply(embed=embed) - + elif num <= 0: embed = discord.Embed( - title = "Don't be stupid. Honestly.", - description = "", - color = 0xff0000 + title="Don't be stupid. Honestly.", description="", color=0xFF0000 ) await ctx.reply(embed=embed) elif num <= 100: for i in range(num): - curr += str(random.randint(1,sides)) + curr += str(random.randint(1, sides)) curr += " " embed = discord.Embed( - title = "Your dice roll results came out!", - description = curr, - color = self.client.primary_colour + title="Your dice roll results came out!", + description=curr, + color=self.client.primary_colour, ) await ctx.reply(embed=embed) else: embed = discord.Embed( - title = "Don't be stupid. Honestly.", - description = "", - color = 0xff0000 + title="Don't be stupid. Honestly.", description="", color=0xFF0000 ) await ctx.reply(embed=embed) - @commands.command(name="dice",description="rolls the number of dice you specify.",usage="dice ") - async def dice(self,ctx,num:int): + + @commands.command( + name="dice", + description="rolls the number of dice you specify.", + usage="dice ", + ) + async def dice(self, ctx, num: int): curr = "" if num <= 0: embed = discord.Embed( - title = "Don't be stupid. Honestly.", - description = "", - color = 0xff0000 + title="Don't be stupid. Honestly.", description="", color=0xFF0000 ) await ctx.reply(embed=embed) elif num <= 100: for i in range(num): - curr += str(random.randint(1,6)) + curr += str(random.randint(1, 6)) curr += " " embed = discord.Embed( - title = "Your dice roll results came out!", - description = curr, - color = self.client.primary_colour + title="Your dice roll results came out!", + description=curr, + color=self.client.primary_colour, ) await ctx.reply(embed=embed) else: embed = discord.Embed( - title = "Don't be stupid. Honestly.", - description = "", - color = 0xff0000 + title="Don't be stupid. Honestly.", description="", color=0xFF0000 ) await ctx.reply(embed=embed) - @commands.command(name="numprop",description = "tells you the property of a number you specify!", usage="numprop ") - async def numprop(self,ctx,num:int): - + + @commands.command( + name="numprop", + description="tells you the property of a number you specify!", + usage="numprop ", + ) + async def numprop(self, ctx, num: int): + if num > 1000000000000: embed = discord.Embed( - title = "Bruh. I'm not going to waste my time trying to find out more about that big guy.", - description = "", - color = 0xff0000 + title="Bruh. I'm not going to waste my time trying to find out more about that big guy.", + description="", + color=0xFF0000, ) await ctx.reply(embed=embed) return elif num < 0: - embed=discord.Embed( - title = "Hey. I won't evaluate negative numbers for you.", + embed = discord.Embed( + title="Hey. I won't evaluate negative numbers for you.", description="", - color = 0xff0000 + color=0xFF0000, ) await ctx.reply(embed=embed) return - embed=discord.Embed( - title = "Thinking... :thinking::thinking::thinking:", - description = "", - color = 0xffff00 + embed = discord.Embed( + title="Thinking... :thinking::thinking::thinking:", + description="", + color=0xFFFF00, ) message = await ctx.reply(embed=embed) - embed=discord.Embed( - title = "The number ", - description = "", - color = self.client.primary_colour + embed = discord.Embed( + title="The number ", description="", color=self.client.primary_colour ) if num == 0: embed.add_field( - name = "This number, when added to anything, gives the thing you added it to!", - value = "HoW iNtErEsTiNg!", - inline=True + name="This number, when added to anything, gives the thing you added it to!", + value="HoW iNtErEsTiNg!", + inline=True, ) root = math.sqrt(num) if int(root + 0.5) ** 2 == num: - embed.add_field( - name = "Perfect Square!", - value = "Fascinating.", - inline=True - ) + embed.add_field(name="Perfect Square!", value="Fascinating.", inline=True) if num % 2 == 0: embed.add_field( - name = "Even!", - value = "Also known as a multiple of 2!", - inline = True + name="Even!", value="Also known as a multiple of 2!", inline=True ) else: embed.add_field( - name = "Odd!", - value = "It is not a multiple of 2!", - inline = True + name="Odd!", value="It is not a multiple of 2!", inline=True ) flag = False if num > 1: # check for factors - for i in range(2, math.ceil(root)+1): + for i in range(2, math.ceil(root) + 1): if i != num: if (num % i) == 0: flag = True break - if not flag and num == 1: embed.add_field( name="Not prime and not composite!", - value = "That's special!", - inline=True + value="That's special!", + inline=True, ) elif not flag and num == 0: embed.add_field( name="Not prime and not composite!", - value = "That's special!", - inline=True + value="That's special!", + inline=True, ) elif flag: embed.add_field( name="Composite!", - value = "That means that it has more than 2 factors!", - inline=True + value="That means that it has more than 2 factors!", + inline=True, ) else: - embed.add_field( - name = "Prime!", - value = "Ooh!", - inline = True - ) + embed.add_field(name="Prime!", value="Ooh!", inline=True) if "69420" in str(num): embed.add_field( - name = "VERRRRYYYYYYY SUSSSSSS!!!", - value = "That's because it contains :six::nine::four::two::zero: in it!!!!!!", - inline = True + name="VERRRRYYYYYYY SUSSSSSS!!!", + value="That's because it contains :six::nine::four::two::zero: in it!!!!!!", + inline=True, ) elif "69" in str(num): - embed.add_field( - name = "SUS!", - value = "because it contains 69!!!", - inline= True - ) + embed.add_field(name="SUS!", value="because it contains 69!!!", inline=True) elif "420" in str(num): embed.add_field( - name = "SUS!", - value = "because it contains 420!!!", - inline=True + name="SUS!", value="because it contains 420!!!", inline=True ) res = str(num) == str(num)[::-1] if res: embed.add_field( - name = "Palindrome!", - value = "Reads same forwards and backwards!", - inline = True + name="Palindrome!", + value="Reads same forwards and backwards!", + inline=True, ) time.sleep(1) await message.edit(embed=embed) - @commands.command(name="lmgtfy",description="Command that creats a Let Me Google That For You link for all your queries!",usage="lmgtfy") - async def lmgtfy(self,ctx,*quer:str): + @commands.command( + name="lmgtfy", + description="Command that creats a Let Me Google That For You link for all your queries!", + usage="lmgtfy", + ) + async def lmgtfy(self, ctx, *quer: str): curr_url = "https://lmgtfy.app/?q=" - query = ' '.join(quer) - query = query.replace(" ","+") + query = " ".join(quer) + query = query.replace(" ", "+") curr_url += query - embed=discord.Embed( - title = curr_url, - description ="Let Me Google That For You!", - color = self.client.primary_colour + embed = discord.Embed( + title=curr_url, + description="Let Me Google That For You!", + color=self.client.primary_colour, ) await ctx.reply(embed=embed) - @commands.command(name="choose",description="Chooses a random choice from the set of words given",usage = "choose ") - async def choose(self,ctx,*choices:str): + + @commands.command( + name="choose", + description="Chooses a random choice from the set of words given", + usage="choose ", + ) + async def choose(self, ctx, *choices: str): chosen = random.choice(choices) - embed=discord.Embed( - title = chosen + " was chosen!", - description = "Poggers!", - color = self.client.primary_colour + embed = discord.Embed( + title=chosen + " was chosen!", + description="Poggers!", + color=self.client.primary_colour, ) await ctx.reply(embed=embed) - @commands.command(name="kawaii",description="Makes what you say kawaii <3",usage="kawaii ") - async def kawaii(self,ctx,*msg:str): + @commands.command( + name="kawaii", + description="Makes what you say kawaii <3", + usage="kawaii ", + ) + async def kawaii(self, ctx, *msg: str): words = " ".join(msg) - final= "" + final = "" previous_char = "" for i in words: if i == "s" == previous_char: @@ -473,11 +522,19 @@ async def kawaii(self,ctx,*msg:str): else: final += i previous_char = i - final = final.replace("s","sh").replace("z","zh").replace("rr","ww").replace("nine","9").replace("four","4").replace("one","1") + final = ( + final.replace("s", "sh") + .replace("z", "zh") + .replace("rr", "ww") + .replace("nine", "9") + .replace("four", "4") + .replace("one", "1") + ) if final[-1] == "y": - final = final[:-1]+"ie" - + final = final[:-1] + "ie" + await ctx.reply(final) - + + def setup(client): client.add_cog(General(client)) diff --git a/cogs/hangman.py b/cogs/hangman.py index 05d12cc..97a2f5f 100644 --- a/cogs/hangman.py +++ b/cogs/hangman.py @@ -12,11 +12,12 @@ import asyncio import time from utils.paginator import Paginator -import firebase_admin +import firebase_admin from firebase_admin import firestore alpha = "abcdefghijklmnopqrstuvwxyz" + class Hangman(commands.Cog): def __init__(self, client): self.client = client @@ -38,15 +39,16 @@ async def hangmanList(self, ctx): page = discord.Embed( title="Help", description="List of hangman topics", - colour=self.client.primary_colour + colour=self.client.primary_colour, + ) + page.set_author( + name=self.client.user.name, icon_url=self.client.user.avatar_url ) - page.set_author(name=self.client.user.name, - icon_url=self.client.user.avatar_url) page.set_footer(text="Press Next to see the topics :D") pages.append(page) length = len(myList) - total_pages = length//20 + 1 + total_pages = length // 20 + 1 count = 0 count1 = 0 for i in range(0, total_pages): @@ -54,17 +56,16 @@ async def hangmanList(self, ctx): string = "" for j in range(0, 20): count += 1 - if i*20 + j >= length: + if i * 20 + j >= length: break - curList = myList[i*20+j] + curList = myList[i * 20 + j] string += f"{count}. `{str(curList)}` \n" page = discord.Embed( - title=str(count1), - description=string, - colour=self.client.primary_colour + title=str(count1), description=string, colour=self.client.primary_colour + ) + page.set_author( + name=self.client.user.name, icon_url=self.client.user.avatar_url ) - page.set_author(name=self.client.user.name, - icon_url=self.client.user.avatar_url) pages.append(page) page_num = 0 msg = await ctx.send( @@ -78,7 +79,7 @@ async def hangman(self, ctx): #! Hangman Firebase Initalisation self.initiation = self.client.get_cog("Initiation") await self.initiation.checkserver(ctx) - doc_ref = self.db.collection(u'users').document(str(ctx.author.id)) + doc_ref = self.db.collection("users").document(str(ctx.author.id)) doc = doc_ref.get() data = doc.to_dict() @@ -92,24 +93,50 @@ def check(msg): for topic in words: myList.append(topic.rstrip("\n")) words.close() - await ctx.reply(embed=discord.Embed(title="You have **2 minutes** to choose one topic. Do `m!hangmanList` to check all the topics.", colour=0x00ff00)) + await ctx.reply( + embed=discord.Embed( + title="You have **2 minutes** to choose one topic. Do `m!hangmanList` to check all the topics.", + colour=0x00FF00, + ) + ) #! Waiting for a reply - chosenTopic = "" + chosenTopic = "" while True: try: - message = await self.client.wait_for('message', timeout=120, check=check) - if message.content == "m!hangmanList" or message.content == "!hangmanList": + message = await self.client.wait_for( + "message", timeout=120, check=check + ) + if ( + message.content == "m!hangmanList" + or message.content == "!hangmanList" + ): continue elif message.content in myList: chosenTopic = message.content - await message.reply(embed=discord.Embed(title="You have chosen **" + chosenTopic + "**", colour=0x00ff00)) + await message.reply( + embed=discord.Embed( + title="You have chosen **" + chosenTopic + "**", + colour=0x00FF00, + ) + ) break else: - await message.reply(embed=discord.Embed(title="That is not a valid topic- Spacing, Capitalisation and Spelling are important", colour=0x00ff00)) + await message.reply( + embed=discord.Embed( + title="That is not a valid topic- Spacing, Capitalisation and Spelling are important", + colour=0x00FF00, + ) + ) except asyncio.TimeoutError: - await ctx.reply(embed=discord.Embed(title="Hangman game aborted due to Timeout", description="", colour=0x00ff00)) + await ctx.reply( + embed=discord.Embed( + title="Hangman game aborted due to Timeout", + description="", + colour=0x00FF00, + ) + ) return if chosenTopic == "": @@ -150,34 +177,34 @@ def check(msg): answer = answer + "□" embed = discord.Embed( - title="Your hangman game: ", - description=answer, - color=0xffff00 + title="Your hangman game: ", description=answer, color=0xFFFF00 ) - def maxi(a,b): + + def maxi(a, b): if a > b: return a else: return b - lives = maxi(5,math.floor(len(wordChoice)*2/3)) + + lives = maxi(5, math.floor(len(wordChoice) * 2 / 3)) word_guessed = 0 await ctx.reply(embed=embed) guessed_letter = [] #! Main Hangman Portion while answer != wordChoice and lives > 0: - + if currentGuess == correctWord: break try: - message = await self.client.wait_for('message', timeout=45, check=check) + message = await self.client.wait_for("message", timeout=45, check=check) messageanswer = message.content.lower() if len(str(messageanswer)) == 1: if str(messageanswer) in guessed_letter: - embed=discord.Embed( + embed = discord.Embed( title="You already guessed that letter!", description="Try again!", - color=0xff0000 + color=0xFF0000, ) await message.reply(embed=embed) continue @@ -195,13 +222,13 @@ def maxi(a,b): embed = discord.Embed( title="Oof... Your guess wasn't correct.", description=f"Try again using individual character or whole word guesses! You have {lives} lives left", - color=0xff0000 + color=0xFF0000, ) else: embed = discord.Embed( title="Pog! Your guess is correct!", description=f"The word now is {' '.join(currentGuess)}! You have {lives} lives left", - color=self.client.primary_colour + color=self.client.primary_colour, ) await message.reply(embed=embed) @@ -212,7 +239,7 @@ def maxi(a,b): embed = discord.Embed( title="You won!", description=f"Congratulations, you guessed the word {wordChoice} correctly! You have {data['money']} money now!", - color=0x00ff00 + color=0x00FF00, ) await ctx.reply(embed=embed) doc_ref.set(data) @@ -222,11 +249,17 @@ def maxi(a,b): embed = discord.Embed( title="Your guess was wrong!", description=f"Try again using individual character or whole word guesses! You have {lives} lives left", - color=0xff0000 + color=0xFF0000, ) await message.reply(embed=embed) except asyncio.TimeoutError: - await ctx.reply(embed=discord.Embed(title="Hangman game aborted due to Timeout", description="", colour=0x00ff00)) + await ctx.reply( + embed=discord.Embed( + title="Hangman game aborted due to Timeout", + description="", + colour=0x00FF00, + ) + ) return if lives == 0: deduct = random.randint(1, 10) @@ -236,7 +269,7 @@ def maxi(a,b): embed = discord.Embed( title="You lost!", description=f"The word was {wordChoice}, {deduct} money was subtracted off your account :(. You currently have f{data['money']} money", - color=0xff0000 + color=0xFF0000, ) await message.reply(embed=embed) doc_ref.set(data) @@ -246,7 +279,7 @@ def maxi(a,b): embed = discord.Embed( title="You won!", description=f"Congratulations, you guessed the word {wordChoice} correctly! You have {data['money']} money now!", - color=0x00ff00 + color=0x00FF00, ) await message.reply(embed=embed) doc_ref.set(data) @@ -255,6 +288,7 @@ def maxi(a,b): def setup(client): client.add_cog(Hangman(client)) + # ! DO NOT DELETE- DATABASE RETRIEVER # # --------GET HANGMAN FILES------------ # starttime = time.time() diff --git a/cogs/initiation.py b/cogs/initiation.py index 359eeb1..9decda5 100644 --- a/cogs/initiation.py +++ b/cogs/initiation.py @@ -5,72 +5,81 @@ from firebase_admin import firestore import os -class Initiation (commands.Cog): + +class Initiation(commands.Cog): def __init__(self, client): self.client = client self.db = firestore.client() self.hidden = True - async def initiate(self, ctx): - self.doc_ref = self.db.collection(u'users').document(u'{}'.format(str(ctx.author.id))) - self.doc_ref.set({ - u'money': 0, - u'countingsaves': 0, - u'name': str(ctx.author.name), - }) + self.doc_ref = self.db.collection(u"users").document( + u"{}".format(str(ctx.author.id)) + ) + self.doc_ref.set( + { + u"money": 0, + u"countingsaves": 0, + u"name": str(ctx.author.name), + } + ) await self.serverinitiate(ctx) embed = discord.Embed( title="Account Initiation", description="Your account has been initiated. Now you can start running currency commands :D", - colour=self.client.primary_colour + colour=self.client.primary_colour, ) if isinstance(ctx, discord.Message): await ctx.channel.send(embed=embed) else: await ctx.send(embed=embed) - async def serverinitiate(self,ctx): - self.doc_ref = self.db.collection(u'servers').document(u'{}'.format(str(ctx.guild.id))) + async def serverinitiate(self, ctx): + self.doc_ref = self.db.collection(u"servers").document( + u"{}".format(str(ctx.guild.id)) + ) self.doc = self.doc_ref.get() self.usr = {} if self.doc.exists: self.dict2 = self.doc.to_dict() - self.dict2["users"][u'{}'.format(str(ctx.author.id))] = self.usr + self.dict2["users"][u"{}".format(str(ctx.author.id))] = self.usr self.doc_ref.set(self.dict2) else: - self.doc_ref.set({ - u'users':{ - str(ctx.author.id): self.usr - }, - u'all': {}, - u'countingChannels': { - "counting": { - "name": "counting", - "count": 0, - "highest_count": 0, - "last_user": None - } - }, - u'name': str(ctx.guild.name) - }) - + self.doc_ref.set( + { + u"users": {str(ctx.author.id): self.usr}, + u"all": {}, + u"countingChannels": { + "counting": { + "name": "counting", + "count": 0, + "highest_count": 0, + "last_user": None, + } + }, + u"name": str(ctx.guild.name), + } + ) + async def checkserver(self, ctx, data=None): - doc_ref = self.db.collection(u'servers').document(u'{}'.format(str(ctx.guild.id))) + doc_ref = self.db.collection(u"servers").document( + u"{}".format(str(ctx.guild.id)) + ) doc = doc_ref.get() if doc.exists and (str(ctx.author.id) in doc.to_dict()["users"]): if data != None: return data else: - await self.serverinitiate(ctx) + await self.serverinitiate(ctx) if data != None: dat = {} - docs = self.db.collection(u'servers').stream() + docs = self.db.collection(u"servers").stream() for doc in docs: dat[doc.id] = doc.to_dict() - + return dat + def setup(client): client.add_cog(Initiation(client)) - # pass \ No newline at end of file + # pass diff --git a/cogs/quiz.py b/cogs/quiz.py index 7dd5aab..72804d0 100644 --- a/cogs/quiz.py +++ b/cogs/quiz.py @@ -24,37 +24,51 @@ def __init__(self, client): self.hidden = False # @cooldown(1, 20, BucketType.user) - @commands.command(name="trivia", description="Answer a trivia question using reactions! Provide a number from 1 to 3 specifying the difficulty of the trivia question you want.", usage="trivia ") + @commands.command( + name="trivia", + description="Answer a trivia question using reactions! Provide a number from 1 to 3 specifying the difficulty of the trivia question you want.", + usage="trivia ", + ) async def trivia(self, ctx, difficulty=100000000000): word = "hard" moneyToAdd = 0 - if(difficulty == 1): + if difficulty == 1: word = "easy" moneyToAdd = 2 - elif(difficulty == 2): + elif difficulty == 2: word = "medium" moneyToAdd = 5 - elif(difficulty == 3): + elif difficulty == 3: word = "hard" moneyToAdd = 10 else: - await ctx.reply(embed=discord.Embed(title="Error", description="A difficulty level of 1, 2 or 3 is needed! Note that the harder the question is, the more points you will get if u get it right!", colour=self.client.primary_colour)) + await ctx.reply( + embed=discord.Embed( + title="Error", + description="A difficulty level of 1, 2 or 3 is needed! Note that the harder the question is, the more points you will get if u get it right!", + colour=self.client.primary_colour, + ) + ) return r = { - "response_code": 'value1', + "response_code": "value1", "results": [ { - "category": 'value2', - "type": 'value3', - "difficulty": 'value4', - "question": 'value5', - "correct_answer": 'value6', - "incorrect_answers": 'value7' + "category": "value2", + "type": "value3", + "difficulty": "value4", + "question": "value5", + "correct_answer": "value6", + "incorrect_answers": "value7", } - ] + ], } - result = json.loads(requests.post( - f"https://opentdb.com/api.php?amount=1&difficulty={word}&type=multiple", data=r).text) + result = json.loads( + requests.post( + f"https://opentdb.com/api.php?amount=1&difficulty={word}&type=multiple", + data=r, + ).text + ) results = result["results"][0] arr = results["incorrect_answers"] @@ -63,14 +77,16 @@ async def trivia(self, ctx, difficulty=100000000000): count = 0 description = "" for i in arr: - description += f'({count+1}) {i}\n' + description += f"({count+1}) {i}\n" count += 1 embed = discord.Embed( title=f"TRIVIA- You have 10 seconds to answer ({word})", - description=results["question"].replace( - """, '\"').replace("'", "\'")+'\n'+description, - - colour=self.client.primary_colour + description=results["question"] + .replace(""", '"') + .replace("'", "'") + + "\n" + + description, + colour=self.client.primary_colour, ) message = await ctx.reply(embed=embed) await message.add_reaction("1️⃣") @@ -83,62 +99,68 @@ def check(reaction, user): return user == ctx.author and reaction.message == message try: - reaction, user = await self.client.wait_for('reaction_add', timeout=10.0, check=check) + reaction, user = await self.client.wait_for( + "reaction_add", timeout=10.0, check=check + ) except asyncio.TimeoutError: embed = discord.Embed( title="You were too slow! Try again next time.", description=" ", - color=self.client.primary_colour + color=self.client.primary_colour, ) await ctx.reply(embed=embed) else: # find which option is correct???? index = None - if reaction.emoji == '1️⃣': + if reaction.emoji == "1️⃣": index = 0 - elif reaction.emoji == '2️⃣': + elif reaction.emoji == "2️⃣": index = 1 - elif reaction.emoji == '3️⃣': + elif reaction.emoji == "3️⃣": index = 2 - elif reaction.emoji == '4️⃣': + elif reaction.emoji == "4️⃣": index = 3 else: return ans = arr[index] self.initation = self.client.get_cog("Initiation") await self.initiation.checkserver(ctx) - doc_ref = self.db.collection(u'users').document( - u'{}'.format(str(ctx.author.id))) + doc_ref = self.db.collection("users").document( + "{}".format(str(ctx.author.id)) + ) doc = doc_ref.get() if doc.exists: dict1 = doc.to_dict() if ans == str(results["correct_answer"]): - dict1["money"] = dict1["money"] + \ - random.randint(0, moneyToAdd) + dict1["money"] = dict1["money"] + random.randint(0, moneyToAdd) embed = discord.Embed( title="Correct Answer! You win 3 money!", - description="You now have " + - str(dict1["money"]) + " money!", - color=self.client.primary_colour + description="You now have " + str(dict1["money"]) + " money!", + color=self.client.primary_colour, ) await ctx.reply(embed=embed) else: - dict1["money"] = dict1["money"] - \ - int(random.randint(0, moneyToAdd)/3) + dict1["money"] = dict1["money"] - int( + random.randint(0, moneyToAdd) / 3 + ) embed = discord.Embed( title="Wrong Answer! You lost 1 money!", - description=f"You now have " + - str(dict1["money"]) + - f" money! The correct answer was {results['correct_answer']} :", - color=self.client.primary_colour + description=f"You now have " + + str(dict1["money"]) + + f" money! The correct answer was {results['correct_answer']} :", + color=self.client.primary_colour, ) await ctx.reply(embed=embed) doc_ref.set(dict1) - @commands.command(name="math", description="Answer a math question correctly to gain coins. If you don't get it correct you lose coins!", usage="math") + @commands.command( + name="math", + description="Answer a math question correctly to gain coins. If you don't get it correct you lose coins!", + usage="math", + ) async def math(self, ctx): first = random.randint(1, 100) second = random.randint(1, 100) @@ -146,38 +168,42 @@ async def math(self, ctx): oper = "+" if operandation < 9: oper = "*" - theanswer = str(first*second) - timehehe = 10 + (first+second-69)/20 + theanswer = str(first * second) + timehehe = 10 + (first + second - 69) / 20 elif operandation < 40: oper = "-" - theanswer = str(first-second) - timehehe = 6 + (first+second-49)/30 + theanswer = str(first - second) + timehehe = 6 + (first + second - 49) / 30 else: - timehehe = 4 + (first+second-69)/60 - theanswer = str(first+second) + timehehe = 4 + (first + second - 69) / 60 + theanswer = str(first + second) timehehe = int(timehehe) question_ask = "What is " + str(first) + oper + str(second) + "?" embed = discord.Embed( title=question_ask, - - description="You have " + - str(timehehe) + " seconds to answer! You only have one chance.", - color=self.client.primary_colour + description="You have " + + str(timehehe) + + " seconds to answer! You only have one chance.", + color=self.client.primary_colour, ) await ctx.reply(embed=embed) def check(msg): return msg.author == ctx.author and msg.channel == ctx.channel + try: - messageanswer = await self.client.wait_for('message', timeout=timehehe, check=check) + messageanswer = await self.client.wait_for( + "message", timeout=timehehe, check=check + ) msgcontent = messageanswer.content self.initation = self.client.get_cog("Initiation") await self.initiation.checkserver(ctx) - doc_ref = self.db.collection(u'users').document( - u'{}'.format(str(ctx.author.id))) + doc_ref = self.db.collection("users").document( + "{}".format(str(ctx.author.id)) + ) doc = doc_ref.get() if doc.exists == False: print("Nonexistant database") @@ -188,7 +214,7 @@ def check(msg): embed = discord.Embed( title="Your answer " + theanswer + " was correct!", description=f"You are veery beeg brain! U gained {added}", - color=self.client.primary_colour + color=self.client.primary_colour, ) dict1["money"] += added await ctx.reply(embed=embed) @@ -197,7 +223,7 @@ def check(msg): embed = discord.Embed( title="Your answer was wrong! The correct answer was " + theanswer, description=f"Not beeg brain :'( U lost 1 money!", - color=self.client.primary_colour + color=self.client.primary_colour, ) dict1["money"] -= 1 if dict1["money"] < 0: @@ -208,40 +234,45 @@ def check(msg): embed = discord.Embed( title="You took too long. You math noob.", description="How saddening", - color=self.client.primary_colour + color=self.client.primary_colour, ) await ctx.reply(embed=embed) - @commands.command(name="scramble", description="Try to unscramble a word!", usage="scramble") + @commands.command( + name="scramble", description="Try to unscramble a word!", usage="scramble" + ) async def scramble(self, ctx): wordCount = 5 chosenWords = [] correctWords = [] with open(file=str(os.getcwd()) + "/cogs/word.txt", mode="r") as f: - wordDict = f.read().split('\n') + wordDict = f.read().split("\n") for i in range(wordCount): firstWord = list(random.choice(wordDict)) word = copy.copy(firstWord) - random.shuffle(firstWord) - newWord = ''.join(word) - newStartWord = ''.join(firstWord) + random.shuffle(firstWord) + newWord = "".join(word) + newStartWord = "".join(firstWord) chosenWords.append(newStartWord) correctWords.append(newWord) print(correctWords) embed = discord.Embed( title="Scrambled words", description=f"The words you have to unscramble are: {', '.join(chosenWords)}", - color=self.client.primary_colour + color=self.client.primary_colour, ) await ctx.reply(embed=embed) - await ctx.send("You have 1 minute to unscramble the word. Everytime u send a message and it contains a correct word, the timer will reset") + await ctx.send( + "You have 1 minute to unscramble the word. Everytime u send a message and it contains a correct word, the timer will reset" + ) - # firebase + # firebase def check(msg): return msg.author == ctx.author and msg.channel == ctx.channel + self.initation = self.client.get_cog("Initiation") await self.initiation.checkserver(ctx) - doc_ref = self.db.collection(u'users').document(u'{}'.format(str(ctx.author.id))) + doc_ref = self.db.collection("users").document("{}".format(str(ctx.author.id))) doc = doc_ref.get() if doc.exists == False: print("Nonexistant database") @@ -250,16 +281,18 @@ def check(msg): while True: try: - messageanswer = await self.client.wait_for('message', timeout=60, check=check) + messageanswer = await self.client.wait_for( + "message", timeout=60, check=check + ) msgcontent = messageanswer.content if msgcontent in correctWords: toAdd = len(msgcontent) - dict1["money"] += math.floor(toAdd*1.5) + dict1["money"] += math.floor(toAdd * 1.5) moneynow = dict1["money"] embed = discord.Embed( title="Correct answer", description=f"The word was {msgcontent}, you gained {toAdd} money! You now have {moneynow} money! :D", - color=self.client.primary_colour + color=self.client.primary_colour, ) await messageanswer.reply(embed=embed) correctWords.remove(msgcontent) @@ -267,7 +300,7 @@ def check(msg): embed = discord.Embed( title="You won!", description="You have won the game!", - color=self.client.primary_colour + color=self.client.primary_colour, ) await messageanswer.reply(embed=embed) break @@ -275,7 +308,7 @@ def check(msg): embed = discord.Embed( title="Wrong answer", description="Continue guessing. Oof. Oof. Oof.", - color=0xff0000 + color=0xFF0000, ) await messageanswer.reply(embed=embed) @@ -285,114 +318,122 @@ def check(msg): embed = discord.Embed( title="Time has run out...", description=f"How saddening, you lost {lost} money, you currently have {dict1['money']}", - color=self.client.primary_colour + color=self.client.primary_colour, ) await ctx.reply(embed=embed) break doc_ref.set(dict1) - @check.is_banned() @commands.command( name="snake eyes", description="A random dice game that everyone loves.", usage="snakeeyes", - aliases=["se","snakeyes"] + aliases=["se", "snakeyes"], ) - async def se(self, ctx,amount:int): + async def se(self, ctx, amount: int): self.initation = self.client.get_cog("Initiation") await self.initation.checkserver(ctx) - doc_ref = self.db.collection(u'users').document( - u'{}'.format(str(ctx.author.id))) + doc_ref = self.db.collection("users").document("{}".format(str(ctx.author.id))) doc = doc_ref.get() if doc.exists: dict1 = doc.to_dict() - if dict1['money'] < amount: + if dict1["money"] < amount: embed = discord.Embed( title="Amount in bank too low", description="The amount that you want to gamble is more than what you have in your bank.", - color=self.client.primary_colour + color=self.client.primary_colour, + ) + embed.set_author( + name=ctx.author.display_name, icon_url=ctx.author.avatar_url ) - embed.set_author(name=ctx.author.display_name, - icon_url=ctx.author.avatar_url) await ctx.reply(embed=embed) return if amount <= 0: - doc_ref = self.db.collection(u'users').document( - u'{}'.format(str(ctx.author.id))) + doc_ref = self.db.collection("users").document( + "{}".format(str(ctx.author.id)) + ) doc = doc_ref.get() if doc.exists: dict1 = doc.to_dict() - + doc_ref.set(dict1) embed = discord.Embed( title="Amount gambled unacceptable", description="It appears that you have been attempting to exploit the system and this is very bad!!! Stop doing this or we'll set your balance to 0.", - color=self.client.primary_colour + color=self.client.primary_colour, + ) + embed.set_author( + name=ctx.author.display_name, icon_url=ctx.author.avatar_url ) - embed.set_author(name=ctx.author.display_name, - icon_url=ctx.author.avatar_url) await ctx.reply(embed=embed) return embed = discord.Embed( - title = "Rolling dice...", - description = ":game_die::game_die:", - color=self.client.primary_colour + title="Rolling dice...", + description=":game_die::game_die:", + color=self.client.primary_colour, ) messagec = await ctx.reply(embed=embed) asyncio.sleep(2) - dice1 = random.randint(1,6) - dice2 = random.randint(1,6) + dice1 = random.randint(1, 6) + dice2 = random.randint(1, 6) if dice1 != 1 and dice2 != 1: dict1["money"] -= amount nowmoney = dict1["money"] doc_ref.set(dict1) embed = discord.Embed( - title = "You rolled " + str(dice1) + " and " + str(dice2) + "!", - description= "You didn't get any snake eyes. Beeg sed. You now have " + str(nowmoney) + " money.", - color = 0xff0000 - + title="You rolled " + str(dice1) + " and " + str(dice2) + "!", + description="You didn't get any snake eyes. Beeg sed. You now have " + + str(nowmoney) + + " money.", + color=0xFF0000, ) await messagec.edit(embed=embed) elif dice1 == 1 and dice2 != 1: - earnt = math.floor(1.8*amount) + earnt = math.floor(1.8 * amount) dict1["money"] += earnt doc_ref.set(dict1) nowmoney = dict1["money"] embed = discord.Embed( - title = "You rolled " + str(dice1) + " and " + str(dice2) + "!", - description = "You got one snake eye! You won 1.8x your bet. You now have " + str(nowmoney) + " money.", - color = self.client.primary_colour + title="You rolled " + str(dice1) + " and " + str(dice2) + "!", + description="You got one snake eye! You won 1.8x your bet. You now have " + + str(nowmoney) + + " money.", + color=self.client.primary_colour, ) await messagec.edit(embed=embed) elif dice1 != 1 and dice2 == 1: - earnt = math.floor(1.8*amount) + earnt = math.floor(1.8 * amount) dict1["money"] += earnt nowmoney = dict1["money"] doc_ref.set(dict1) embed = discord.Embed( - title = "You rolled " + str(dice1) + " and " + str(dice2) + "!", - description = "You got one snake eye! You won 1.8x your bet. You now have " + str(nowmoney) + " money.", - color = self.client.primary_colour + title="You rolled " + str(dice1) + " and " + str(dice2) + "!", + description="You got one snake eye! You won 1.8x your bet. You now have " + + str(nowmoney) + + " money.", + color=self.client.primary_colour, ) await messagec.edit(embed=embed) else: - earnt = 10*amount + earnt = 10 * amount dict1["money"] += earnt nowmoney = dict1["money"] doc_ref.set(dict1) embed = discord.Embed( - title = "You rolled " + str(dice1) + " and " + str(dice2) + "!", - description = "You got two snake eyes! You won 10x your bet. You now have " + str(nowmoney) + " money. Woo!", - color = self.client.primary_colour + title="You rolled " + str(dice1) + " and " + str(dice2) + "!", + description="You got two snake eyes! You won 10x your bet. You now have " + + str(nowmoney) + + " money. Woo!", + color=self.client.primary_colour, ) await messagec.edit(embed=embed) else: await self.initation.initiate(ctx) - + def setup(client): client.add_cog(Games(client)) diff --git a/cogs/starboard.py b/cogs/starboard.py index 1bd007d..0546b63 100644 --- a/cogs/starboard.py +++ b/cogs/starboard.py @@ -1,9 +1,10 @@ import discord from discord.ext import commands -import firebase_admin +import firebase_admin from firebase_admin import firestore from utils import check + class Starboard(commands.Cog): def __init__(self, client): self.client = client @@ -12,7 +13,11 @@ def __init__(self, client): self.initiation = self.client.get_cog("Initiation") @check.is_admin() - @commands.command(name="starboard", description="Starts a starboard", usage="m!starboard #starboard") + @commands.command( + name="starboard", + description="Starts a starboard", + usage="m!starboard #starboard", + ) async def starboard(self, ctx, channel: discord.TextChannel = None): if channel == None: await ctx.reply("You need to specify a channel") @@ -20,7 +25,7 @@ async def starboard(self, ctx, channel: discord.TextChannel = None): try: self.initation = self.client.get_cog("Initiation") await self.initation.checkserver(ctx) - doc_ref = self.db.collection(u'servers').document(str(ctx.guild.id)) + doc_ref = self.db.collection("servers").document(str(ctx.guild.id)) doc = doc_ref.get() data = doc.to_dict() data["starboard"] = {"channel": channel.id} @@ -33,14 +38,14 @@ async def starboard(self, ctx, channel: discord.TextChannel = None): async def on_reaction_add(self, reaction, user): print("WORKING") self.initiation = self.client.get_cog("Initiation") - doc_ref = self.db.collection(u'servers').document(str(reaction.message.guild.id)) + doc_ref = self.db.collection("servers").document(str(reaction.message.guild.id)) doc = doc_ref.get() data = doc.to_dict() channel = self.client.get_channel(int(data["starboard"]["channel"])) await self.initiation.checkserver(reaction.message) if "starboard" not in data: - print('b') + print("b") return if channel is None: print("a") @@ -49,11 +54,35 @@ async def on_reaction_add(self, reaction, user): if reaction.count > 1: if reaction.emoji == "⭐": try: - msg = await channel.fetch_message(data["starboard"][str(reaction.message.id)]) - await msg.edit(embed=discord.Embed(title=f"Starboard: {reaction.count}", description=reaction.message.content, color=0x00ff00).set_footer(text=f"React with {'🌟'} to star this message").set_author(name=reaction.message.author.name, icon_url=reaction.message.author.avatar_url)) + msg = await channel.fetch_message( + data["starboard"][str(reaction.message.id)] + ) + await msg.edit( + embed=discord.Embed( + title=f"Starboard: {reaction.count}", + description=reaction.message.content, + color=0x00FF00, + ) + .set_footer(text=f"React with {'🌟'} to star this message") + .set_author( + name=reaction.message.author.name, + icon_url=reaction.message.author.avatar_url, + ) + ) doc_ref.set(data) except KeyError: - message = await channel.send(embed=discord.Embed(title=f"Starboard: {reaction.count}", description=reaction.message.content, color=0x00ff00).set_footer(text=f"React with {'🌟'} to star this message").set_author(name=reaction.message.author.name, icon_url=reaction.message.author.avatar_url)) + message = await channel.send( + embed=discord.Embed( + title=f"Starboard: {reaction.count}", + description=reaction.message.content, + color=0x00FF00, + ) + .set_footer(text=f"React with {'🌟'} to star this message") + .set_author( + name=reaction.message.author.name, + icon_url=reaction.message.author.avatar_url, + ) + ) data["starboard"][str(reaction.message.id)] = message.id doc_ref.set(data) diff --git a/cogs/suggestions.py b/cogs/suggestions.py index 9e00007..2e7152d 100644 --- a/cogs/suggestions.py +++ b/cogs/suggestions.py @@ -4,20 +4,25 @@ from utils import check -class Suggestions (commands.Cog): +class Suggestions(commands.Cog): def __init__(self, client): self.client = client self.hidden = False @check.is_banned() - @commands.command(name="Suggestions", description="Suggest anything that you want us to know about!!! Be it a game that you really want to be implemented, or some comments you have on what can be improved :D", usage="suggest ", aliases=["suggest"]) + @commands.command( + name="Suggestions", + description="Suggest anything that you want us to know about!!! Be it a game that you really want to be implemented, or some comments you have on what can be improved :D", + usage="suggest ", + aliases=["suggest"], + ) async def suggest(self, ctx, *msg): suggestion = " ".join(msg[:]) channel = self.client.get_channel(866339642075775058) embed = discord.Embed( title="New Suggestion", description=f"{ctx.author.mention} has submitted a suggestion.", - colour=self.client.primary_colour + colour=self.client.primary_colour, ) embed.add_field(name="Suggestion", value=suggestion, inline=False) message = await channel.send(embed=embed) @@ -25,24 +30,26 @@ async def suggest(self, ctx, *msg): acknowledgement = discord.Embed( title="Suggestion Submitted", description=f"Your suggestion has been submitted. Thank you for your suggestion.", - colour = self.client.primary_colour + colour=self.client.primary_colour, ) await ctx.reply(embed=acknowledgement) def check(reaction, user): - return user == ctx.author and reaction.message == message and reaction.emoji == "❌" + return ( + user == ctx.author + and reaction.message == message + and reaction.emoji == "❌" + ) + await message.add_reaction("⬆️") await message.add_reaction("⬇️") await message.add_reaction("❌") - reaction, user = await self.client.wait_for('reaction_add', check=check) + reaction, user = await self.client.wait_for("reaction_add", check=check) await message.delete() delete_channel = self.client.get_channel(866339642075775058) await delete_channel.send(embed=embed) - - def setup(client): client.add_cog(Suggestions(client)) - diff --git a/cogs/tickets.py b/cogs/tickets.py index c4d7311..924a9b8 100644 --- a/cogs/tickets.py +++ b/cogs/tickets.py @@ -6,36 +6,38 @@ import firebase_admin from firebase_admin import firestore + class Ticket(commands.Cog): def __init__(self, client): self.client = client self.hidden = True self.db = firestore.client() - doc_ref = self.db.collection(u'tickets').document('ticket-ref') + doc_ref = self.db.collection("tickets").document("ticket-ref") doc = doc_ref.get() if doc.exists: - self.messages = doc.to_dict()['messages'] - self.count = doc.to_dict()['count'] - self.active_tickets = doc.to_dict()['active_tickets'] + self.messages = doc.to_dict()["messages"] + self.count = doc.to_dict()["count"] + self.active_tickets = doc.to_dict()["active_tickets"] else: self.messages = {} self.count = {} self.active_tickets = {} - - - - - @commands.command(name="newticket", description="Creates a new message that responds to ") + @commands.command( + name="newticket", description="Creates a new message that responds to " + ) async def newticket(self, ctx): embed = discord.Embed( title="Get tickets here :D", description="To create a ticket react with 🎫 :D", - colour=self.client.primary_colour + colour=self.client.primary_colour, + ) + embed.set_footer( + text="MaxiGames - The Best Minigame Bot", + icon_url=self.client.user.avatar_url, ) - embed.set_footer(text="MaxiGames - The Best Minigame Bot", icon_url=self.client.user.avatar_url) msg = await ctx.send(embed=embed) - await msg.add_reaction('🎫') + await msg.add_reaction("🎫") if str(ctx.guild.id) not in self.messages: self.messages[str(ctx.guild.id)] = [str(msg.id)] self.count[str(ctx.guild.id)] = 0 @@ -44,103 +46,158 @@ async def newticket(self, ctx): self.messages[str(ctx.guild.id)].append(str(msg.id)) await ctx.message.delete() # print(self.messages) + @commands.Cog.listener() async def on_reaction_add(self, reaction, user): if user == self.client.user: return if str(reaction.message.guild.id) in self.messages: - if str(reaction.message.id) in self.messages[str(reaction.message.guild.id)]: - if reaction.emoji == '🎫': - if str(user.id) in self.active_tickets[str(reaction.message.guild.id)]: - embed=discord.Embed( + if ( + str(reaction.message.id) + in self.messages[str(reaction.message.guild.id)] + ): + if reaction.emoji == "🎫": + if ( + str(user.id) + in self.active_tickets[str(reaction.message.guild.id)] + ): + embed = discord.Embed( title="Ticket Present", description="You can only have 1 ticket open per server. Please close the other ticket before starting a new one :D", - colour = self.client.primary_colour + colour=self.client.primary_colour, + ) + embed.set_footer( + text="MaxiGames - The Best Minigame Bot", + icon_url=self.client.user.avatar_url, ) - embed.set_footer(text="MaxiGames - The Best Minigame Bot", icon_url=self.client.user.avatar_url) await reaction.message.channel.send(embed=embed) return - print('New ticket') + print("New ticket") found = False for category in reaction.message.guild.categories: - if category.name=="open-tickets": + if category.name == "open-tickets": found = True - break - + break + if not found: - category = await reaction.message.guild.create_category(f'open-tickets', position=0) + category = await reaction.message.guild.create_category( + f"open-tickets", position=0 + ) overwrites = { - reaction.message.guild.default_role: discord.PermissionOverwrite(view_channel=False), - user: discord.PermissionOverwrite(read_messages=True, add_reactions=True, send_messages=True) + reaction.message.guild.default_role: discord.PermissionOverwrite( + view_channel=False + ), + user: discord.PermissionOverwrite( + read_messages=True, add_reactions=True, send_messages=True + ), } self.count[str(reaction.message.guild.id)] += 1 - self.active_tickets[str(reaction.message.guild.id)][str(user.id)] = self.count[str(reaction.message.guild.id)] - channel = await reaction.message.guild.create_text_channel(f'ticket-{self.count[str(reaction.message.guild.id)]}', overwrites=overwrites, category=category) - - embed=discord.Embed( + self.active_tickets[str(reaction.message.guild.id)][ + str(user.id) + ] = self.count[str(reaction.message.guild.id)] + channel = await reaction.message.guild.create_text_channel( + f"ticket-{self.count[str(reaction.message.guild.id)]}", + overwrites=overwrites, + category=category, + ) + + embed = discord.Embed( title="New Ticket", description=f"Welcome {user.mention} to your new ticket.", - colour=self.client.primary_colour + colour=self.client.primary_colour, + ) + embed.set_footer( + text="MaxiGames - The Best Minigame Bot", + icon_url=self.client.user.avatar_url, ) - embed.set_footer(text="MaxiGames - The Best Minigame Bot", icon_url=self.client.user.avatar_url) - startmsg = await channel.send(embed=embed, components=[[Button(style=ButtonStyle.grey, label="🔒 Close")]], allowed_mentions = discord.AllowedMentions.all()) - await reaction.message.remove_reaction('🎫', user) + startmsg = await channel.send( + embed=embed, + components=[[Button(style=ButtonStyle.grey, label="🔒 Close")]], + allowed_mentions=discord.AllowedMentions.all(), + ) + await reaction.message.remove_reaction("🎫", user) - doc_ref = self.db.collection(u'tickets').document('ticket-ref') + doc_ref = self.db.collection("tickets").document("ticket-ref") data = { - 'active_tickets': self.active_tickets, - 'messages': self.messages, - 'count': self.count + "active_tickets": self.active_tickets, + "messages": self.messages, + "count": self.count, } doc_ref.set(data) while True: + def check(interaction): - return interaction.user == user and interaction.message.channel == channel and interaction.component.label == "🔒 Close" - res = await self.client.wait_for("button_click", check = check) + return ( + interaction.user == user + and interaction.message.channel == channel + and interaction.component.label == "🔒 Close" + ) + + res = await self.client.wait_for("button_click", check=check) await res.respond( - type=InteractionType.DeferredUpdateMessage # , content=f"{res.component.label} pressed" + type=InteractionType.DeferredUpdateMessage # , content=f"{res.component.label} pressed" ) - confirmation=discord.Embed( + confirmation = discord.Embed( title="Confirm closing of ticket", description=f"Please confirm that you want to delete this ticket. This is not reversible.", - colour=self.client.primary_colour + colour=self.client.primary_colour, + ) + embed.set_footer( + text="MaxiGames - The Best Minigame Bot", + icon_url=self.client.user.avatar_url, + ) + confirm = await channel.send( + embed=confirmation, + components=[ + [ + Button(style=ButtonStyle.red, label="Delete"), + Button(style=ButtonStyle.grey, label="Cancel"), + ] + ], ) - embed.set_footer(text="MaxiGames - The Best Minigame Bot", icon_url=self.client.user.avatar_url) - confirm = await channel.send(embed=confirmation, components=[[Button(style=ButtonStyle.red, label="Delete"), Button(style=ButtonStyle.grey, label="Cancel")]]) def check(interaction): - return interaction.user == user and interaction.message.channel == channel - - res = await self.client.wait_for("button_click", check = check) + return ( + interaction.user == user + and interaction.message.channel == channel + ) + + res = await self.client.wait_for("button_click", check=check) await res.respond( - type=InteractionType.DeferredUpdateMessage # , content=f"{res.component.label} pressed" + type=InteractionType.DeferredUpdateMessage # , content=f"{res.component.label} pressed" ) if res.component.label == "Delete": await channel.delete() - self.active_tickets[str(reaction.message.guild.id)].pop(str(user.id)) - self.messages[str(reaction.message.guild.id)].remove(str(reaction.message.id)) - doc_ref = self.db.collection(u'tickets').document('ticket-ref') + self.active_tickets[str(reaction.message.guild.id)].pop( + str(user.id) + ) + self.messages[str(reaction.message.guild.id)].remove( + str(reaction.message.id) + ) + doc_ref = self.db.collection("tickets").document( + "ticket-ref" + ) data = { - 'active_tickets': self.active_tickets, - 'messages': self.messages, - 'count': self.count + "active_tickets": self.active_tickets, + "messages": self.messages, + "count": self.count, } doc_ref.set(data) break else: await confirm.delete() - #APPLICATIONS: VSCODE DEFENDER: bad tux! if you see this you CANNOT change any of the code :D - + # APPLICATIONS: VSCODE DEFENDER: bad tux! if you see this you CANNOT change any of the code :D + @commands.Cog.listener() async def on_disconnect(self): - doc_ref = self.db.collection(u'tickets').document('ticket-ref') + doc_ref = self.db.collection("tickets").document("ticket-ref") data = { - 'active_tickets': self.active_tickets, - 'messages': self.messages, - 'count': self.count + "active_tickets": self.active_tickets, + "messages": self.messages, + "count": self.count, } doc_ref.set(data) @@ -149,7 +206,6 @@ async def on_disconnect(self): async def deletechannel(self, ctx): await ctx.channel.delete() - def setup(client): client.add_cog(Ticket(client)) diff --git a/cogs/tictactoe.py b/cogs/tictactoe.py index 917efd6..cb6125d 100644 --- a/cogs/tictactoe.py +++ b/cogs/tictactoe.py @@ -2,66 +2,88 @@ from discord.ext import commands import asyncio + class TicTacToe(commands.Cog): def __init__(self, client): self.client = client self.hidden = False - - @commands.command(name="ttt", description="tic tac toe game u can play with your friend!", usage="ttt") + + @commands.command( + name="ttt", + description="tic tac toe game u can play with your friend!", + usage="ttt", + ) async def ttt(self, ctx): player1 = "" player2 = "" - - message = await ctx.reply("React on this message to start a tic tac toe game, 2 people are needed!") + + message = await ctx.reply( + "React on this message to start a tic tac toe game, 2 people are needed!" + ) await message.add_reaction("✅") - + def check(reaction, user): if reaction.message == message and user.id != self.client.user.id: return True - else: return False + else: + return False try: - reaction1,user1 = await self.client.wait_for('reaction_add', timeout=45, check=check) + reaction1, user1 = await self.client.wait_for( + "reaction_add", timeout=45, check=check + ) print(user1.id) while True: - reaction2,user2 = await self.client.wait_for('reaction_add', timeout=45, check=check) + reaction2, user2 = await self.client.wait_for( + "reaction_add", timeout=45, check=check + ) print(user2.id) if user2 == user1: print("attempted to break the system in ttt") else: break - await ctx.reply(f"2 players have joined, tic tac toe game starting... <@{user1.id}>, <@{user2.id}>") + await ctx.reply( + f"2 players have joined, tic tac toe game starting... <@{user1.id}>, <@{user2.id}>" + ) except asyncio.TimeoutError: await ctx.reply("No one joined, please try again later!") return - - #tic tac toe game - board = [[" "," "," "],[" "," "," "],[" "," "," "]] + + # tic tac toe game + board = [[" ", " ", " "], [" ", " ", " "], [" ", " ", " "]] player1 = user1 player2 = user2 turn = 0 while True: if turn == 0: turn = 1 - await ctx.send(f"{player1.mention}'s turn! Type a number from 1 to 9 to place a marker on the board") + await ctx.send( + f"{player1.mention}'s turn! Type a number from 1 to 9 to place a marker on the board" + ) while True: try: - message = await self.client.wait_for('message', timeout=45, check=lambda m: m.author == player1) + message = await self.client.wait_for( + "message", timeout=45, check=lambda m: m.author == player1 + ) try: - selected = int(message.content)-1 - #restrict number to 1-9 + selected = int(message.content) - 1 + # restrict number to 1-9 if selected < 0 or selected > 8: await message.reply("Invalid number, please try again") continue - #prevent overwriting - if board[int(selected/3)][int(selected%3)] != " ": + # prevent overwriting + if board[int(selected / 3)][int(selected % 3)] != " ": await message.reply("You can't overwrite a marker!") else: - if int(message.content) and int(message.content) in range(1,10): - board[int(selected/3)][int(selected%3)] = "x" + if int(message.content) and int( + message.content + ) in range(1, 10): + board[int(selected / 3)][int(selected % 3)] = "x" break else: - await message.reply("Please enter a valid number from 1 to 9") + await message.reply( + "Please enter a valid number from 1 to 9" + ) except ValueError: await message.reply("Please enter a number from 1 to 9") continue @@ -69,26 +91,34 @@ def check(reaction, user): await message.reply("Timeout") return else: - turn = 0 - await ctx.send(f"{player2.mention}'s turn! Type a number from 1 to 9 to place a marker on the board") + turn = 0 + await ctx.send( + f"{player2.mention}'s turn! Type a number from 1 to 9 to place a marker on the board" + ) while True: try: - message = await self.client.wait_for('message', timeout=45, check=lambda m: m.author == player2) + message = await self.client.wait_for( + "message", timeout=45, check=lambda m: m.author == player2 + ) try: - selected = int(message.content)-1 - #restrict number to 1-9 + selected = int(message.content) - 1 + # restrict number to 1-9 if selected < 0 or selected > 8: await message.reply("Invalid number, please try again") continue - #prevent overwriting - if board[int(selected/3)][int(selected%3)] != " ": + # prevent overwriting + if board[int(selected / 3)][int(selected % 3)] != " ": await message.reply("You can't overwrite a marker!") else: - if int(message.content) and int(message.content) in range(1,10): - board[int(selected/3)][int(selected%3)] = "o" + if int(message.content) and int( + message.content + ) in range(1, 10): + board[int(selected / 3)][int(selected % 3)] = "o" break else: - await message.reply("Please enter a valid number from 1 to 9") + await message.reply( + "Please enter a valid number from 1 to 9" + ) except ValueError: await message.reply("Please enter a number from 1 to 9") continue @@ -106,51 +136,75 @@ def check(reaction, user): string += toAdd string += "\n" await message.reply(f"```{string}```") - if board[0][0] == board[1][1] == board[2][2] == "X" or board[0][0] == board[1][1] == board[2][2] == "o": #diagonals + if ( + board[0][0] == board[1][1] == board[2][2] == "X" + or board[0][0] == board[1][1] == board[2][2] == "o" + ): # diagonals if board[0][0] == "x": await ctx.reply(f"{player1.mention} wins!") else: await ctx.reply(f"{player2.mention} wins!") break - elif board[0][2] == board[1][1] == board[2][0] == "X" or board[0][2] == board[1][1] == board[2][0] == "o": + elif ( + board[0][2] == board[1][1] == board[2][0] == "X" + or board[0][2] == board[1][1] == board[2][0] == "o" + ): if board[0][2] == "x": await ctx.reply(f"{player1.mention} wins!") else: await ctx.reply(f"{player2.mention} wins!") break - #horizontal - elif board[0][0] == board[0][1] == board[0][2] == "x" or board[0][0] == board[0][1] == board[0][2] == "o": + # horizontal + elif ( + board[0][0] == board[0][1] == board[0][2] == "x" + or board[0][0] == board[0][1] == board[0][2] == "o" + ): if board[0][0] == "x": await ctx.reply(f"{player1.mention} wins!") else: await ctx.reply(f"{player2.mention} wins!") break - elif board[1][0] == board[1][1] == board[1][2] == "x" or board[1][0] == board[1][1] == board[1][2] == "o": + elif ( + board[1][0] == board[1][1] == board[1][2] == "x" + or board[1][0] == board[1][1] == board[1][2] == "o" + ): if board[1][0] == "x": await ctx.reply(f"{player1.mention} wins!") else: await ctx.reply(f"{player2.mention} wins!") break - elif board[2][0] == board[2][1] == board[2][2] == "x" or board[2][0] == board[2][1] == board[2][2] == "o": + elif ( + board[2][0] == board[2][1] == board[2][2] == "x" + or board[2][0] == board[2][1] == board[2][2] == "o" + ): if board[2][0] == "x": await ctx.reply(f"{player1.mention} wins!") else: await ctx.reply(f"{player2.mention} wins!") break - #vertical - elif board[0][0] == board[1][0] == board[2][0] == "x" or board[0][0] == board[1][0] == board[2][0] == "o": + # vertical + elif ( + board[0][0] == board[1][0] == board[2][0] == "x" + or board[0][0] == board[1][0] == board[2][0] == "o" + ): if board[0][0] == "x": await ctx.reply(f"{player1.mention} wins!") else: await ctx.reply(f"{player2.mention} wins!") break - elif board[0][1] == board[1][1] == board[2][1] == "x" or board[0][1] == board[1][1] == board[2][1] == "o": + elif ( + board[0][1] == board[1][1] == board[2][1] == "x" + or board[0][1] == board[1][1] == board[2][1] == "o" + ): if board[0][1] == "x": await ctx.reply(f"{player1.mention} wins!") else: await ctx.reply(f"{player2.mention} wins!") break - elif board[0][2] == board[1][2] == board[2][2] == "x" or board[0][2] == board[1][2] == board[2][2] == "o": + elif ( + board[0][2] == board[1][2] == board[2][2] == "x" + or board[0][2] == board[1][2] == board[2][2] == "o" + ): if board[0][2] == "x": await ctx.reply(f"{player1.mention} wins!") else: @@ -160,7 +214,7 @@ def check(reaction, user): await ctx.reply("Draw!") break await ctx.send("Game over, please start a new game!") - + def setup(client): client.add_cog(TicTacToe(client)) diff --git a/cogs/todo.py b/cogs/todo.py index 216a05b..2417b14 100644 --- a/cogs/todo.py +++ b/cogs/todo.py @@ -1,27 +1,28 @@ import discord from discord.ext import commands -import firebase_admin +import firebase_admin from firebase_admin import firestore from utils import check + class Todo(commands.Cog): def __init__(self, client): self.client = client self.db = firestore.client() self.initation = self.client.get_cog("Initiation") self.hidden = True - + @check.is_staff() @commands.command() async def todoADD(self, ctx, *msg): task = " ".join(msg) self.initation = self.client.get_cog("Initiation") await self.initation.checkserver(ctx) - doc_ref = self.db.collection(u'servers').document(str(ctx.guild.id)) + doc_ref = self.db.collection("servers").document(str(ctx.guild.id)) doc = doc_ref.get() data = doc.to_dict() try: - data["todo"].append(task) + data["todo"].append(task) except KeyError: data["todo"] = [task] doc_ref.set(data) @@ -32,7 +33,7 @@ async def todoADD(self, ctx, *msg): async def todo(self, ctx): self.initation = self.client.get_cog("Initiation") await self.initation.checkserver(ctx) - doc_ref = self.db.collection(u'servers').document(str(ctx.guild.id)) + doc_ref = self.db.collection("servers").document(str(ctx.guild.id)) doc = doc_ref.get() data = doc.to_dict() count = 0 @@ -41,21 +42,26 @@ async def todo(self, ctx): count += 1 description += f"({count}) {i} \n" embed = discord.Embed( - title='TODO LIST', description=description, colour=self.client.primary_colour) + title="TODO LIST", + description=description, + colour=self.client.primary_colour, + ) await ctx.send(embed=embed) - + @check.is_staff() @commands.command() async def todoREM(self, ctx, number): self.initation = self.client.get_cog("Initiation") await self.initation.checkserver(ctx) - doc_ref = self.db.collection(u'servers').document(str(ctx.guild.id)) + doc_ref = self.db.collection("servers").document(str(ctx.guild.id)) doc = doc_ref.get() data = doc.to_dict() try: - data["todo"].pop(int(number)-1) + data["todo"].pop(int(number) - 1) except: - await ctx.send("Item does not exist. Do note that you are supposed to state the number of the element u want to remove") + await ctx.send( + "Item does not exist. Do note that you are supposed to state the number of the element u want to remove" + ) return doc_ref.set(data) await ctx.send("Successfully removed, run `todo` to check the list") diff --git a/config.py b/config.py index 278f5a6..cc6cbb3 100644 --- a/config.py +++ b/config.py @@ -4,4 +4,4 @@ primary_colour = discord.Colour.green() error_colour = discord.Colour.teal() -icon_url = "www.google.com" \ No newline at end of file +icon_url = "www.google.com" diff --git a/start.py b/start.py index ac37ae0..8cd0feb 100644 --- a/start.py +++ b/start.py @@ -1,15 +1,18 @@ from flask import Flask from threading import Thread -app = Flask('') +app = Flask("") -@app.route('/') + +@app.route("/") def home(): return "Hallooooooo." + def run(): - app.run(host='0.0.0.0',port=8080) + app.run(host="0.0.0.0", port=8080) + def keep_alive(): t = Thread(target=run) - t.start() \ No newline at end of file + t.start() diff --git a/utils/check.py b/utils/check.py index 871fe28..db012e8 100644 --- a/utils/check.py +++ b/utils/check.py @@ -1,4 +1,3 @@ - import firebase_admin from firebase_admin import firestore @@ -7,9 +6,11 @@ from cogs.initiation import Initiation db = firestore.client() + + def is_staff(): async def predicate(ctx): - doc_ref = db.collection(u'admin').document(u'{}'.format("authorised")) + doc_ref = db.collection(u"admin").document(u"{}".format("authorised")) doc = doc_ref.get() people = doc.to_dict() allowed = people["owner"] + people["staff"] @@ -17,12 +18,13 @@ async def predicate(ctx): raise commands.NotOwner() else: return True - + return commands.check(predicate) + def is_owner(): async def predicate(ctx): - doc_ref = db.collection(u'admin').document(u'{}'.format("authorised")) + doc_ref = db.collection(u"admin").document(u"{}".format("authorised")) doc = doc_ref.get() people = doc.to_dict() allowed = people["owner"] @@ -30,40 +32,46 @@ async def predicate(ctx): raise commands.NotOwner() else: return True - + return commands.check(predicate) + def is_banned(): async def predicate(ctx): - doc_ref = db.collection(u'admin').document(u'{}'.format("banned")) + doc_ref = db.collection(u"admin").document(u"{}".format("banned")) doc = doc_ref.get() people = doc.to_dict() if str(ctx.author.id) in people: raise commands.MissingPermissions([]) else: return True - + return commands.check(predicate) + def is_admin(): async def predicate(ctx): - doc_ref = db.collection(u'admin').document(u'{}'.format("authorised")) + doc_ref = db.collection(u"admin").document(u"{}".format("authorised")) doc = doc_ref.get() people = doc.to_dict() allowed = people["owner"] + people["staff"] - if str(ctx.author.id) not in allowed and not ctx.message.author.guild_permissions.administrator: + if ( + str(ctx.author.id) not in allowed + and not ctx.message.author.guild_permissions.administrator + ): raise commands.MissingPermissions([]) else: return True + return commands.check(predicate) - + async def _isadmin(ctx, pri=True): - doc_ref = db.collection(u'admin').document(u'{}'.format("authorised")) + doc_ref = db.collection(u"admin").document(u"{}".format("authorised")) doc_ = doc_ref.get() if doc_.exists: doc = doc_.to_dict() - if str(ctx.author.id) in doc['owner'] or str(ctx.author.id) in doc['staff']: + if str(ctx.author.id) in doc["owner"] or str(ctx.author.id) in doc["staff"]: staff = True if ctx.message.author.guild_permissions.administrator or staff: if pri: @@ -73,4 +81,3 @@ async def _isadmin(ctx, pri=True): if pri: await ctx.reply("What made you think you did...") return False - diff --git a/utils/paginator.py b/utils/paginator.py index 71b1c6c..ce22019 100644 --- a/utils/paginator.py +++ b/utils/paginator.py @@ -9,24 +9,24 @@ import copy -#creds https://github.com/khk4912/EZPaginator/blob/master/EZPaginator/EZPaginator.py +# creds https://github.com/khk4912/EZPaginator/blob/master/EZPaginator/EZPaginator.py class Paginator: def __init__( - self, + self, client: Union[ discord.Client, discord.AutoShardedClient, commands.Bot, commands.AutoShardedBot, - ], + ], ctx: commands.Context, - message: discord.Message, - pages: List[discord.Embed], + message: discord.Message, + pages: List[discord.Embed], buttons: List[List[Button]] = [[]], previous_symbol: str = "⬅️ Previous", next_symbol: str = "Next ➡️", timeout: int = 60, - start_page:int = 0 + start_page: int = 0, ): self.client = client self.ctx = ctx @@ -38,89 +38,116 @@ def __init__( self.timeout = timeout self.page_num = start_page - if (not( + if not ( isinstance(client, discord.Client) or isinstance(client, discord.AutoShardedClient) or isinstance(client, commands.Bot) - or isinstance(client, commands.AutoShardedBot)) + or isinstance(client, commands.AutoShardedBot) ): raise TypeError("Paginator client must be a discord.Client or commands.Bot") # print("values initiated") - + async def start(self): - add_on_buttons: List[Button] = [Button(style=ButtonStyle.green, label=self.previous_symbol, disabled=True), Button(style=ButtonStyle.green, label=self.next_symbol)] + add_on_buttons: List[Button] = [ + Button(style=ButtonStyle.green, label=self.previous_symbol, disabled=True), + Button(style=ButtonStyle.green, label=self.next_symbol), + ] component = copy.copy(self.buttons) component[0] = add_on_buttons + component[0] - + # print(component) components = [add_on_buttons] await self.message.edit( - embed=self.pages[self.page_num], - components=copy.copy(component) + embed=self.pages[self.page_num], components=copy.copy(component) ) def check(interation): - return interation.message == self.message and self.ctx.author == interation.user - + return ( + interation.message == self.message + and self.ctx.author == interation.user + ) + while True: try: - res = await self.client.wait_for("button_click", timeout = self.timeout, check = check) + res = await self.client.wait_for( + "button_click", timeout=self.timeout, check=check + ) # print(res) await res.respond( - type=InteractionType.DeferredUpdateMessage # , content=f"{res.component.label} pressed" + type=InteractionType.DeferredUpdateMessage # , content=f"{res.component.label} pressed" ) if res.component.label == self.previous_symbol: self.page_num -= 1 if self.page_num <= 0: - self.page_num=0 - add_on_buttons = [Button(style=ButtonStyle.green, label=self.previous_symbol, disabled=True), Button(style=ButtonStyle.green, label=self.next_symbol)] + self.page_num = 0 + add_on_buttons = [ + Button( + style=ButtonStyle.green, + label=self.previous_symbol, + disabled=True, + ), + Button(style=ButtonStyle.green, label=self.next_symbol), + ] component = copy.copy(self.buttons) component[0] = add_on_buttons + component[0] - + # print(component) components = [add_on_buttons] await self.message.edit( embed=self.pages[self.page_num], - components=copy.copy(component) + components=copy.copy(component), ) else: - add_on_buttons = [Button(style=ButtonStyle.green, label=self.previous_symbol), Button(style=ButtonStyle.green, label=self.next_symbol)] + add_on_buttons = [ + Button(style=ButtonStyle.green, label=self.previous_symbol), + Button(style=ButtonStyle.green, label=self.next_symbol), + ] component = copy.copy(self.buttons) component[0] = add_on_buttons + component[0] - + # print(component) components = [add_on_buttons] await self.message.edit( embed=self.pages[self.page_num], - components=copy.copy(component) + components=copy.copy(component), ) elif res.component.label == self.next_symbol: self.page_num += 1 - if self.page_num >= len(self.pages)-1: - self.page_num = len(self.pages)-1 - add_on_buttons = [Button(style=ButtonStyle.green, label=self.previous_symbol), Button(style=ButtonStyle.green, label=self.next_symbol, disabled=True)] + if self.page_num >= len(self.pages) - 1: + self.page_num = len(self.pages) - 1 + add_on_buttons = [ + Button(style=ButtonStyle.green, label=self.previous_symbol), + Button( + style=ButtonStyle.green, + label=self.next_symbol, + disabled=True, + ), + ] component = copy.copy(self.buttons) component[0] = add_on_buttons + component[0] - + # print(component) components = [add_on_buttons] await self.message.edit( embed=self.pages[self.page_num], - components=copy.copy(component) + components=copy.copy(component), ) else: - add_on_buttons = [Button(style=ButtonStyle.green, label=self.previous_symbol), Button(style=ButtonStyle.green, label=self.next_symbol)] + self.buttons[0] + add_on_buttons = [ + Button(style=ButtonStyle.green, label=self.previous_symbol), + Button(style=ButtonStyle.green, label=self.next_symbol), + ] + self.buttons[0] component = copy.copy(self.buttons) component[0] = add_on_buttons + component[0] - + # print(component) components = [add_on_buttons] await self.message.edit( embed=self.pages[self.page_num], - components=copy.copy(component) + components=copy.copy(component), ) except asyncio.TimeoutError: @@ -128,10 +155,8 @@ def check(interation): component = copy.copy(self.buttons) if component != [[]]: await self.message.edit( - embed=self.pages[self.page_num], - components=copy.copy(component) + embed=self.pages[self.page_num], components=copy.copy(component) ) else: await self.message.delete() return - From eb4ba4d65add7db79f9329793afea0821ec27432 Mon Sep 17 00:00:00 2001 From: Isaac Date: Tue, 20 Jul 2021 14:32:09 +0800 Subject: [PATCH 07/19] lol --- cogs/starboard.py | 61 +++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/cogs/starboard.py b/cogs/starboard.py index 0546b63..f3d89fd 100644 --- a/cogs/starboard.py +++ b/cogs/starboard.py @@ -51,40 +51,39 @@ async def on_reaction_add(self, reaction, user): print("a") return - if reaction.count > 1: - if reaction.emoji == "⭐": - try: - msg = await channel.fetch_message( - data["starboard"][str(reaction.message.id)] + if reaction.count > 1 and reaction.emoji == "⭐": + try: + msg = await channel.fetch_message( + data["starboard"][str(reaction.message.id)] + ) + await msg.edit( + embed=discord.Embed( + title=f"Starboard: {reaction.count}", + description=reaction.message.content, + color=0x00FF00, ) - await msg.edit( - embed=discord.Embed( - title=f"Starboard: {reaction.count}", - description=reaction.message.content, - color=0x00FF00, - ) - .set_footer(text=f"React with {'🌟'} to star this message") - .set_author( - name=reaction.message.author.name, - icon_url=reaction.message.author.avatar_url, - ) + .set_footer(text=f"React with {'🌟'} to star this message") + .set_author( + name=reaction.message.author.name, + icon_url=reaction.message.author.avatar_url, ) - doc_ref.set(data) - except KeyError: - message = await channel.send( - embed=discord.Embed( - title=f"Starboard: {reaction.count}", - description=reaction.message.content, - color=0x00FF00, - ) - .set_footer(text=f"React with {'🌟'} to star this message") - .set_author( - name=reaction.message.author.name, - icon_url=reaction.message.author.avatar_url, - ) + ) + doc_ref.set(data) + except KeyError: + message = await channel.send( + embed=discord.Embed( + title=f"Starboard: {reaction.count}", + description=reaction.message.content, + color=0x00FF00, ) - data["starboard"][str(reaction.message.id)] = message.id - doc_ref.set(data) + .set_footer(text=f"React with {'🌟'} to star this message") + .set_author( + name=reaction.message.author.name, + icon_url=reaction.message.author.avatar_url, + ) + ) + data["starboard"][str(reaction.message.id)] = message.id + doc_ref.set(data) def setup(client): From 971bd1a3e53f18f5601689e33be927a13b062d5f Mon Sep 17 00:00:00 2001 From: neon_paradox Date: Tue, 20 Jul 2021 14:34:04 +0800 Subject: [PATCH 08/19] yay new category for hangman this is pogz!!! (i handcrafted the list yay) --- DataBase/Maxigames | 46 ++++++++++++++++++++++++++++++++++++++++++++++ DataBase/words.txt | 1 + 2 files changed, 47 insertions(+) create mode 100644 DataBase/Maxigames diff --git a/DataBase/Maxigames b/DataBase/Maxigames new file mode 100644 index 0000000..93b1e2d --- /dev/null +++ b/DataBase/Maxigames @@ -0,0 +1,46 @@ +commands +tux +neonparadox +nianny +ajr +maxigames +beta +starboard +ticket +topgg +discord +bot +client +python +minigames +uptimerobot +dice +bigdice +kawaii +connectfour +tictactoe +hallo +current +seconds +invite +official +whoami +fibonacci +lmgtfy +counting +trivia +scramble +snakeeyes +math +suggest +coinflip +gamble +money +balance +leaderboard +hourly +daily +hangmanlist +servercount +randnum +numprop diff --git a/DataBase/words.txt b/DataBase/words.txt index fbf19ec..dad4f11 100644 --- a/DataBase/words.txt +++ b/DataBase/words.txt @@ -73,6 +73,7 @@ Languages Legal Terms Mammals Math and Numbers +Maxigames Measurement Metals Military From fa49f411de287be208242329e1f41b302b7d3bc2 Mon Sep 17 00:00:00 2001 From: Isaac Date: Tue, 20 Jul 2021 14:42:03 +0800 Subject: [PATCH 09/19] bruh --- cogs/economy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cogs/economy.py b/cogs/economy.py index 5c8983a..b34c7dc 100644 --- a/cogs/economy.py +++ b/cogs/economy.py @@ -296,7 +296,7 @@ async def _leaderboard(self, ctx): count = 1 for i in sorted(dict3.items(), key=lambda kv: (kv[1]), reverse=True): user = self.client.get_user(int(i[0])) - descriptio += f"{count}) {user.mention} - {i[1]} points\n" + description += f"{count}) {user.mention} - {i[1]} points\n" count += 1 if count > 10: break From 0440656bd644f67baaca2ea7b9bc5e4920574894 Mon Sep 17 00:00:00 2001 From: neon_paradox Date: Tue, 20 Jul 2021 14:43:15 +0800 Subject: [PATCH 10/19] :( --- cogs/economy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cogs/economy.py b/cogs/economy.py index 5c8983a..0f6d3a4 100644 --- a/cogs/economy.py +++ b/cogs/economy.py @@ -20,7 +20,7 @@ def __init__(self, client): # Curb gambling addiction @check.is_banned() @cooldown(1, 5, BucketType.user) - @commands.command(name="Coinflip", aliases=["coinflip", "cf", "kymchi"]) + @commands.command(name="Coinflip", aliases=["coinflip", "cf"]) async def _coinflip(self, ctx, choice: str, amount: int = 1): self.initation = self.client.get_cog("Initiation") await self.initation.checkserver(ctx) From 245b463f8b57b6a48fdb27e79ce833d37b796ad2 Mon Sep 17 00:00:00 2001 From: Ang Jun Ray Date: Tue, 20 Jul 2021 14:51:47 +0800 Subject: [PATCH 11/19] hangmanLB done! --- cogs/hangman.py | 74 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 3 deletions(-) diff --git a/cogs/hangman.py b/cogs/hangman.py index bdca98a..6f690e5 100644 --- a/cogs/hangman.py +++ b/cogs/hangman.py @@ -71,8 +71,8 @@ async def hangmanList(self, ctx): ) page = Paginator(self.client, ctx, msg, pages, timeout=120) await page.start() - - @commands.command() + + @commands.command(name="hangman", description="Play a hangman game and potentially win points!", usage="hangman") async def hangman(self, ctx): #! Hangman Firebase Initalisation self.initiation = self.client.get_cog("Initiation") @@ -203,6 +203,9 @@ def check(msg): if messageanswer == wordChoice: add = random.randint(1, 10) data["money"] += add + if "hangmanWins" not in data: + data["hangmanWins"] = 0 + data["hangmanWins"] += 1 embed = discord.Embed( title="You won!", description=f"Congratulations, you guessed the word {wordChoice} correctly! You have {data['money']} money now!", @@ -229,7 +232,7 @@ def check(msg): data["money"] = 0 embed = discord.Embed( title="You lost!", - description=f"The word was {wordChoice}, {deduct} money was subtracted off your account :(. You currently have f{data['money']} money", + description=f"The word was {wordChoice}, {deduct} money was subtracted off your account :(. You currently have {data['money']} money", color=0xff0000 ) await ctx.reply(embed=embed) @@ -237,6 +240,11 @@ def check(msg): elif word_guessed == 0: add = random.randint(1, 10) data["money"] += add + + if "hangmanWins" not in data: + data["hangmanWins"] = 0 + data["hangmanWins"] += 1 + embed = discord.Embed( title="You won!", description=f"Congratulations, you guessed the word {wordChoice} correctly! You have {data['money']} money now!", @@ -244,6 +252,66 @@ def check(msg): ) await ctx.reply(embed=embed) doc_ref.set(data) + + @commands.command(title="hangmanLB", description="The leaderboard for hangman", aliases=["hangmanleaderboard"]) + async def hangmanLB(self, ctx): + #! Hangman Firebase Initalisation + self.initiation = self.client.get_cog("Initiation") + await self.initiation.checkserver(ctx) + doc_ref = self.db.collection(u'users') + collection = doc_ref.stream() + + userWinData = [] + for doc in collection: + dictionary = doc.to_dict() + if "hangmanWins" in dictionary: + userWinData.append({"wins":dictionary["hangmanWins"], "name": await self.client.fetch_user(doc.id)}) + + userWinData = sorted(userWinData, key=lambda k: k['wins'], reverse=True) + #! PAGES + pages = [] + page = discord.Embed( + title="Leaderboard!", + description="Hangman leaderboard", + colour=self.client.primary_colour + ) + page.set_author(name=self.client.user.name, + icon_url=self.client.user.avatar_url) + page.set_footer(text="Press Next to see the topics :D") + pages.append(page) + + length = len(userWinData) + total_pages = length//20 + 1 + count = 0 + count1 = 0 + for i in range(0, total_pages): + count1 += 1 + string = "" + for j in range(0, 20): + count += 1 + if i*20 + j >= length: + break + curList = userWinData[i*20+j] + name = curList['name'].name + disc = curList['name'].discriminator + wins = curList['wins'] + string += f"#{count}. `{name}#{disc}`-`{wins}`\n" + + page = discord.Embed( + title=f"Page: {count1}", + description=string, + colour=self.client.primary_colour + ) + page.set_author(name=self.client.user.name, + icon_url=self.client.user.avatar_url) + pages.append(page) + + page_num = 0 + msg = await ctx.send( + embed=pages[page_num], + ) + page = Paginator(self.client, ctx, msg, pages, timeout=120) + await page.start() def setup(client): From 8be9c122add64cbe64e91261183e9531cc607833 Mon Sep 17 00:00:00 2001 From: Ang Jun Ray Date: Tue, 20 Jul 2021 18:07:15 +0800 Subject: [PATCH 12/19] test --- .gitignore | 3 ++- app.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 7ef81c6..66c66b4 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ ban.py /env main.exe #im teleporting to you yay -main.cpp \ No newline at end of file +main.cpp +serviceAccountKey2.json \ No newline at end of file diff --git a/app.py b/app.py index 0ab0f64..5e4fe99 100644 --- a/app.py +++ b/app.py @@ -16,7 +16,7 @@ data = json.load(file) client = Client(command_prefix=[data["prefixBeta"]], help_command=None) -cred = credentials.Certificate("serviceAccountKey.json") +cred = credentials.Certificate("serviceAccountKey2.json") firebase_admin.initialize_app(cred) db = firestore.client() From 80a6449d375b6efe4d8d40d6198f504563f1ac48 Mon Sep 17 00:00:00 2001 From: Isaac Date: Tue, 20 Jul 2021 18:24:37 +0800 Subject: [PATCH 13/19] Added threshold to starboard --- cogs/initiation.py | 1 + cogs/starboard.py | 27 ++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/cogs/initiation.py b/cogs/initiation.py index 9decda5..7d4b584 100644 --- a/cogs/initiation.py +++ b/cogs/initiation.py @@ -49,6 +49,7 @@ async def serverinitiate(self, ctx): { u"users": {str(ctx.author.id): self.usr}, u"all": {}, + u"starboard_threshold": 1, u"countingChannels": { "counting": { "name": "counting", diff --git a/cogs/starboard.py b/cogs/starboard.py index f3d89fd..f73beb8 100644 --- a/cogs/starboard.py +++ b/cogs/starboard.py @@ -12,6 +12,31 @@ def __init__(self, client): self.db = firestore.client() self.initiation = self.client.get_cog("Initiation") + @check.is_admin() + @commands.command( + name="starboard-threshold", + description="Starts a starboard", + usage="m!starboard #starboard", + aliases=["starthresh"] + ) + async def starboard_threshold(self, ctx, thresh: int): + self.initation = self.client.get_cog("Initiation") + await self.initation.checkserver(ctx) + doc_ref = self.db.collection("servers").document(str(ctx.guild.id)) + doc = doc_ref.get() + data = doc.to_dict() + + if thresh == None: + data["starboard_threshold"] = 5 + await ctx.reply("Reset starboard threshold to 5.") + elif type(thresh) != int or thresh < 1: + await ctx.reply("Must set to a positive integer!") + else: + data["starboard_threshold"] = thresh + await ctx.reply(f"Starboard threshold has been set to {thresh}!") + + doc_ref.set(data) + @check.is_admin() @commands.command( name="starboard", @@ -51,7 +76,7 @@ async def on_reaction_add(self, reaction, user): print("a") return - if reaction.count > 1 and reaction.emoji == "⭐": + if reaction.count >= data["starboard_threshold"] and reaction.emoji == "⭐": try: msg = await channel.fetch_message( data["starboard"][str(reaction.message.id)] From e6986753d71c599c43ee761f9a137d88e1d4eb7a Mon Sep 17 00:00:00 2001 From: nianny Date: Tue, 20 Jul 2021 18:32:22 +0800 Subject: [PATCH 14/19] weird stuff --- cogs/tickets.py | 72 +++++++++++++++++++++++++++++-------------------- transcript.txt | 7 +++++ 2 files changed, 50 insertions(+), 29 deletions(-) create mode 100644 transcript.txt diff --git a/cogs/tickets.py b/cogs/tickets.py index c4d7311..df0be90 100644 --- a/cogs/tickets.py +++ b/cogs/tickets.py @@ -1,7 +1,7 @@ from gc import DEBUG_SAVEALL import discord from discord.ext import commands -from discord_components import ButtonStyle, Button, InteractionType +from discord_components import ButtonStyle, Button, InteractionType, message from utils import check import firebase_admin from firebase_admin import firestore @@ -21,6 +21,9 @@ def __init__(self, client): self.messages = {} self.count = {} self.active_tickets = {} + print(self.messages) + print(self.count) + print(self.active_tickets) @@ -42,16 +45,37 @@ async def newticket(self, ctx): self.active_tickets[str(ctx.guild.id)] = {} else: self.messages[str(ctx.guild.id)].append(str(msg.id)) + doc_ref = self.db.collection(u'tickets').document('ticket-ref') + doc = doc_ref.get() + if doc.exists: + data = doc.to_dict() + data["messages"] = self.messages + data["count"] = self.count + data["active_tickets"] = self.active_tickets + else: + data = { + 'active_tickets': self.active_tickets, + 'messages': self.messages, + 'count': self.count + } + doc_ref.set(data) await ctx.message.delete() # print(self.messages) + @commands.Cog.listener() - async def on_reaction_add(self, reaction, user): - if user == self.client.user: + async def on_raw_reaction_add(self, payload): + if payload.user_id == self.client.user.id: return - if str(reaction.message.guild.id) in self.messages: - if str(reaction.message.id) in self.messages[str(reaction.message.guild.id)]: - if reaction.emoji == '🎫': - if str(user.id) in self.active_tickets[str(reaction.message.guild.id)]: + reaction_guild = self.client.get_guild(payload.guild_id) + reaction_channel = self.client.get_channel(payload.channel_id) + # reaction_message = self.client.get_message(reaction_channel, payload.message_id) + print(str(payload.message_id)) + print(str(payload.guild_id)) + if str(payload.guild_id) in self.messages: + + if str(payload.message_id) in self.messages[str(payload.guild_id)]: + if payload.emoji == '🎫': + if str(payload.user_id) in self.active_tickets[str(payload.guild_id)]: embed=discord.Embed( title="Ticket Present", description="You can only have 1 ticket open per server. Please close the other ticket before starting a new one :D", @@ -71,20 +95,20 @@ async def on_reaction_add(self, reaction, user): category = await reaction.message.guild.create_category(f'open-tickets', position=0) overwrites = { reaction.message.guild.default_role: discord.PermissionOverwrite(view_channel=False), - user: discord.PermissionOverwrite(read_messages=True, add_reactions=True, send_messages=True) + payload.member: discord.PermissionOverwrite(read_messages=True, add_reactions=True, send_messages=True) } - self.count[str(reaction.message.guild.id)] += 1 - self.active_tickets[str(reaction.message.guild.id)][str(user.id)] = self.count[str(reaction.message.guild.id)] - channel = await reaction.message.guild.create_text_channel(f'ticket-{self.count[str(reaction.message.guild.id)]}', overwrites=overwrites, category=category) + self.count[str(payload.guild_id)] += 1 + self.active_tickets[str(payload.guild_id)][str(payload.user_id)] = self.count[str(payload.guild_id)] + channel = await reaction.message.guild.create_text_channel(f'ticket-{self.count[str(payload.guild_id)]}', overwrites=overwrites, category=category) embed=discord.Embed( title="New Ticket", - description=f"Welcome {user.mention} to your new ticket.", + description=f"Welcome {payload.member.mention} to your new ticket.", colour=self.client.primary_colour ) embed.set_footer(text="MaxiGames - The Best Minigame Bot", icon_url=self.client.user.avatar_url) startmsg = await channel.send(embed=embed, components=[[Button(style=ButtonStyle.grey, label="🔒 Close")]], allowed_mentions = discord.AllowedMentions.all()) - await reaction.message.remove_reaction('🎫', user) + await reaction.message.remove_reaction('🎫', payload.member) doc_ref = self.db.collection(u'tickets').document('ticket-ref') data = { @@ -96,7 +120,7 @@ async def on_reaction_add(self, reaction, user): while True: def check(interaction): - return interaction.user == user and interaction.message.channel == channel and interaction.component.label == "🔒 Close" + return interaction.user == payload.member and interaction.message.channel == channel and interaction.component.label == "🔒 Close" res = await self.client.wait_for("button_click", check = check) await res.respond( type=InteractionType.DeferredUpdateMessage # , content=f"{res.component.label} pressed" @@ -108,19 +132,19 @@ def check(interaction): colour=self.client.primary_colour ) embed.set_footer(text="MaxiGames - The Best Minigame Bot", icon_url=self.client.user.avatar_url) - confirm = await channel.send(embed=confirmation, components=[[Button(style=ButtonStyle.red, label="Delete"), Button(style=ButtonStyle.grey, label="Cancel")]]) + confirm = await channel.send(embed=confirmation, components=[[Button(style=ButtonStyle.red, label="Close"), Button(style=ButtonStyle.grey, label="Cancel")]]) def check(interaction): - return interaction.user == user and interaction.message.channel == channel + return interaction.user == payload.member and interaction.message.channel == channel res = await self.client.wait_for("button_click", check = check) await res.respond( type=InteractionType.DeferredUpdateMessage # , content=f"{res.component.label} pressed" ) - if res.component.label == "Delete": + if res.component.label == "Close": await channel.delete() - self.active_tickets[str(reaction.message.guild.id)].pop(str(user.id)) - self.messages[str(reaction.message.guild.id)].remove(str(reaction.message.id)) + self.active_tickets[str(payload.guild_id)].pop(str(payload.user_id)) + # self.messages[str(reaction.message.guild.id)].remove(str(reaction.message.id)) doc_ref = self.db.collection(u'tickets').document('ticket-ref') data = { 'active_tickets': self.active_tickets, @@ -133,16 +157,6 @@ def check(interaction): await confirm.delete() #APPLICATIONS: VSCODE DEFENDER: bad tux! if you see this you CANNOT change any of the code :D - - @commands.Cog.listener() - async def on_disconnect(self): - doc_ref = self.db.collection(u'tickets').document('ticket-ref') - data = { - 'active_tickets': self.active_tickets, - 'messages': self.messages, - 'count': self.count - } - doc_ref.set(data) @check.is_staff() @commands.command() diff --git a/transcript.txt b/transcript.txt new file mode 100644 index 0000000..8840a07 --- /dev/null +++ b/transcript.txt @@ -0,0 +1,7 @@ +nianny#6969: df +nianny#6969: fsa +nianny#6969: ads +nianny#6969: f +nianny#6969: das +nianny#6969: sf +nianny#6969: fdda From 80567876db4c0dfd6d9b08ba5144d190c9cc8a85 Mon Sep 17 00:00:00 2001 From: neon_paradox Date: Tue, 20 Jul 2021 19:48:18 +0800 Subject: [PATCH 15/19] updated system to something tux likes because its more nice-looking :D --- cogs/general.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/cogs/general.py b/cogs/general.py index 9993dab..50b13aa 100644 --- a/cogs/general.py +++ b/cogs/general.py @@ -511,8 +511,6 @@ async def kawaii(self, ctx, *msg: str): final = "" previous_char = "" for i in words: - if i == "s" == previous_char: - continue elif i == "h" and previous_char == "s": continue elif i == "z" == previous_char: @@ -522,8 +520,17 @@ async def kawaii(self, ctx, *msg: str): else: final += i previous_char = i + new = final + first_time = 1 + while new != final or first_time = 1: + first_time = 0 + final = new + new = final.replace("zz","z").replace("ss","s") + final = new final = ( - final.replace("s", "sh") + final.replace("sh","s") + .replace("zh","z") + .replace("s", "sh") .replace("z", "zh") .replace("rr", "ww") .replace("nine", "9") From 9ca3e2187c7e7f3267316cf37df8d118b49de248 Mon Sep 17 00:00:00 2001 From: nianny Date: Tue, 20 Jul 2021 20:00:12 +0800 Subject: [PATCH 16/19] hi --- cogs/general.py | 4 +- cogs/tickets.py | 121 ++++++------------------------------------------ 2 files changed, 17 insertions(+), 108 deletions(-) diff --git a/cogs/general.py b/cogs/general.py index 50b13aa..18ada39 100644 --- a/cogs/general.py +++ b/cogs/general.py @@ -511,6 +511,8 @@ async def kawaii(self, ctx, *msg: str): final = "" previous_char = "" for i in words: + if i == "s" == previous_char: + continue elif i == "h" and previous_char == "s": continue elif i == "z" == previous_char: @@ -522,7 +524,7 @@ async def kawaii(self, ctx, *msg: str): previous_char = i new = final first_time = 1 - while new != final or first_time = 1: + while new != final or first_time == 1: first_time = 0 final = new new = final.replace("zz","z").replace("ss","s") diff --git a/cogs/tickets.py b/cogs/tickets.py index e753d83..09d4447 100644 --- a/cogs/tickets.py +++ b/cogs/tickets.py @@ -22,15 +22,8 @@ def __init__(self, client): self.messages = {} self.count = {} self.active_tickets = {} -<<<<<<< HEAD print(self.messages) - print(self.count) - print(self.active_tickets) - - - -======= ->>>>>>> 80a6449d375b6efe4d8d40d6198f504563f1ac48 + @commands.command( name="newticket", description="Creates a new message that responds to " @@ -68,17 +61,16 @@ async def newticket(self, ctx): } doc_ref.set(data) await ctx.message.delete() - # print(self.messages) @commands.Cog.listener() async def on_raw_reaction_add(self, payload): if payload.user_id == self.client.user.id: return + print(payload.guild_id) + print(payload.message_id) reaction_guild = self.client.get_guild(payload.guild_id) reaction_channel = self.client.get_channel(payload.channel_id) - # reaction_message = self.client.get_message(reaction_channel, payload.message_id) - print(str(payload.message_id)) - print(str(payload.guild_id)) + # reaction_message = reaction_channel.fetch_message(payload.message_id) if str(payload.guild_id) in self.messages: if str(payload.message_id) in self.messages[str(payload.guild_id)]: @@ -93,27 +85,26 @@ async def on_raw_reaction_add(self, payload): text="MaxiGames - The Best Minigame Bot", icon_url=self.client.user.avatar_url, ) - await reaction.message.channel.send(embed=embed) + await reaction_channel.send(embed=embed) return print("New ticket") found = False - for category in reaction.message.guild.categories: + for category in reaction_guild.categories: if category.name == "open-tickets": found = True break if not found: - category = await reaction.message.guild.create_category( + category = await reaction_guild.create_category( f"open-tickets", position=0 ) overwrites = { -<<<<<<< HEAD - reaction.message.guild.default_role: discord.PermissionOverwrite(view_channel=False), + reaction_guild.default_role: discord.PermissionOverwrite(view_channel=False), payload.member: discord.PermissionOverwrite(read_messages=True, add_reactions=True, send_messages=True) } self.count[str(payload.guild_id)] += 1 self.active_tickets[str(payload.guild_id)][str(payload.user_id)] = self.count[str(payload.guild_id)] - channel = await reaction.message.guild.create_text_channel(f'ticket-{self.count[str(payload.guild_id)]}', overwrites=overwrites, category=category) + channel = await reaction_guild.create_text_channel(f'ticket-{self.count[str(payload.guild_id)]}', overwrites=overwrites, category=category) embed=discord.Embed( title="New Ticket", @@ -122,41 +113,7 @@ async def on_raw_reaction_add(self, payload): ) embed.set_footer(text="MaxiGames - The Best Minigame Bot", icon_url=self.client.user.avatar_url) startmsg = await channel.send(embed=embed, components=[[Button(style=ButtonStyle.grey, label="🔒 Close")]], allowed_mentions = discord.AllowedMentions.all()) - await reaction.message.remove_reaction('🎫', payload.member) -======= - reaction.message.guild.default_role: discord.PermissionOverwrite( - view_channel=False - ), - user: discord.PermissionOverwrite( - read_messages=True, add_reactions=True, send_messages=True - ), - } - self.count[str(reaction.message.guild.id)] += 1 - self.active_tickets[str(reaction.message.guild.id)][ - str(user.id) - ] = self.count[str(reaction.message.guild.id)] - channel = await reaction.message.guild.create_text_channel( - f"ticket-{self.count[str(reaction.message.guild.id)]}", - overwrites=overwrites, - category=category, - ) - - embed = discord.Embed( - title="New Ticket", - description=f"Welcome {user.mention} to your new ticket.", - colour=self.client.primary_colour, - ) - embed.set_footer( - text="MaxiGames - The Best Minigame Bot", - icon_url=self.client.user.avatar_url, - ) - startmsg = await channel.send( - embed=embed, - components=[[Button(style=ButtonStyle.grey, label="🔒 Close")]], - allowed_mentions=discord.AllowedMentions.all(), - ) - await reaction.message.remove_reaction("🎫", user) ->>>>>>> 80a6449d375b6efe4d8d40d6198f504563f1ac48 + await reaction_message.remove_reaction('🎫', payload.member) doc_ref = self.db.collection("tickets").document("ticket-ref") data = { @@ -169,18 +126,8 @@ async def on_raw_reaction_add(self, payload): while True: def check(interaction): -<<<<<<< HEAD return interaction.user == payload.member and interaction.message.channel == channel and interaction.component.label == "🔒 Close" res = await self.client.wait_for("button_click", check = check) -======= - return ( - interaction.user == user - and interaction.message.channel == channel - and interaction.component.label == "🔒 Close" - ) - - res = await self.client.wait_for("button_click", check=check) ->>>>>>> 80a6449d375b6efe4d8d40d6198f504563f1ac48 await res.respond( type=InteractionType.DeferredUpdateMessage # , content=f"{res.component.label} pressed" ) @@ -203,7 +150,6 @@ def check(interaction): ] ], ) -<<<<<<< HEAD embed.set_footer(text="MaxiGames - The Best Minigame Bot", icon_url=self.client.user.avatar_url) confirm = await channel.send(embed=confirmation, components=[[Button(style=ButtonStyle.red, label="Close"), Button(style=ButtonStyle.grey, label="Cancel")]]) @@ -211,62 +157,23 @@ def check(interaction): return interaction.user == payload.member and interaction.message.channel == channel res = await self.client.wait_for("button_click", check = check) -======= - - def check(interaction): - return ( - interaction.user == user - and interaction.message.channel == channel - ) - - res = await self.client.wait_for("button_click", check=check) ->>>>>>> 80a6449d375b6efe4d8d40d6198f504563f1ac48 await res.respond( type=InteractionType.DeferredUpdateMessage # , content=f"{res.component.label} pressed" ) if res.component.label == "Close": await channel.delete() -<<<<<<< HEAD - self.active_tickets[str(payload.guild_id)].pop(str(payload.user_id)) # self.messages[str(reaction.message.guild.id)].remove(str(reaction.message.id)) + self.active_tickets[str(payload.guild_id)].pop(str(payload.user_id)) doc_ref = self.db.collection(u'tickets').document('ticket-ref') -======= - self.active_tickets[str(reaction.message.guild.id)].pop( - str(user.id) - ) - self.messages[str(reaction.message.guild.id)].remove( - str(reaction.message.id) - ) - doc_ref = self.db.collection("tickets").document( - "ticket-ref" - ) ->>>>>>> 80a6449d375b6efe4d8d40d6198f504563f1ac48 data = { - "active_tickets": self.active_tickets, - "messages": self.messages, - "count": self.count, + 'active_tickets': self.active_tickets, + 'messages': self.messages, + 'count': self.count } doc_ref.set(data) break else: await confirm.delete() - -<<<<<<< HEAD - #APPLICATIONS: VSCODE DEFENDER: bad tux! if you see this you CANNOT change any of the code :D -======= - # APPLICATIONS: VSCODE DEFENDER: bad tux! if you see this you CANNOT change any of the code :D - - @commands.Cog.listener() - async def on_disconnect(self): - doc_ref = self.db.collection("tickets").document("ticket-ref") - data = { - "active_tickets": self.active_tickets, - "messages": self.messages, - "count": self.count, - } - doc_ref.set(data) ->>>>>>> 80a6449d375b6efe4d8d40d6198f504563f1ac48 - @check.is_staff() @commands.command() async def deletechannel(self, ctx): From 85abd8033389fc4936250bc27590c6a3adb7ca96 Mon Sep 17 00:00:00 2001 From: Ang Jun Ray Date: Tue, 20 Jul 2021 20:01:58 +0800 Subject: [PATCH 17/19] Update starboard.py --- cogs/starboard.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cogs/starboard.py b/cogs/starboard.py index f73beb8..d0f28d0 100644 --- a/cogs/starboard.py +++ b/cogs/starboard.py @@ -17,9 +17,9 @@ def __init__(self, client): name="starboard-threshold", description="Starts a starboard", usage="m!starboard #starboard", - aliases=["starthresh"] + aliases=["starthresh", "starcount"] ) - async def starboard_threshold(self, ctx, thresh: int): + async def starboard_threshold(self, ctx, thresh: int = None): self.initation = self.client.get_cog("Initiation") await self.initation.checkserver(ctx) doc_ref = self.db.collection("servers").document(str(ctx.guild.id)) @@ -54,6 +54,7 @@ async def starboard(self, ctx, channel: discord.TextChannel = None): doc = doc_ref.get() data = doc.to_dict() data["starboard"] = {"channel": channel.id} + data["starboard_threshold"] = 5 doc_ref.set(data) await ctx.reply(f"Starboard channel has been set to {channel}!") except: From f5c0a30a938e2f5f6f0c22be942c2ea12758848a Mon Sep 17 00:00:00 2001 From: Isaac Date: Tue, 20 Jul 2021 20:58:49 +0800 Subject: [PATCH 18/19] settings!! --- cogs/getsettings.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 cogs/getsettings.py diff --git a/cogs/getsettings.py b/cogs/getsettings.py new file mode 100644 index 0000000..6f586b2 --- /dev/null +++ b/cogs/getsettings.py @@ -0,0 +1,36 @@ +import discord +from discord.ext import commands +import firebase_admin +from firebase_admin import firestore +from utils import check + + +class GetSettings(commands.Cog): + def __init__(self, client): + self.client = client + self.hidden = True + self.db = firestore.client() + self.initiation = self.client.get_cog("Initiation") + + @commands.command( + name="getsettings", + description="Views current MaxiGames settings :D", + usage="getsettings", + aliases=["gs", "tux"] + ) + async def getsettings(self, ctx): + self.initation = self.client.get_cog("Initiation") + await self.initation.checkserver(ctx) + doc_ref = self.db.collection("servers").document(str(ctx.guild.id)) + doc = doc_ref.get() + data = doc.to_dict() + + m = "" + for k, v in data.items(): + m += (f"\n**{k}**:\n {v}\n") + + await ctx.send(m) + + +def setup(client): + client.add_cog(Starboard(client)) From 8527465fd224f7c3abe8797cbd84ca319a3bd0e4 Mon Sep 17 00:00:00 2001 From: Ang Jun Ray Date: Tue, 20 Jul 2021 21:32:14 +0800 Subject: [PATCH 19/19] made getsettings in general --- cogs/general.py | 26 +++++++++++++++++++++++++- cogs/getsettings.py | 36 ------------------------------------ 2 files changed, 25 insertions(+), 37 deletions(-) delete mode 100644 cogs/getsettings.py diff --git a/cogs/general.py b/cogs/general.py index 9993dab..2cc1b8b 100644 --- a/cogs/general.py +++ b/cogs/general.py @@ -7,7 +7,8 @@ import random from discord_slash import cog_ext, SlashContext from utils.paginator import Paginator - +from utils import check +from firebase_admin import firestore class General(commands.Cog): def __init__(self, client): @@ -22,6 +23,9 @@ def __init__(self, client): 6: "Sunday", } self.hidden = False + self.client = client + self.db = firestore.client() + self.initiation = self.client.get_cog("Initiation") @commands.command() async def hallo(self, ctx): @@ -535,6 +539,26 @@ async def kawaii(self, ctx, *msg: str): await ctx.reply(final) + @commands.command( + name="getsettings", + description="Views current MaxiGames settings :D", + usage="getsettings", + aliases=["gs", "tux"], + ) + @check.is_staff() + async def getsettings(self, ctx): + self.initiation = self.client.get_cog("Initiation") + await self.initiation.checkserver(ctx) + doc_ref = self.db.collection("servers").document(str(ctx.guild.id)) + doc = doc_ref.get() + data = doc.to_dict() + + m = "" + for k, v in data.items(): + m += (f"\n**{k}**:\n {v}\n") + + await ctx.send(m) + def setup(client): client.add_cog(General(client)) diff --git a/cogs/getsettings.py b/cogs/getsettings.py deleted file mode 100644 index 6f586b2..0000000 --- a/cogs/getsettings.py +++ /dev/null @@ -1,36 +0,0 @@ -import discord -from discord.ext import commands -import firebase_admin -from firebase_admin import firestore -from utils import check - - -class GetSettings(commands.Cog): - def __init__(self, client): - self.client = client - self.hidden = True - self.db = firestore.client() - self.initiation = self.client.get_cog("Initiation") - - @commands.command( - name="getsettings", - description="Views current MaxiGames settings :D", - usage="getsettings", - aliases=["gs", "tux"] - ) - async def getsettings(self, ctx): - self.initation = self.client.get_cog("Initiation") - await self.initation.checkserver(ctx) - doc_ref = self.db.collection("servers").document(str(ctx.guild.id)) - doc = doc_ref.get() - data = doc.to_dict() - - m = "" - for k, v in data.items(): - m += (f"\n**{k}**:\n {v}\n") - - await ctx.send(m) - - -def setup(client): - client.add_cog(Starboard(client))