bug fix/install scripts
This commit is contained in:
81
SCRIPTS/install/install.bat
Normal file
81
SCRIPTS/install/install.bat
Normal file
@@ -0,0 +1,81 @@
|
||||
@echo off
|
||||
REM OC Bot - Installation Script (Windows)
|
||||
REM Usage: install.bat
|
||||
REM Coded by Ball Studios 🎨
|
||||
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
echo =========================================
|
||||
echo OC Bot - Installation Script
|
||||
echo Coded by Ball Studios <20>x1f3a8
|
||||
echo =========================================
|
||||
echo.
|
||||
|
||||
REM Check if Python is installed
|
||||
python3 --version >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo ❌ Python 3 is not installed!
|
||||
echo Please install Python 3.11+ from https://www.python.org
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
for /f "tokens=2" %%i in ('python3 --version 2^>^&1') do set PYTHON_VERSION=%%i
|
||||
echo ✅ Python !PYTHON_VERSION! found
|
||||
echo.
|
||||
|
||||
REM Create virtual environment if it doesn't exist
|
||||
if not exist "venv" (
|
||||
echo 📦 Creating virtual environment...
|
||||
python3 -m venv venv
|
||||
echo ✅ Virtual environment created
|
||||
) else (
|
||||
echo ✅ Virtual environment already exists
|
||||
)
|
||||
|
||||
echo.
|
||||
|
||||
REM Activate virtual environment
|
||||
echo 🔧 Activating virtual environment...
|
||||
call venv\Scripts\activate.bat
|
||||
echo ✅ Virtual environment activated
|
||||
echo.
|
||||
|
||||
REM Upgrade pip
|
||||
echo 📦 Upgrading pip...
|
||||
python -m pip install --upgrade pip >nul 2>&1
|
||||
echo ✅ Pip upgraded
|
||||
echo.
|
||||
|
||||
REM Install requirements
|
||||
echo 📦 Installing dependencies...
|
||||
pip install -r requirements.txt
|
||||
echo ✅ Dependencies installed
|
||||
echo.
|
||||
|
||||
REM Setup .env file
|
||||
if not exist ".env" (
|
||||
echo 📝 Creating .env file...
|
||||
copy .env.example .env
|
||||
echo ⚠️ .env file created. Please edit it with your settings:
|
||||
echo - DISCORD_TOKEN
|
||||
echo - DB_HOST
|
||||
echo - DB_USER
|
||||
echo - DB_PASSWORD
|
||||
echo - DB_NAME
|
||||
echo.
|
||||
) else (
|
||||
echo ✅ .env file already exists
|
||||
)
|
||||
|
||||
echo.
|
||||
echo =========================================
|
||||
echo ✅ Installation Complete!
|
||||
echo =========================================
|
||||
echo.
|
||||
echo 📝 Next steps:
|
||||
echo 1. Edit .env with your Discord token and database credentials
|
||||
echo 2. Create the database using MariaDB client
|
||||
echo 3. Run the bot: python bot.py
|
||||
echo.
|
||||
pause
|
||||
88
SCRIPTS/install/install.sh
Normal file
88
SCRIPTS/install/install.sh
Normal file
@@ -0,0 +1,88 @@
|
||||
#!/bin/bash
|
||||
# OC Bot - Installation Script
|
||||
# Usage: bash install.sh
|
||||
# Coded by Ball Studios 🎨
|
||||
|
||||
set -e
|
||||
|
||||
echo "========================================="
|
||||
echo " OC Bot - Installation Script"
|
||||
echo " Coded by Ball Studios 🎨"
|
||||
echo "========================================="
|
||||
echo ""
|
||||
|
||||
# Check if Python is installed
|
||||
if ! command -v python3 &> /dev/null; then
|
||||
echo "❌ Python 3 is not installed!"
|
||||
echo "Please install Python 3.11+ from https://www.python.org"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PYTHON_VERSION=$(python3 --version | cut -d' ' -f2)
|
||||
echo "✅ Python $PYTHON_VERSION found"
|
||||
echo ""
|
||||
|
||||
# Check if git is installed
|
||||
if ! command -v git &> /dev/null; then
|
||||
echo "❌ Git is not installed!"
|
||||
echo "Please install Git from https://git-scm.com"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ Git found"
|
||||
echo ""
|
||||
|
||||
# Create virtual environment if it doesn't exist
|
||||
if [ ! -d "venv" ]; then
|
||||
echo "📦 Creating virtual environment..."
|
||||
python3 -m venv venv
|
||||
echo "✅ Virtual environment created"
|
||||
else
|
||||
echo "✅ Virtual environment already exists"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# Activate virtual environment
|
||||
echo "🔧 Activating virtual environment..."
|
||||
source venv/bin/activate
|
||||
echo "✅ Virtual environment activated"
|
||||
echo ""
|
||||
|
||||
# Upgrade pip
|
||||
echo "📦 Upgrading pip..."
|
||||
pip install --upgrade pip
|
||||
echo "✅ Pip upgraded"
|
||||
echo ""
|
||||
|
||||
# Install requirements
|
||||
echo "📦 Installing dependencies..."
|
||||
pip install -r requirements.txt
|
||||
echo "✅ Dependencies installed"
|
||||
echo ""
|
||||
|
||||
# Setup .env file
|
||||
if [ ! -f ".env" ]; then
|
||||
echo "📝 Creating .env file..."
|
||||
cp .env.example .env
|
||||
echo "⚠️ .env file created. Please edit it with your settings:"
|
||||
echo " - DISCORD_TOKEN"
|
||||
echo " - DB_HOST"
|
||||
echo " - DB_USER"
|
||||
echo " - DB_PASSWORD"
|
||||
echo " - DB_NAME"
|
||||
echo ""
|
||||
else
|
||||
echo "✅ .env file already exists"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "========================================="
|
||||
echo " ✅ Installation Complete!"
|
||||
echo "========================================="
|
||||
echo ""
|
||||
echo "📝 Next steps:"
|
||||
echo "1. Edit .env with your Discord token and database credentials"
|
||||
echo "2. Create the database: mysql -u root -p -e 'CREATE DATABASE rp_bot;'"
|
||||
echo "3. Run the bot: python3 bot.py"
|
||||
echo ""
|
||||
104
SCRIPTS/update/UPDATE_GUIDE.md
Normal file
104
SCRIPTS/update/UPDATE_GUIDE.md
Normal file
@@ -0,0 +1,104 @@
|
||||
# Update Scripts Guide
|
||||
|
||||
Simple scripts to update your OC Bot installation with the latest code and fixes from GitHub.
|
||||
|
||||
## What Was Fixed Recently
|
||||
|
||||
### 1. **database.py** - SQL Syntax Errors
|
||||
- Added backticks around reserved SQL keywords (`trigger`, `characters`)
|
||||
- Fixed all database queries to work with MariaDB 10.5+
|
||||
- Maintains cached trigger lookups for performance
|
||||
|
||||
### 2. **cogs/help.py** - Command Conflict Fix
|
||||
- Fixed conflict with discord.py's built-in help command
|
||||
- Help command now works as `,help` without errors
|
||||
- Support for `,help <topic>` still works
|
||||
|
||||
### 3. **requirements.txt** - Python 3.13 Support
|
||||
- Updated discord.py to >=2.5.0 for Python 3.13 compatibility
|
||||
- Fixed `audioop` module error
|
||||
- All dependencies now verified working
|
||||
|
||||
## Usage
|
||||
|
||||
### Linux / macOS
|
||||
|
||||
```bash
|
||||
bash update.sh
|
||||
```
|
||||
|
||||
The script will:
|
||||
- ✅ Check for Git repository
|
||||
- ✅ Fetch latest changes from GitHub
|
||||
- ✅ Pull code updates
|
||||
- ✅ Create/activate virtual environment
|
||||
- ✅ Upgrade pip
|
||||
- ✅ Install/update all dependencies
|
||||
- ✅ Show warnings if database changes needed
|
||||
|
||||
### Windows
|
||||
|
||||
```bash
|
||||
update.bat
|
||||
```
|
||||
|
||||
Same process as Linux, but Windows-compatible.
|
||||
|
||||
## Features
|
||||
|
||||
- **Smart Detection**: Only updates dependencies if requirements.txt changed
|
||||
- **Change Tracking**: Shows which files were modified
|
||||
- **Safety Checks**: Warns about database changes
|
||||
- **Error Handling**: Reports any failures immediately
|
||||
- **Restart Guidance**: Tells you when to restart the bot
|
||||
|
||||
## If You Get Database Errors
|
||||
|
||||
After updating, if you see SQL errors, recreate the database:
|
||||
|
||||
```sql
|
||||
DROP DATABASE rp_bot;
|
||||
CREATE DATABASE rp_bot;
|
||||
```
|
||||
|
||||
The bot will automatically recreate tables with the correct schema.
|
||||
|
||||
## Manual Update Steps
|
||||
|
||||
If the scripts don't work, do this manually:
|
||||
|
||||
```bash
|
||||
# 1. Pull latest code
|
||||
git pull origin main
|
||||
|
||||
# 2. Activate virtual environment
|
||||
source venv/bin/activate # Linux/Mac
|
||||
# or
|
||||
venv\Scripts\activate.bat # Windows
|
||||
|
||||
# 3. Install dependencies
|
||||
pip install --upgrade -r requirements.txt
|
||||
|
||||
# 4. Restart bot
|
||||
python3 bot.py
|
||||
```
|
||||
|
||||
## Recent Changes Summary
|
||||
|
||||
| File | Change | Impact |
|
||||
|------|--------|--------|
|
||||
| database.py | Fixed SQL syntax for reserved keywords | Database operations now work on MariaDB |
|
||||
| cogs/help.py | Removed command conflict | Help command now loads without errors |
|
||||
| requirements.txt | Updated discord.py to 2.5.0+ | Python 3.13 compatibility |
|
||||
|
||||
## Support
|
||||
|
||||
If updates fail:
|
||||
1. Check Git is installed: `git --version`
|
||||
2. Check Python version: `python3 --version` (need 3.11+)
|
||||
3. Check MySQL/MariaDB is running
|
||||
4. Try manual update steps above
|
||||
|
||||
---
|
||||
|
||||
**Coded by Ball Studios 🎨**
|
||||
105
SCRIPTS/update/update.bat
Normal file
105
SCRIPTS/update/update.bat
Normal file
@@ -0,0 +1,105 @@
|
||||
@echo off
|
||||
REM OC Bot - Smart Update Script (Windows)
|
||||
REM Usage: update.bat
|
||||
REM Pulls latest code and applies only necessary changes
|
||||
REM Coded by Ball Studios 🎨
|
||||
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
echo =========================================
|
||||
echo OC Bot - Smart Update Script
|
||||
echo Coded by Ball Studios 🎨
|
||||
echo =========================================
|
||||
echo.
|
||||
|
||||
REM Check if this is a git repository
|
||||
if not exist ".git" (
|
||||
echo ❌ This is not a Git repository!
|
||||
echo Please clone from GitHub first
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo 📦 Checking for updates...
|
||||
echo.
|
||||
|
||||
REM Fetch latest changes from GitHub
|
||||
echo 🔄 Fetching latest code from GitHub...
|
||||
git fetch origin
|
||||
if errorlevel 1 (
|
||||
echo ❌ Git fetch failed!
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
echo ✅ Fetched latest changes
|
||||
echo.
|
||||
|
||||
REM Check if there are updates available
|
||||
for /f %%i in ('git rev-parse HEAD') do set LOCAL=%%i
|
||||
for /f %%i in ('git rev-parse origin/main') do set REMOTE=%%i
|
||||
|
||||
if "!LOCAL!"=="!REMOTE!" (
|
||||
echo ✅ Already up to date!
|
||||
) else (
|
||||
echo 📥 Pulling latest changes...
|
||||
git pull origin main
|
||||
if errorlevel 1 (
|
||||
echo ❌ Git pull failed!
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
echo ✅ Code updated
|
||||
)
|
||||
|
||||
echo.
|
||||
|
||||
REM Check if virtual environment exists
|
||||
if not exist "venv" (
|
||||
echo 📦 Creating virtual environment...
|
||||
python3 -m venv venv
|
||||
if errorlevel 1 (
|
||||
echo ❌ Failed to create virtual environment!
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
echo ✅ Virtual environment created
|
||||
)
|
||||
|
||||
REM Activate virtual environment
|
||||
echo 🔧 Activating virtual environment...
|
||||
call venv\Scripts\activate.bat
|
||||
echo ✅ Virtual environment activated
|
||||
echo.
|
||||
|
||||
REM Upgrade pip
|
||||
echo 📦 Upgrading pip...
|
||||
python -m pip install --upgrade pip >nul 2>&1
|
||||
echo ✅ Pip upgraded
|
||||
echo.
|
||||
|
||||
REM Update requirements
|
||||
echo 📦 Installing/updating dependencies...
|
||||
pip install --upgrade -r requirements.txt
|
||||
if errorlevel 1 (
|
||||
echo ❌ Failed to install dependencies!
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
echo ✅ Dependencies updated
|
||||
echo.
|
||||
|
||||
echo =========================================
|
||||
echo ✅ Update Complete!
|
||||
echo =========================================
|
||||
echo.
|
||||
echo 📝 Summary:
|
||||
echo - Code pulled from GitHub
|
||||
echo - Dependencies updated
|
||||
echo.
|
||||
echo ⚠️ If database errors occur, recreate it:
|
||||
echo DROP DATABASE rp_bot;
|
||||
echo CREATE DATABASE rp_bot;
|
||||
echo.
|
||||
echo ⚙️ Next: Restart the bot to apply updates
|
||||
echo.
|
||||
pause
|
||||
125
SCRIPTS/update/update.sh
Normal file
125
SCRIPTS/update/update.sh
Normal file
@@ -0,0 +1,125 @@
|
||||
#!/bin/bash
|
||||
# OC Bot - Smart Update Script
|
||||
# Usage: bash update.sh
|
||||
# Pulls latest code and applies only necessary changes
|
||||
# Coded by Ball Studios 🎨
|
||||
|
||||
set -e
|
||||
|
||||
echo "========================================="
|
||||
echo " OC Bot - Smart Update Script"
|
||||
echo " Coded by Ball Studios 🎨"
|
||||
echo "========================================="
|
||||
echo ""
|
||||
|
||||
# Check if this is a git repository
|
||||
if [ ! -d ".git" ]; then
|
||||
echo "❌ This is not a Git repository!"
|
||||
echo "Please clone from GitHub first:"
|
||||
echo "git clone https://github.com/BallStudios/rp-bot.git"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for uncommitted changes
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
echo "⚠️ You have uncommitted changes:"
|
||||
git status --short
|
||||
echo ""
|
||||
read -p "Continue anyway? (y/n) " -n 1 -r
|
||||
echo
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo "Update cancelled."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "📦 Checking for updates..."
|
||||
echo ""
|
||||
|
||||
# Fetch latest changes from GitHub
|
||||
echo "🔄 Fetching latest code from GitHub..."
|
||||
git fetch origin
|
||||
echo "✅ Fetched latest changes"
|
||||
echo ""
|
||||
|
||||
# Check if there are updates available
|
||||
LOCAL=$(git rev-parse HEAD)
|
||||
REMOTE=$(git rev-parse origin/main)
|
||||
|
||||
if [ "$LOCAL" = "$REMOTE" ]; then
|
||||
echo "✅ Already up to date!"
|
||||
echo ""
|
||||
else
|
||||
echo "📥 Pulling latest changes..."
|
||||
git pull origin main
|
||||
echo "✅ Code updated"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# Check if virtual environment exists
|
||||
if [ ! -d "venv" ]; then
|
||||
echo "📦 Creating virtual environment..."
|
||||
python3 -m venv venv
|
||||
echo "✅ Virtual environment created"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# Activate virtual environment
|
||||
echo "🔧 Activating virtual environment..."
|
||||
source venv/bin/activate
|
||||
echo "✅ Virtual environment activated"
|
||||
echo ""
|
||||
|
||||
# Check for changed files
|
||||
echo "🔍 Checking for code changes..."
|
||||
CHANGED_FILES=$(git diff --name-only HEAD origin/main 2>/dev/null || echo "")
|
||||
|
||||
if [ -n "$CHANGED_FILES" ]; then
|
||||
echo "📝 Changed files:"
|
||||
echo "$CHANGED_FILES" | sed 's/^/ - /'
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# Upgrade pip
|
||||
echo "📦 Upgrading pip..."
|
||||
pip install --upgrade pip > /dev/null 2>&1
|
||||
echo "✅ Pip upgraded"
|
||||
echo ""
|
||||
|
||||
# Update requirements if changed
|
||||
if echo "$CHANGED_FILES" | grep -q "requirements.txt"; then
|
||||
echo "📦 Installing/updating dependencies (requirements.txt changed)..."
|
||||
pip install --upgrade -r requirements.txt
|
||||
echo "✅ Dependencies updated"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# Database migration notice
|
||||
if echo "$CHANGED_FILES" | grep -q "database.py"; then
|
||||
echo "⚠️ database.py has been updated!"
|
||||
echo ""
|
||||
echo "If you encounter database errors after restart, run:"
|
||||
echo " mysql -u root -p -e 'DROP DATABASE rp_bot; CREATE DATABASE rp_bot;'"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# Help system migration notice
|
||||
if echo "$CHANGED_FILES" | grep -q "cogs/help.py"; then
|
||||
echo "✅ Help system has been updated (fixed conflict with discord.py)"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
echo "========================================="
|
||||
echo " ✅ Update Complete!"
|
||||
echo "========================================="
|
||||
echo ""
|
||||
echo "📝 Summary:"
|
||||
echo "- Code pulled from GitHub"
|
||||
echo "- Dependencies updated"
|
||||
if [ -n "$CHANGED_FILES" ]; then
|
||||
echo "- Files changed: $(echo \"$CHANGED_FILES\" | wc -l)"
|
||||
fi
|
||||
echo ""
|
||||
echo "⚙️ Next: Restart the bot to apply updates"
|
||||
echo ""
|
||||
@@ -5,7 +5,7 @@ class Help(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
@commands.command(name='help')
|
||||
@commands.command(name='help', invoke_without_command=True)
|
||||
async def help_command(self, ctx, topic=None):
|
||||
"""Show help information"""
|
||||
if not topic:
|
||||
@@ -424,4 +424,6 @@ class Help(commands.Cog):
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
async def setup(bot):
|
||||
# Remove default help command to avoid conflicts
|
||||
bot.remove_command('help')
|
||||
await bot.add_cog(Help(bot))
|
||||
|
||||
32
database.py
32
database.py
@@ -44,24 +44,24 @@ class Database:
|
||||
|
||||
# Characters table
|
||||
self.cursor.execute('''
|
||||
CREATE TABLE IF NOT EXISTS characters (
|
||||
CREATE TABLE IF NOT EXISTS `characters` (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
user_id BIGINT NOT NULL,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
trigger VARCHAR(100) NOT NULL,
|
||||
`trigger` VARCHAR(100) NOT NULL,
|
||||
avatar_url TEXT,
|
||||
description TEXT,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
last_used TIMESTAMP NULL,
|
||||
FOREIGN KEY (user_id) REFERENCES users(user_id),
|
||||
UNIQUE KEY unique_user_trigger (user_id, trigger)
|
||||
UNIQUE KEY unique_user_trigger (user_id, `trigger`)
|
||||
)
|
||||
''')
|
||||
|
||||
# Index for fast trigger lookups
|
||||
self.cursor.execute('''
|
||||
CREATE INDEX IF NOT EXISTS idx_user_trigger
|
||||
ON characters(user_id, trigger)
|
||||
ON `characters`(user_id, `trigger`)
|
||||
''')
|
||||
|
||||
self.connection.commit()
|
||||
@@ -80,7 +80,7 @@ class Database:
|
||||
|
||||
try:
|
||||
self.cursor.execute(
|
||||
'SELECT * FROM characters WHERE user_id = %s AND trigger = %s',
|
||||
'SELECT * FROM `characters` WHERE user_id = %s AND `trigger` = %s',
|
||||
(user_id, trigger)
|
||||
)
|
||||
result = self.cursor.fetchone()
|
||||
@@ -97,7 +97,7 @@ class Database:
|
||||
async def get_character_by_id(self, char_id):
|
||||
"""Get character by ID"""
|
||||
try:
|
||||
self.cursor.execute('SELECT * FROM characters WHERE id = %s', (char_id,))
|
||||
self.cursor.execute('SELECT * FROM `characters` WHERE id = %s', (char_id,))
|
||||
return self.cursor.fetchone()
|
||||
except Error as e:
|
||||
logger.error(f'Get character by ID error: {e}')
|
||||
@@ -114,8 +114,8 @@ class Database:
|
||||
|
||||
# Insert character
|
||||
self.cursor.execute(
|
||||
'''INSERT INTO characters
|
||||
(user_id, name, trigger, avatar_url, description)
|
||||
'''INSERT INTO `characters`
|
||||
(user_id, name, `trigger`, avatar_url, description)
|
||||
VALUES (%s, %s, %s, %s, %s)''',
|
||||
(user_id, name, trigger, avatar_url, description)
|
||||
)
|
||||
@@ -135,7 +135,7 @@ class Database:
|
||||
"""Get all characters for a user"""
|
||||
try:
|
||||
self.cursor.execute(
|
||||
'SELECT * FROM characters WHERE user_id = %s ORDER BY created_at DESC',
|
||||
'SELECT * FROM `characters` WHERE user_id = %s ORDER BY created_at DESC',
|
||||
(user_id,)
|
||||
)
|
||||
return self.cursor.fetchall()
|
||||
@@ -153,14 +153,14 @@ class Database:
|
||||
return False
|
||||
|
||||
# Get old trigger for cache clearing
|
||||
self.cursor.execute('SELECT user_id, trigger FROM characters WHERE id = %s', (char_id,))
|
||||
self.cursor.execute('SELECT user_id, `trigger` FROM `characters` WHERE id = %s', (char_id,))
|
||||
old_char = self.cursor.fetchone()
|
||||
|
||||
set_clause = ', '.join([f'{k} = %s' for k in updates.keys()])
|
||||
set_clause = ', '.join([f'`{k}` = %s' if k == 'trigger' else f'{k} = %s' for k in updates.keys()])
|
||||
values = list(updates.values()) + [char_id]
|
||||
|
||||
self.cursor.execute(
|
||||
f'UPDATE characters SET {set_clause} WHERE id = %s',
|
||||
f'UPDATE `characters` SET {set_clause} WHERE id = %s',
|
||||
values
|
||||
)
|
||||
self.connection.commit()
|
||||
@@ -186,10 +186,10 @@ class Database:
|
||||
"""Delete a character"""
|
||||
try:
|
||||
# Get character info for cache clearing
|
||||
self.cursor.execute('SELECT user_id, trigger FROM characters WHERE id = %s', (char_id,))
|
||||
self.cursor.execute('SELECT user_id, `trigger` FROM `characters` WHERE id = %s', (char_id,))
|
||||
char = self.cursor.fetchone()
|
||||
|
||||
self.cursor.execute('DELETE FROM characters WHERE id = %s', (char_id,))
|
||||
self.cursor.execute('DELETE FROM `characters` WHERE id = %s', (char_id,))
|
||||
self.connection.commit()
|
||||
|
||||
# Clear cache
|
||||
@@ -207,7 +207,7 @@ class Database:
|
||||
"""Update last_used timestamp for a character"""
|
||||
try:
|
||||
self.cursor.execute(
|
||||
'UPDATE characters SET last_used = NOW() WHERE id = %s',
|
||||
'UPDATE `characters` SET last_used = NOW() WHERE id = %s',
|
||||
(char_id,)
|
||||
)
|
||||
self.connection.commit()
|
||||
@@ -220,7 +220,7 @@ class Database:
|
||||
"""Check if trigger is available for a user"""
|
||||
try:
|
||||
self.cursor.execute(
|
||||
'SELECT id FROM characters WHERE user_id = %s AND trigger = %s',
|
||||
'SELECT id FROM `characters` WHERE user_id = %s AND `trigger` = %s',
|
||||
(user_id, trigger)
|
||||
)
|
||||
return self.cursor.fetchone() is None
|
||||
|
||||
Reference in New Issue
Block a user