Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 36 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
import json
import random
from dotenv import load_dotenv
from cusswords import badwords,starter_response_to_cussWords
from cusswords import badwords, starter_response_to_cussWords
import motor.motor_asyncio
import asyncio

load_dotenv()
client = discord.Client()


client = discord.Client(intents=discord.Intents.all())

mongo_client = motor.motor_asyncio.AsyncIOMotorClient(os.getenv("MONGO_URI"))
db = mongo_client["dadbot"]

def get_quote():
response = requests.get('https://zenquotes.io/api/random')
Expand All @@ -35,11 +37,11 @@ def get_activity():
async def on_ready():
print("We have logged in as {0.user}".format(client))


@client.event
async def on_message(message):
if message.author == client.user:
return

msg = message.content

if message.content.startswith('bsdk'):
Expand All @@ -51,6 +53,34 @@ async def on_message(message):
if message.content.startswith('I am bored daddy'):
activity = get_activity()
await message.channel.send(f'Are you bored ? ...{activity}')

if any(word in msg for word in badwords):
await message.channel.send(random.choice(starter_response_to_cussWords))
client.run(os.getenv("TOKEN"))
user_id = str(message.author.id)
guild_id = str(message.guild.id)
user_data = await db.warnings.find_one({"user_id": user_id, "guild_id": guild_id})
if not user_data:
count = 1
await db.warnings.insert_one({"user_id": user_id, "guild_id": guild_id, "count": count})
else:
count = user_data["count"] + 1
await db.warnings.update_one(
{"user_id": user_id, "guild_id": guild_id},
{"$set": {"count": count}}
)
await message.channel.send(f"{message.author.mention}, this is your warning #{count}")
if count == 3:
mute_role = discord.utils.get(message.guild.roles, name="Muted")
if mute_role:
await message.author.add_roles(mute_role)
await message.channel.send(f"{message.author.mention} has been muted for 12 hours")
await asyncio.sleep(12 * 60 * 60)
await message.author.remove_roles(mute_role)
await message.channel.send(f"{message.author.mention} has been unmuted")
else:
await message.channel.send("'Muted' role not found. Please create one.")
elif count >= 5:
await message.channel.send(f"{message.author.mention} has been banned for repeated offenses")
await message.guild.ban(message.author, reason="Exceeded 5 warnings")

client.run(os.getenv("TOKEN"))