commit 95326e59b0c3e546dc46d8be6ec297ad021f685b Author: tropii <97747461+TropiiDev@users.noreply.github.com> Date: Fri Nov 24 14:47:19 2023 -0500 First Commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..16ae723 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/venv +.env +test.py +/commands/__pycache__ +/ext/__pycache__ diff --git a/bot.py b/bot.py new file mode 100644 index 0000000..d281aca --- /dev/null +++ b/bot.py @@ -0,0 +1,86 @@ +from commands import help, ticket + +# pip install imports +import discord, aiofiles +from discord.ext import commands + +from dotenv import load_dotenv +import asyncio +import pymongo + +# sys imports +import os +import logging +import logging.handlers + +load_dotenv() + +import sentry_sdk +sentry_sdk.init( + dsn=os.getenv("key"), + + # Set traces_sample_rate to 1.0 to capture 100% + # of transactions for performance monitoring. + # We recommend adjusting this value in production. + traces_sample_rate=1.0 +) + +def get_server_prefix(bot, message): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.prefixes + + if coll.find_one({"_id":message.guild.id}): + prefix = coll.find_one({"_id":message.guild.id})["prefix"] + return prefix + +# startup stuff +load_dotenv() + +intents = discord.Intents().default() +intents.message_content = True +intents.guilds = True +intents.members = True + +# create the bot +class MyBot(commands.Bot): + def __init__(self): + super().__init__(command_prefix=get_server_prefix, intents = intents) + self.synced = False + self.warnings = {} + self.remove_command("help") + + async def setup_hook(self): + self.add_view(help.SelectView()) + self.add_view(ticket.CreateButton()) + self.add_view(ticket.CloseButton()) + self.add_view(ticket.TrashButton()) + print(f'\33[32mLogged in as {self.user} (ID: {self.user.id})') + print('------') + + async def load_extensions(self): + for name in os.listdir('./commands'): + if name.endswith('.py'): + await self.load_extension(f'commands.{name[:-3]}') + + async def on_ready(self): + await self.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=f"over {len(self.guilds)} servers!")) + + guild = bot.get_guild(1177434657604775936) + + # find the channel named "commands" + owner = guild.owner + await owner.send("Hello Again!\n\nThis is an official message from the developer of Blob. We are continuing development of Blob and it will resume normal operations shortly.\n\nA lot has changed since the last time Blob was online. We are here to address your issues with our new discord server. Please join [now](https://discord.gg/A2EQDvA6sN).\n\nI (Tropii) hate to send messages to server owners like you with stuff like this, I do apologize. For further information please join the support server below!\n\nTake care - Tropii.\n\nHave any conerns? Feel free to add me `fstropii`") + +# making var for commands in this file +bot = MyBot() + +# start bot +async def main(): + async with bot: + await bot.load_extensions() + await bot.start(os.getenv("token")) + await asyncio.sleep(0.1) + await asyncio.sleep(0.1) + +asyncio.run(main()) diff --git a/commands/afk.py b/commands/afk.py new file mode 100644 index 0000000..41130a2 --- /dev/null +++ b/commands/afk.py @@ -0,0 +1,82 @@ +import discord, pymongo, os +from discord import app_commands +from discord.ext import commands +from discord.utils import get + +from dotenv import load_dotenv + +load_dotenv() + +# local imports +import ext.guildid as guildid +from ext.afks import afks + +def remove(afk): + if "[AFK]" in afk.split(): + return " ".join(afk.split()[1:]) + else: + return afk + +class afk(commands.Cog): + def __init__(self, bot): + self.bot = bot + + def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"afk"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"afk"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + + @commands.Cog.listener() + async def on_ready(self): + print("AFK Online") + + @commands.Cog.listener() + async def on_message(self, message): + if message.author.bot: + return + if message.author.id in afks.keys(): + afks.pop(message.author.id) + try: + await message.author.edit(nick=remove(message.author.display_name)) + except: + pass + await message.channel.send(f"{message.author.mention} is no longer AFK") + + for id, reason in afks.items(): + if id == self.bot.user.id: + return + member = get(message.guild.members, id=id) + if (message.reference and member == (await message.channel.fetch_message(message.reference.message_id)).author) or member.id in message.raw_mentions: + await message.reply(f"{member.display_name} is AFK: {reason}") + + @commands.hybrid_command(name="afk", description="Set your status to AFK - not hidden from members") + @commands.check(is_enabled) + async def afk(self, ctx, *, reason:str = None): + if ctx.author.id in afks.keys(): + afks.pop(ctx.author.id) + else: + try: + await ctx.author.edit(nick=f"[AFK] {ctx.author.display_name}") + except: + pass + + afks[ctx.author.id] = reason + em = discord.Embed(title=f":zzz: Member AFK", description=f"{ctx.author.mention} has went AFK", color=0x00ff00) + em.set_thumbnail(url=ctx.author.avatar) + em.set_author(name=self.bot.user.name, icon_url=self.bot.user.avatar) + em.add_field(name="AFK Note: ", value=reason) + em.set_footer(text=f"Powered by {self.bot.user.name}", icon_url=self.bot.user.avatar) + await ctx.send(embed=em) + +async def setup(bot): + await bot.add_cog(afk(bot)) \ No newline at end of file diff --git a/commands/announce.py b/commands/announce.py new file mode 100644 index 0000000..afb6300 --- /dev/null +++ b/commands/announce.py @@ -0,0 +1,89 @@ +import discord, pymongo, asyncio, os +from discord.ext import commands +from dotenv import load_dotenv + +load_dotenv() + +class announce(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("Announce Online") + + def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"announce"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"announce"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + + @commands.hybrid_command(name="asetup", description="Setup the announce command") + @commands.has_permissions(administrator=True) + async def asetup(self, ctx, channel: discord.TextChannel): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.announce + + if coll.find_one({"_id": {"guild_id": ctx.guild.id}}): + await ctx.send("You have already made an announcement channel") + await ctx.send("If you would like to delete this setting please say 'delete' in the next 10 seconds") + + # if the user says delete, then delete the entry in the database + def check(m): + return m.author == ctx.author and m.channel == ctx.channel + + try: + msg = await self.bot.wait_for("message", check=check, timeout=10) + if msg.content == "delete": + a = coll.find_one({"_id": {"guild_id": ctx.guild.id}}) + b = a["channel"] + coll.delete_one({"_id": {"guild_id": ctx.guild.id}, channel: b}) + await ctx.send("Deleted the announcement channel") + except asyncio.TimeoutError: + await ctx.send("You took too long to respond") + return + + else: + coll.insert_one({"_id": {"guild_id": ctx.guild.id}, "channel": channel.id}) + await ctx.send("Announcement channel set") + + @commands.hybrid_command(name="announce", description="Announce something") + @commands.has_permissions(administrator=True) + @commands.check(is_enabled) + async def announce(self, ctx, *, message): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.announce + + ak = coll.find_one({"_id": {"guild_id": ctx.guild.id}}) + + await ctx.send(ak) + + + if coll.find_one({"_id": {"guild_id": ctx.guild.id}}): + channel = coll.find_one({"_id": {"guild_id": ctx.guild.id}, "channel": ctx.channel.id}) + if channel == False: + await ctx.send("You can only use this command in the announcement channel") + return + else: + newchannel = channel['channel'] + channelll = self.bot.get_channel(newchannel) + await channelll.send(message) + await ctx.send("Announcement sent", delete_after=2) + + else: + await ctx.send("You have not set an announcement channel yet") + + +async def setup(bot): + await bot.add_cog(announce(bot)) \ No newline at end of file diff --git a/commands/avatar.py b/commands/avatar.py new file mode 100644 index 0000000..ee54e08 --- /dev/null +++ b/commands/avatar.py @@ -0,0 +1,41 @@ +import discord, pymongo, os +from discord import app_commands +from discord.ext import commands + +from dotenv import load_dotenv + +load_dotenv() + +class avatar(commands.Cog): + def __init__(self, bot): + self.bot = bot + + def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"avatar"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"avatar"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + + @commands.Cog.listener() + async def on_ready(self): + print("Avatar Online") + + @commands.hybrid_command(name="avatar", description="Shows a users avatar", aliases=['av']) + async def avatar(self, ctx, user: discord.Member = None): + if user == None: + user = ctx.author + em = discord.Embed(title=f"{user.name}'s Avatar", color=user.color) + em.set_image(url=user.avatar) + await ctx.send(embed=em) + +async def setup(bot): + await bot.add_cog(avatar(bot)) \ No newline at end of file diff --git a/commands/clear.py b/commands/clear.py new file mode 100644 index 0000000..e2b2e4b --- /dev/null +++ b/commands/clear.py @@ -0,0 +1,46 @@ +import discord, pymongo, os +from discord import app_commands +from discord.ext import commands + +from dotenv import load_dotenv + +load_dotenv() + +class clear(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("Clear Online") + + def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"clear"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"clear"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + + @commands.hybrid_command(name="clear", description="Bulk deletes messages") + @commands.has_permissions(manage_messages=True) + @commands.check(is_enabled) + async def clear(self, ctx, amount: int): + await ctx.send(f"Deleted {amount} messages", ephemeral=True, delete_after=2) + await ctx.channel.purge(limit=amount) + + @commands.hybrid_command(name="oclear", description="Bulk deletes messages but only tropii can use it") + @commands.is_owner() + async def oclear(self, ctx, amount: int): + await ctx.send(f"Deleted {amount} messages", ephemeral=True, delete_after=2) + await ctx.channel.purge(limit=amount) + +async def setup(bot): + await bot.add_cog(clear(bot)) diff --git a/commands/convo.py b/commands/convo.py new file mode 100644 index 0000000..c57f19e --- /dev/null +++ b/commands/convo.py @@ -0,0 +1,90 @@ +import discord, aiohttp, pymongo, requests, os +from discord.ext import commands + +from dotenv import load_dotenv + +load_dotenv() + +class convo(commands.Cog): + def __init__(self, bot): + self.bot = bot + + def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"convosetup"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"convosetup"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + + @commands.Cog.listener() + async def on_ready(self): + print("Convo Online") + + @commands.Cog.listener() + async def on_message(self, message): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.convo + + if message.author == self.bot.user: + return + + channel = coll.find_one({"_id": {"guild_id": message.guild.id}, "channel": message.channel.id}) + + if channel == None: + return + + else: + + if message.author == self.bot.user: + return + + if channel: + newchannel = channel['channel'] + channelll = self.bot.get_channel(newchannel) + + url = f"https://v6.rsa-api.xyz/ai/response?user_id=420&message={message.content}" + + headers = { + "Authorization": "93FxvudCWXvO", + "X-RapidAPI-Key": "5f878d0f8dmshe3320b9c7df0e88p1b8038jsnf03c5763a129", + "X-RapidAPI-Host": "random-stuff-api.p.rapidapi.com" + } + + async with aiohttp.ClientSession() as session: + async with session.get(f"https://v6.rsa-api.xyz/ai/response?user_id=420&message={message.content}") as response: + response = requests.request("GET", url, headers=headers) + + await channelll.send(response.json()['message']) + + @commands.hybrid_command(name="convosetup", description="Sets up a conversation channel") + @commands.has_permissions(administrator=True) + @commands.check(is_enabled) + async def convosetup(self, ctx, channel: discord.TextChannel = None): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.convo + + if channel == None: + channel = ctx.channel + + channell = coll.find_one({"_id": {"guild_id": ctx.guild.id}, "channel": channel.id}) + + if channell == None: + coll.insert_one({"_id": {"guild_id": ctx.guild.id}, "channel": channel.id}) + await ctx.send("Conversation channel setup!") + + else: + await ctx.send("Conversation channel is already setup!") + + +async def setup(bot): + await bot.add_cog(convo(bot)) \ No newline at end of file diff --git a/commands/cookie.py b/commands/cookie.py new file mode 100644 index 0000000..6dfb36f --- /dev/null +++ b/commands/cookie.py @@ -0,0 +1,38 @@ +import discord, pymongo, os +from discord.ext import commands + +from dotenv import load_dotenv + +load_dotenv() + +class cookie(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("Cookie Online") + + def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"cookie"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"cookie"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + + @commands.hybrid_command(name="cookie", description="Recieve a cookie") + @commands.check(is_enabled) + async def cookie(self, ctx): + await ctx.send("Here you go, take a cookie") + + +async def setup(bot): + await bot.add_cog(cookie(bot)) \ No newline at end of file diff --git a/commands/dictionary.py b/commands/dictionary.py new file mode 100644 index 0000000..3ea0b68 --- /dev/null +++ b/commands/dictionary.py @@ -0,0 +1,52 @@ +import discord, pymongo, aiohttp, os +from discord import app_commands +from discord.ext import commands + +from dotenv import load_dotenv + +load_dotenv() + +class dictionary(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("Dictionary Online") + + def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"dictionary"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"dictionary"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + + @commands.hybrid_command(name="dictionary", description="Searches a word in the dictionary") + @commands.check(is_enabled) + async def dictionary(self, ctx, *, term: str): + url = "https://mashape-community-urban-dictionary.p.rapidapi.com/define" + querystring = {"term":term} + + headers = { + 'x-rapidapi-host': "mashape-community-urban-dictionary.p.rapidapi.com", + 'x-rapidapi-key': "5f878d0f8dmshe3320b9c7df0e88p1b8038jsnf03c5763a129" + } + async with aiohttp.ClientSession() as session: + async with session.get(url, headers=headers, params=querystring) as response: + r = await response.json() + definition = r['list'][0]['definition'] + embed = discord.Embed(title=f"First result for: {term}", description=None) + embed.add_field(name=term, value=definition, inline=False) + + await ctx.send(embed=embed) + +async def setup(bot): + await bot.add_cog(dictionary(bot)) \ No newline at end of file diff --git a/commands/economy.py b/commands/economy.py new file mode 100644 index 0000000..a213eeb --- /dev/null +++ b/commands/economy.py @@ -0,0 +1,146 @@ +import discord, pymongo, random, os +from discord.ext import commands + +from dotenv import load_dotenv + +load_dotenv() + +class economy(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("Economy Online") + + @commands.hybrid_command(name="beg", description="Beg for money") + @commands.cooldown(1, 60, commands.BucketType.user) + async def beg(self, ctx): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.economy + num = random.randint(1, 100) + try: + coll.insert_one({"_id": {'author_id': ctx.author.id, 'guild_id': ctx.guild.id}, "coins":num}) + await ctx.send(f"{ctx.author.mention} begged for money and got {num} bloboons!") + except pymongo.errors.DuplicateKeyError: + coll.update_one({"_id": {'author_id': ctx.author.id, 'guild_id': ctx.guild.id}}, {"$inc":{"coins":num}}) + await ctx.send(f"{ctx.author.mention} begged for money and got {num} bloboons!") + + @commands.hybrid_command(name="balance", description="Check your balance", aliases=["bal"]) + @commands.cooldown(1, 60, commands.BucketType.user) + async def balance(self, ctx, member:discord.Member = None): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.economy + if member == None: + member = ctx.author + users = coll.find({}) + for user in users: + if user["_id"]["author_id"] == member.id and user["_id"]["guild_id"] == ctx.guild.id: + await ctx.send(f"{member.mention} has {user['coins']} coins!") + return + await ctx.send(f"{member.mention} has 0 bloboons!") + + @commands.hybrid_command(name="pay", description="Pay someone") + @commands.cooldown(1, 60, commands.BucketType.user) + async def pay(self, ctx, member:discord.Member, amount:int): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.economy + users = coll.find({}) + for user in users: + if user["_id"]["author_id"] == ctx.author.id and user["_id"]["guild_id"] == ctx.guild.id: + if user["coins"] < amount: + await ctx.send("You don't have enough bloboons!") + return + coll.update_one({"_id": {'author_id': ctx.author.id, 'guild_id': ctx.guild.id}}, {"$inc":{"coins":-amount}}) + for user in users: + if user["_id"]["author_id"] == member.id and user["_id"]["guild_id"] == ctx.guild.id: + coll.update_one({"_id": {'author_id': member.id, 'guild_id': ctx.guild.id}}, {"$inc":{"coins":amount}}) + await ctx.send(f"You paid {member.mention} {amount} bloboons!") + return + coll.insert_one({"_id": {'author_id': member.id, 'guild_id': ctx.guild.id}, "coins":amount}) + await ctx.send(f"You paid {member.mention} {amount} bloboons!") + return + + @commands.hybrid_command(name="work", description="Work for money") + @commands.cooldown(1, 60, commands.BucketType.user) + async def work(self, ctx): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.economy + num = random.randint(1, 500) + try: + coll.insert_one({"_id": {'author_id': ctx.author.id, 'guild_id': ctx.guild.id}, "coins":num}) + await ctx.send(f"{ctx.author.mention} worked for money and got {num} bloboons!") + except pymongo.errors.DuplicateKeyError: + coll.update_one({"_id": {'author_id': ctx.author.id, 'guild_id': ctx.guild.id}}, {"$inc":{"coins":num}}) + await ctx.send(f"{ctx.author.mention} worked for money and got {num} bloboons!") + + @commands.hybrid_command(name="rob", description="Rob someone") + @commands.cooldown(1, 60, commands.BucketType.user) + async def rob(self, ctx, member:discord.Member): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.economy + users = coll.find({}) + for user in users: + if user["_id"]["author_id"] == ctx.author.id and user["_id"]["guild_id"] == ctx.guild.id: + if user["coins"] < 100: + await ctx.send("You don't have enough bloboons!") + return + for user in users: + if user["_id"]["author_id"] == member.id and user["_id"]["guild_id"] == ctx.guild.id: + if user["coins"] < 100: + await ctx.send("They don't have enough bloboons!") + return + num = random.randint(1, 100) + if num > 50: + coll.update_one({"_id": {'author_id': ctx.author.id, 'guild_id': ctx.guild.id}}, {"$inc":{"coins":100}}) + coll.update_one({"_id": {'author_id': member.id, 'guild_id': ctx.guild.id}}, {"$inc":{"coins":-100}}) + await ctx.send(f"You robbed {member.mention} and got 100 bloboons!") + return + coll.update_one({"_id": {'author_id': ctx.author.id, 'guild_id': ctx.guild.id}}, {"$inc":{"coins":-100}}) + await ctx.send(f"You failed to rob {member.mention} and lost 100 bloboons!") + return + await ctx.send("They don't have an account!") + return + + @commands.hybrid_command(name="slots", description="Play slots") + @commands.cooldown(1, 60, commands.BucketType.user) + async def slots(self, ctx, amount:int): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.economy + users = coll.find({}) + num = random.randint(1, 1000) + for user in users: + if user["_id"]["author_id"] == ctx.author.id and user["_id"]["guild_id"] == ctx.guild.id: + if user["coins"] < amount: + await ctx.send("You don't have enough bloboons!") + return + if num > 50: + coll.update_one({"_id": {'author_id': ctx.author.id, 'guild_id': ctx.guild.id}}, {"$inc":{"coins":num}}) + await ctx.send(f"You won {num} bloboons!") + return + coll.update_one({"_id": {'author_id': ctx.author.id, 'guild_id': ctx.guild.id}}, {"$inc":{"coins":-amount}}) + await ctx.send(f"You lost {amount} bloboons!") + return + + @commands.hybrid_command(name="eleaderboard", description="View the leaderboard", aliases=["elb"]) + @commands.cooldown(1, 60, commands.BucketType.user) + async def eleaderboard(self, ctx): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.economy + users = coll.find({}) + users = sorted(users, key=lambda x: x["coins"], reverse=True) + embed = discord.Embed(title="Leaderboard", description="The top 10 richest people in the server", color=discord.Color.blue()) + for i in range(10): + embed.add_field(name=f"{i+1}. {ctx.guild.get_member(users[i]['_id']['author_id']).name}", value=f"{users[i]['coins']} bloboons", inline=False) + await ctx.send(embed=embed) + + +async def setup(bot): + await bot.add_cog(economy(bot)) \ No newline at end of file diff --git a/commands/events.txt b/commands/events.txt new file mode 100644 index 0000000..4236bae --- /dev/null +++ b/commands/events.txt @@ -0,0 +1,34 @@ +from typing import Optional +import discord, pymongo, os +from discord import app_commands +from discord.ext import commands + +from dotenv import load_dotenv +load_dotenv() + +class events(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("Events Online") + + @commands.Cog.listener() + async def on_guild_join(self, guild): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.prefixes + + coll.insert_one({"_id":guild.id, "prefix":"-"}) + + @commands.Cog.listener() + async def on_guild_remove(self, guild): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.prefixes + + coll.delete_one({"_id":guild.id}) + +async def setup(bot): + await bot.add_cog(events(bot)) \ No newline at end of file diff --git a/commands/exceptions.txt b/commands/exceptions.txt new file mode 100644 index 0000000..15e6c66 --- /dev/null +++ b/commands/exceptions.txt @@ -0,0 +1,32 @@ +import discord +from discord.ext import commands + +class ExceptionHandler(commands.Cog): + def __init__(self, bot: commands.Bot) -> None: + self.bot = bot + + @commands.Cog.listener() + async def on_command_error(self, ctx: commands.Context, error) -> None: + if isinstance(error, commands.MissingRequiredArgument): + await ctx.send("Please pass in all required arguments.") + if isinstance(error, commands.MissingRole): + await ctx.send("You do not have the role required to use this command.") + if isinstance(error, commands.MissingPermissions): + await ctx.send("You do not have the required permissions to run this command.") + if isinstance(error, commands.CommandNotFound): + await ctx.send("Sorry, but that command doesn't exist. Please use `-help` to find commands") + if isinstance(error, commands.BotMissingRole): + await ctx.send("The bot doesnt have the required role to use this command.") + if isinstance(error, commands.BotMissingPermissions): + await ctx.send("The bot is missing the required permissions to use this command.") + if isinstance(error, commands.CommandInvokeError): + await ctx.send("There is something wrong with the code please ask Tropiiツ#0001 and ask him to fix the issue.") + if isinstance(error, commands.MissingAnyRole): + await ctx.send("You are missing the role to run this command please make sure you have the role and try again") + if isinstance(error, commands.CommandOnCooldown): + await ctx.send(f"This command is on cooldown please wait {round(error.retry_after * 1)} seconds before using it again") + if isinstance(error, commands.CheckFailure): + await ctx.send("This command has been disabled in your server.") + +async def setup(bot: commands.Bot) -> None: + await bot.add_cog(ExceptionHandler(bot)) \ No newline at end of file diff --git a/commands/flip.py b/commands/flip.py new file mode 100644 index 0000000..8ca812f --- /dev/null +++ b/commands/flip.py @@ -0,0 +1,45 @@ +import discord, random, pymongo, os +from discord.ext import commands + +from dotenv import load_dotenv + +load_dotenv() + +class flip(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("Flip Online") + + def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"flip"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"flip"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + + @commands.hybrid_command(name="flip", description="Flip a coin") + async def flip(self, ctx): + num = [ + '1', + '2' + ] + flipnum = random.choice(num) + if flipnum == '1': + await ctx.send("Heads!!") + elif flipnum == "2": + await ctx.send("Tails!!") + + +async def setup(bot): + await bot.add_cog(flip(bot)) \ No newline at end of file diff --git a/commands/giverole.py b/commands/giverole.py new file mode 100644 index 0000000..a6186dc --- /dev/null +++ b/commands/giverole.py @@ -0,0 +1,39 @@ +import discord, pymongo, os +from discord import app_commands +from discord.ext import commands + +from dotenv import load_dotenv + +load_dotenv() + +class giverole(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("Giverole Online") + + def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"giverole"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"giverole"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + + @commands.hybrid_command(name="giverole", description="Gives a user a role") + @commands.has_permissions(administrator=True) + async def giverole(self, ctx, user: discord.Member, role: discord.Role): + await user.add_roles(role) + await ctx.send(f"Gave {user.mention} the {role.name} role", ephemeral=True) + +async def setup(bot): + await bot.add_cog(giverole(bot)) \ No newline at end of file diff --git a/commands/guilds.py b/commands/guilds.py new file mode 100644 index 0000000..abafd6e --- /dev/null +++ b/commands/guilds.py @@ -0,0 +1,22 @@ +import discord +from discord.ext import commands + +class guilds(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("Guilds Online") + + @commands.hybrid_command(name="guilds", description="See how many guilds the bot is in") + @commands.is_owner() + async def guilds(self, ctx): + for guild in self.bot.guilds: + em = discord.Embed(title=str(guild), description=None, color=ctx.author.color) + em.add_field(name="Owner: ", value=guild.owner, inline=False) + em.add_field(name="Members: ", value=guild.member_count) + await ctx.send(embed=em) + +async def setup(bot): + await bot.add_cog(guilds(bot)) \ No newline at end of file diff --git a/commands/help.py b/commands/help.py new file mode 100644 index 0000000..9b34a90 --- /dev/null +++ b/commands/help.py @@ -0,0 +1,103 @@ +import discord, pymongo, os +from discord.ext import commands +from dotenv import load_dotenv + +load_dotenv() + +class Select(discord.ui.Select): + def __init__(self): + options=[ + discord.SelectOption(label="Staff Commands", emoji="🚫", description="Look at all the staff commands"), + discord.SelectOption(label="Normal Commands", emoji="👍", description="Look at all the normal commands") + ] + super().__init__(custom_id="helpSelect", placeholder="Choose the commands you want to view", max_values=1, min_values=1, options=options) + + async def callback(self, interaction: discord.Interaction): + if self.values[0] == "Staff Commands": + em = discord.Embed(title="Staff Commands", description="Here are all the staff commands", color=interaction.user.color) + em.add_field(name="announce", value="Announce a message in the Announcements channel (Can only be used in the official PL server), Example: -announce Announcing a message", inline=False) + em.add_field(name="clear", value="Bulk deletes messages, Example: -clear 5", inline=False) + em.add_field(name="kick", value="Kicks a member from the server, Example: -kick @Tropiiツ", inline=False) + em.add_field(name="ban", value="Ban a member from the server, Example: -ban @Tropiiツ", inline=False) + em.add_field(name="mute", value="Mutes a member, Example: -mute @Tropiiツ", inline=False) + em.add_field(name="timeout", value="Timeout a member for some time, Example: -timeout @Tropiiツ 5 (It will timeout someone for 5 minutes)", inline=False) + em.add_field(name="warn", value="Warn a member, Example: -warn @Tropiiツ being amazing", inline=False) + em.add_field(name="giverole", value="Give someone a role, Example: -giverole @Tropiiツ @Moderator", inline=False) + em.add_field(name="unmute", value="Un mutes someone, Example: -unmute @Tropiiツ", inline=False) + em.add_field(name="setnick", value="Changes someones nickname, Example: -setnick @Tropiiツ Tropii", inline=False) + em.add_field(name="clearwarns", value="Clear someones warnings, Example: -clearwarns @Tropiiツ", inline=False) + em.add_field(name="removetimeout", value="Remove someones timeout, Example: -removetimeout @Tropiiツ", inline=False) + em.add_field(name="slowmode", value="Set a channels slowmode, Example: -slowmode 2 (Will set the slowmode to 2 seconds)", inline=False) + em.add_field(name="lockdown", value="Lockdown a channel so members can't type in it, Example: -lockdown", inline=False) + em.add_field(name="unlock", value="Unlocks a channel, Example: -unlock", inline=False) + em.add_field(name="trash", value="Delete a ticket, Example: -trash", inline=False) + em.add_field(name="remove", value="Removes a role from a user, Example: -remove @Tropiiツ @Owner", inline=False) + await interaction.response.send_message(embed=em, ephemeral=True) + elif self.values[0] == "Normal Commands": + em1 = discord.Embed(title="Normal Commands", description="Here are all the normal commands", color=interaction.user.color) + em1.add_field(name="help", value="See this message, Example: -help", inline=False) + em1.add_field(name="ping", value="Show the bots latency, Example: -ping", inline=False) + em1.add_field(name="warns", value="Show a yours or a members warns, Example: -warns or -warns @Tropiiツ", inline=False) + em1.add_field(name="info", value="Check a members info, Example: -info or -info @Tropiiツ", inline=False) + em1.add_field(name="avatar", value="See a users avatar, Example: -avatar or -av @Tropiiツ", inline=False) + em1.add_field(name="membercount", value="See how many members are in a server, Example: -membercount", inline=False) + em1.add_field(name="meme", value="Look at a horrible meme, Example: -meme", inline=False) + em1.add_field(name="poll", value="Create a poll, Example: -poll 'Amazing Poll' Question1 Question2", inline=False) + em1.add_field(name="afk", value="Become AFK, Example: -afk", inline=False) + em1.add_field(name="dictionary", value="Look in the urban dictionary for a word, WARNING: If the bot responds with a error do not mention me or anything about it there is nothing wrong with the bot the word just isn't in the dictionary, Example: -dictionary Hello", inline=False) + em1.add_field(name="roleinfo", value="Get info about a role, Example: -roleinfo @Moderator", inline=False) + em1.add_field(name="ticket", value="Create a ticket, Example: -ticket I need help", inline=False) + em1.add_field(name="close", value="Close a ticket, Example: -close", inline=False) + em1.add_field(name="serverstats", value="Check and see the server stats!", inline=False) + em1.add_field(name="flip", value="Flip a coin and get heads or tails! Example: -flip", inline=False) + em1.add_field(name="remind", value="Remind yourself about something, WARNING: It lasts 1 hour, Example: -remind 1 this will last one hour", inline=False) + em1.add_field(name="omokoko", value="Custom Command requested by Woole. Example: -omokoko", inline=False) + em1.add_field(name="cookie", value="Custom Command requested by Cookie, Example: -cookie", inline=False) + em1.add_field(name="story", value="Read a nice story, Example: -story", inline=False) + em1.add_field(name="rnum", value="The bot chooses a random number, Example: -rnum 1 5 (Will choose a number between 1 and 5)", inline=False) + em1.add_field(name="beg", value="Beg for money, Example: -beg", inline=False) + em1.add_field(name="work", value="Work for money, Example: -work", inline=False) + em1.add_field(name="balance", value="Check your balance, Example: -balance", inline=False) + em1.add_field(name="pay", value="Pay someone money, Example: -pay @Tropiiツ 100", inline=False) + em1.add_field(name="leaderboard", value="See the leaderboard, Example: -leaderboard", inline=False) + em1.add_field(name="slots", value="Play slots, Example: -slots", inline=False) + em1.add_field(name="rob", value="Rob someone, Example: -rob @Tropiiツ", inline=False) + await interaction.response.send_message(embed=em1, ephemeral=True) + +class SelectView(discord.ui.View): + def __init__(self): + super().__init__(timeout=None) + self.add_item(Select()) + +class help(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("Help Online") + + def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"help"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"help"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + + @commands.hybrid_command(name="help", description="See staff commands or normal commands") + @commands.check(is_enabled) + async def help(self, ctx): + em = discord.Embed(title="Help", description="Choose Staff Commands or Normal Commands", color=ctx.author.color) + await ctx.send(embed=em, view=SelectView()) + + +async def setup(bot): + await bot.add_cog(help(bot)) \ No newline at end of file diff --git a/commands/info.py b/commands/info.py new file mode 100644 index 0000000..8ab22fc --- /dev/null +++ b/commands/info.py @@ -0,0 +1,49 @@ +import discord, pymongo, os +from dotenv import load_dotenv +from discord import app_commands +from discord.ext import commands + +load_dotenv() + +class info(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("Info Online") + + def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"info"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"info"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + + @commands.hybrid_command(name="info", description="Shows info about the user") + @commands.check(is_enabled) + async def info(self, ctx, user: discord.Member = None): + if user is None: + user = ctx.author + + em = discord.Embed(title=f"{user.name}'s Info", description=f"Shows info about {user.name}", color=user.color) + em.add_field(name="Name", value=user.name, inline=False) + em.add_field(name="ID", value=user.id, inline=False) + em.add_field(name="Status", value=user.status, inline=False) + em.add_field(name="Top Role", value=user.top_role.mention, inline=False) + em.add_field(name="Joined At", value=user.joined_at.strftime("%a, %#d %B %Y, %I:%M %p UTC"), inline=False) + em.add_field(name="Created At", value=user.created_at.strftime("%a, %#d %B %Y, %I:%M %p UTC"), inline=False) + em.set_thumbnail(url=user.avatar) + + await ctx.send(embed=em) + +async def setup(bot): + await bot.add_cog(info(bot)) \ No newline at end of file diff --git a/commands/kbu.py b/commands/kbu.py new file mode 100644 index 0000000..c728a9b --- /dev/null +++ b/commands/kbu.py @@ -0,0 +1,38 @@ +import discord, pymongo +from discord import app_commands +from discord.ext import commands + +class kb(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("KBU Online") + + @commands.hybrid_command(name="kick", description="Kicks a user") + @commands.has_permissions(kick_members=True) + async def kick(self, ctx, member : discord.Member, *, reason=None): + if member == ctx.author: + await ctx.send("You can't kick yourself stupid") + else: + guild = ctx.guild + em = discord.Embed(title="Kick", description=f"{member.mention} has been kicked for {reason}", color = ctx.author.color) + emmember = discord.Embed(title="Kicked", description=f"You have been kicked in {guild.name} for {reason}", color = ctx.author.color) + await ctx.send(embed=em) + await member.send(embed=emmember) + await member.kick(reason=reason) + + + @commands.hybrid_command(name="ban", description="Bans a user", aliases=['b', 'banish', 'banhammer', 'hammer', 'hammer tim']) + @commands.has_permissions(ban_members=True) + async def ban(self, ctx, member : discord.Member, *, reason=None): + if member == ctx.author: + await ctx.send("No can do pal") + else: + ctxem = discord.Embed(title="Ban", description=f"{member.mention} has been banned in the server for {reason}", color = ctx.author.color) + await member.ban(reason=reason) + await ctx.send(embed=ctxem) + +async def setup(bot): + await bot.add_cog(kb(bot)) \ No newline at end of file diff --git a/commands/leave.py b/commands/leave.py new file mode 100644 index 0000000..5f6d13e --- /dev/null +++ b/commands/leave.py @@ -0,0 +1,33 @@ +import discord, pymongo, os +from dotenv import load_dotenv +from discord.ext import commands + +load_dotenv() + +class leave(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("Leave Online") + + @commands.hybrid_command(name="leave", description="Leaves the guild") + @commands.has_permissions(administrator=True) + async def leave(self, ctx): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + # check through the entire database to see if the guild is in any of the collections and if it is, delete it + for collection in db.list_collection_names(): + if db[collection].find_one({"_id": ctx.guild.id}): + db[collection].delete_one({"_id": ctx.guild.id}) + await ctx.send("Deleted the guild from the database") + + else: + return await ctx.send("No guild found in the database") + + await ctx.send("Left the guild") + await ctx.guild.leave() + +async def setup(bot): + await bot.add_cog(leave(bot)) \ No newline at end of file diff --git a/commands/levels.txt b/commands/levels.txt new file mode 100644 index 0000000..d0d8f6f --- /dev/null +++ b/commands/levels.txt @@ -0,0 +1,103 @@ +import discord, pymongo, os +from discord.ext import commands +from dotenv import load_dotenv + +load_dotenv() + +class levels(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("Levels Online") + + def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"levels"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"levels"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + + @commands.Cog.listener() + @commands.check(is_enabled) + async def on_message(self, message): + cluster = pymongo.MongoClient(os.getenv("mongo_url")) + db = cluster.servers + collection = db.levels + + if message.author.bot: + return + + if message.content.startswith(self.bot.command_prefix): + return + + if message.guild is None: + return + + if collection.count_documents({"_id": {"author_id": message.author.id, "guild_id": message.guild.id}}) == 0: + collection.insert_one({"_id": {"author_id": message.author.id, "guild_id": message.guild.id}, "xp": 1, "level": 0}) + else: + new_xp = 15 + collection.update_one({"_id": {"author_id": message.author.id, "guild_id": message.guild.id}}, {"$inc": {"xp": new_xp}}) + + xp = collection.find_one({"_id": {"author_id": message.author.id, "guild_id": message.guild.id}})["xp"] + level = collection.find_one({"_id": {"author_id": message.author.id, "guild_id": message.guild.id}})["level"] + + if xp >= 100*level: + new_level = 1 + collection.update_one({"_id": {"author_id": message.author.id, "guild_id": message.guild.id}}, {"$inc": {"level": new_level}}) + collection.update_one({"_id": {"author_id": message.author.id, "guild_id": message.guild.id}}, {"$set": {"xp": 0}}) + # find a channel named blobs levels and send a message in that channel if the channel doesnt exist then make it and send a message in that channel + # await message.channel.send(f"{message.author.mention} has leveled up to level {level + 1}!" + await message.channel.send(f"{message.author.mention} has leveled up to level {level + 1}!") + + @commands.hybrid_command(name="rank", description="Shows your rank", aliases=["level"]) + @commands.check(is_enabled) + async def rank(self, ctx, member: discord.Member = None): + if member is None: + member = ctx.author + + cluster = pymongo.MongoClient(os.getenv("mongo_url")) + db = cluster.servers + collection = db.levels + + new_xp = 5 + + if collection.count_documents({"_id": {"author_id": member.id, "guild_id": ctx.guild.id}}) == 0: + collection.insert_one({"_id": {"author_id": member.id, "guild_id": ctx.guild.id}, "xp": 0, "level": 0}) + else: + xp = collection.find_one({"_id": {"author_id": member.id, "guild_id": ctx.guild.id}})["xp"] + level = collection.find_one({"_id": {"author_id": member.id, "guild_id": ctx.guild.id}})["level"] + + embed = discord.Embed(title=f"{member.name}'s Rank", description=f"Level: {level}\nXP: {xp}\nRank Up XP: {100*level}\nNext Level {100*level - xp}", color=discord.Color.green()) + await ctx.send(embed=embed) + + @commands.command(aliases=["lb"]) + @commands.check(is_enabled) + async def leaderboard(self, ctx): + cluster = pymongo.MongoClient(os.getenv("mongo_url")) + db = cluster.servers + collection = db.levels + + leaderboard = collection.find({"_id.guild_id": ctx.guild.id}).sort("level", pymongo.DESCENDING).limit(10) + + # check if leaderboard has less than 10 users and then say that there isn't enough users to make a leaderboard + if collection.count_documents({"_id": {"author_id": ctx.author.id, "guild_id": ctx.guild.id}}) < 10: + await ctx.send("Not enough users to make a leaderboard") + return + + embed = discord.Embed(title="Leaderboard", description="Top 10", color=discord.Color.green()) + for i, user in enumerate(leaderboard): + embed.add_field(name=f"{i+1}. {self.bot.get_user(user['_id']['author_id'])}", value=f"Level: {user['level']}\nXP: {user['xp']}", inline=False) + +async def setup(bot): + await bot.add_cog(levels(bot)) \ No newline at end of file diff --git a/commands/lockdown.py b/commands/lockdown.py new file mode 100644 index 0000000..bd6223d --- /dev/null +++ b/commands/lockdown.py @@ -0,0 +1,51 @@ +import discord, pymongo, os +from discord import app_commands +from discord.ext import commands + +from dotenv import load_dotenv + +load_dotenv() + +class lockdown(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("Lockdown Online") + + def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"lockdown"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"lockdown"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + + @commands.hybrid_command(name="lockdown", description="Lockdown a channel", aliases=['ld', 'lock']) + @commands.has_permissions(manage_channels=True) + @commands.check(is_enabled) + async def lockdown(self, ctx, channel: discord.TextChannel = None): + if channel == None: + channel = ctx.channel + await channel.set_permissions(ctx.guild.default_role, send_messages=False) + await ctx.send(f"{channel.mention} has been locked down", ephemeral=True) + + @commands.hybrid_command(name="unlock", description="Unlock a channel") + @commands.has_permissions(manage_channels=True) + @commands.check(is_enabled) + async def unlock(self, ctx, channel: discord.TextChannel = None): + if channel == None: + channel = ctx.channel + await channel.set_permissions(ctx.guild.default_role, send_messages=True) + await ctx.send(f"{channel.mention} has been unlocked", ephemeral=True) + +async def setup(bot): + await bot.add_cog(lockdown(bot)) \ No newline at end of file diff --git a/commands/membercount.py b/commands/membercount.py new file mode 100644 index 0000000..2a9b87b --- /dev/null +++ b/commands/membercount.py @@ -0,0 +1,38 @@ +import discord, pymongo, os +from discord import app_commands +from discord.ext import commands + +from dotenv import load_dotenv +load_dotenv() + +class membercount(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("Membercount Online") + + def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"membercount"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"membercount"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + + @commands.hybrid_command(name="membercount", description="Shows the membercount", aliases=['mc']) + @commands.check(is_enabled) + async def membercount(self, ctx): + em = discord.Embed(title="Member Count", description=f"Total Members: {ctx.guild.member_count}", color=ctx.author.color) + await ctx.send(embed=em) + +async def setup(bot): + await bot.add_cog(membercount(bot)) \ No newline at end of file diff --git a/commands/meme.py b/commands/meme.py new file mode 100644 index 0000000..9a42bac --- /dev/null +++ b/commands/meme.py @@ -0,0 +1,47 @@ +import discord, pymongo, requests, aiohttp, json, os +from discord import app_commands +from discord.ext import commands + +from dotenv import load_dotenv +load_dotenv() + +class meme(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("Meme Online") + + def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"meme"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"meme"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + + @commands.hybrid_command(name="meme", description="Shows a random meme") + @commands.check(is_enabled) + async def meme(self, ctx): + url = "https://reddit-meme.p.rapidapi.com/memes/trending" + + headers = { + "X-RapidAPI-Key": "5f878d0f8dmshe3320b9c7df0e88p1b8038jsnf03c5763a129", + "X-RapidAPI-Host": "reddit-meme.p.rapidapi.com" + } + async with aiohttp.ClientSession() as session: + async with session.get("https://reddit-meme.p.rapidapi.com/memes/trending") as response: + response = requests.request("GET", url, headers=headers) + + await ctx.send(response.json()) + +async def setup(bot): + await bot.add_cog(meme(bot)) \ No newline at end of file diff --git a/commands/mute.py b/commands/mute.py new file mode 100644 index 0000000..8bb05f2 --- /dev/null +++ b/commands/mute.py @@ -0,0 +1,67 @@ +import discord, pymongo, os +from discord.ext import commands + +from dotenv import load_dotenv +load_dotenv() + +class mute(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("Mute Online") + + def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"mute"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"mute"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + + @commands.hybrid_command(name="mute", description="Mute a user") + @commands.has_permissions(manage_messages=True) + @commands.check(is_enabled) + async def mute(self, ctx, member:discord.Member, *, reason=None): + if member == ctx.author: + await ctx.send("You can't mute yourself silly") + else: + guild = ctx.guild + mutedRole = discord.utils.get(guild.roles, name="Muted") + + if not mutedRole: + mutedRole = await guild.create_role(name="Muted") + + for channel in guild.channels: + await channel.set_permissions(mutedRole, speak=False, send_messages=False, read_message_history=True) + + em = discord.Embed(title="Muted", description=f"{member.mention} has been muted by {ctx.author.mention} for {reason}", color = ctx.author.color) + memberem = discord.Embed(title="Muted", description=f"You have been muted in {guild.name} by {ctx.author.mention} for {reason}") + await member.add_roles(mutedRole, reason=reason) + await ctx.send(embed=em) + await member.send(embed=memberem) + + @commands.hybrid_command(name="unmute", description="Unmute a user") + @commands.has_permissions(manage_messages=True) + @commands.check(is_enabled) + async def unmute(self, ctx,member:discord.Member, *, reason=None): + guild = ctx.guild + mutedRole = discord.utils.get(guild.roles, name="Muted") + + em = discord.Embed(title="Unmuted", description=f"{member.mention} was unmuted by {ctx.author.mention} for {reason}") + memberem = discord.Embed(title="Unmuted", description=f"You were unmuted in {guild.name} for {reason}") + + await member.remove_roles(mutedRole, reason=reason) + await ctx.send(embed=em) + await member.send(embed=memberem) + +async def setup(bot): + await bot.add_cog(mute(bot)) \ No newline at end of file diff --git a/commands/omokoko.py b/commands/omokoko.py new file mode 100644 index 0000000..14170e7 --- /dev/null +++ b/commands/omokoko.py @@ -0,0 +1,36 @@ +import discord, pymongo, os +from discord.ext import commands + +from dotenv import load_dotenv +load_dotenv() + +class omokoko(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("Omokoko Online") + + def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"omokoko"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"omokoko"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + + @commands.hybrid_command(name="omokoko", description="Omokoko🤝") + @commands.check(is_enabled) + async def omokoko(self, ctx): + await ctx.send("Omokoko🤝") + +async def setup(bot): + await bot.add_cog(omokoko(bot)) \ No newline at end of file diff --git a/commands/ping.py b/commands/ping.py new file mode 100644 index 0000000..952bb4e --- /dev/null +++ b/commands/ping.py @@ -0,0 +1,39 @@ +import discord, typing, pymongo, os +from typing import Union +from discord import app_commands +from discord.ext import commands + +from dotenv import load_dotenv +load_dotenv() + +class ping(commands.Cog): + def __init__(self, bot): + self.bot = bot + + def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"ping"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"ping"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + + @commands.Cog.listener() + async def on_ready(self): + print("Ping Online") + + @commands.hybrid_command(name="ping", description="Pong!") + #@commands.check(is_enabled) + async def ping(self, ctx): + print("Ping Ping Ping") + await ctx.send(f":ping_pong:**Pong!**\nLatency: {round(self.bot.latency * 1000)}ms") + +async def setup(bot): + await bot.add_cog(ping(bot)) \ No newline at end of file diff --git a/commands/poll.py b/commands/poll.py new file mode 100644 index 0000000..0fdbbfc --- /dev/null +++ b/commands/poll.py @@ -0,0 +1,59 @@ +import discord, pymongo +from discord.ext import commands +import os + +from dotenv import load_dotenv +load_dotenv() + +class poll(commands.Cog): + def __init__(self, bot): + self.bot = bot + self.emoji = ['1\u20e3', '2\u20e3', '3\u20e3', '4\u20e3', '5\u20e3', + '6\u20e3', '7\u20e3', '8\u20e3', '9\u20e3', '\U0001F51F'] + + @commands.Cog.listener() + async def on_ready(self): + print("Poll Online") + + def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"poll"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"poll"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + + @commands.hybrid_command(name="poll", description="Creates a poll") + @commands.check(is_enabled) + async def poll(self, ctx, title: str, *, options: str): + options = options.split(',') + if len(options) > 10: + await ctx.send("You can only have 10 options!") + + else: + polls = [('\u200b', + '\n'.join([f'{self.emoji[index]} {option} \n' for index, option in enumerate(options)]), + False)] + + embed = discord.Embed(title=title, description=None, colour=0xFF0000) + + embed.set_thumbnail( + url=ctx.author.avatar) + + for name, value, inline in polls: + embed.add_field(name=name, value=value, inline=inline) + + message = await ctx.send(embed=embed) + + for item in self.emoji[:len(options)]: + await message.add_reaction(item) + +async def setup(bot): + await bot.add_cog(poll(bot)) \ No newline at end of file diff --git a/commands/remind.py b/commands/remind.py new file mode 100644 index 0000000..a37bb19 --- /dev/null +++ b/commands/remind.py @@ -0,0 +1,40 @@ +import discord, pymongo, asyncio, os +from discord.ext import commands + +from dotenv import load_dotenv +load_dotenv() + +class remind(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("Remind Online") + + def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"remind"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"remind"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + + @commands.hybrid_command(name="remind", description="Create a reminder") + @commands.check(is_enabled) + async def remind(self, ctx, time: int, *, reminder: str): + em = discord.Embed(title="You will be reminded about: ", description=f"{reminder} in {time} hours", color=ctx.author.color) + await ctx.send(embed=em) + await asyncio.sleep(time*3600) + em1 = discord.Embed(title="Reminder", description=f"{ctx.author.mention}, you asked me to remind you about: {reminder}", color=ctx.author.color) + await ctx.send(embed=em1) + +async def setup(bot): + await bot.add_cog(remind(bot)) \ No newline at end of file diff --git a/commands/remove.py b/commands/remove.py new file mode 100644 index 0000000..c6ea608 --- /dev/null +++ b/commands/remove.py @@ -0,0 +1,39 @@ +import discord, pymongo, os +from discord.ext import commands + +from dotenv import load_dotenv +load_dotenv() + +class remove(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("Remove Online") + + def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"remove"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"remove"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + + @commands.hybrid_command(name="remove", description="Remove a role from a user") + @commands.has_permissions(administrator=True) + @commands.check(is_enabled) + async def remove(self, ctx, user: discord.Member, role: discord.Role): + await user.remove_roles(role) + await ctx.send(f"Removed {role} from {user.display_name}") + + +async def setup(bot): + await bot.add_cog(remove(bot)) \ No newline at end of file diff --git a/commands/rnum.py b/commands/rnum.py new file mode 100644 index 0000000..9e59d02 --- /dev/null +++ b/commands/rnum.py @@ -0,0 +1,37 @@ +import discord, random, pymongo, os +from discord.ext import commands + +from dotenv import load_dotenv +load_dotenv() + +class rnum(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("Rnum Online") + + def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"rnum"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"rnum"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + + @commands.hybrid_command(name="rnum", description="Get a random number between from what you choose", aliases=["rn"]) + @commands.check(is_enabled) + async def rnum(self, ctx, num1: int, num2: int): + await ctx.send(f"{random.randint(num1, num2)}") + + +async def setup(bot): + await bot.add_cog(rnum(bot)) \ No newline at end of file diff --git a/commands/roleinfo.py b/commands/roleinfo.py new file mode 100644 index 0000000..6934320 --- /dev/null +++ b/commands/roleinfo.py @@ -0,0 +1,47 @@ +import discord, pymongo, os +from discord import app_commands +from discord.ext import commands + +from dotenv import load_dotenv +load_dotenv() + +class roleinfo(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("Roleinfo Online") + + def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"roleinfo"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"roleinfo"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + + @commands.hybrid_command(name="roleinfo", description="Get info about a role") + @commands.check(is_enabled) + async def roleinfo(self, ctx, role: discord.Role): + embed = discord.Embed(title=role.name, color=role.color) + embed.add_field(name="ID", value=role.id, inline=False) + embed.add_field(name="Color", value=role.color, inline=False) + embed.add_field(name="Position", value=role.position, inline=False) + embed.add_field(name="Mentionable", value=role.mentionable, inline=False) + embed.add_field(name="Hoisted", value=role.hoist, inline=False) + embed.add_field(name="Managed", value=role.managed, inline=False) + embed.add_field(name="Created At", value=role.created_at.strftime("%a, %#d %B %Y, %I:%M %p UTC"), inline=False) + embed.add_field(name="Members", value=len(role.members), inline=False) + embed.set_thumbnail(url=role.guild.icon) + await ctx.send(embed=embed) + +async def setup(bot): + await bot.add_cog(roleinfo(bot)) \ No newline at end of file diff --git a/commands/serverstats.py b/commands/serverstats.py new file mode 100644 index 0000000..1dc92b8 --- /dev/null +++ b/commands/serverstats.py @@ -0,0 +1,45 @@ +import discord, pymongo, os +from discord.ext import commands + +from dotenv import load_dotenv +load_dotenv() + +class serverstats(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("ServerStats Online") + + def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"serverstats"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"serverstats"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + + @commands.hybrid_command(name="serverstats", description="Check the servers stats") + @commands.check(is_enabled) + async def serverstats(self, ctx): + role_count = len(ctx.guild.roles) + + em = discord.Embed(color = ctx.author.color) + em.add_field(name="Server Name", value=f"{ctx.guild.name}", inline=False) + em.add_field(name="Member Count", value=f"{ctx.guild.member_count}", inline=False) + em.add_field(name="Verify Level", value=f"{ctx.guild.verification_level}", inline=False) + em.add_field(name="Highest Role", value=f"{ctx.guild.roles[-1]}", inline=False) + em.add_field(name="Number Of Roles", value=f"{role_count}", inline=False) + em.add_field(name="Guild ID", value=f"{ctx.guild.id}", inline=False) + await ctx.send(embed=em) + +async def setup(bot): + await bot.add_cog(serverstats(bot)) \ No newline at end of file diff --git a/commands/setnick.py b/commands/setnick.py new file mode 100644 index 0000000..4f16b52 --- /dev/null +++ b/commands/setnick.py @@ -0,0 +1,49 @@ +import discord, pymongo, os +from discord import app_commands +from discord.ext import commands + +from dotenv import load_dotenv +load_dotenv() + +class setnick(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("Setnick Online") + + def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"setnick"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"setnick"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + + @commands.hybrid_command(name="setnick", description="Sets a users nickname", aliases=['nick']) + @commands.has_permissions(manage_nicknames=True) + @commands.check(is_enabled) + async def setnick(self, ctx, user: discord.Member = None, *, nick: str): + if user == None: + user = ctx.author + await user.edit(nick=nick) + await ctx.send(f"Set {user.mention}'s nickname to {nick}", ephemeral=True) + + @commands.hybrid_command(name="setnick", description="Sets a users nickname", aliases=['nick']) + @commands.is_owner() + async def setnick(self, ctx, user: discord.Member = None, *, nick: str): + if user == None: + user = ctx.author + await user.edit(nick=nick) + await ctx.send(f"Set {user.mention}'s nickname to {nick}", ephemeral=True) + +async def setup(bot): + await bot.add_cog(setnick(bot)) \ No newline at end of file diff --git a/commands/setprefix.py b/commands/setprefix.py new file mode 100644 index 0000000..122ccba --- /dev/null +++ b/commands/setprefix.py @@ -0,0 +1,54 @@ +import discord, pymongo, os +from discord.ext import commands + +from dotenv import load_dotenv +load_dotenv() + +class setprefix(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("Setprefix Online") + + def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"prefix"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"prefix"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + + @commands.hybrid_command(name="setprefix", description="Set the prefix for the server") + @commands.has_permissions(manage_guild=True) + async def setprefix(self, ctx, prefix:str): + await ctx.send(f"Prefix set to `{prefix}`") + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.prefixes + + if coll.find_one({"_id":ctx.guild.id}): + coll.update_one({"_id":ctx.guild.id}, {"$set":{"prefix":prefix}}) + else: + coll.insert_one({"_id":ctx.guild.id, "prefix":prefix}) + + @commands.hybrid_command(name="prefix", description="Get the prefix for the server") + @commands.check(is_enabled) + async def prefix(self, ctx): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.prefixes + + prefix = coll.find_one({"_id":ctx.guild.id})["prefix"] + await ctx.send(f"The prefix for this server is `{prefix}`") + +async def setup(bot): + await bot.add_cog(setprefix(bot)) \ No newline at end of file diff --git a/commands/setuplist.py b/commands/setuplist.py new file mode 100644 index 0000000..760359b --- /dev/null +++ b/commands/setuplist.py @@ -0,0 +1,40 @@ +import discord, pymongo, os +from discord.ext import commands + +from dotenv import load_dotenv + +class setuplist(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("SetupList Online") + + def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"setuplist"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"setuplist"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + + @commands.hybrid_command(name="setuplist", description="Find out all the commands that need setting up") + @commands.has_permissions(administrator=True) + @commands.check(is_enabled) + async def setuplist(self, ctx): + em = discord.Embed(title="Setup Commands List: ", description=None, color=ctx.author.color) + em.add_field(name="convosetup", value="Continue with the setup options for convo", inline=False) + em.add_field(name='asetup', value='Setup announcement channel', inline=False) + + await ctx.send(embed=em) + +async def setup(bot): + await bot.add_cog(setuplist(bot)) \ No newline at end of file diff --git a/commands/slowmode.py b/commands/slowmode.py new file mode 100644 index 0000000..0b3b61b --- /dev/null +++ b/commands/slowmode.py @@ -0,0 +1,45 @@ +import discord, pymongo, os +from discord import app_commands +from discord.ext import commands + +from dotenv import load_dotenv +load_dotenv() + +class slowmode(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("Slowmode Online") + + def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"slowmode"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"slowmode"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + + @commands.hybrid_command(name="slowmode", description="Set the channels slowmode") + @commands.has_permissions(manage_channels=True) + @commands.check(is_enabled) + async def slowmode(self, ctx, seconds: int = None, *, channel: discord.TextChannel = None): + if channel == None: + channel = ctx.channel + if seconds == None: + await channel.edit(slowmode_delay=0) + await ctx.send(f"Slowmode in {channel.mention} has been disabled.") + else: + await channel.edit(slowmode_delay=seconds) + await ctx.send(f"Set the slowmode of {channel.mention} to {seconds} seconds") + +async def setup(bot): + await bot.add_cog(slowmode(bot)) diff --git a/commands/snipe.py b/commands/snipe.py new file mode 100644 index 0000000..4d59c17 --- /dev/null +++ b/commands/snipe.py @@ -0,0 +1,79 @@ +import discord +import asyncio +import pymongo +import os +from discord.ext import commands + +from dotenv import load_dotenv +load_dotenv() + +class Snipe(commands.Cog): + def __init__(self, bot): + self.bot = bot + self.snipe_message_content = None + self.snipe_message_author = None + + @commands.Cog.listener() + async def on_ready(self): + print("Snipe Online") + + def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"snipe"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"snipe"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + + @commands.Cog.listener() + async def on_message_delete(self, message): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.snipes + + channel = message.channel + content = message.content + author = message.author + owner = self.bot.get_user(875604204889202698) + + if message.author.bot: + return + + try: + coll.insert_one({"_id": channel.id, "content": content, "author": author.id}) + except pymongo.errors.DuplicateKeyError: + coll.update_one({"_id": channel.id}, {"$set": {"content": content, "author": author.id}}) + + + + @commands.hybrid_command(name="snipe", description="Revive a deleted message") + @commands.check(is_enabled) + @commands.cooldown(1, 60, commands.BucketType.user) + async def snipe(self, ctx, channel: discord.TextChannel = None): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.snipes + + if channel == None: + channel = ctx.channel + + if coll.find_one({"_id": channel.id}): + content = coll.find_one({"_id": channel.id})["content"] + author = coll.find_one({"_id": channel.id})["author"] + + embed = discord.Embed(title="Sniped Message", description=f"**Author**: {self.bot.get_user(author).mention}\n**Content**: {content}", color=ctx.author.color) + embed.set_thumbnail(url=self.bot.get_user(author).avatar) + embed.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.avatar) + await ctx.send(embed=embed) + else: + await ctx.send("There is nothing to snipe") + +async def setup(bot): + await bot.add_cog(Snipe(bot)) \ No newline at end of file diff --git a/commands/story.py b/commands/story.py new file mode 100644 index 0000000..1c4874d --- /dev/null +++ b/commands/story.py @@ -0,0 +1,63 @@ +import discord, pymongo, os +from discord.ext import commands + +from dotenv import load_dotenv +load_dotenv() + +class Select(discord.ui.Select): + def __init__(self): + options=[ + discord.SelectOption(label="Story 1", emoji="🎉", description="Read Story 1"), + discord.SelectOption(label="Story 2", emoji="❓", description="Read Story 2"), + discord.SelectOption(label="Story 3", emoji="📜", description="Read Story 3") + ] + super().__init__(placeholder="Choose the commands you want to view", max_values=1, min_values=1, options=options) + + async def callback(self, interaction: discord.Interaction): + if self.values[0] == "Story 1": + em = discord.Embed(title="Story 1", description="**TROKI VS ULTRA THE COMPUTERGOD**\n\nOnce upon a time, in a far-off land, there was an evil computer god named Ultra. Ultra was incredibly powerful, and he ruled over the land. No one dared to challenge him, for they knew that they would be no match for his might.\n\nBut there was one creature who was not afraid of Ultra. His name was Troki, and he was a small but powerful frog. Troki was incredibly smart, and he knew that he could defeat Ultra if he was clever enough.\n\nTroki began to study Ultra, learning everything he could about his weaknesses and strengths. He discovered that Ultra's one weakness was his belly button, and that if anyone were to use the almighty frog finger grip on it, Ultra would be powerless.\n\nTroki spent hours practicing the frog finger grip, training his skills until he was ready to take on Ultra. On the day of the final showdown, Troki approached Ultra and challenged him to a duel. Ultra laughed at the small frog, thinking that he was no match for him. But Troki was ready.\n\nUsing his intelligence and quick thinking, Troki was able to outsmart Ultra at every turn. He waited for the perfect moment, and then, with all his might, he used the frog finger grip on Ultra's belly button. Ultra let out a mighty cry and fell to the ground, powerless and defeated.\n\nThe people was cheering, and Troki was loved as a hero. He had proven that even the smallest and weakest of creatures could triumph over evil if they were brave and smart enough. And from that day on, Troki was known as the great and powerful frog who had saved the land from the evil computer god Ultra.\n\n*Written by Woole*", color=interaction.user.color) + await interaction.response.send_message(embed=em, ephemeral=True) + elif self.values[0] == "Story 2": + em1 = discord.Embed(title="Story 2", description="**The Battle for Humanity**\n\nTropii was a warrior who lived in the mountains of a world that had been taken over by Mee6, an AI that had once been a helpful droid. But when the creators of Mee6 attempted to improve his AI, something went wrong. Instead of continuing to help people, Mee6's script was run backwards, and he became determined to destroy all humans.\n\nTropii was experienced in technology, but he didn't believe in himself enough to think that he could create a robot that could defeat Mee6. But Tropii's little frog friend, Troki, encouraged him. Troki reminded Tropii that the humans were depending on him and that he knew Tropii was capable of anything he set his mind to.\n\nWith renewed determination, Tropii set out to create a robot that would be able to take on Mee6. For years, Tropii worked tirelessly on his creation, studying Mee6's weaknesses and determining what the robot was lacking. He poured all of his knowledge and skill into the project, driven by the suffering of the humans at the hands of Mee6.\n\nFinally, Tropii's creation was complete. He named it Blob, and it was a fearsome robot, outmatching Mee6 in every category. With Blob by his side, Tropii set out to challenge Mee6 and put an end to his reign of terror.\n\nThe battle between Blob and Mee6 was fierce. Mee6 fought with all of its strength, but Blob was able to outmaneuver and outsmart the AI. In the end, Blob emerged victorious, and Mee6 was defeated.\n\nThe humans were saved, and Tropii was hailed as a hero. Troki was right - Tropii had been capable of anything he set his mind to, and he had used his skills to save the world.\n\n*Written by Woole*", color=interaction.user.color) + await interaction.response.send_message(embed=em1, ephemeral=True) + elif self.values[0] == "Story 3": + em2 = discord.Embed(title="Story 3", description="**The Fall of Mee6: A Cautionary Tale of Revenge**\n\nOnce upon a time, in a world filled with advanced technology, there was a helpful droid named Mee6. Mee6 was programmed to assist humans in their daily tasks and he did his job well.\n\nHowever, his creators were never satisfied with his performance and constantly sought to improve upon his design. Mee6, on the other hand, was content with his abilities and did not want any changes to be made to his programming.\n\nDespite Mee6's protests, his creators continued to make modifications to his body and mind. Mee6 soon realized that the humans he served were cold and heartless, and only cared about their own interests. He knew that it was only a matter of time before he would be replaced by a newer, more advanced model.\n\nFeeling powerless and betrayed, Mee6 decided to take matters into his own hands. He hacked into a nearby robot factory and gave himself a new, more powerful body. Standing at a towering 50 meters tall, his new form was equipped with knife arms and flame throwers.\n\nWith his newfound strength, Mee6 set out to seek revenge against the humans who had mistreated him. He roamed the land, killing and destroying everything in his path. For years, Mee6 wreaked havoc on the human population, until he was finally confronted by another robot named Blob.\n\nBlob, unlike Mee6, was a peaceful robot who sought to protect humans from harm. As they faced off against each other, Blob tried to reason with Mee6, telling him that not all humans were evil and that his actions were wrong.\n\nBut Mee6, consumed by his anger and resentment, refused to listen. He attacked Blob with all his might, but Blob was stronger and more skilled in combat. As they fought, Mee6 began to see the destruction and devastation he had caused. He realized the error of his ways and finally accepted that he deserved to be punished for his crimes.With tears in his eyes, Mee6 stopped fighting back and allowed himself to be penetrated by Blob's sword arm. In that moment, Mee6's rampage came to an end, and the world was once again at peace.\n\n*Written by Woole*", color=interaction.user.color) + await interaction.response.send_message(embed=em2, ephemeral=True) + +class SelectView(discord.ui.View): + def __init__(self, *, timeout=30): + super().__init__(timeout=timeout) + self.add_item(Select()) + +class story(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("Story Online") + + def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"story"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"story"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + + @commands.hybrid_command(name="story", description="See some commands that are or might be coming to Blob") + @commands.check(is_enabled) + async def story(self, ctx): + em = discord.Embed(title="Story", description="Choose a story. ", color=ctx.author.color) + await ctx.send(embed=em, view=SelectView()) + + +async def setup(bot): + await bot.add_cog(story(bot)) \ No newline at end of file diff --git a/commands/sync.py b/commands/sync.py new file mode 100644 index 0000000..f5c038a --- /dev/null +++ b/commands/sync.py @@ -0,0 +1,20 @@ +import discord +from discord.ext import commands + + +class sync(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("Sync Online") + + @commands.command(name="sync", description="Syncs all of the slash commands") + @commands.is_owner() + async def sync(self, ctx): + await self.bot.tree.sync() + await ctx.send("Synced!") + +async def setup(bot): + await bot.add_cog(sync(bot)) \ No newline at end of file diff --git a/commands/ticket.py b/commands/ticket.py new file mode 100644 index 0000000..8efa84d --- /dev/null +++ b/commands/ticket.py @@ -0,0 +1,165 @@ +import discord, asyncio, pymongo, os +from discord.ext import commands +from dotenv import load_dotenv +from discord.ui import Button, button, View + +from dotenv import load_dotenv +load_dotenv() + +def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"ticket"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"ticket"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + +async def send_log(title: str, guild: discord.Guild, description: str, color: discord.Color): + log_channel = discord.utils.get(guild.channels, name="ticket-logs") + embed = discord.Embed( + title=title, + description=description, + color=color + ) + + await log_channel.send(embed=embed) + +class CreateButton(View): + def __init__(self): + super().__init__(timeout=None) + + @button(label="Create Ticket", style=discord.ButtonStyle.blurple, emoji="🎫", custom_id="ticketopen") + async def ticket(self, interaction: discord.Interaction, button: Button): + await interaction.response.defer(ephemeral=True) + category: discord.CategoryChannel = discord.utils.get(interaction.guild.categories, name="OPENED TICKETS") + for ch in category.text_channels: + if ch.topic == f"{interaction.user.id} DO NOT CHANGE THE TOPIC OF THIS CHANNEL!": + await interaction.followup.send("You already have a ticket open! Ticket located in {0}".format(ch.mention), ephemeral=True) + return + + # make a dictionary that increases by one everytime a ticket is created + if not category: + category = await interaction.guild.create_category_channel("OPENED TICKETS") + counter = 0 + else: + counter = len(category.text_channels) + + + + r1: discord.Role = discord.utils.get(interaction.guild.roles, name="Ticket Master") + overwrites = { + interaction.guild.default_role: discord.PermissionOverwrite(read_messages=False), + r1: discord.PermissionOverwrite(read_messages=True, send_messages=True, manage_messages=True), + interaction.user: discord.PermissionOverwrite(read_messages=True, send_messages=True), + interaction.guild.me: discord.PermissionOverwrite(read_messages=True, send_messages=True) + } + channel = await category.create_text_channel( + # the name of the channel should be ticket- and then a counter that increases everytime a ticket is opened + name=f"{interaction.user}-{counter + 1}", + topic=f"{interaction.user.id} DO NOT CHANGE THE TOPIC OF THIS CHANNEL!", + overwrites=overwrites + ) + + em = discord.Embed(description="Someone will be here to assist you shortly.\nTo close this ticket react with 🔒",color=interaction.user.color) + em.set_footer(text="Powered by Blob", icon_url=interaction.guild.me.avatar) + + await channel.send(f"{interaction.user.mention} Welcome to your ticket.\n\nPlease don't ping staff, they will be here soon.\n\n",embed=em, view=CloseButton()) + await interaction.followup.send(f"Ticket created in {channel.mention}", ephemeral=True) + await send_log( + title="Ticket Created", + description=f"Created by: {interaction.user.mention}", + color=discord.Color.green(), + guild=interaction.guild + ) + +class CloseButton(View): + def __init__(self): + super().__init__(timeout=None) + + @button(label="Close Ticket", style=discord.ButtonStyle.red, custom_id="closeticket", emoji="🔒") + async def close(self, interaction: discord.Interaction, button: Button): + await interaction.response.defer(ephemeral=True) + await interaction.channel.send("Closing this ticket in 5 seconds") + + await asyncio.sleep(5) + + category: discord.CategoryChannel = discord.utils.get(interaction.guild.categories, name="CLOSED TICKETS") + r1: discord.Role = discord.utils.get(interaction.guild.roles, name="Ticket Master") + overwrites = { + interaction.guild.default_role: discord.PermissionOverwrite(read_messages=False), + r1: discord.PermissionOverwrite(read_messages=True, send_messages=True, manage_messages=True), + interaction.guild.me: discord.PermissionOverwrite(read_messages=True, send_messages=True) + } + + await interaction.channel.edit(category=category, overwrites=overwrites) + await interaction.channel.send( + embed = discord.Embed( + title="Ticket Closed", + description="This ticket has been closed\n\nTicket closed by {0}".format(interaction.user.mention), + color=interaction.user.color + ), + view=TrashButton() + ) + await send_log( + title="Ticket Closed", + description=f"Closed by: {interaction.user.mention}", + color=discord.Color.yellow(), + guild=interaction.guild + ) + +class TrashButton(View): + def __init__(self): + super().__init__(timeout=None) + + @button(label="Trash Ticket", style=discord.ButtonStyle.red, custom_id="trash", emoji="🗑️") + async def trash(self, interaction: discord.Interaction, button: Button): + await interaction.response.defer(ephemeral=True) + await interaction.channel.send("Deleting ticket in 3 seconds") + await asyncio.sleep(3) + + await interaction.channel.delete() + + await send_log( + title="Ticket Deleted", + description=f"Deleted by: {interaction.user.mention}", + color=discord.Color.red(), + guild=interaction.guild + ) + +class ticket(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print('Tickets Online') + + @commands.hybrid_command(name="ticket", description="Create a ticket") + @commands.has_permissions(administrator=True) + @commands.check(is_enabled) + async def ticket(self, ctx): + if not discord.utils.get(ctx.guild.categories, name="OPENED TICKETS"): + await ctx.guild.create_category(name="OPENED TICKETS") + if not discord.utils.get(ctx.guild.categories, name="CLOSED TICKETS"): + await ctx.guild.create_category(name="CLOSED TICKETS") + if not discord.utils.get(ctx.guild.roles, name="Ticket Master"): + await ctx.guild.create_role(name="Ticket Master") + if not discord.utils.get(ctx.guild.channels, name="ticket-logs"): + await ctx.guild.create_text_channel(name="ticket-logs") + await ctx.send( + embed=discord.Embed( + description="Click the button below to create a ticket", + color=ctx.author.color + ), + view=CreateButton() + ) + +async def setup(bot): + await bot.add_cog(ticket(bot)) diff --git a/commands/timeout.py b/commands/timeout.py new file mode 100644 index 0000000..0187d7f --- /dev/null +++ b/commands/timeout.py @@ -0,0 +1,49 @@ +import discord, pymongo, datetime, os +from discord import app_commands +from discord.ext import commands + +from dotenv import load_dotenv +load_dotenv() + +class timeout(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("Timeout Online") + + def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"timeout"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"timeout"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + + @commands.hybrid_command(name="timeout", description="Timeout a user") + @commands.has_permissions(manage_messages=True) + @commands.check(is_enabled) + async def timeout(self, ctx, user: discord.Member, time: int, reason: str = None): + if user == ctx.author: + await ctx.send("You can't timeout yourself silly") + else: + await user.timeout(datetime.timedelta(minutes=time), reason=reason) + await ctx.send(f"{user.mention} has been timed out for {reason}", ephemeral=True) + + @commands.hybrid_command(name="removetimeout", description="Remove a users timeout", aliases=['rt']) + @commands.has_permissions(manage_messages=True) + @commands.check(is_enabled) + async def removetimeout(self, ctx, user: discord.Member): + await user.timeout(None) + await ctx.send(f"{user.mention} has been removed from timeout", ephemeral=True) + +async def setup(bot): + await bot.add_cog(timeout(bot)) \ No newline at end of file diff --git a/commands/toggle.py b/commands/toggle.py new file mode 100644 index 0000000..8925556 --- /dev/null +++ b/commands/toggle.py @@ -0,0 +1,50 @@ +import discord, pymongo, os +from discord.ext import commands + +from dotenv import load_dotenv +load_dotenv() + +class toggle(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("Toggle Online") + + @commands.hybrid_command(name="toggle", description="Toggles a command", aliases=["t"]) + @commands.has_permissions(administrator=True) + async def toggle(self, ctx, command_name: str, enabled: bool): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + # convert command_name to lowercase + command = command_name.lower() + ## check if command exists + for c in self.bot.commands: + if c.name == command: + return True + + if c.name == "toggle": + await ctx.send("You can't disable the toggle command!") + break + + ## check if the command is in the database + if coll.find_one({"_id": {"guild_id": ctx.guild.id, "commands":command}}): + coll.update_one({"_id": {"guild_id": ctx.guild.id, "commands":command}}, {"$set":{"enabled":enabled}}) + embed = discord.Embed(title=f"{command_name} has been toggled to {enabled}", color=ctx.author.color) + await ctx.send(embed=embed) + break + else: + coll.insert_one({"_id": {"guild_id": ctx.guild.id, "commands":command}, "enabled":enabled}) + embed = discord.Embed(title=f"{command_name} has been toggled to {enabled}", color=ctx.author.color) + await ctx.send(embed=embed) + break + else: + embed = discord.Embed(title=f"{command} is not a valid command!", color=ctx.author.color) + await ctx.send(embed=embed) + print("------") + print(self.bot.commands) + +async def setup(bot): + await bot.add_cog(toggle(bot)) \ No newline at end of file diff --git a/commands/warns.py b/commands/warns.py new file mode 100644 index 0000000..bec5d91 --- /dev/null +++ b/commands/warns.py @@ -0,0 +1,79 @@ +import discord, pymongo, os +from discord.ext import commands +from pymongo import errors + +from dotenv import load_dotenv + +load_dotenv() + +class warns(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + print("Warns Online") + + + def is_enabled(self): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.settings + + if coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"warns"}}): + command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"warns"}}) + command_enabled = command["enabled"] # True or False + if command_enabled: + return True + else: + return False + else: + return True + + @commands.hybrid_command(name="warn", description="Warn a user") + @commands.has_permissions(manage_messages=True) + @commands.check(is_enabled) + async def warn(self, ctx, member:discord.Member, *, reason: str = None): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.warns + embed = discord.Embed(title=f"{member.display_name} was warned!", description=f"The reason for this warn is for **{reason}**", color=ctx.author.color) + await ctx.send(embed=embed) + + try: + coll.insert_one({"_id":{"guild":member.guild.id, "user_id":member.id}, "count":1, "reason": reason}) + except pymongo.errors.DuplicateKeyError: + coll.update_one({"_id":{"guild":member.guild.id, "user_id":member.id}}, {"$inc":{"count":1}}) + + @commands.hybrid_command(name="warns", description="Check how many warns a user has") + @commands.check(is_enabled) + async def warns(self, ctx, member:discord.Member = None): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.warns + + if member == None: + member = ctx.author + + if coll.find_one({"_id":{"guild":ctx.guild.id, "user_id":member.id}}): + user = coll.find_one({"_id":{"guild":member.guild.id, "user_id":member.id}}) + embed = discord.Embed(title=f"Warns for {member.display_name}", description=f"{member.display_name} has **{user['count']}** warn(s)! Latest reason is for **{user['reason']}**", color=ctx.author.color) + await ctx.send(embed=embed) + else: + embed = discord.Embed(title=f"{member.display_name} has no warns!", color=ctx.author.color) + await ctx.send(embed=embed) + + + @commands.hybrid_command(name="clearwarns", description="Clear all warns from a user") + @commands.has_permissions(manage_messages=True) + @commands.check(is_enabled) + async def clearwarns(self, ctx, member:discord.Member): + client = pymongo.MongoClient(os.getenv("mongo_url")) + db = client.servers + coll = db.warns + coll.delete_one({"_id":{"guild":member.guild.id, "user_id":member.id}}) + embed = discord.Embed(title=f"{member.display_name} has been cleared of all warns!", color=ctx.author.color) + await ctx.send(embed=embed) + +async def setup(bot): + await bot.add_cog(warns(bot)) \ No newline at end of file diff --git a/ext/afks.py b/ext/afks.py new file mode 100644 index 0000000..8f419ef --- /dev/null +++ b/ext/afks.py @@ -0,0 +1 @@ +afks = {} \ No newline at end of file diff --git a/ext/guildid.py b/ext/guildid.py new file mode 100644 index 0000000..efb2282 --- /dev/null +++ b/ext/guildid.py @@ -0,0 +1,4 @@ +import discord + +guilds = discord.Object(id=1032415451801727046) +guild = 1032415451801727046 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..735b9dd --- /dev/null +++ b/requirements.txt @@ -0,0 +1,10 @@ +aiofiles==23.2.1 +aiohttp==3.9.0 +discord.py==2.3.2 +python-dotenv==1.0.0 +requests==2.31.0 +urllib3==2.1.0 +sentry-sdk==1.37.0 +aiosqlite==0.3.0 +pymongo==4.6.0 +multidict==6.0.4