1
Fork 0
mirror of https://github.com/wlinator/luminara.git synced 2024-10-02 18:03:12 +00:00

Huge renaming

This commit is contained in:
wlinator 2024-02-28 14:01:20 +01:00
parent 7841614715
commit 471a5b2d87
45 changed files with 357 additions and 424 deletions

View file

@ -1,14 +1,14 @@
import json
import logging
racu_logs = logging.getLogger('Racu.Core')
logs = logging.getLogger('Racu.Core')
def load_strings(path="config/strings.en-US.json"):
with open(path, 'r') as file:
data = json.load(file)
racu_logs.debug(f"{path} was loaded.")
logs.debug(f"{path} was loaded.")
return data
@ -16,7 +16,7 @@ def load_levels(path="config/levels.en-US.json"):
with open(path, 'r') as file:
data = json.load(file)
racu_logs.debug(f"{path} was loaded.")
logs.debug(f"{path} was loaded.")
return data
@ -24,7 +24,7 @@ def load_economy_config(path="config/economy.json"):
with open(path, 'r') as file:
data = json.load(file)
racu_logs.debug(f"{path} was loaded.")
logs.debug(f"{path} was loaded.")
return data
@ -32,7 +32,7 @@ def load_reactions(path="config/reactions.json"):
with open(path, 'r') as file:
data = json.load(file)
racu_logs.debug(f"{path} was loaded.")
logs.debug(f"{path} was loaded.")
return data
@ -40,5 +40,5 @@ def load_birthday_messages(path="config/birthday.json"):
with open(path, 'r') as file:
data = json.load(file)
racu_logs.debug(f"{path} was loaded.")
logs.debug(f"{path} was loaded.")
return data

View file

@ -4,7 +4,7 @@ from mysql.connector import Error
from dotenv import load_dotenv
import os
racu_logs = logging.getLogger('Racu.Core')
logs = logging.getLogger('Racu.Core')
load_dotenv('.env')
@ -29,7 +29,7 @@ def execute_query(query, values=None):
conn.commit()
conn.close()
racu_logs.debug(f"database.execute_query: 'query': {query}, 'values': {values}")
logs.debug(f"database.execute_query: 'query': {query}, 'values': {values}")
return cursor
@ -37,7 +37,7 @@ def select_query(query, values=None):
conn = cnxpool.get_connection()
cursor = conn.cursor()
racu_logs.debug(f"database.select_query: 'query': {query}, 'values': {values}")
logs.debug(f"database.select_query: 'query': {query}, 'values': {values}")
if values:
cursor.execute(query, values)
@ -54,7 +54,7 @@ def select_query_one(query, values=None):
conn = cnxpool.get_connection()
cursor = conn.cursor()
racu_logs.debug(f"database.select_query_one: 'query': {query}, 'values': {values}")
logs.debug(f"database.select_query_one: 'query': {query}, 'values': {values}")
if values:
cursor.execute(query, values)

View file

@ -1,9 +1,9 @@
import logging
from data.Inventory import Inventory
from data.Item import Item
from services.Inventory import Inventory
from services.Item import Item
racu_logs = logging.getLogger('Racu.Core')
logs = logging.getLogger('Racu.Core')
class ItemHandler:
@ -17,7 +17,7 @@ class ItemHandler:
inv.add_item(item)
field += f"- **1 {item.display_name}**.\n"
racu_logs.info(f"[ItemHandler] {self.ctx.author.name} was given 1 rave_coin | bet > 9000")
logs.info(f"[ItemHandler] {self.ctx.author.name} was given 1 rave_coin | bet > 9000")
return field
@ -31,7 +31,7 @@ class ItemHandler:
field += f"- **1 {item.display_name}**.\n"
racu_logs.info(f"[ItemHandler] {self.ctx.author.name} was given 1 bitch_coin | blackjack")
logs.info(f"[ItemHandler] {self.ctx.author.name} was given 1 bitch_coin | blackjack")
return field
return field

View file

@ -0,0 +1,51 @@
import logging
from datetime import datetime
import pytz
import re
class RacuFormatter(logging.Formatter):
def __init__(self, fmt=None, datefmt=None):
super().__init__(fmt, datefmt)
self.timezone = pytz.timezone('US/Eastern')
def format(self, record):
message = record.getMessage()
message = re.sub(r'\n', '', message) # Remove newlines
message = re.sub(r'\s+', ' ', message) # Remove multiple spaces
message = message.strip() # Remove leading and trailing spaces
record.msg = message
return super().format(record)
def formatTime(self, record, datefmt=None):
timestamp = self.timezone.localize(datetime.fromtimestamp(record.created))
if datefmt:
return timestamp.strftime(datefmt)
else:
return str(timestamp)
def setup_logger():
# Initialize the logger
logger = logging.getLogger('Racu.Core')
if logger.handlers:
# Handlers already exist, no need to add more
return logger
logger.setLevel(logging.DEBUG)
# Create console handler and set level and formatter
console_handler = logging.StreamHandler()
console_handler.setLevel(logging.INFO)
console_formatter = RacuFormatter('[%(asctime)s] [%(name)s] %(message)s',
datefmt='%Y-%m-%d %H:%M:%S')
console_handler.setFormatter(console_formatter)
logger.addHandler(console_handler)
logger.propagate = False
logging.captureWarnings(True)
return logger

View file

@ -1,6 +1,6 @@
import random
from sb_tools import universal
from utils import checks
class ReactionHandler:
@ -12,7 +12,7 @@ class ReactionHandler:
content = message.content.lower()
if (content.startswith("racu ") or content.startswith("racu, ")) and content.endswith("?"):
if await universal.eightball_check(message):
if await checks.eightball(message):
response = random.choice(self.eightball)
await message.reply(content=response)

View file

@ -3,10 +3,10 @@ import random
import time
from config import json_loader
from data.Currency import Currency
from data.Xp import Xp
from services.Currency import Currency
from services.Xp import Xp
racu_logs = logging.getLogger('Racu.Core')
logs = logging.getLogger('Racu.Core')
strings = json_loader.load_strings()
level_messages = json_loader.load_levels()
@ -55,7 +55,7 @@ class XPHandler:
async def process_xp(self, message):
if message.channel.id == 746796138195058788 or message.channel.id == 814590778650263604:
racu_logs.info(f"[XpHandler] {message.author.name} sent a message in a xp-blacklisted channel.")
logs.info(f"[XpHandler] {message.author.name} sent a message in a xp-blacklisted channel.")
return
current_time = time.time()
@ -63,7 +63,7 @@ class XPHandler:
xp = Xp(user_id)
if xp.ctime and current_time < xp.ctime:
racu_logs.info(f"[XpHandler] {message.author.name} sent a message but is on XP cooldown.")
logs.info(f"[XpHandler] {message.author.name} sent a message but is on XP cooldown.")
return
new_xp = xp.xp + xp.xp_gain
@ -78,7 +78,7 @@ class XPHandler:
except Exception as err:
# fallback to v1 (generic leveling)
lvl_message = level_messages(xp.level, message.author)
racu_logs.error("[XpHandler] level_messages v1 fallback was triggered: ", err)
logs.error("[XpHandler] level_messages v1 fallback was triggered: ", err)
await message.reply(content=lvl_message)
@ -87,7 +87,7 @@ class XPHandler:
try:
await self.assign_level_role(message.author, xp.level)
except Exception as error:
racu_logs.error(f"[XpHandler] Assign level role FAILED; {error}")
logs.error(f"[XpHandler] Assign level role FAILED; {error}")
"""
AWARD CURRENY_SPECIAL ON LEVEL-UP
@ -96,11 +96,11 @@ class XPHandler:
user_currency.add_special(1)
user_currency.push()
racu_logs.info(f"[XpHandler] {message.author.name} leveled up to lv {xp.level}.")
logs.info(f"[XpHandler] {message.author.name} leveled up to lv {xp.level}.")
else:
xp.xp += xp.xp_gain
racu_logs.info(f"[XpHandler] {message.author.name} gained {xp.xp_gain} XP | "
logs.info(f"[XpHandler] {message.author.name} gained {xp.xp_gain} XP | "
f"lv {xp.level} with {xp.xp} XP.")
xp.ctime = current_time + xp.new_cooldown

141
main.py
View file

@ -1,104 +1,42 @@
import logging
import os
import platform
import re
import sys
import time
from datetime import datetime
import discord
import pytz
from discord.ext import commands
from dotenv import load_dotenv
import sb_tools.resources
import utils.resources
from config import json_loader
from data.Item import Item
from handlers.ReactionHandler import ReactionHandler
from handlers.XPHandler import XPHandler
from handlers import LoggingHandler
load_dotenv('.env')
instance = os.getenv("INSTANCE")
sbbot = discord.Bot(
client = discord.Bot(
owner_id=os.getenv('OWNER_ID'),
intents=discord.Intents.all(),
activity=discord.Activity(
name="Kaiju's Rave Cave",
type=discord.ActivityType.listening,
state=f"v{sb_tools.resources.__version__}",
timestamps={
"start": time.time()
},
details="/daily | /level | /leaderboard",
assets={
"large_image": "ravecoin",
"large_text": "Coins art by geardiabolus",
"small_image": "admin_badge",
"small_text": f"Made by {sb_tools.resources.__author__}",
}
),
status=discord.Status.online
)
class RacuFormatter(logging.Formatter):
def __init__(self, fmt=None, datefmt=None):
super().__init__(fmt, datefmt)
self.timezone = pytz.timezone('US/Eastern')
def format(self, record):
message = record.getMessage()
message = re.sub(r'\n', '', message) # Remove newlines
message = re.sub(r'\s+', ' ', message) # Remove multiple spaces
message = message.strip() # Remove leading and trailing spaces
record.msg = message
return super().format(record)
def formatTime(self, record, datefmt=None):
timestamp = self.timezone.localize(datetime.fromtimestamp(record.created))
if datefmt:
return timestamp.strftime(datefmt)
else:
return str(timestamp)
logs = LoggingHandler.setup_logger()
def setup_logger():
# Initialize the logger
logger = logging.getLogger('Racu.Core')
if logger.handlers:
# Handlers already exist, no need to add more
return logger
logger.setLevel(logging.DEBUG)
# Create console handler and set level and formatter
console_handler = logging.StreamHandler()
console_handler.setLevel(logging.INFO)
console_formatter = RacuFormatter('[%(asctime)s] [%(name)s] %(message)s',
datefmt='%Y-%m-%d %H:%M:%S')
console_handler.setFormatter(console_formatter)
logger.addHandler(console_handler)
logger.propagate = False
logging.captureWarnings(True)
return logger
racu_logs = setup_logger()
@sbbot.event
@client.event
async def on_ready():
racu_logs.info(f"[INFO] Logged in as {sbbot.user.name}")
racu_logs.info(f"[INFO] discord.py API version: {discord.__version__}")
racu_logs.info(f"[INFO] Python version: {platform.python_version()}")
racu_logs.info(f"[INFO] Running on: {platform.system()} {platform.release()} ({os.name})")
racu_logs.info("-------------------------------------------------------")
logs.info(f"[INFO] Logged in as {client.user.name}")
logs.info(f"[INFO] discord.py API version: {discord.__version__}")
logs.info(f"[INFO] Python version: {platform.python_version()}")
logs.info(f"[INFO] Running on: {platform.system()} {platform.release()} ({os.name})")
logs.info("-------------------------------------------------------")
"""
https://docs.pycord.dev/en/stable/api/events.html#discord.on_ready
@ -107,13 +45,9 @@ async def on_ready():
"""
@sbbot.event
@client.event
async def on_message(message):
if message.author.bot:
return
# remove if debugging leveling or reaction handler:
if instance.lower() != "main":
if message.author.bot or instance.lower() != "main":
return
try:
@ -124,11 +58,11 @@ async def on_message(message):
await reaction_handler.handle_message(message)
except Exception as error:
racu_logs.error(f"[EventHandler] on_message (check debug log): {error}", exc_info=False)
racu_logs.debug(f"[EventHandler] on_message (w/ stacktrace): {error}", exc_info=True)
logs.error(f"[EventHandler] on_message (check debug log): {error}", exc_info=False)
logs.debug(f"[EventHandler] on_message (w/ stacktrace): {error}", exc_info=True)
@sbbot.event
@client.event
async def on_member_join(member):
guild = member.guild
@ -158,7 +92,7 @@ async def on_member_join(member):
await guild.get_channel(welcome_channel_id).send(embed=embed, content=member.mention)
@sbbot.event
@client.event
async def on_application_command_completion(ctx) -> None:
"""
This code is executed when a slash_command has been successfully executed.
@ -171,20 +105,20 @@ async def on_application_command_completion(ctx) -> None:
executed_command = str(split[0])
if ctx.guild is not None:
# racu_logs.info(
# logs.info(
# f"Executed {executed_command} command in {ctx.guild.name} (ID: {ctx.guild.id}) "
# f"by {ctx.author} (ID: {ctx.author.id})"
# )
racu_logs.info(f"[CommandHandler] {ctx.author.name} successfully did \"/{executed_command}\". "
logs.info(f"[CommandHandler] {ctx.author.name} successfully did \"/{executed_command}\". "
f"| guild: {ctx.guild.name} ")
else:
# racu_logs.info(
# logs.info(
# f"Executed {executed_command} command by {ctx.author} (ID: {ctx.author.id}) in DMs."
# )
racu_logs.info(f"[CommandHandler] {ctx.author.name} successfully did \"/{executed_command}\". | direct message")
logs.info(f"[CommandHandler] {ctx.author.name} successfully did \"/{executed_command}\". | direct message")
@sbbot.event
@client.event
async def on_application_command_error(ctx, error) -> None:
if isinstance(error, commands.CommandOnCooldown):
@ -198,28 +132,28 @@ async def on_application_command_error(ctx, error) -> None:
f"You can use this command again in **{cooldown}**.",
ephemeral=True)
racu_logs.info(f"[CommandHandler] {ctx.author.name} tried to do a command on cooldown.")
logs.info(f"[CommandHandler] {ctx.author.name} tried to do a command on cooldown.")
elif isinstance(error, commands.MissingPermissions):
await ctx.respond(strings["error_missing_permissions"].format(ctx.author.name), ephemeral=True)
racu_logs.info(f"[CommandHandler] {ctx.author.name} has missing permissions to do a command: "
logs.info(f"[CommandHandler] {ctx.author.name} has missing permissions to do a command: "
f"{ctx.command.qualified_name}")
elif isinstance(error, commands.BotMissingPermissions):
await ctx.respond(strings["error_bot_missing_permissions"].format(ctx.author.name), ephemeral=True)
racu_logs.info(f"[CommandHandler] Racu is missing permissions: {ctx.command.qualified_name}")
logs.info(f"[CommandHandler] Racu is missing permissions: {ctx.command.qualified_name}")
else:
racu_logs.error(f"[CommandHandler] on_application_command_error: {error}", exc_info=True)
logs.error(f"[CommandHandler] on_application_command_error: {error}", exc_info=True)
# if you use this, set "exc_info" to False above
# racu_logs.debug(f"[CommandHandler] on_application_command_error (w/ stacktrace): {error}", exc_info=True)
# logs.debug(f"[CommandHandler] on_application_command_error (w/ stacktrace): {error}", exc_info=True)
@sbbot.event
@client.event
async def on_error(event: str, *args, **kwargs) -> None:
racu_logs.error(f"[EventHandler] on_error INFO: errors.event.{event} | '*args': {args} | '**kwargs': {kwargs}")
racu_logs.error(f"[EventHandler] on_error EXCEPTION: {sys.exc_info()}")
logs.error(f"[EventHandler] on_error INFO: errors.event.{event} | '*args': {args} | '**kwargs': {kwargs}")
logs.error(f"[EventHandler] on_error EXCEPTION: {sys.exc_info()}")
# load all json
@ -242,12 +176,12 @@ def load_cogs():
module_name = f'modules.{filename[:-3]}'
try:
sbbot.load_extension(module_name)
client.load_extension(module_name)
loaded_modules.add(filename)
racu_logs.info(f"[MODULE] {filename[:-3].upper()} loaded.")
logs.info(f"[MODULE] {filename[:-3].upper()} loaded.")
except Exception as e:
racu_logs.error(f"[MODULE] Failed to load module {filename}: {e}")
logs.error(f"[MODULE] Failed to load module {filename}: {e}")
if __name__ == '__main__':
@ -256,15 +190,12 @@ if __name__ == '__main__':
thus NOT when main is imported from a cog. (sys.modules)
"""
racu_logs.info("RACU IS BOOTING")
racu_logs.info("\n")
logs.info("RACU IS BOOTING")
logs.info("\n")
load_cogs()
# empty line to separate modules from system info in logs
racu_logs.info("\n")
logs.info("\n")
# replace all items, if there are any changes they will be overwritten
# Item.insert_items()
sbbot.run(os.getenv('TOKEN'))
client.run(os.getenv('TOKEN'))

View file

@ -7,7 +7,7 @@ import dropbox
from discord.ext import commands, tasks
from dotenv import load_dotenv
racu_logs = logging.getLogger('Racu.Core')
logs = logging.getLogger('Racu.Core')
load_dotenv('.env')
oauth2_refresh_token = os.getenv("DBX_OAUTH2_REFRESH_TOKEN")
@ -52,8 +52,8 @@ async def backup_cleanup(dbx):
class BackupCog(commands.Cog):
def __init__(self, sbbot):
self.bot = sbbot
def __init__(self, client):
self.bot = client
self.do_backup.start()
@tasks.loop(hours=1)
@ -64,14 +64,14 @@ class BackupCog(commands.Cog):
await create_db_backup(dbx)
await backup_cleanup(dbx)
racu_logs.info("[BACKUP] database backup success.")
logs.info("[BACKUP] database backup success.")
except Exception as error:
racu_logs.error(f"[BACKUP] database backup failed. {error}")
racu_logs.info(f"[BACKUP] Dropbox failure: {error}")
logs.error(f"[BACKUP] database backup failed. {error}")
logs.info(f"[BACKUP] Dropbox failure: {error}")
else:
racu_logs.info("[BACKUP] No backup was made, instance not \"MAIN\".")
logs.info("[BACKUP] No backup was made, instance not \"MAIN\".")
def setup(sbbot):
sbbot.add_cog(BackupCog(sbbot))
def setup(client):
client.add_cog(BackupCog(client))

View file

@ -5,8 +5,8 @@ import discord
from discord.ext import commands
from dotenv import load_dotenv
from data.Currency import Currency
from sb_tools import universal
from services.Currency import Currency
from utils import checks
load_dotenv('.env')
@ -15,15 +15,15 @@ cash_balance_name = os.getenv("CASH_BALANCE_NAME")
class BalanceCog(commands.Cog):
def __init__(self, sbbot):
self.bot = sbbot
def __init__(self, client):
self.bot = client
@commands.slash_command(
name="balance",
description="See how much cash you have.",
guild_only=True
)
@commands.check(universal.channel_check)
@commands.check(checks.channel)
async def balance(self, ctx):
# Currency handler
ctx_currency = Currency(ctx.author.id)
@ -42,5 +42,5 @@ class BalanceCog(commands.Cog):
await ctx.respond(embed=embed)
def setup(sbbot):
sbbot.add_cog(BalanceCog(sbbot))
def setup(client):
client.add_cog(BalanceCog(client))

View file

@ -10,11 +10,11 @@ from discord.commands import SlashCommandGroup
from discord.ext import commands, tasks
from config import json_loader
from data.Birthday import Birthday
from services.Birthday import Birthday
from main import strings
from utils import time
racu_logs = logging.getLogger('Racu.Core')
logs = logging.getLogger('Racu.Core')
months = [
"January", "February", "March", "April",
@ -26,8 +26,8 @@ messages = json_loader.load_birthday_messages()
class BirthdayCog(commands.Cog):
def __init__(self, sbbot):
self.bot = sbbot
def __init__(self, client):
self.bot = client
self.daily_birthday_check.start()
birthday = SlashCommandGroup("birthday", "various birthday commands.")
@ -123,7 +123,7 @@ class BirthdayCog(commands.Cog):
async def daily_birthday_check(self):
wait_time = time.seconds_until(7, 0)
racu_logs.info(f"[BirthdayHandler] Waiting until 7 AM Eastern for daily check: {round(wait_time)}s")
logs.info(f"[BirthdayHandler] Waiting until 7 AM Eastern for daily check: {round(wait_time)}s")
await asyncio.sleep(wait_time)
birthday_ids = Birthday.today()
@ -144,17 +144,17 @@ class BirthdayCog(commands.Cog):
message = random.choice(messages["birthday_messages"])
await channel.send(message.format(user.mention))
racu_logs.info(f"[BirthdayHandler] Sent message for user with ID {user_id}")
logs.info(f"[BirthdayHandler] Sent message for user with ID {user_id}")
except discord.HTTPException:
racu_logs.info(f"[BirthdayHandler] Not sent because user with ID {user_id} not in Guild.")
logs.info(f"[BirthdayHandler] Not sent because user with ID {user_id} not in Guild.")
except Exception as err:
racu_logs.error(f"[BirthdayHandler] Something went wrong: {err}")
logs.error(f"[BirthdayHandler] Something went wrong: {err}")
else:
racu_logs.info("[BirthdayHandler] No Birthdays Today.")
logs.info("[BirthdayHandler] No Birthdays Today.")
def setup(sbbot):
sbbot.add_cog(BirthdayCog(sbbot))
def setup(client):
client.add_cog(BirthdayCog(client))

View file

@ -7,13 +7,13 @@ import pytz
from discord.ext import commands
from dotenv import load_dotenv
from data.BlackJackStats import BlackJackStats
from data.Currency import Currency
from services.BlackJackStats import BlackJackStats
from services.Currency import Currency
from handlers.ItemHandler import ItemHandler
from main import economy_config, strings
from sb_tools import economy_embeds, economy_functions, universal, interaction, embeds
from utils import economy_embeds, economy_functions, checks, interaction, embeds
racu_logs = logging.getLogger('Racu.Core')
logs = logging.getLogger('Racu.Core')
load_dotenv('.env')
est = pytz.timezone('US/Eastern')
@ -113,15 +113,15 @@ def blackjack_finished(ctx, bet, player_hand_value, dealer_hand_value, payout, s
class BlackJackCog(commands.Cog):
def __init__(self, sbbot):
self.bot = sbbot
def __init__(self, client):
self.bot = client
@commands.slash_command(
name="blackjack",
description="Start a game of blackjack.",
guild_only=True
)
@commands.check(universal.channel_check)
@commands.check(checks.channel)
async def blackjack(self, ctx, *, bet: discord.Option(int)):
# check if the player already has an active blackjack going
@ -275,12 +275,12 @@ class BlackJackCog(commands.Cog):
except Exception as e:
await ctx.respond(embed=embeds.command_error_1(e))
racu_logs.error("[CommandHandler] Something went wrong in the gambling command: ", e)
logs.error("[CommandHandler] Something went wrong in the gambling command: ", e)
finally:
# remove player from active games list
del active_blackjack_games[ctx.author.id]
def setup(sbbot):
sbbot.add_cog(BlackJackCog(sbbot))
def setup(client):
client.add_cog(BlackJackCog(client))

View file

@ -5,8 +5,8 @@ import discord
from discord.ext import commands
from dotenv import load_dotenv
from data.Currency import Currency
from sb_tools import economy_embeds, universal
from services.Currency import Currency
from utils import economy_embeds, checks
load_dotenv('.env')
@ -18,15 +18,15 @@ with open("config/economy.json") as file:
class AwardCog(commands.Cog):
def __init__(self, sbbot):
self.bot = sbbot
def __init__(self, client):
self.bot = client
@commands.slash_command(
name="give",
description="Give another user some currency.",
guild_only=True
)
@commands.check(universal.channel_check)
@commands.check(checks.channel)
async def give(self, ctx, *,
user: discord.Option(discord.Member),
currency: discord.Option(choices=["cash", special_balance_name]),
@ -75,8 +75,8 @@ class AwardCog(commands.Cog):
description="Award currency - owner only command.",
guild_only=True
)
@commands.check(universal.channel_check)
@commands.check(universal.owner_check)
@commands.check(checks.channel)
@commands.check(checks.bot_owner)
async def award(self, ctx, *,
user: discord.Option(discord.Member),
currency: discord.Option(choices=["cash_balance", "special_balance"]),
@ -102,5 +102,5 @@ class AwardCog(commands.Cog):
await ctx.respond(embed=economy_embeds.award(user, currency, Currency.format(amount)))
def setup(sbbot):
sbbot.add_cog(AwardCog(sbbot))
def setup(client):
client.add_cog(AwardCog(client))

View file

@ -4,9 +4,9 @@ import discord
from discord.ext import commands
from dotenv import load_dotenv
from data.Currency import Currency
from services.Currency import Currency
from main import economy_config
from sb_tools import economy_embeds, universal, interaction
from utils import economy_embeds, checks, interaction
load_dotenv('.env')
@ -15,15 +15,15 @@ cash_balance_name = os.getenv("CASH_BALANCE_NAME")
class ExchangeCog(commands.Cog):
def __init__(self, sbbot):
self.bot = sbbot
def __init__(self, client):
self.bot = client
@commands.slash_command(
name="exchange",
description=f"Exchange {special_balance_name} for cash.",
guild_only=True
)
@commands.check(universal.channel_check)
@commands.check(checks.channel)
async def exchange(self, ctx, *, amount: discord.Option(int)):
# Currency handler
@ -59,5 +59,5 @@ class ExchangeCog(commands.Cog):
await ctx.edit(embed=embed)
def setup(sbbot):
sbbot.add_cog(ExchangeCog(sbbot))
def setup(client):
client.add_cog(ExchangeCog(client))

View file

@ -2,17 +2,14 @@ import json
import os
from datetime import datetime, timedelta
import discord
from discord.ext import commands
from dotenv import load_dotenv
import utils.time
from data.Dailies import Dailies
from data.Currency import Currency
from services.Dailies import Dailies
from services.Currency import Currency
from main import strings
from sb_tools import universal
import utils
import time
from utils import checks
load_dotenv('.env')
@ -24,20 +21,20 @@ with open("config/economy.json") as file:
class DailyCog(commands.Cog):
def __init__(self, sbbot):
self.bot = sbbot
def __init__(self, client):
self.bot = client
@commands.slash_command(
name="daily",
description="Claim your daily cash!",
guild_only=True
)
@commands.check(universal.channel_check)
@commands.check(checks.channel)
async def daily(self, ctx):
ctx_daily = Dailies(ctx.author.id)
if not ctx_daily.can_be_claimed():
wait_time = datetime.now() + timedelta(seconds=utils.time.seconds_until(7,0))
wait_time = datetime.now() + timedelta(seconds=utils.time.seconds_until(7, 0))
unix_time = int(round(wait_time.timestamp()))
return await ctx.respond(content=strings["daily_no_claim"].format(ctx.author.name, unix_time))
@ -56,5 +53,5 @@ class DailyCog(commands.Cog):
await ctx.respond(content=output)
def setup(sbbot):
sbbot.add_cog(DailyCog(sbbot))
def setup(client):
client.add_cog(DailyCog(client))

View file

@ -5,9 +5,9 @@ import discord
from discord.ext import commands
from dotenv import load_dotenv
from data.Currency import Currency
from services.Currency import Currency
from main import economy_config
from sb_tools import economy_embeds, universal, interaction
from utils import economy_embeds, checks, interaction
load_dotenv('.env')
@ -15,15 +15,15 @@ cash_balance_name = os.getenv("CASH_BALANCE_NAME")
class GamblingCog(commands.Cog):
def __init__(self, sbbot):
self.bot = sbbot
def __init__(self, client):
self.bot = client
@commands.slash_command(
name="duel",
description="Challenge another player to a fight.",
guild_only=True
)
@commands.check(universal.channel_check)
@commands.check(checks.channel)
async def duel(self, ctx, *, opponent: discord.Option(discord.Member), bet: discord.Option(int)):
challenger = ctx.author
@ -87,5 +87,5 @@ class GamblingCog(commands.Cog):
opponent_currency.push()
def setup(sbbot):
sbbot.add_cog(GamblingCog(sbbot))
def setup(client):
client.add_cog(GamblingCog(client))

View file

@ -6,14 +6,14 @@ import subprocess
import discord
from discord.ext import commands
from sb_tools import interaction, embeds, universal
from utils import interaction, embeds, checks
racu_logs = logging.getLogger('Racu.Core')
logs = logging.getLogger('Racu.Core')
class BasicCog(commands.Cog):
def __init__(self, sbbot):
self.bot = sbbot
def __init__(self, client):
self.bot = client
@commands.slash_command(
name="intro",
@ -43,13 +43,13 @@ class BasicCog(commands.Cog):
em = discord.Embed(description="You're muted in the Rave Cave. You can't perform this command.",
color=0xadcca6)
await ctx.respond(embed=em)
racu_logs.warning(f"{ctx.author.name} couldn't do the intro command: Muted in the Race Cave")
logs.warning(f"{ctx.author.name} couldn't do the intro command: Muted in the Race Cave")
return
# elif member and not discord.utils.get(member.roles, id=719995790319157279):
# em = discord.Embed(description="It seems that you don't have permission to do that!")
# await ctx.respond(embed=em)
# racu_logs.warning(f"{ctx.author.name} couldn't do the intro command: No Permissions")
# logs.warning(f"{ctx.author.name} couldn't do the intro command: No Permissions")
# return
embed = discord.Embed(color=0xadcca6,
@ -78,7 +78,7 @@ class BasicCog(commands.Cog):
return message.author == ctx.author and isinstance(message.channel, discord.DMChannel)
if view.clickedShort:
racu_logs.debug(f"{ctx.author.name} clicked Short Intro")
logs.debug(f"{ctx.author.name} clicked Short Intro")
# START NICKNAME
await ctx.send(embed=embeds.simple_question_first("How would you like to be identified in the server?"))
@ -89,7 +89,7 @@ class BasicCog(commands.Cog):
if len(nickname) > 100:
nickname = nickname[:100]
nickname = nickname.replace("\n", " ")
racu_logs.debug(f"{ctx.author.name} nickname: {nickname}")
logs.debug(f"{ctx.author.name} nickname: {nickname}")
# START AGE
await ctx.send(embed=embeds.simple_question_5("How old are you?"),
@ -101,7 +101,7 @@ class BasicCog(commands.Cog):
if len(age) > 5:
age = age[:5]
age = age.replace("\n", " ")
racu_logs.debug(f"{ctx.author.name} age: {age}")
logs.debug(f"{ctx.author.name} age: {age}")
# START LOCATION
view = interaction.LocationOptions(ctx)
@ -116,7 +116,7 @@ class BasicCog(commands.Cog):
await ctx.send(embed=embeds.no_time())
return
racu_logs.debug(f"{ctx.author.name} location: {location}")
logs.debug(f"{ctx.author.name} location: {location}")
# START PRONOUNS
await ctx.send(
@ -129,7 +129,7 @@ class BasicCog(commands.Cog):
if len(pronouns) > 30:
pronouns = pronouns[:30]
pronouns = pronouns.replace("\n", " ")
racu_logs.debug(f"{ctx.author.name} pronouns: {pronouns}")
logs.debug(f"{ctx.author.name} pronouns: {pronouns}")
# START LIKES
await ctx.send(embed=embeds.simple_question_300("Likes & interests"),
@ -141,7 +141,7 @@ class BasicCog(commands.Cog):
if len(likes) > 300:
likes = likes[:300]
likes = likes.replace("\n", " ")
racu_logs.debug(f"{ctx.author.name} likes: {likes}")
logs.debug(f"{ctx.author.name} likes: {likes}")
# START DISLIKES
await ctx.send(embed=embeds.simple_question_300("Dislikes"),
@ -153,7 +153,7 @@ class BasicCog(commands.Cog):
if len(dislikes) > 300:
dislikes = dislikes[:300]
dislikes = dislikes.replace("\n", " ")
racu_logs.debug(f"{ctx.author.name} dislikes: {dislikes}")
logs.debug(f"{ctx.author.name} dislikes: {dislikes}")
# POST EXAMPLE EMBED AND FINAL IF APPROVED
em = embeds.final_embed_short(ctx, nickname, age, location, pronouns, likes, dislikes)
@ -166,40 +166,40 @@ class BasicCog(commands.Cog):
intro_channel = guild.get_channel(channel_id)
await intro_channel.send(embed=em, content=f"Introduction of <@{ctx.author.id}>")
await ctx.send(embed=embeds.final_confirmation(channel_id))
racu_logs.info(f"[CommandHandler] {ctx.author.name} introduction was submitted.")
logs.info(f"[CommandHandler] {ctx.author.name} introduction was submitted.")
return
else:
await ctx.send(embed=embeds.no_time())
racu_logs.warning(f"{ctx.author.id} Intro Timeout")
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds.no_time())
racu_logs.warning(f"{ctx.author.id} Intro Timeout")
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds.no_time())
racu_logs.warning(f"{ctx.author.id} Intro Timeout")
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds.no_time())
racu_logs.warning(f"{ctx.author.id} Intro Timeout")
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds.no_time())
racu_logs.warning(f"{ctx.author.id} Intro Timeout")
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds.no_time())
racu_logs.warning(f"{ctx.author.id} Intro Timeout")
logs.warning(f"{ctx.author.id} Intro Timeout")
return
elif view.clickedLong:
racu_logs.debug(f"{ctx.author.name} clicked Long Intro")
logs.debug(f"{ctx.author.name} clicked Long Intro")
# START NICKNAME
await ctx.send(embed=embeds.simple_question_first_extended(
@ -211,7 +211,7 @@ class BasicCog(commands.Cog):
if len(nickname) > 100:
nickname = nickname[:100]
nickname = nickname.replace("\n", " ")
racu_logs.debug(f"{ctx.author.name} nickname: {nickname}")
logs.debug(f"{ctx.author.name} nickname: {nickname}")
# START AGE
await ctx.send(embed=embeds.simple_question_5("How old are you?"),
@ -223,7 +223,7 @@ class BasicCog(commands.Cog):
if len(age) > 5:
age = age[:5]
age = age.replace("\n", " ")
racu_logs.debug(f"{ctx.author.name} age: {age}")
logs.debug(f"{ctx.author.name} age: {age}")
# START LOCATION
view = interaction.LocationOptions(ctx)
@ -238,7 +238,7 @@ class BasicCog(commands.Cog):
await ctx.send(embed=embeds.no_time())
return
racu_logs.debug(f"{ctx.author.name} location: {location}")
logs.debug(f"{ctx.author.name} location: {location}")
# START LANGUAGES
await ctx.send(
@ -252,7 +252,7 @@ class BasicCog(commands.Cog):
if len(languages) > 30:
languages = languages[:30]
languages = languages.replace("\n", " ")
racu_logs.debug(f"{ctx.author.name} languages: {languages}")
logs.debug(f"{ctx.author.name} languages: {languages}")
# START PRONOUNS
await ctx.send(
@ -265,7 +265,7 @@ class BasicCog(commands.Cog):
if len(pronouns) > 30:
pronouns = pronouns[:30]
pronouns = pronouns.replace("\n", " ")
racu_logs.debug(f"{ctx.author.name} pronouns: {pronouns}")
logs.debug(f"{ctx.author.name} pronouns: {pronouns}")
# START SEXUALITY
await ctx.send(
@ -278,7 +278,7 @@ class BasicCog(commands.Cog):
if len(sexuality) > 30:
sexuality = sexuality[:30]
sexuality = sexuality.replace("\n", " ")
racu_logs.debug(f"{ctx.author.name} sexuality: {sexuality}")
logs.debug(f"{ctx.author.name} sexuality: {sexuality}")
# START RELATIONSHIP_STATUS
await ctx.send(
@ -292,7 +292,7 @@ class BasicCog(commands.Cog):
if len(relationship_status) > 30:
relationship_status = relationship_status[:30]
relationship_status = relationship_status.replace("\n", " ")
racu_logs.debug(f"{ctx.author.name} relationship_status: {relationship_status}")
logs.debug(f"{ctx.author.name} relationship_status: {relationship_status}")
# START LIKES
await ctx.send(embed=embeds.simple_question_300("Likes & interests"),
@ -304,7 +304,7 @@ class BasicCog(commands.Cog):
if len(likes) > 300:
likes = likes[:300]
likes = likes.replace("\n", " ")
racu_logs.debug(f"{ctx.author.name} likes: {likes}")
logs.debug(f"{ctx.author.name} likes: {likes}")
# START DISLIKES
await ctx.send(embed=embeds.simple_question_300("Dislikes"),
@ -317,7 +317,7 @@ class BasicCog(commands.Cog):
if len(dislikes) > 300:
dislikes = dislikes[:300]
dislikes = dislikes.replace("\n", " ")
racu_logs.debug(f"{ctx.author.name} dislikes: {dislikes}")
logs.debug(f"{ctx.author.name} dislikes: {dislikes}")
# START EXTRA
await ctx.send(embed=embeds.simple_question_300(
@ -332,7 +332,7 @@ class BasicCog(commands.Cog):
if len(extra) > 300:
extra = extra[:300]
extra = extra.replace("\n", " ")
racu_logs.debug(f"{ctx.author.name} extra: {extra}")
logs.debug(f"{ctx.author.name} extra: {extra}")
# POST EXAMPLE EMBED AND FINAL IF APPROVED
em = embeds.final_embed_extended(ctx, nickname, age, location,
@ -350,62 +350,62 @@ class BasicCog(commands.Cog):
await intro_channel.send(embed=em,
content=f"Introduction of <@{ctx.author.id}>")
await ctx.send(embed=embeds.final_confirmation(channel_id))
racu_logs.info(f"[CommandHandler] {ctx.author.name} introduction was submitted.")
logs.info(f"[CommandHandler] {ctx.author.name} introduction was submitted.")
return
else:
await ctx.send(embed=embeds.no_time())
racu_logs.warning(f"{ctx.author.id} Intro Timeout")
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds.no_time())
racu_logs.warning(f"{ctx.author.id} Intro Timeout")
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds.no_time())
racu_logs.warning(f"{ctx.author.id} Intro Timeout")
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds.no_time())
racu_logs.warning(f"{ctx.author.id} Intro Timeout")
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds.no_time())
racu_logs.warning(f"{ctx.author.id} Intro Timeout")
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds.no_time())
racu_logs.warning(f"{ctx.author.id} Intro Timeout")
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds.no_time())
racu_logs.warning(f"{ctx.author.id} Intro Timeout")
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds.no_time())
racu_logs.warning(f"{ctx.author.id} Intro Timeout")
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds.no_time())
racu_logs.warning(f"{ctx.author.id} Intro Timeout")
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds.no_time())
racu_logs.warning(f"{ctx.author.id} Intro Timeout")
logs.warning(f"{ctx.author.id} Intro Timeout")
return
else:
await ctx.send(embed=embeds.no_time())
racu_logs.warning(f"{ctx.author.id} Intro Timeout")
logs.warning(f"{ctx.author.id} Intro Timeout")
return
def setup(sbbot):
sbbot.add_cog(BasicCog(sbbot))
def setup(client):
client.add_cog(BasicCog(client))

View file

@ -5,8 +5,8 @@ import discord
from discord.ext import commands
from dotenv import load_dotenv
from data.Inventory import Inventory
from sb_tools import universal
from services.Inventory import Inventory
from utils import checks
load_dotenv('.env')
@ -19,15 +19,15 @@ with open("config/economy.json") as file:
class InventoryCog(commands.Cog):
def __init__(self, sbbot):
self.bot = sbbot
def __init__(self, client):
self.bot = client
@commands.slash_command(
name="inventory",
description="Display your inventory.",
guild_only=True
)
@commands.check(universal.channel_check)
@commands.check(checks.channel)
async def inventory(self, ctx):
inventory = Inventory(ctx.author.id)
inventory_dict = inventory.get_inventory()
@ -59,5 +59,5 @@ class InventoryCog(commands.Cog):
await ctx.respond(embed=embed)
def setup(sbbot):
sbbot.add_cog(InventoryCog(sbbot))
def setup(client):
client.add_cog(InventoryCog(client))

View file

@ -5,11 +5,11 @@ import discord
from discord.ext import commands
from dotenv import load_dotenv
from data.Currency import Currency
from data.Inventory import Inventory
from data.Item import Item
from data.ShopItem import ShopItem
from sb_tools import universal
from services.Currency import Currency
from services.Inventory import Inventory
from services.Item import Item
from services.ShopItem import ShopItem
from utils import checks
load_dotenv('.env')
@ -22,15 +22,15 @@ with open("config/economy.json") as file:
class ItemCog(commands.Cog):
def __init__(self, sbbot):
self.bot = sbbot
def __init__(self, client):
self.bot = client
@commands.slash_command(
name="item",
description="View the information about a specific item.",
guild_only=True
)
@commands.check(universal.channel_check)
@commands.check(checks.channel)
async def item_command(self, ctx, *, item: discord.Option(choices=Item.get_all_item_names())):
# create item object from choice
item = Item.get_item_by_display_name(item)
@ -80,7 +80,7 @@ class ItemCog(commands.Cog):
name="gift",
description="Award items to someone."
)
@commands.check(universal.owner_check)
@commands.check(checks.bot_owner)
async def gift(self, ctx, *,
user: discord.Option(discord.Member),
item: discord.Option(choices=Item.get_all_item_names()),
@ -104,5 +104,5 @@ class ItemCog(commands.Cog):
await ctx.respond(embed=embed)
def setup(sbbot):
sbbot.add_cog(ItemCog(sbbot))
def setup(client):
client.add_cog(ItemCog(client))

View file

@ -3,13 +3,13 @@ import logging
import discord
from discord.ext import commands
from data.Currency import Currency
from data.Xp import Xp
from data.Dailies import Dailies
from sb_tools import universal
from services.Currency import Currency
from services.Xp import Xp
from services.Dailies import Dailies
from utils import checks
from datetime import datetime, timedelta
racu_logs = logging.getLogger('Racu.Core')
logs = logging.getLogger('Racu.Core')
class LeaderboardV2Cog(commands.Cog):
@ -18,15 +18,15 @@ class LeaderboardV2Cog(commands.Cog):
This aims to show more information & a new "dailies" leaderboard.
"""
def __init__(self, sbbot):
self.bot = sbbot
def __init__(self, client):
self.bot = client
@commands.slash_command(
name="leaderboard",
description="Are ya winning' son?",
guild_only=True
)
@commands.check(universal.channel_check)
@commands.check(checks.channel)
# @commands.cooldown(1, 180, commands.BucketType.user)
async def leaderboard_v2(self, ctx):
"""
@ -55,7 +55,7 @@ class LeaderboardV2Cog(commands.Cog):
except Exception as error:
name = "Unknown User"
racu_logs.debug(f"Currency Leaderboard: Unknown User, {error}")
logs.debug(f"Currency Leaderboard: Unknown User, {error}")
embed.add_field(
name=f"#{rank} - {name}",
@ -120,7 +120,7 @@ class LeaderboardCommandView(discord.ui.View):
async def on_timeout(self):
await self.message.edit(view=None)
#racu_logs.info(f"[CommandHandler] /leaderboard command timed out - this is normal behavior.")
#logs.info(f"[CommandHandler] /leaderboard command timed out - this is normal behavior.")
self.stop()
async def interaction_check(self, interaction) -> bool:
@ -151,7 +151,7 @@ class LeaderboardCommandView(discord.ui.View):
except Exception as error:
name = "Unknown User"
racu_logs.debug(f"Currency Leaderboard: Unknown User, {error}")
logs.debug(f"Currency Leaderboard: Unknown User, {error}")
embed.add_field(
name=f"#{rank} - {name}",
@ -174,7 +174,7 @@ class LeaderboardCommandView(discord.ui.View):
except Exception as error:
name = "Unknown User"
racu_logs.debug(f"Currency Leaderboard: Unknown User, {error}")
logs.debug(f"Currency Leaderboard: Unknown User, {error}")
embed.add_field(
name=f"#{rank} - {name}",
@ -196,7 +196,7 @@ class LeaderboardCommandView(discord.ui.View):
except Exception as error:
name = "Unknown User"
racu_logs.debug(f"Currency Leaderboard: Unknown User, {error}")
logs.debug(f"Currency Leaderboard: Unknown User, {error}")
claimed_at = datetime.fromisoformat(claimed_at)
claimed_at = claimed_at.date()
@ -210,5 +210,5 @@ class LeaderboardCommandView(discord.ui.View):
await interaction.response.edit_message(embed=embed)
def setup(sbbot):
sbbot.add_cog(LeaderboardV2Cog(sbbot))
def setup(client):
client.add_cog(LeaderboardV2Cog(client))

View file

@ -1,19 +1,19 @@
from discord.ext import commands
from data.Xp import Xp
from sb_tools import embeds, universal
from services.Xp import Xp
from utils import embeds, checks
class LevelCog(commands.Cog):
def __init__(self, sbbot):
self.bot = sbbot
def __init__(self, client):
self.bot = client
@commands.slash_command(
name="level",
description="Displays your level and rank.",
guild_only=True
)
@commands.check(universal.channel_check)
@commands.check(checks.channel)
async def level(self, ctx):
xp_data = Xp(ctx.author.id)
rank = xp_data.calculate_rank()
@ -23,5 +23,5 @@ class LevelCog(commands.Cog):
needed_xp_for_next_level, rank))
def setup(sbbot):
sbbot.add_cog(LevelCog(sbbot))
def setup(client):
client.add_cog(LevelCog(client))

View file

@ -5,7 +5,7 @@ from discord.ext import commands
from main import strings
racu_logs = logging.getLogger('Racu.Core')
logs = logging.getLogger('Racu.Core')
def hierarchy_check(user, target):
@ -16,8 +16,8 @@ def hierarchy_check(user, target):
class SimpleModCog(commands.Cog):
def __init__(self, sbbot):
self.bot = sbbot
def __init__(self, client):
self.bot = client
"""
This cog contains simple moderation commands
@ -49,7 +49,7 @@ class SimpleModCog(commands.Cog):
if not dm_channel:
await ctx.respond(strings["error_mod_invoke_error"].format(ctx.author.name), ephemeral=True)
racu_logs.error(f"[CommandHandler] error during kick command: {err}")
logs.error(f"[CommandHandler] error during kick command: {err}")
@commands.slash_command(
name="ban",
@ -80,8 +80,8 @@ class SimpleModCog(commands.Cog):
if not dm_channel:
await ctx.respond(strings["error_mod_invoke_error"].format(ctx.author.name), ephemeral=True)
racu_logs.error(f"[CommandHandler] error during ban command: {err}")
logs.error(f"[CommandHandler] error during ban command: {err}")
def setup(sbbot):
sbbot.add_cog(SimpleModCog(sbbot))
def setup(client):
client.add_cog(SimpleModCog(client))

View file

@ -3,24 +3,24 @@ import logging
from discord.ext import commands
from main import strings
from sb_tools import universal
from utils import checks
racu_logs = logging.getLogger('Racu.Core')
logs = logging.getLogger('Racu.Core')
class PingCog(commands.Cog):
def __init__(self, sbbot):
self.bot = sbbot
def __init__(self, client):
self.bot = client
@commands.slash_command(
name="ping",
description="Simple status check.",
guild_only=True
)
@commands.check(universal.channel_check)
@commands.check(checks.channel)
async def ping(self, ctx):
await ctx.respond(content=strings["ping"].format(ctx.author.name))
def setup(sbbot):
sbbot.add_cog(PingCog(sbbot))
def setup(client):
client.add_cog(PingCog(client))

View file

@ -3,25 +3,25 @@ import logging
import discord
from discord.ext import commands
from sb_tools import universal
from utils import checks
racu_logs = logging.getLogger('Racu.Core')
logs = logging.getLogger('Racu.Core')
class SayCog(commands.Cog):
def __init__(self, sbbot):
self.bot = sbbot
def __init__(self, client):
self.bot = client
@commands.slash_command(
name="tess",
description="Bot admin only",
guild_only=True
)
@commands.check(universal.owner_check)
@commands.check(checks.bot_owner)
async def tess_command(self, ctx, *, txt: discord.Option(str)):
await ctx.respond(content="", ephemeral=True)
await ctx.send(content=txt)
def setup(sbbot):
sbbot.add_cog(SayCog(sbbot))
def setup(client):
client.add_cog(SayCog(client))

View file

@ -6,12 +6,12 @@ import discord
from discord.ext import commands
from dotenv import load_dotenv
from data.Currency import Currency
from data.Inventory import Inventory
from data.Item import Item
from sb_tools import interaction, universal
from services.Currency import Currency
from services.Inventory import Inventory
from services.Item import Item
from utils import interaction, checks
racu_logs = logging.getLogger('Racu.Core')
logs = logging.getLogger('Racu.Core')
load_dotenv('.env')
special_balance_name = os.getenv("SPECIAL_BALANCE_NAME")
@ -49,7 +49,7 @@ class SellCommandView(discord.ui.View):
description="You ran out of time."
)
await self.message.edit(embed=embed, view=None)
racu_logs.warning(f"{self.ctx.author.name}: /sell command timed out.")
logs.warning(f"{self.ctx.author.name}: /sell command timed out.")
self.stop()
async def interaction_check(self, interaction) -> bool:
@ -81,15 +81,15 @@ def is_number_between(value, upper_limit):
class SellCog(commands.Cog):
def __init__(self, sbbot):
self.bot = sbbot
def __init__(self, client):
self.bot = client
@commands.slash_command(
name="sell",
description="Sell items from your inventory.",
guild_only=True
)
@commands.check(universal.channel_check)
@commands.check(checks.channel)
async def sell(self, ctx):
inv = Inventory(ctx.author.id)
items = inv.get_sell_data()
@ -155,7 +155,7 @@ class SellCog(commands.Cog):
await ctx.respond(
embed=discord.Embed(description="You ran out of time.", color=discord.Color.red()),
content=ctx.author.mention)
# racu_logs.warning(f"{ctx.author.id} Sell Timeout")
# logs.warning(f"{ctx.author.id} Sell Timeout")
return
else:
@ -198,7 +198,7 @@ class SellCog(commands.Cog):
except Exception as e:
await ctx.respond("Something went wrong, let Tess know about this.")
racu_logs.error(f"[CommandHandler] /sell post-confirmation error: {e}")
logs.error(f"[CommandHandler] /sell post-confirmation error: {e}")
return
else:
@ -212,5 +212,5 @@ class SellCog(commands.Cog):
await ctx.edit(embed=embed)
def setup(sbbot):
sbbot.add_cog(SellCog(sbbot))
def setup(client):
client.add_cog(SellCog(client))

View file

@ -5,9 +5,9 @@ import discord
from discord.ext import commands
from dotenv import load_dotenv
from data.Currency import Currency
from data.ShopItem import ShopItem
from sb_tools import universal
from services.Currency import Currency
from services.ShopItem import ShopItem
from utils import checks
load_dotenv('.env')
special_balance_name = os.getenv("SPECIAL_BALANCE_NAME")
@ -18,15 +18,15 @@ with open("config/economy.json") as file:
class ShopCog(commands.Cog):
def __init__(self, sbbot):
self.bot = sbbot
def __init__(self, client):
self.bot = client
@commands.slash_command(
name="shop",
description="Display the shop.",
guild_only=True
)
@commands.check(universal.beta_check)
@commands.check(checks.beta_command)
async def shop(self, ctx):
shop = ShopItem.get_shop_all()
@ -54,5 +54,5 @@ class ShopCog(commands.Cog):
await ctx.respond(embed=embed)
def setup(sbbot):
sbbot.add_cog(ShopCog(sbbot))
def setup(client):
client.add_cog(ShopCog(client))

View file

@ -7,18 +7,18 @@ import discord
import pytz
from discord.ext import commands
from data.Currency import Currency
from data.SlotsStats import SlotsStats
from services.Currency import Currency
from services.SlotsStats import SlotsStats
from handlers.ItemHandler import ItemHandler
from main import economy_config, strings
from sb_tools import economy_embeds, universal
from utils import economy_embeds, checks
est = pytz.timezone('US/Eastern')
def get_emotes(sbbot):
def get_emotes(client):
decoration = economy_config["slots"]["emotes"]
emojis = {name: sbbot.get_emoji(emoji_id) for name, emoji_id in decoration.items()}
emojis = {name: client.get_emoji(emoji_id) for name, emoji_id in decoration.items()}
return emojis
@ -155,15 +155,15 @@ def slots_finished(ctx, payout_type, bet, payout, results, emojis):
class SlotsCog(commands.Cog):
def __init__(self, sbbot):
self.bot = sbbot
def __init__(self, client):
self.bot = client
@commands.slash_command(
name="slots",
descriptions="Spin the slots for a chance to win the jackpot!",
guild_only=True
)
@commands.check(universal.channel_check)
@commands.check(checks.channel)
async def slots(self, ctx, *, bet: discord.Option(int)):
# Currency handler
@ -236,5 +236,5 @@ class SlotsCog(commands.Cog):
stats.push()
def setup(sbbot):
sbbot.add_cog(SlotsCog(sbbot))
def setup(client):
client.add_cog(SlotsCog(client))

View file

@ -7,7 +7,7 @@ from discord.ext import commands
from dotenv import load_dotenv
from db import database
from sb_tools import universal
from utils import checks
load_dotenv('.env')
@ -20,8 +20,8 @@ with open("config/economy.json") as file:
class OwnerOnlyCog(commands.Cog):
def __init__(self, sbbot):
self.bot = sbbot
def __init__(self, client):
self.bot = client
sql = discord.SlashCommandGroup(name="sql", description="Perform SQL commands (DANGEROUS)")
@ -30,7 +30,7 @@ class OwnerOnlyCog(commands.Cog):
description="Perform a SELECT query in the database.",
guild_only=True
)
@commands.check(universal.owner_check)
@commands.check(checks.bot_owner)
async def select(self, ctx, *, query: discord.Option(str)):
if query.lower().startswith("select "):
query = query[7:]
@ -47,7 +47,7 @@ class OwnerOnlyCog(commands.Cog):
description="Change a value in the database. (DANGEROUS)",
guild_only=True
)
@commands.check(universal.owner_check)
@commands.check(checks.bot_owner)
async def inject(self, ctx, *, query: discord.Option(str)):
try:
database.execute_query(query)
@ -56,5 +56,5 @@ class OwnerOnlyCog(commands.Cog):
await ctx.respond(content=f"Query:\n```{query}```\nError message:\n```{error}```", ephemeral=True)
def setup(sbbot):
sbbot.add_cog(OwnerOnlyCog(sbbot))
def setup(client):
client.add_cog(OwnerOnlyCog(client))

View file

@ -5,11 +5,11 @@ import discord
from discord.ext import commands
from dotenv import load_dotenv
from data.BlackJackStats import BlackJackStats
from data.Currency import Currency
from data.SlotsStats import SlotsStats
from services.BlackJackStats import BlackJackStats
from services.Currency import Currency
from services.SlotsStats import SlotsStats
from main import strings, economy_config
from sb_tools import universal
from utils import checks
load_dotenv('.env')
@ -22,15 +22,15 @@ with open("config/economy.json") as file:
class StatsCog(commands.Cog):
def __init__(self, sbbot):
self.bot = sbbot
def __init__(self, client):
self.bot = client
@commands.slash_command(
name="stats",
description="Display your stats (BETA)",
guild_only=True
)
@commands.check(universal.channel_check)
@commands.check(checks.channel)
async def stats(self, ctx, *, game: discord.Option(choices=["BlackJack", "Slots"])):
output = ""
@ -73,5 +73,5 @@ class StatsCog(commands.Cog):
await ctx.respond(content=output)
def setup(sbbot):
sbbot.add_cog(StatsCog(sbbot))
def setup(client):
client.add_cog(StatsCog(client))

View file

@ -1,12 +1,12 @@
from discord.ext import commands
import datetime, time
from main import strings
from sb_tools import universal
from utils import checks
class UptimeCog(commands.Cog):
def __init__(self, sbbot):
self.bot = sbbot
def __init__(self, client):
self.bot = client
self.start_time = time.time()
@commands.slash_command(
@ -14,7 +14,7 @@ class UptimeCog(commands.Cog):
description="Simple status check.",
guild_only=True
)
@commands.check(universal.channel_check)
@commands.check(checks.channel)
async def uptime(self, ctx):
current_time = time.time()
@ -24,5 +24,5 @@ class UptimeCog(commands.Cog):
await ctx.respond(content=strings["uptime"].format(ctx.author.name, text))
def setup(sbbot):
sbbot.add_cog(UptimeCog(sbbot))
def setup(client):
client.add_cog(UptimeCog(client))

View file

@ -3,7 +3,7 @@ from datetime import datetime, timedelta
import pytz
from data.Currency import Currency
from services.Currency import Currency
from db import database
with open("config/economy.json") as file:

View file

@ -1,9 +1,9 @@
import logging
from data import Item
from services import Item
from db import database
racu_logs = logging.getLogger('Racu.Core')
logs = logging.getLogger('Racu.Core')
class Inventory:
@ -76,5 +76,5 @@ class Inventory:
return item_names
except Exception as e:
racu_logs.error(e)
logs.error(e)
return []

View file

@ -4,7 +4,7 @@ import sqlite3
from db import database
racu_logs = logging.getLogger('Racu.Core')
logs = logging.getLogger('Racu.Core')
class Item:
@ -49,30 +49,6 @@ class Item:
return database.select_query_one(query, (self.id,))
@staticmethod
def insert_items():
with open("config/default_items.json", 'r') as file:
items_data = json.load(file)
for index, (item_id, item_data) in enumerate(items_data.items(), start=1):
name = item_data["name"]
display_name = item_data["display_name"]
description = item_data["description"]
image_url = item_data["image_url"]
emote_id = item_data["emote_id"]
quote = item_data["quote"]
item_type = item_data["type"]
query = """
REPLACE INTO item
(id, name, display_name, description, image_url, emote_id, quote, type)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s)
"""
database.execute_query(query,
(index, name, display_name, description, image_url, emote_id, quote, item_type))
racu_logs.info("[ItemHandler] Items inserted into the database successfully.")
@staticmethod
def get_all_item_names():
query = "SELECT display_name FROM item"
@ -87,7 +63,7 @@ class Item:
return item_names
except sqlite3.Error:
racu_logs.error(sqlite3.Error)
logs.error(sqlite3.Error)
return []
@staticmethod

View file

@ -1,4 +1,4 @@
from data.Item import Item
from services.Item import Item
from db import database

View file

@ -17,7 +17,7 @@ class SlotsStats:
def push(self):
"""
Insert the data from any given slots game into the database
Insert the services from any given slots game into the database
"""
query = """
INSERT INTO stats_slots (user_id, is_won, bet, payout, spin_type, icons)

View file

@ -7,7 +7,7 @@ from dotenv import load_dotenv
load_dotenv('.env')
async def channel_check(ctx):
async def channel(ctx):
desired_channel_id = 1118587309365940407 # bot-chat in RCU
owner_id = os.getenv("OWNER_ID")
@ -19,12 +19,12 @@ async def channel_check(ctx):
return True
async def beta_check(ctx):
async def beta_command(ctx):
owner_id = os.getenv("OWNER_ID")
if ctx.author.id != int(owner_id):
embed = discord.Embed(description=f"You can't use this command just yet! It's currently undergoing testing and "
f"fine-tuning to ensure the best experience for all users. Stay tuned for its "
f"official release.",
f"fine-tuning to ensure the best experience for all users. Stay tuned for its"
f" official release.",
color=discord.Color.red())
await ctx.respond(embed=embed, ephemeral=True)
return False
@ -32,10 +32,10 @@ async def beta_check(ctx):
return True
async def owner_check(ctx):
async def bot_owner(ctx):
owner_id = os.getenv("OWNER_ID")
if ctx.author.id != int(owner_id):
embed = discord.Embed(description=f"Only Tess can do this command.",
embed = discord.Embed(description=f"Only Esther can do this command.",
color=discord.Color.red())
await ctx.respond(embed=embed, ephemeral=True)
return False
@ -43,7 +43,7 @@ async def owner_check(ctx):
return True
async def eightball_check(message):
async def eightball(message):
desired_channel_id = 1118587309365940407
if message.channel.id != desired_channel_id:

View file

@ -90,17 +90,3 @@ def out_of_time():
description="Uh-oh! Time's up. Your bet is forfeited as the game concludes."
)
return embed
def coinflip(ctx, guess_side, throw_side, bet):
embed = discord.Embed(
title=f"You bet {cash_balance_name}{bet} on {guess_side}."
)
embed.set_author(name=ctx.author.name, icon_url=ctx.author.avatar.url)
if throw_side == "heads":
embed.set_thumbnail(url="https://media.tenor.com/nEu74vu_sT4AAAAC/heads-coinflip.gif")
else:
embed.set_thumbnail(url="https://media.tenor.com/kK8D7hQXX5wAAAAC/coins-tails.gif")
return embed

View file

@ -1,6 +1,6 @@
import discord
from data.Xp import Xp
from services.Xp import Xp
def command_error_1(error):
@ -107,14 +107,6 @@ def final_confirmation(channel_id):
return embed
#
# def level_up_message(level, rank):
# embed = discord.Embed(color=0xadcca6,
# title=f"You reached level {level}!")
# embed.set_footer(text=f"Rank: #{rank} | Leaderboard coming soon")
# return embed
def level_command_message(ctx, level, xp, next_level_xp, rank):
embed = discord.Embed(color=0xadcca6,
title=f"{ctx.author.name} - lv. {level}")