0% found this document useful (0 votes)
79 views7 pages

Message

Uploaded by

samimahdadi8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views7 pages

Message

Uploaded by

samimahdadi8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

import discord

from [Link] import commands, tasks


from [Link] import Button, View
import json
import os
import datetime
import asyncio
import sys
import signal

TOKEN = 'BOT_TOKEN_HERE'

intents = [Link]()
bot = [Link](command_prefix='/', intents=intents)

STATS_FILE = 'rizz_stats.json'
LOGS_FILE = 'mod_logs.json'
PROBATION_DATA_FILE = 'probation_data.json'

stats = {}
mod_logs = {}
probation_data = {}
bot_messages = []

def load_stats():
global stats
if [Link](STATS_FILE):
with open(STATS_FILE, 'r') as f:
stats = [Link](f)

def save_stats():
with open(STATS_FILE, 'w') as f:
[Link](stats, f)

def load_logs():
global mod_logs
if [Link](LOGS_FILE):
with open(LOGS_FILE, 'r') as f:
mod_logs = [Link](f)

def save_logs():
with open(LOGS_FILE, 'w') as f:
[Link](mod_logs, f)

def load_probation_data():
try:
with open(PROBATION_DATA_FILE, 'r') as f:
return [Link](f)
except FileNotFoundError:
return {}

def save_probation_data(data):
with open(PROBATION_DATA_FILE, 'w') as f:
[Link](data, f, indent=4)

probation_data = load_probation_data()
def stop_bot(signal, frame):
global should_stop
should_stop = True
save_logs()
asyncio.run_coroutine_threadsafe(on_shutdown(), [Link])
asyncio.run_coroutine_threadsafe([Link](), [Link])
[Link](0)

def has_role_or_higher(*role_names):
async def predicate(interaction: [Link]):
user_roles = [[Link] for role in [Link]]
return any(role in user_roles for role in role_names)
return discord.app_commands.check(predicate)

@[Link]
async def on_ready():
load_stats()
load_logs()
load_probation_data()
global bot_messages
bot_messages = []
print("Bot is ready")
await
bot.change_presence(activity=[Link](type=[Link],
name="Developed by whoknowslol._"))
try:
await [Link]()
commands_synced = len([Link].get_commands())
print(f"Synced Commands: {commands_synced}")
except Exception as e:
print(f"An error occurred while syncing commands: {e}")
delete_bot_messages.start()

@[Link]
async def on_shutdown():
save_stats()
save_logs()
save_probation_data()

@[Link]
async def on_message(message):
if [Link] == [Link]:
bot_messages.append(message)

def log_mod_action(user_id, action, moderator, reason=None):


if user_id not in mod_logs:
mod_logs[user_id] = []
log_entry = {
"action": action,
"moderator": moderator,
"timestamp": [Link]().isoformat()
}
if reason:
log_entry["reason"] = reason
mod_logs[user_id].append(log_entry)
save_logs()

@[Link](name="rizztrack", description="Check your or another user's rizz


level")
async def rizztrack(interaction: [Link], user: [Link] = None):
if user is None:
user = [Link]
user_id = str([Link])

rizz_level = [Link](user_id, 0)

if isinstance(rizz_level, dict):
rizz_level = rizz_level.get('rizzed', 0)

if not isinstance(rizz_level, int):


rizz_level = 0

await [Link].send_message(f"{[Link]} has {rizz_level} rizz


points.")

@[Link](name="test", description="Responds with pong!")


async def test(interaction: [Link]):
await [Link].send_message("Pong!")

@[Link](name="hello", description="Replies with a greeting message")


async def hello(interaction: [Link]):
user = [Link]
await [Link].send_message(f"Hello, {[Link]}!")

@[Link](name="rizz", description="Rizz up another user")


async def rizz(interaction: [Link], user: [Link]):
view = View()
yes_button = Button(label="Yes", style=[Link])
no_button = Button(label="No", style=[Link])
view.add_item(yes_button)
view.add_item(no_button)

async def yes_callback(interaction: [Link]):


if [Link] == user:
stats[str([Link])] = [Link](str([Link]),
0) + 1
save_stats()
await [Link].send_message(f"You have rizzed up
{[Link]} Now make babies! 💀")
else:
await [Link].send_message("Stop tryna get a free point
💀", ephemeral=True)

async def no_callback(interaction: [Link]):


if [Link] == user:
stats[str([Link])] = [Link](str([Link]),
0) - 1
save_stats()
await [Link].send_message("You have failed -1 point for
you I'm disappointed! 😡")
else:
await [Link].send_message("Stop tryna get a free point
💀", ephemeral=True)

yes_button.callback = yes_callback
no_button.callback = no_callback
await [Link].send_message(f"Are you rizzed up, {[Link]}?",
view=view)

@[Link](name="lock", description="Lock the current channel")


@has_role_or_higher("Head Moderator", "Administrator", "Founder", "Staff Manager",
"Moderator")
async def lock(interaction: [Link]):
channel = [Link]
role_name = "Moderator"
seagull_role = [Link]([Link], name=role_name)
if seagull_role:
overwrite = [Link](send_messages=False)
try:
await channel.set_permissions(seagull_role, overwrite=overwrite)
log_mod_action(str([Link]), "lock", [Link])
await [Link].send_message("Channel locked",
ephemeral=True)
except [Link]:
await [Link].send_message("I do not have permission to
lock this channel.", ephemeral=True)
except Exception as e:
await [Link].send_message(f"An error occurred: {e}",
ephemeral=True)
else:
await [Link].send_message(f"Role '{role_name}' not found.",
ephemeral=True)

@[Link](name="unlock", description="Unlock the current channel")


@has_role_or_higher("Head Moderator", "Administrator", "Founder", "Staff Manager",
"Moderator")
async def unlock(interaction: [Link]):
channel = [Link]
role_name = "Moderator"
seagull_role = [Link]([Link], name=role_name)
if seagull_role:
try:
await channel.set_permissions(seagull_role, send_messages=True)
log_mod_action(str([Link]), "unlock", [Link])
await [Link].send_message("Channel unlocked",
ephemeral=True)
except [Link]:
await [Link].send_message("I do not have permission to
unlock this channel.", ephemeral=True)
except Exception as e:
await [Link].send_message(f"An error occurred: {e}",
ephemeral=True)
else:
await [Link].send_message(f"Role '{role_name}' not found.",
ephemeral=True)

@[Link](name="probate", description="Put a user on probation")


@has_role_or_higher("Head Moderator", "Administrator", "Founder", "Staff Manager")
async def probate(interaction: [Link], user: [Link], reason:
str):
probation_role = [Link]([Link], name="Probationary
Moderator")
if probation_role not in [Link]:
previous_roles_ids = [[Link] for role in [Link] if [Link] in
["Moderator", "Trial Moderator"]]
probation_data[str([Link])] = {
"previous_roles": previous_roles_ids
}
save_probation_data(probation_data)

roles_to_remove = [[Link]([Link],
name="Moderator"),
[Link]([Link], name="Trial
Moderator")]
await user.remove_roles(*roles_to_remove)
await user.add_roles(probation_role)

await [Link].send_message(f"{[Link]} has been put on


probation for: {reason}")
else:
await [Link].send_message(f"{[Link]} is already on
probation.", ephemeral=True)

@[Link](name="unprobate", description="Remove probation from a user")


@has_role_or_higher("Head Moderator", "Administrator", "Founder", "Staff Manager")
async def unprobate(interaction: [Link], user: [Link]):
probation_role = [Link]([Link], name="Probationary
Moderator")

if probation_role in [Link]:
if str([Link]) in probation_data:
previous_roles_ids = probation_data[str([Link])].get("previous_roles",
[])
previous_roles = [[Link].get_role(role_id) for role_id in
previous_roles_ids]
probation_data.pop(str([Link]))
save_probation_data(probation_data)

await user.remove_roles(probation_role)
await user.add_roles(*previous_roles)

await [Link].send_message(f"{[Link]} has been


removed from probation.")
else:
await [Link].send_message(f"{[Link]} was not on
probation.", ephemeral=True)
else:
await [Link].send_message(f"{[Link]} is not on
probation.", ephemeral=True)

@[Link](name="help", description="List all available commands")


async def help_command(interaction: [Link]):
commands = [
"/rizztrack - Check your or another user's rizz level",
"/test - Responds with pong!",
"/hello - Replies with a greeting message",
"/rizz - Rizz up another user",
"/lock - Lock the current channel",
"/unlock - Unlock the current channel",
"/probate - Put a user on probation",
"/unprobate - Remove probation from a user",
"/modlogs - View the moderation logs for a specific user or all logs"
]
embed = [Link](title="Help Command", description="Here are the available
commands:", color=[Link]())
embed.add_field(name="Commands", value="\n".join(commands), inline=False)
await [Link].send_message(embed=embed, ephemeral=True)

@[Link](name="modlogs", description="View the moderation logs for a


specific user or all logs")
@has_role_or_higher("Head Moderator", "Administrator", "Founder", "Staff Manager",
"Moderator")
async def modlogs(interaction: [Link], user: [Link] = None):
try:
with open('mod_logs.json', 'r') as file:
data = [Link](file)

embed = [Link](title="Moderator Logs", color=[Link]())

if user:
user_id = str([Link])
actions = [Link](user_id, [])

if actions:
actions_text = ""
for action in actions:
moderator_id = [Link]('moderator')
moderator_mention = f"<@{moderator_id}>" if moderator_id else
"Unknown"
action_str = f"**Action:** {[Link]('action', 'N/A')}\n" \
f"**Moderator:** {moderator_mention}\n" \
f"**Timestamp:** {[Link]('timestamp', 'N/A')}\
n" \
f"**Reason:** {[Link]('reason', 'N/A')}\n\n"
actions_text += action_str

embed.add_field(name=f"Logs for {user}", value=actions_text or "No


logs found for this user.", inline=False)
else:
embed.add_field(name=f"Logs for {user}", value="No logs found for
this user.", inline=False)
else:
if data:
for user_id, actions in [Link]():
user = [Link].get_member(int(user_id))
user_name = [Link] if user else f"User ID {user_id}"
actions_text = ""
for action in actions:
moderator_id = [Link]('moderator')
moderator_mention = f"<@{moderator_id}>" if moderator_id
else "Unknown"
action_str = f"**Action:** {[Link]('action', 'N/A')}\n"
\
f"**Moderator:** {moderator_mention}\n" \
f"**Timestamp:** {[Link]('timestamp',
'N/A')}\n" \
f"**Reason:** {[Link]('reason', 'N/A')}\n\
n"
actions_text += action_str

embed.add_field(name=f"Logs for {user_name}",


value=actions_text or "No logs found.", inline=False)
else:
embed.add_field(name="Logs", value="No logs available.",
inline=False)

await [Link].send_message(embed=embed)
except Exception as e:
await [Link].send_message(f"An error occurred: {e}",
ephemeral=True)

@[Link](minutes=1)
async def delete_bot_messages():
for message in bot_messages:
if [Link] == [Link]:
try:
await [Link]()
except [Link]:
pass
bot_messages.clear()

[Link]([Link], stop_bot)
[Link]([Link], stop_bot)

[Link](TOKEN)

You might also like