The final commit

This commit is contained in:
TropiiDev 2025-01-25 16:31:29 -05:00
parent 73f51b2ba9
commit 79cf925bd3
55 changed files with 849 additions and 2314 deletions

6
.gitignore vendored
View File

@ -1,6 +1,6 @@
/venv
/venv/
.env
test.py
/commands/__pycache__
/ext/__pycache__
/.vs
/.vs
/.idea

21
bot.py
View File

@ -1,4 +1,4 @@
from commands import help, ticket, store
from commands import help, ticket
# pip install imports
import discord, aiofiles
@ -9,9 +9,7 @@ import asyncio
import pymongo
# sys imports
import os
import logging
import logging.handlers
import os
load_dotenv()
@ -25,15 +23,6 @@ sentry_sdk.init(
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()
@ -45,7 +34,7 @@ intents.members = True
# create the bot
class MyBot(commands.Bot):
def __init__(self):
super().__init__(command_prefix=get_server_prefix, intents = intents)
super().__init__(command_prefix="!", intents = intents)
self.synced = False
self.warnings = {}
self.remove_command("help")
@ -55,7 +44,6 @@ class MyBot(commands.Bot):
self.add_view(ticket.CreateButton())
self.add_view(ticket.CloseButton())
self.add_view(ticket.TrashButton())
self.add_view(store.SelectView())
print(f'\33[32mLogged in as {self.user} (ID: {self.user.id})')
print('------')
@ -64,9 +52,6 @@ class MyBot(commands.Bot):
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!"))
# making var for commands in this file
bot = MyBot()

View File

@ -1,45 +1,26 @@
import discord, pymongo, os
import discord
from discord import app_commands
from discord.ext import commands
from discord.utils import get
from dotenv import load_dotenv
afks = {}
load_dotenv()
# a remove func that removes [AFK] from the users name and returns it
def remove(user):
if "[AFK]" in user.split():
return " ".join(user.split()[1:])
# 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
return user
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")
# When the user sends a message remove them from the afk list
@commands.Cog.listener()
async def on_message(self, message):
if message.author.bot:
@ -52,31 +33,30 @@ class afk(commands.Cog):
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:
for user_id, reason in afks.items():
if user_id == self.bot.user.id:
return
member = get(message.guild.members, id=id)
member = get(message.guild.members, id=user_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)
@app_commands.command(name="afk", description="Set your status to AFK")
async def afk(self, interaction: discord.Interaction, *, reason:str = None):
if interaction.user.id in afks.keys():
afks.pop(interaction.user.id)
else:
try:
await ctx.author.edit(nick=f"[AFK] {ctx.author.display_name}")
await interaction.user.edit(nick=f"[AFK] {interaction.user.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)
afks[interaction.user.id] = reason
em = discord.Embed(title=f":zzz: Member AFK", description=f"{interaction.user.mention} has went AFK", color=0x00ff00)
em.set_thumbnail(url=interaction.user.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)
await interaction.response.send_message(embed=em)
async def setup(bot):
await bot.add_cog(afk(bot))

View File

@ -1,79 +0,0 @@
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":
coll.delete_one({"_id": {"guild_id": ctx.guild.id}})
await ctx.send("Announcement channel deleted, adding new channel...")
coll.insert_one({"_id": {"guild_id": ctx.guild.id}, "channel": channel.id})
await ctx.send("Announcement channel set")
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
if coll.find_one({"_id": {"guild_id": ctx.guild.id}}):
channel_id = coll.find_one({"_id": {"guild_id": ctx.guild.id}})["channel"]
channel = discord.utils.get(ctx.guild.text_channels, id=channel_id)
await channel.send(message)
await ctx.send("Announcement sent!", delete_after=2.0)
else:
await ctx.send("You have not set an announcement channel yet")
async def setup(bot):
await bot.add_cog(announce(bot))

View File

@ -1,41 +0,0 @@
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))

54
commands/channel.py Normal file
View File

@ -0,0 +1,54 @@
import discord
from discord import app_commands
from discord.ext import commands
class Channel(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_ready(self):
print("Channel Online")
channel = app_commands.Group(name="channel", description="Manage channels in the server")
@channel.command(name="lock", description="Disable messaging in the specified channel for users with the default role")
@commands.has_permissions(manage_channels=True)
async def lock(self, interaction: discord.Interaction, channel: discord.TextChannel = None):
if channel is None:
channel = interaction.channel
await channel.set_permissions(interaction.guild.default_role, send_messages=False)
await interaction.response.send_message(f"Users with {interaction.guild.default_role} cannot type in {channel.mention}", ephemeral=True)
@channel.command(name="unlock", description="Unlock a channel")
@commands.has_permissions(manage_channels=True)
async def unlock(self, interaction: discord.Interaction, channel: discord.TextChannel = None):
if channel is None:
channel = interaction.channel
await channel.set_permissions(interaction.guild.default_role, send_messages=True)
await interaction.response.send_message(f"Users with {interaction.guild.default_role} can now type in {channel.mention}", ephemeral=True)
@channel.command(name="slowmode", description="Set the channels slowmode")
@commands.has_permissions(manage_channels=True)
async def slowmode(self, interaction: discord.Interaction, seconds: int = None, *, channel: discord.TextChannel = None):
if channel is None:
channel = interaction.channel
if seconds is None or seconds == 0:
await channel.edit(slowmode_delay=0)
await interaction.response.send_message(f"Slowmode in {channel.mention} has been disabled.")
return
await channel.edit(slowmode_delay=seconds)
await interaction.response.send_message(f"Set the slowmode of {channel.mention} to {seconds} seconds")
@channel.command(name="clear", description="Bulk deletes messages")
@commands.has_permissions(manage_messages=True)
async def clear(self, interaction: discord.Interaction, amount: int):
await interaction.response.send_message(f"Deleted {amount} messages", ephemeral=True, delete_after=2)
await interaction.channel.purge(limit=amount)
async def setup(bot):
await bot.add_cog(Channel(bot))

View File

@ -1,46 +0,0 @@
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))

View File

@ -1,78 +0,0 @@
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.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):
await ctx.send("API for this command is no longer active. Convo disabled until further notice")
"""
@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'])
"""
async def setup(bot):
await bot.add_cog(convo(bot))

View File

@ -1,38 +0,0 @@
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))

View File

@ -1,52 +0,0 @@
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))

View File

@ -1,9 +1,14 @@
import discord, pymongo, random, os
import discord
import pymongo
import random
import os
from discord.ext import commands
from discord import app_commands
from dotenv import load_dotenv
load_dotenv()
client = pymongo.MongoClient(os.getenv("mongo_url"))
db = client.economy
coll = db.users
class economy(commands.Cog):
def __init__(self, bot):
@ -13,135 +18,110 @@ class economy(commands.Cog):
async def on_ready(self):
print("Economy Online")
@commands.hybrid_command(name="beg", description="Beg for money")
economy = app_commands.Group(name="economy", description="All the economy commands")
@economy.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
async def beg(self, interaction: discord.Interaction):
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"])
async def balance(self, ctx, member:discord.Member = None):
client = pymongo.MongoClient(os.getenv("mongo_url"))
db = client.servers
coll = db.economy
user = coll.find_one({"_id": interaction.user.id})
if user is not None:
coll.update_one({"_id": interaction.user.id}, {"$inc": {"coins": num}})
else:
coll.insert_one({"_id": interaction.user.id, "coins": num})
await interaction.response.send_message(f"{interaction.user.mention} you earned {num} coins")
@economy.command(name="balance", description="Check your balance")
async def balance(self, interaction: discord.Interaction, member :discord.Member = None):
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!")
member = interaction.user
@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
user = coll.find_one({"_id": member.id})
@commands.hybrid_command(name="work", description="Work for money")
if user is None:
await interaction.response.send_message(f"{member.mention} You have 0 coins")
return
await interaction.response.send_message(f"{member.mention} you have {user['coins']} coins")
@economy.command(name="pay", description="Pay someone")
@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
async def pay(self, interaction: discord.Interaction, member :discord.Member, amount:int):
user = coll.find_one({"_id": interaction.user.id})
member_acc = coll.find_one({"_id": member.id})
if user is None or member_acc is None:
await interaction.response.send_message(f"Cannot send coins to {member.mention}.")
return
if user['coins'] < amount:
await interaction.response.send_message("You do not have enough coins")
return
coll.update_one({"_id": interaction.user.id}, {"$inc": {"coins": -amount}})
coll.update_one({"_id": member.id}, {"$inc": {"coins": amount}})
await interaction.response.send_message(f"{member.mention} has been sent {amount} coins!")
@economy.command(name="work", description="Work for money")
@commands.cooldown(1, 60, commands.BucketType.user)
async def work(self, interaction: discord.Interaction):
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!")
user = coll.find_one({"_id": interaction.user.id})
if user is None:
coll.insert_one({"_id": interaction.user.id, "coins": num})
else:
coll.update_one({"_id": interaction.user.id}, {"$inc": {"coins": num}})
await interaction.response.send_message(f"You earned {num} coins!")
@commands.hybrid_command(name="rob", description="Rob someone")
@economy.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
async def rob(self, interaction: discord.Interaction, member: discord.Member):
user = coll.find_one({"_id": interaction.user.id})
member_acc = coll.find_one({"_id": member.id})
@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
if user is None or member_acc is None:
await interaction.response.send_message(f"Unable to rob {member.mention}", ephemeral=True)
return
@commands.hybrid_command(name="eleaderboard", description="View the leaderboard", aliases=["elb"])
if member_acc['coins'] < 500:
await interaction.response.send_message(f"{member.mention} has too little coins to steal from", ephemeral=True)
return
amount = random.randint(500, member_acc['coins'])
coll.update_one({"_id": interaction.user.id}, {"$inc": {"coins": amount}})
coll.update_one({"_id": member.id}, {"$inc": {"coins": -amount}})
await interaction.response.send_message(f"You have successfully robbed {member.mention} for {amount} coins!")
@economy.command(name="slots", description="Play slots")
@commands.cooldown(1, 60, commands.BucketType.user)
async def eleaderboard(self, ctx):
await ctx.send("Command disabled")
"""
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']).display_name}", value=f"{users[i]['coins']} bloboons", inline=False)
await ctx.send(embed=embed)
"""
async def slots(self, interaction: discord.Interaction, bet: int):
num = bet * 2
chance = random.randint(0, 10)
user = coll.find_one({"_id": interaction.user.id})
if user is None:
await interaction.response.send_message("You do not have an account yet. Please beg for some money.")
return
if chance < 5:
coll.update_one({"_id": interaction.user.id}, {"$inc": {"coins": -bet}})
await interaction.response.send_message(f"You lost.. Total amount lost is {bet}")
return
coll.update_one({"_id": interaction.user.id}, {"$inc": {"coins": num}})
await interaction.response.send_message(f"Congrats! You won {num} amount of coins!")
async def setup(bot):
await bot.add_cog(economy(bot))

View File

@ -1,34 +0,0 @@
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))

View File

@ -1,32 +0,0 @@
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))

View File

@ -1,9 +1,7 @@
import discord, random, pymongo, os
import discord
import random
from discord.ext import commands
from dotenv import load_dotenv
load_dotenv()
from discord import app_commands
class flip(commands.Cog):
def __init__(self, bot):
@ -13,32 +11,17 @@ class flip(commands.Cog):
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):
@app_commands.command(name="flip", description="Flip a coin")
async def flip(self, interaction: discord.Interaction):
num = [
'1',
'2'
]
flipnum = random.choice(num)
if flipnum == '1':
await ctx.send("Heads!!")
elif flipnum == "2":
await ctx.send("Tails!!")
flip_num = random.choice(num)
if flip_num == '1':
await interaction.response.send_message("Heads!!")
elif flip_num == "2":
await interaction.response.send_message("Tails!!")
async def setup(bot):

View File

@ -1,39 +0,0 @@
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))

View File

@ -1,22 +0,0 @@
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))

View File

@ -1,67 +1,91 @@
import discord, pymongo, os
import discord
from discord import app_commands
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")
discord.SelectOption(label="Channel Commands", emoji="📖", description="Look at all the channel commands"),
discord.SelectOption(label="Level Commands", emoji="🎚️", description="Look at all the level commands"),
discord.SelectOption(label="Role Commands", emoji="👔", description="Look at all the role commands"),
discord.SelectOption(label="Server Commands", emoji="💻", description="Look at all the server commands"),
discord.SelectOption(label="User Commands", emoji="🧑", description="Look at all the user commands"),
discord.SelectOption(label="Economy Commands", emoji="💵", description="Look at all the economy commands"),
discord.SelectOption(label="Warns Commands", emoji="⚠️", description="Look at all the warns commands"),
discord.SelectOption(label="Ticket Commands", emoji="🎫", description="Look at all the ticket commands"),
discord.SelectOption(label="Other Commands", emoji="🎈", description="Look at all the other 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, 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)
em.add_field(name="joinrole", value="Set the role a user gets on join, Example: -joinrole @Member", inline=False)
if self.values[0] == "Channel Commands":
em = discord.Embed(title="Channel Commands", description="Here are all the channel commands", color=interaction.user.color)
em.add_field(name="slowmode", value="Set the channels slow mode.", inline=False)
em.add_field(name="lock", value="Lock a channel from the default role in the server", inline=False)
em.add_field(name="unlock", value="Unlock a channel from the default role in the server", inline=False)
em.add_field(name="clear", value="Bulk delete messages", 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="More!", value="Check the bot dashboard for more!", inline=False)
await interaction.response.send_message(embed=em1, ephemeral=True)
elif self.values[0] == "Level Commands":
em = discord.Embed(title="Normal Commands", description="Here are all the normal commands", color=interaction.user.color)
em.add_field(name="rank", value="See your rank in the server", inline=False)
em.add_field(name="leaderboard", value="See the top 10 people in your server", inline=False)
em.add_field(name="setup", value="Setup levels in your server", inline=False)
em.add_field(name="edit", value="Edit the config for your server", inline=False)
await interaction.response.send_message(embed=em, ephemeral=True)
elif self.values[0] == "Role Commands":
em = discord.Embed(title="Role Commands", description="Here are all the role commands", color=interaction.user.color)
em.add_field(name='info', value="Get the info on a role in your server", inline=False)
em.add_field(name="give", value="Give a member in the server a role", inline=False)
em.add_field(name="join", value="Set the role a user gets when they join a server", inline=False)
em.add_field(name="remove", value="Remove a role from a user", inline=False)
await interaction.response.send_message(embed=em, ephemeral=True)
elif self.values[0] == "Server Commands":
em = discord.Embed(title="Role Commands", description="Here are all the server commands", color=interaction.user.color)
em.add_field(name="stats", value="Get the stats on the server", inline=False)
em.add_field(name="members", value="Show the member count", inline=False)
em.add_field(name="leave", value="Remove the bot from the server", inline=False)
await interaction.response.send_message(embed=em, ephemeral=True)
elif self.values[0] == "User Commands":
em = discord.Embed(title="User Commands", description="Here are all the user commands", color=interaction.user.color)
em.add_field(name="info", value="Get info about a user", inline=False)
em.add_field(name="avatar", value="Get a users avatar", inline=False)
em.add_field(name="nick", value="Set a users nickname", inline=False)
em.add_field(name="ban", value="Ban a user from the server", inline=False)
em.add_field(name="kick", value="Kick a user from the server", inline=False)
em.add_field(name="timeout", value="Timeout a user", inline=False)
em.add_field(name="untimeout", value="Remove a users timeout", inline=False)
await interaction.response.send_message(embed=em, ephemeral=True)
elif self.values[0] == "Economy Commands":
em = discord.Embed(title="Economy Commands", description="Here are all the economy commands", color=interaction.user.color)
em.add_field(name="beg", value="Beg for money", inline=False)
em.add_field(name="work", value="Work for money", inline=False)
em.add_field(name="slots", value="Play the slot machine", inline=False)
em.add_field(name="rob", value="Steal someones money from them", inline=False)
em.add_field(name="balance", value="Check how much money you have", inline=False)
em.add_field(name="pay", value="Send someone some money", inline=False)
await interaction.response.send_message(embed=em, ephemeral=True)
elif self.values[0] == "Warns Commands":
em = discord.Embed(title="Warns Commands", description="Here are all the warns commands", color=interaction.user.color)
em.add_field(name="warn", value="Warn a user", inline=False)
em.add_field(name="clear", value="Clear all warns for a user", inline=False)
em.add_field(name="check", value="Check a users warns", inline=False)
await interaction.response.send_message(embed=em, ephemeral=True)
elif self.values[0] == "Ticket Commands":
em = discord.Embed(title="Ticket Commands", description="Here are all the ticket commands", color=interaction.user.color)
em.add_field(name="setup", value="Setup the user for tickets", inline=False)
em.add_field(name="create", value="Create a ticket", inline=False)
await interaction.response.send_message(embed=em, ephemeral=True)
elif self.values[0] == "Other Commands":
em = discord.Embed(title="Other Commands", description="See all the uncategorized commands", color=interaction.user.color)
em.add_field(name="afk", value="Set your afk status", inline=False)
em.add_field(name="flip", value="Flip a coin", inline=False)
em.add_field(name="help", value="See this message", inline=False)
em.add_field(name="ping", value="Check the bot's latency", inline=False)
em.add_field(name="number", value="Generate a random number between 2 numbers", inline=False)
em.add_field(name="remind", value="Set a reminder", inline=False)
em.add_field(name="snipe", value="Recover a the last deleted message in a channel", inline=False)
await interaction.response.send_message(embed=em, ephemeral=True)
class SelectView(discord.ui.View):
def __init__(self):
@ -76,26 +100,10 @@ class help(commands.Cog):
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())
@app_commands.command(name="help", description="See all the commands")
async def help(self, interaction: discord.Interaction):
em = discord.Embed(title="Help", description="Select an item from the dropdown menu to view the commands", color=interaction.user.color)
await interaction.response.send_message(embed=em, view=SelectView())
async def setup(bot):

View File

@ -1,49 +0,0 @@
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))

View File

@ -1,59 +0,0 @@
import discord, pymongo, os
from discord.ext import commands
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":"joinrole"}}):
command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"joinrole"}})
command_enabled = command["enabled"] # True or False
if command_enabled:
return True
else:
return False
else:
return True
class joinrole(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_ready(self):
print("Joinrole Online")
@commands.hybrid_command(name="joinrole", description="Set the joinrole")
@commands.check(is_enabled)
@commands.has_permissions(manage_roles=True)
async def joinrole(self, ctx, role:discord.Role):
client = pymongo.MongoClient(os.getenv("mongo_url"))
db = client.servers
coll = db.roles
roles = coll.find_one({"_id": {"guild_id": ctx.guild.id}})
if not roles:
coll.insert_one({"_id": {"guild_id": ctx.guild.id}, "joinrole": role.id})
await ctx.send(f"Set the joinrole to {role.mention}!")
return
else:
coll.update_one({"_id": {"guild_id": ctx.guild.id}}, {"$set": {"joinrole": role.id}})
await ctx.send(f"Set the joinrole to {role.mention}!")
@commands.Cog.listener()
async def on_member_join(self, member):
client = pymongo.MongoClient(os.getenv("mongo_url"))
db = client.servers
coll = db.roles
joinrole = coll.find_one({"_id": {"guild_id": member.guild.id}})
if joinrole:
role = member.guild.get_role(joinrole["joinrole"])
await member.add_roles(role)
async def setup(bot):
await bot.add_cog(joinrole(bot))

View File

@ -1,38 +0,0 @@
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))

View File

@ -1,33 +0,0 @@
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))

148
commands/levels.py Normal file
View File

@ -0,0 +1,148 @@
import discord
import pymongo
import os
from discord import app_commands
from discord.ext import commands
client = pymongo.MongoClient(os.getenv("mongo_url"))
db = client.levels
class Levels(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_ready(self):
print("Levels Online")
levels = app_commands.Group(name="levels", description="All the leveling commands!")
@commands.Cog.listener()
async def on_message(self, message):
# get the guilds coll
guilds_coll = db.guilds
if message.author.bot:
return
if message.content.startswith(self.bot.command_prefix):
return
if message.guild is None:
return
if guilds_coll.find_one({"_id": message.guild.id}) is None or guilds_coll.find_one({"_id": message.guild.id})['disabled'] == True:
return
xp_inc = guilds_coll.find_one({"_id": message.guild.id})["xp_inc"]
# check if user has an account in the db
coll = db.accounts
users = coll.find_one({"_id": message.author.id})
if users is None:
coll.insert_one({"_id": message.author.id, "xp": xp_inc, "level": 1, "guild": message.guild.id})
else:
coll.update_one({"_id": message.author.id}, {"$inc": {"xp": xp_inc}})
user = coll.find_one({"_id": message.author.id})
if user['xp'] >= user['level'] * 100:
coll.update_one({"_id": message.author.id}, {"$inc": {"level": 1}})
guild_channel = guilds_coll.find_one({"_id": message.guild.id})['channel']
if guild_channel is None:
await message.guild.owner.send(f"There is an issue with leveling! User: {message.author.id} has leveled up but no log channel is set..")
else:
channel = message.guild.get_channel(guild_channel)
await channel.send(f"{message.author.display_name} has reached level {user['level']}!")
if user['level'] == 50 or user['level'] == 100:
await message.guild.owner.send(f"{message.author.display_name} has reached level 50 or 100!")
@levels.command(name="setup", description='Set the levels channel')
@commands.has_permissions(manage_messages=True)
async def setup(self, interaction: discord.Interaction, channel: discord.TextChannel = None, xp: int = None):
if channel == None:
channel = interaction.channel
if xp is None:
xp = 5
await interaction.response.send_message(f"Starting the setup process")
coll = db.guilds
coll.insert_one({"_id": interaction.guild.id, "channel": channel.id, "xp_inc": xp, "disabled": False})
await interaction.followup.send(f"The channel set for levels logging is <#{channel.id}>\nThe xp increment is {xp}")
@levels.command(name='edit', description='Edit the current config')
@commands.has_permissions(manage_messages=True)
async def edit(self, interaction: discord.Interaction, channel: discord.TextChannel = None, xp: int = None, disabled: bool = None):
if channel == None:
channel = interaction.channel
if xp is None:
xp = 5
if disabled is None:
disabled = False
await interaction.response.send_message(f"Editing the current config...")
coll = db.guilds
guild = coll.find_one({"_id": interaction.guild.id})
if guild is None:
await interaction.followup.send("The guilds is not currently setup for leveling")
return
coll.update_one({"_id": interaction.guild.id}, {"$set": {"channel": channel.id, "xp_inc": xp, "disabled": disabled}})
await interaction.followup.send(f"Current channel: <#{channel.id}>\nXP is: {xp}\nAre levels disabled? {disabled}")
@levels.command(name="rank", description='Show your current level and xp!')
async def rank(self, interaction: discord.Interaction, member: discord.Member = None):
if member is None:
member = interaction.user
user_coll = db.accounts
guild_coll = db.guilds
user = user_coll.find_one({"_id": member.id})
guild = guild_coll.find_one({"_id": interaction.guild.id})
if user is None:
await interaction.response.send_message("This user hasn't sent a message! They don't have a rank.")
return
em = discord.Embed(title="Rank", description=f"{member.display_name}'s current rank is...", color=member.color)
em.add_field(name="Level", value=user['level'], inline=False)
em.add_field(name='XP', value=user['xp'], inline=False)
em.add_field(name='XP required to level up', value=f"{(user['level'] * 100) - user['xp']}", inline=False)
em.add_field(name='Disabled?', value=guild['disabled'])
await interaction.response.send_message(embed=em)
@levels.command(name="leaderboard", description="View the leaderboard")
async def leaderboard(self, interaction: discord.Interaction):
coll = db.accounts
leaderboard = coll.find({"_id": interaction.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 coll.count_documents({"guild": interaction.guild.id}) < 10:
await interaction.response.send_message("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)
await interaction.response.send_message(embed=embed)
async def setup(bot):
await bot.add_cog(Levels(bot))

View File

@ -1,103 +0,0 @@
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))

View File

@ -1,51 +0,0 @@
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))

View File

@ -1,38 +0,0 @@
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))

View File

@ -1,60 +0,0 @@
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://humor-jokes-and-memes.p.rapidapi.com/memes/random"
querystring = {"number":"1","media-type":"image","keywords-in-image":"false","min-rating":"4"}
headers = {
"X-RapidAPI-Key": "fc3dac086bmsh835062c787b309ep1c9d10jsnf9716a0fe3fb",
"X-RapidAPI-Host": "humor-jokes-and-memes.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)
json_data = json.loads(response.text)
description = json_data["description"]
url = json_data["url"]
embed = discord.Embed(
title="Meme",
description=description,
color=ctx.author.color
)
embed.set_image(url=url)
await ctx.send(embed=embed)
async def setup(bot):
await bot.add_cog(meme(bot))

View File

@ -1,67 +0,0 @@
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))

20
commands/number.py Normal file
View File

@ -0,0 +1,20 @@
import discord
import random
from discord.ext import commands
from discord import app_commands
class Number(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_ready(self):
print("Number Online")
@app_commands.command(name="number", description="Get a random number between from what you choose")
async def number(self, interaction: discord.Interaction, num1: int, num2: int):
await interaction.response.send_message(f"{random.randint(num1, num2)}")
async def setup(bot):
await bot.add_cog(Number(bot))

View File

@ -1,36 +0,0 @@
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))

View File

@ -1,39 +1,18 @@
import discord, typing, pymongo, os
from typing import Union
import discord
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")
@app_commands.command(name="ping", description="Pong!")
async def ping(self, interaction: discord.Interaction):
await interaction.response.send_message(f":ping_pong:**Pong!**\nLatency: {round(self.bot.latency * 1000)}ms")
async def setup(bot):
await bot.add_cog(ping(bot))

View File

@ -1,59 +0,0 @@
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))

View File

@ -1,59 +0,0 @@
import discord, pymongo, os
from discord.ext import commands
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":"redeem"}}):
command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"redeem"}})
command_enabled = command["enabled"] # True or False
if command_enabled:
return True
else:
return False
else:
return True
class redeem(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_ready(self):
print("Redeem Online")
@commands.hybrid_command(name="redeem", description="Redeem a ticket")
@commands.check(is_enabled)
async def redeem(self, ctx, ticket_type: str):
client = pymongo.MongoClient(os.getenv("mongo_url"))
db = client.servers
coll = db.economy
guild = ctx.guild
user = ctx.author
userColl = coll.find_one({"_id": {'author_id': user.id, 'guild_id': guild.id}})
if not userColl:
await ctx.send("You don't have any coins!")
return
if not userColl["bought"]:
await ctx.send("You don't have any tickets!")
return
if ticket_type == userColl["bought"]:
coll.update_one({"_id": {"author_id": user.id, "guild_id": guild.id}}, {"$set": {"bought": None}})
await ctx.send("You redeemed your ticket!")
return
else:
await ctx.send("You don't have that ticket!")
return
async def setup(bot):
await bot.add_cog(redeem(bot))

View File

@ -1,5 +1,7 @@
import discord, pymongo, asyncio, os
import discord
import asyncio
from discord.ext import commands
from discord import app_commands
from dotenv import load_dotenv
load_dotenv()
@ -12,29 +14,13 @@ class remind(commands.Cog):
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)
@app_commands.command(name="remind", description="Create a reminder")
async def remind(self, interaction: discord.Interaction, time: int, *, reminder: str):
em = discord.Embed(title="You will be reminded about: ", description=f"{reminder} in {time} hours", color=interaction.user.color)
await interaction.response.send_message(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)
alert_em = discord.Embed(title="Reminder", description=f"{interaction.user.mention}, you asked me to remind you about: {reminder}", color=interaction.user.color)
await interaction.followup.send(embed=alert_em)
async def setup(bot):
await bot.add_cog(remind(bot))

View File

@ -1,39 +0,0 @@
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))

View File

@ -1,37 +0,0 @@
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))

68
commands/role.py Normal file
View File

@ -0,0 +1,68 @@
import discord
import pymongo
import os
from discord import app_commands
from discord.ext import commands
client = pymongo.MongoClient(os.getenv("mongo_url"))
db = client.roles
coll = db.guild
class Role(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_ready(self):
print("Role Online")
role = app_commands.Group(name="role", description="Manage roles in your server!")
@role.command(name="give", description="Gives a user a role")
@commands.has_permissions(administrator=True)
async def give(self, interaction: discord.Interaction, user: discord.Member, role: discord.Role):
await user.add_roles(role)
await interaction.response.send_message(f"Gave {user.mention} the {role.name} role", ephemeral=True)
@role.command(name="join", description="Select the role you want to give to a user when they join the server")
@commands.has_permissions(manage_roles=True)
async def join(self, interaction: discord.Interaction, role: discord.Role):
guild = coll.find_one({"_id": interaction.guild.id})
if guild is None:
coll.insert_one({"_id": interaction.guild.id, "join_role": role.id})
else:
coll.update_one({"_id": interaction.guild.id}, {"$set": {"join_role": role.id}})
await interaction.response.send_message(f"Set the join role to {role.mention}")
@role.command(name="remove", description="Remove a role from a user")
@commands.has_permissions(administrator=True)
async def remove(self, interaction: discord.Interaction, user: discord.Member, role: discord.Role):
await user.remove_roles(role)
await interaction.response.send_message(f"Removed {role} from {user.display_name}")
@role.command(name="info", description="Get info about a role")
async def info(self, interaction: discord.Interaction, 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 interaction.response.send_message(embed=embed)
@commands.Cog.listener()
async def on_member_join(self, member):
role = coll.find_one({"_id": member.guild.id})
if role:
role = member.guild.get_role(role["join_role"])
await member.add_roles(role)
async def setup(bot):
await bot.add_cog(Role(bot))

View File

@ -1,47 +0,0 @@
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))

41
commands/server.py Normal file
View File

@ -0,0 +1,41 @@
import discord
from discord import app_commands
from discord.ext import commands
class Server(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_ready(self):
print("Server Online")
server = app_commands.Group(name="server", description="Manage your server!")
@server.command(name="members", description="Shows how many members are in the server")
async def members(self, interaction: discord.Interaction):
em = discord.Embed(title="Member Count", description=f"Total Members: {interaction.guild.member_count}",
color=interaction.user.color)
await interaction.response.send_message(embed=em)
@server.command(name="stats", description="Check the servers stats")
async def stats(self, interaction: discord.Interaction):
role_count = len(interaction.guild.roles)
em = discord.Embed(color=interaction.user.color)
em.add_field(name="Server Name", value=f"{interaction.guild.name}", inline=False)
em.add_field(name="Member Count", value=f"{interaction.guild.member_count}", inline=False)
em.add_field(name="Verify Level", value=f"{interaction.guild.verification_level}", inline=False)
em.add_field(name="Highest Role", value=f"{interaction.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"{interaction.guild.id}", inline=False)
await interaction.response.send_message(embed=em)
@server.command(name="leave", description="Leaves the guild")
@commands.has_permissions(administrator=True)
async def leave(self, interaction: discord.Interaction):
await interaction.response.send_message("Left the guild")
await interaction.guild.leave()
async def setup(bot):
await bot.add_cog(Server(bot))

View File

@ -1,45 +0,0 @@
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))

View File

@ -1,49 +0,0 @@
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))

View File

@ -1,54 +0,0 @@
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))

View File

@ -1,40 +0,0 @@
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))

View File

@ -1,45 +0,0 @@
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))

View File

@ -1,79 +1,55 @@
import discord
import asyncio
import pymongo
import os
from discord.ext import commands
from discord import app_commands
from dotenv import load_dotenv
load_dotenv()
client = pymongo.MongoClient(os.getenv("mongo_url"))
db = client.snipes
coll = db.guild
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:
snipe = coll.find_one({"_id": channel.id})
if snipe is None:
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}})
return
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)
@app_commands.command(name="snipe", description="Revive a deleted message")
@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
async def snipe(self, interaction: discord.Interaction, channel: discord.TextChannel = None):
if channel is None:
channel = interaction.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 = discord.Embed(title="Sniped Message", description=f"**Author**: {self.bot.get_user(author).mention}\n**Content**: {content}", color=interaction.user.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)
embed.set_footer(text=f"Requested by {interaction.user}", icon_url=interaction.user.avatar)
await interaction.response.send_message(embed=embed)
else:
await ctx.send("There is nothing to snipe")
await interaction.response.send_message("There is nothing to snipe")
async def setup(bot):
await bot.add_cog(Snipe(bot))

View File

@ -1,192 +0,0 @@
# LINKED WITH ECONOMY.PY
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":"store"}}):
command = coll.find_one({"_id": {"guild_id": self.guild.id, "commands":"store"}})
command_enabled = command["enabled"] # True or False
if command_enabled:
return True
else:
return False
else:
return True
class Select(discord.ui.Select):
def __init__(self):
options=[
discord.SelectOption(label="Bronze Ticket", emoji="🥉", description="Cost: 100 bloboons"),
discord.SelectOption(label="Silver Ticket", emoji="🥈", description="Cost: 200 bloboons"),
discord.SelectOption(label="Gold Ticket", emoji="🥇", description="Cost: 400 bloboons"),
discord.SelectOption(label="Diamond Ticket", emoji="💎", description="Cost: 800 bloboons"),
discord.SelectOption(label="Emerald Ticket", emoji="🟢", description="Cost: 1600 bloboons"),
]
super().__init__(custom_id="buyticket", placeholder="What ticket do you want to buy?", max_values=1, min_values=1, options=options)
async def callback(self, interaction: discord.Interaction):
if self.values[0] == "Bronze Ticket":
await interaction.response.defer(ephemeral=True)
client = pymongo.MongoClient(os.getenv("mongo_url"))
db = client.servers
coll = db.economy
cost = 100
guild = interaction.guild
user = interaction.user
userColl = coll.find_one({"_id": {'author_id': user.id, 'guild_id': guild.id}})
if not userColl:
await interaction.followup.send("You don't have any coins!", ephemeral=True)
return
if userColl["coins"] < cost:
await interaction.followup.send("You don't have enough coins!", ephemeral=True)
return
if userColl["coins"] >= cost:
coll.update_one({"_id": {'author_id': user.id, 'guild_id': guild.id}}, {"$inc":{"coins":-cost}})
coll.update_one({"_id": {"author_id": user.id, "guild_id": guild.id}}, {"$set": {"bought": "bronze"}})
await interaction.followup.send("You bought the bronze ticket! Redeem it in the Blob support server for rewards!", ephemeral=True)
return
elif self.values[0] == "Silver Ticket":
await interaction.response.defer(ephemeral=True)
client = pymongo.MongoClient(os.getenv("mongo_url"))
db = client.servers
coll = db.economy
cost = 200
guild = interaction.guild
user = interaction.user
userColl = coll.find_one({"_id": {'author_id': user.id, 'guild_id': guild.id}})
if not userColl:
await interaction.followup.send("You don't have any coins!", ephemeral=True)
return
if userColl["coins"] < cost:
await interaction.followup.send("You don't have enough coins!", ephemeral=True)
return
if userColl["coins"] >= cost:
coll.update_one({"_id": {'author_id': user.id, 'guild_id': guild.id}}, {"$inc":{"coins":-cost}})
coll.update_one({"_id": {"author_id": user.id, "guild_id": guild.id}}, {"$set": {"bought": "silver"}})
await interaction.followup.send("You bought the silver ticket! Redeem it in the Blob support server for rewards!", ephemeral=True)
return
elif self.values[0] == "Gold Ticket":
await interaction.response.defer(ephemeral=True)
client = pymongo.MongoClient(os.getenv("mongo_url"))
db = client.servers
coll = db.economy
cost = 400
guild = interaction.guild
user = interaction.user
userColl = coll.find_one({"_id": {'author_id': user.id, 'guild_id': guild.id}})
if not userColl:
await interaction.followup.send("You don't have any coins!", ephemeral=True)
return
if userColl["coins"] < cost:
await interaction.followup.send("You don't have enough coins!", ephemeral=True)
return
if userColl["coins"] >= cost:
coll.update_one({"_id": {'author_id': user.id, 'guild_id': guild.id}}, {"$inc":{"coins":-cost}})
coll.update_one({"_id": {"author_id": user.id, "guild_id": guild.id}}, {"$set": {"bought": "gold"}})
await interaction.followup.send("You bought the gold ticket! Redeem it in the Blob support server for rewards!", ephemeral=True)
return
elif self.values[0] == "Diamond Ticket":
await interaction.response.defer(ephemeral=True)
client = pymongo.MongoClient(os.getenv("mongo_url"))
db = client.servers
coll = db.economy
cost = 800
guild = interaction.guild
user = interaction.user
userColl = coll.find_one({"_id": {'author_id': user.id, 'guild_id': guild.id}})
if not userColl:
await interaction.followup.send("You don't have any coins!", ephemeral=True)
return
if userColl["coins"] < cost:
await interaction.followup.send("You don't have enough coins!", ephemeral=True)
return
if userColl["coins"] >= cost:
coll.update_one({"_id": {'author_id': user.id, 'guild_id': guild.id}}, {"$inc":{"coins":-cost}})
coll.update_one({"_id": {"author_id": user.id, "guild_id": guild.id}}, {"$set": {"bought": "diamond"}})
await interaction.followup.send("You bought the diamond ticket! Redeem it in the Blob support server for rewards!", ephemeral=True)
return
elif self.values[0] == "Emerald Ticket":
await interaction.response.defer(ephemeral=True)
client = pymongo.MongoClient(os.getenv("mongo_url"))
db = client.servers
coll = db.economy
cost = 1600
guild = interaction.guild
user = interaction.user
userColl = coll.find_one({"_id": {'author_id': user.id, 'guild_id': guild.id}})
if not userColl:
await interaction.followup.send("You don't have any coins!", ephemeral=True)
return
if userColl["coins"] < cost:
await interaction.followup.send("You don't have enough coins!", ephemeral=True)
return
if userColl["coins"] >= cost:
coll.update_one({"_id": {'author_id': user.id, 'guild_id': guild.id}}, {"$inc":{"coins":-cost}})
coll.update_one({"_id": {"author_id": user.id, "guild_id": guild.id}}, {"$set": {"bought": "emerald"}})
await interaction.followup.send("You bought the emerald ticket! Redeem it in the Blob support server for rewards!", ephemeral=True)
return
class SelectView(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
self.add_item(Select())
class store(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_ready(self):
print('Tickets Online')
@commands.hybrid_command(name="store", description="View the store")
@commands.check(is_enabled)
async def store(self, ctx):
em = discord.Embed(title="Shop!", description="Spend some Bloboons to get cool rewards! Redeem in supported servers! Currently has no use", color=ctx.author.color)
em.add_field(name="Bronze Ticket", value="100 Bloboons", inline=False)
em.add_field(name="Silver Ticket", value="200 Bloboons", inline=False)
em.add_field(name="Gold Ticket", value="400 Bloboons", inline=False)
em.add_field(name="Diamond Ticket", value="800 Bloboons", inline=False)
em.add_field(name="Emerald Ticket", value="1600 Bloboons", inline=False)
await ctx.send(
embed=em,
view=SelectView()
)
async def setup(bot):
await bot.add_cog(store(bot))

View File

@ -1,63 +0,0 @@
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))

View File

@ -1,7 +1,6 @@
import discord
from discord.ext import commands
class sync(commands.Cog):
def __init__(self, bot):
self.bot = bot

View File

@ -1,35 +1,26 @@
import discord, asyncio, pymongo, os
import discord
import pymongo
import os
import asyncio
from discord.ext import commands
from dotenv import load_dotenv
from discord.ui import Button, button, View
from discord import app_commands
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
client = pymongo.MongoClient(os.getenv('mongo_url'))
db = client.tickets
async def send_log(title: str, guild: discord.Guild, description: str, color: discord.Color):
log_channel = discord.utils.get(guild.channels, name="ticket-logs")
guild_coll = db.guilds
ticket_log_id = guild_coll.find_one({"_id": guild.id})['log_channel']
ticket_log = guild.get_channel(ticket_log_id)
embed = discord.Embed(
title=title,
description=description,
color=color
)
await log_channel.send(embed=embed)
await ticket_log.send(embed=embed)
class CreateButton(View):
def __init__(self):
@ -38,21 +29,30 @@ class CreateButton(View):
@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)
# db setup
guild_coll = db.guilds
guild = guild_coll.find_one({"_id": interaction.guild.id})
if guild is None:
await interaction.response.send_message("Tickets is not setup for this server...")
return
# category stuff & check if user already has a ticket opened
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)
await interaction.response.send_message(
"You already have a ticket open! Ticket located in {0}".format(ch.mention), ephemeral=True)
return
# send message to let the user know the bot is doing things
await interaction.response.send_message("Creating a ticket...")
# get the ticket number
ticket_num = guild['ticket_count'] + 1
# channel settings & create channel
r1: discord.Role = discord.utils.get(interaction.guild.roles, name="Ticket Master")
overwrites = {
interaction.guild.default_role: discord.PermissionOverwrite(read_messages=False),
@ -61,8 +61,7 @@ class CreateButton(View):
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}",
name=f"ticket-{ticket_num}",
topic=f"{interaction.user.id} DO NOT CHANGE THE TOPIC OF THIS CHANNEL!",
overwrites=overwrites
)
@ -85,11 +84,19 @@ class CloseButton(View):
@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")
channel = interaction.channel
await asyncio.sleep(5)
# get the ticket number
split_channel_name = channel.name.split("ticket-")
ticket = split_channel_name[1]
# send a message to the user letting them know the ticket is being closed
await interaction.response.send_message("Attempting to close this ticket...")
# get the author of the ticket
ticket_author = channel.topic.split(" ")[0]
# edit the channel
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 = {
@ -99,6 +106,17 @@ class CloseButton(View):
}
await interaction.channel.edit(category=category, overwrites=overwrites)
# update the db
ticket_coll = db.tickets
guild_coll = db.guilds
ticket_coll.update_one({"_id": int(ticket_author)}, {"$set": {"opened": False}})
guild_coll.update_one({"_id": interaction.guild.id}, {"$pull": {"opened_tickets": int(ticket)}})
guild_coll.update_one({"_id": interaction.guild.id}, {"$push": {"closed_tickets": int(ticket)}})
# tell the user the ticket was closed
await interaction.channel.send(
embed = discord.Embed(
title="Ticket Closed",
@ -126,6 +144,14 @@ class TrashButton(View):
await interaction.channel.delete()
ticket_coll = db.tickets
guild_coll = db.guilds
ticket_author = int(interaction.channel.topic.split(" ")[0])
ticket = int(interaction.channel.name.split('ticket-')[1])
ticket_coll.delete_one({"_id": ticket_author})
guild_coll.update_one({"_id": interaction.guild.id}, {"$pull": {"closed_tickets": ticket}})
await send_log(
title="Ticket Deleted",
description=f"Deleted by: {interaction.user.mention}",
@ -133,7 +159,7 @@ class TrashButton(View):
guild=interaction.guild
)
class ticket(commands.Cog):
class Ticket(commands.Cog):
def __init__(self, bot):
self.bot = bot
@ -141,25 +167,56 @@ class ticket(commands.Cog):
async def on_ready(self):
print('Tickets Online')
@commands.hybrid_command(name="ticket", description="Create a ticket")
ticket = app_commands.Group(name="tickets", description="Have an issue? Create a ticket now")
@ticket.command(name="setup", description="Setup tickets")
@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(
async def setup(self, interaction: discord.Interaction):
await interaction.response.send_message("Starting the setup process")
coll = db.guilds
guild = coll.find_one({"_id": interaction.guild.id})
if guild is not None:
await interaction.followup.send("Ticket has already been setup for this server")
return
if not discord.utils.get(interaction.guild.categories, name="OPENED TICKETS"):
await interaction.guild.create_category(name="OPENED TICKETS")
if not discord.utils.get(interaction.guild.categories, name="CLOSED TICKETS"):
await interaction.guild.create_category(name="CLOSED TICKETS")
if not discord.utils.get(interaction.guild.roles, name="Ticket Master"):
await interaction.guild.create_role(name="Ticket Master")
if not discord.utils.get(interaction.guild.channels, name="ticket-logs"):
await interaction.guild.create_text_channel(name="ticket-logs")
log_channel = discord.utils.get(interaction.guild.channels, name="ticket-logs")
coll.insert_one({"_id": interaction.guild.id, "ticket_count": 0, "opened_tickets": [], "closed_tickets": [],
"log_channel": log_channel.id})
await interaction.followup.send("Tickets have been setup. Users can use `/ticket create` in any channel.")
await log_channel.send("This channel will now be used for ticket logging.")
@ticket.command(name="create", description="Create a ticket")
@commands.has_permissions(administrator=True)
async def ticket(self, interaction: discord.Interaction):
# db setup
guild_coll = db.guilds
guild = guild_coll.find_one({"_id": interaction.guild.id})
if guild is None:
await interaction.response.send_message("Tickets is not setup for this server...")
return
await interaction.response.send_message(
embed=discord.Embed(
description="Click the button below to create a ticket",
color=ctx.author.color
color=interaction.user.color
),
view=CreateButton()
)
async def setup(bot):
await bot.add_cog(ticket(bot))
await bot.add_cog(Ticket(bot))

View File

@ -1,49 +0,0 @@
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))

View File

@ -1,50 +0,0 @@
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))

101
commands/user.py Normal file
View File

@ -0,0 +1,101 @@
import datetime
import discord
from discord import app_commands
from discord.ext import commands
class User(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_ready(self):
print("User Online")
user = app_commands.Group(name="user", description="Manage users in the server")
@user.command(name="kick", description="Kicks a user")
@commands.has_permissions(kick_members=True)
async def kick(self, interaction: discord.Interaction, member: discord.Member, *, reason: str = None):
if member.id == interaction.user.id:
await interaction.response.send_message("You cannot kick yourself.")
return
guild = interaction.guild
embed = discord.Embed(title="Kick", description=f"{member.mention} has been kicked for {reason}",
color=interaction.user.color)
member_embed = discord.Embed(title="Kicked", description=f"You have been kicked in {guild.name} for {reason}",
color=member.color)
await interaction.response.send_messaged(embed=embed)
await member.send(embed=member_embed)
await member.kick(reason=reason)
@user.command(name="ban", description="Bans a user")
@commands.has_permissions(ban_members=True)
async def ban(self, interaction: discord.Interaction, member: discord.Member, *, reason: str = None):
if member.id == interaction.user.id:
await interaction.response.send_message("You cannot ban yourself.")
return
ban_message = discord.Embed(title="Ban",
description=f"{member.mention} has been banned in the server for {reason}",
color=interaction.user.color)
ban_member_message = discord.Embed(title="Banned", description=f"You have been banned for {reason}",
color=member.color)
await member.send(embed=ban_member_message)
await member.ban(reason=reason)
await interaction.response.send_message(embed=ban_message)
@user.command(name="nick", description="Sets a users nickname")
@commands.has_permissions(manage_nicknames=True)
async def nick(self, interaction: discord.Interaction, nick: str, user: discord.Member = None):
if user is None:
user = interaction.user
await user.edit(nick=nick)
await interaction.response.send_message(f"Set {user.mention}'s nickname to {nick}", ephemeral=True)
@user.command(name="timeout", description="Timeout a user")
@commands.has_permissions(manage_messages=True)
async def timeout(self, interaction: discord.Interaction, user: discord.Member, time: int, reason: str = None):
if user.id is interaction.user.id:
await interaction.response.send_message("You can't timeout yourself")
else:
await user.timeout(datetime.timedelta(minutes=time), reason=reason)
await interaction.response.send_Message(f"{user.mention} has been timed out for {reason}", ephemeral=True)
@user.command(name="untimeout", description="Remove a users timeout")
@commands.has_permissions(manage_messages=True)
async def untimeout(self, interaction: discord.Interaction, user: discord.Member):
await user.timeout(None)
await interaction.response.send_message(f"{user.mention} has been removed from timeout", ephemeral=True)
@user.command(name="avatar", description="Shows a users avatar")
async def avatar(self, interaction: discord.Interaction, user: discord.Member = None):
if user == None:
user = interaction.user
em = discord.Embed(title=f"{user.name}'s Avatar", color=user.color)
em.set_image(url=user.avatar)
await interaction.response.send_message(embed=em)
@user.command(name="info", description="Shows info about the user")
async def info(self, interaction: discord.Interaction, user: discord.Member = None):
if user is None:
user = interaction.user
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 interaction.response.send_message(embed=em)
async def setup(bot):
await bot.add_cog(User(bot))

View File

@ -1,12 +1,13 @@
import discord, pymongo, os
import discord
import pymongo
import os
from discord.ext import commands
from pymongo import errors
from discord import app_commands
from dotenv import load_dotenv
client = pymongo.MongoClient(os.getenv("mongo_url"))
db = client.warns
load_dotenv()
class warns(commands.Cog):
class Warns(commands.Cog):
def __init__(self, bot):
self.bot = bot
@ -14,66 +15,65 @@ class warns(commands.Cog):
async def on_ready(self):
print("Warns Online")
warns = app_commands.Group(name="warns", description="Manage warns in your server")
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")
@warns.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)
async def warn(self, interaction: discord.Interaction, member: discord.Member, *, reason: str = None):
user_coll = db.users
guild_coll = db.guilds
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}})
guild = guild_coll.find_one({"_id": interaction.guild.id})
user = user_coll.find_one({"_id": member.id})
@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 guild is None:
guild_coll.insert_one({"_id": interaction.guild.id})
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)
if user is None:
user_coll.insert_one({"_id": member.id, "count": 1, "warns": [reason]})
else:
embed = discord.Embed(title=f"{member.display_name} has no warns!", color=ctx.author.color)
await ctx.send(embed=embed)
user_coll.update_one({"_id": member.id}, {"$inc": {"count": 1}})
user_coll.update_one({"_id": member.id}, {"$push": {"warns": reason}})
embed = discord.Embed(title="Warned", description=f"{member.mention} you have been warned for {reason}", color=interaction.user.color)
await interaction.response.send_message(embed=embed)
@commands.hybrid_command(name="clearwarns", description="Clear all warns from a user")
@warns.command(name="check", description="Check how many warns a user has")
async def check(self, interaction: discord.Interaction, member: discord.Member = None):
if member is None:
member = interaction.user
user_coll = db.users
user = user_coll.find_one({"_id": member.id})
if user is None:
await interaction.response.send_message("This user has no warns!")
return
warns = user['warns']
em = discord.Embed(title="Warns", description=f"Warns for {member.display_name}", color=interaction.user.color)
for i, warn in enumerate(warns):
em.add_field(name=f"Warn #{i + 1}", value=f"{warn}", inline=False)
await interaction.response.send_message(embed=em)
@warns.command(name="clear", 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 clear(self, interaction: discord.Interaction, member: discord.Member):
user_coll = db.users
user = user_coll.find_one({"_id": member.id})
if user is None:
await interaction.response.send_message(f"{member.mention} has no warns!")
return
user_coll.delete_one({"_id": member.id})
await interaction.response.send_message(f"{member.mention} warns have been cleared!")
async def setup(bot):
await bot.add_cog(warns(bot))
await bot.add_cog(Warns(bot))

View File

@ -1 +0,0 @@
afks = {}

View File

@ -1,4 +0,0 @@
import discord
guilds = discord.Object(id=1032415451801727046)
guild = 1032415451801727046

View File

@ -5,6 +5,4 @@ python-dotenv==1.0.0
requests==2.31.0
urllib3==2.1.0
sentry-sdk==1.39.1
aiosqlite==0.3.0
pymongo==4.6.1
multidict==6.0.4