- This API is part of the AbbyBot project and serves data related to Discord bot servers, users, and bot information.
- Python 3.x
- Flask
- MySQL connector
- dotenv
- requests
Make sure you have all the necessary packages installed by running:
pip install -r requirements.txt
To configure the API, you need a .env
file with the following variables:
DISCORD_TOKEN=your_discord_token
DB_HOST=your_database_host
DB_USER=your_database_user
DB_PASSWORD=your_database_password
DISCORD_API_BASE_URL=https://discord.com/api/v10
IMAGE_FOLDER_PATH=path_to_your_image_folder
BOT_VERSION=your_bot_version
- Clone the repository and navigate to the folder.
- Set up your
.env
file with the appropriate values. - Run the Flask application:
python app.py
The API will be available at http://127.0.0.1:5002/
.
URL: /bot-info
Method: GET
Returns information about the bot, including its ID, name, discriminator, avatar, server count, and version.
{
"bot_id": "123456789",
"bot_name": "AbbyBot",
"discriminator": "1234",
"avatar_url": "https://cdn.discordapp.com/avatars/123456789/avatar.png",
"banner_url": "https://example.com/bot/banner/123456789.png",
"server_count": 12,
"version": "1.0.0"
}
URL: /user-servers
Method: GET
Parameters:
user_id
: Discord user ID (required)
Returns the list of servers a user belongs to, their privileges, and whether they are an owner.
{
"user_id": "987654321",
"servers": [
{
"activated_birthday": 1,
"activated_events": 1,
"activated_logs": 0,
"birthday_channel": 1234567890123456789,
"default_bot_role_id": null,
"default_role_id": null,
"guild_icon_last_updated": "Thu, 24 Oct 2024 21:33:53 GMT",
"guild_icon_url": "https://image-sample.com",
"guild_id": 9876543210123456789,
"guild_language": 1,
"guild_name": "Sever",
"is_admin": 1,
"is_owner": 0,
"join_channel_id": null,
"kick_channel_id": null,
"ban_channel_id": null,
"logs_channel": null,
"owner_id": 1234567890123456789
},
]
}
URL: /user-info
Method: GET
Parameters:
user_id
: Discord user ID (required)
Returns information about the user's profile, including their Discord username, account creation date, birthday, shared servers, and AbbyBot theme.
{
"account_created_at": "Tue, 05 Jun 2017 15:34:20 GMT",
"discord_username": "unit01shinji",
"privilege": "Normal User 🐱",
"servers_shared": 3,
"theme": {
"theme_class": "abby-theme",
"theme_id": 1,
"theme_name": "Abby"
},
"user_birthday": "2001-11-22",
"user_id": 573829101284550144
}
URL: /server-dashboard
Method: GET
Parameters:
guild_id
: Discord Server ID (required)
Returns the list of all users (dashboard) on a server where AbbyBot is, bringing data such as their nicknames, user types (user, admin, owner), their user IDs, birthdays and server roles..
[
{
"Username": "katsuragimisato",
"Nickname in server": "Misato Katsuragi",
"User type": "Owner",
"User ID": "123456789012345678",
"Server roles": [
"rizz",
"gyatt"
],
"Birthday Date": "1986-08-12"
},
{
"Username": "reiayanami",
"Nickname in server": "Rei Ayanami",
"User type": "Admin",
"User ID": "876543210987654321",
"Server roles": [
"fortnite-player"
],
"Birthday Date": null
},
{
"Username": "asukalangleyshyru",
"Nickname in server": "Asuka Langley Sohryu",
"User type": "User",
"User ID": "367397873597284352",
"Server roles": [
"abbybot_dev"
],
"Birthday Date": "2001-12-04"
}
]
URL: /update-birthday
Method: POST
Parameters:
user_id
: The ID of the user whose birthday needs to be updated (required).birthday_date
: The new birthday date inYYYY-MM-DD
format (required).
Updates the birthday of a user in the AbbyBot dashboard. If the user exists, their birthday is updated to the new provided date.
{
"user_id": "123456789012345678",
"birthday_date": "1992-05-14"
}
{
"success": "Birthday updated for user 123456789012345678",
"status_code": 200
}
{
"info": "The birthday is already set to this value. No update needed.",
"status_code": 200
}
{
"error": "Missing user_id or birthday_date",
"status_code": 400
}
{
"error": "Invalid birthday format. Use YYYY-MM-DD.",
"status_code": 400
}
{
"error": "Birthday cannot be in the future.",
"status_code": 400
}
or
{
"error": "Birthday is too old. Please enter a valid date after 1900.",
"status_code": 400
}
{
"error": "No user found with the provided user_id",
"status_code": 404
}
URL: /update-abbybot_theme
Method: POST
Parameters:
user_id
: The ID of the user whose AbbyBot theme needs to be updated (required).theme_id
: The new theme ID to be applied (required).
Updates the birthday of a user in the AbbyBot dashboard. If the user exists, their birthday is updated to the new provided date.
{
"user_id": "123456789012345678",
"theme_id": 2
}
{
"success": "AbbyBot_theme updated for user 123456789012345678",
"status_code": 200
}
{
"info": "No update needed, the theme is already set to this value",
"status_code": 200
}
{
"info": "No user found with the provided user_id",
"status_code": 404
}
URL: /update-language
Method: POST
Parameters:
guild_id
: The ID of the guild who the language needs to be updated (required).language_id
: The new language ID to be applied (required).
Updates the language of a guild in the AbbyBot dashboard. If the guild exists, their language is updated to the new provided date.
{
"guild_id": "123456789012345678",
"language_id": 2
}
{
"success": "Language updated for guild 123456789012345678",
"status_code": 200
}
{
"info": "No update needed, the language is already set",
"status_code": 200
}
{
"info": "No guild found with the provided guild_id",
"status_code": 404
}
URL: /toggle_automatic_events
Method: POST
Parameters:
guild_id
: The ID of the guild who the language needs to be updated (required).activated_events
: The value to enable/disable AbbyBot automatic events, 1 = activated, 0 = deactivated (required).
Update the automatic event trigger for a guild in AbbyBot. If the guild exists, its events are updated to the new value provided.
{
"guild_id": "123456789012345678",
"activated_events": 1
}
{
"success": "Activated auto events for guild 123456789012345678",
"status_code": 200
}
{
"success": "Deactivated auto events for guild 123456789012345678",
"status_code": 200
}
{
"error": "Invalid value for activated_events. It must be 0 or 1.",
"status_code": 400
}
{
"error": "Invalid value for activated_events. It must be a number (0 or 1).",
"status_code": 400
}
{
"info": "No update needed, the activated_events value is already set",
"status_code": 200
}
{
"info": "No guild found with the provided guild_id",
"status_code": 404
}
URL: /toggle-birthday-event
Method: POST
Parameters:
guild_id
: The ID of the guild who the language needs to be updated (required).activated_birthday
: The value to enable/disable AbbyBot birthday events, 1 = activated, 0 = deactivated (required).
Update the birthday event trigger for a guild in AbbyBot. If the guild exists, its birthday events are updated to activated/deactivated.
{
"guild_id": "123456789012345678",
"activated_birthday": 1
}
{
"success": "Activated auto events for guild 123456789012345678",
"status_code": 200
}
{
"success": "Deactivated auto events for guild 123456789012345678",
"status_code": 200
}
{
"error": "Invalid value for activated_birthday. It must be 0 or 1.",
"status_code": 400
}
{
"error": "Invalid value for activated_birthday. It must be a number (0 or 1).",
"status_code": 400
}
{
"info": "No update needed, the activated_birthday value is already set",
"status_code": 200
}
{
"info": "No guild found with the provided guild_id",
"status_code": 404
}
URL: /toggle-logs
Method: POST
Parameters:
guild_id
: The ID of the guild who the language needs to be updated (required).activated_logs
: The value to enable/disable AbbyBot logs events, 1 = activated, 0 = deactivated (required).
Update the logs event trigger for a guild in AbbyBot. If the guild exists, its logs events are updated to activated/deactivated.
{
"guild_id": "123456789012345678",
"activated_logs": 1
}
{
"success": "Activated auto events for guild 123456789012345678",
"status_code": 200
}
{
"success": "Deactivated auto events for guild 123456789012345678",
"status_code": 200
}
{
"error": "Invalid value for activated_logs. It must be 0 or 1.",
"status_code": 400
}
{
"error": "Invalid value for activated_logs. It must be a number (0 or 1).",
"status_code": 400
}
{
"info": "No update needed, the activated_logs value is already set",
"status_code": 200
}
{
"info": "No guild found with the provided guild_id",
"status_code": 404
}
URL: /set-prefix
Method: POST
Parameters:
guild_id
: The ID of the guild who the language needs to be updated (required).prefix
: The prefix for AbbyBot in a guild, ex: abbybot_ (required).
Updates the prefix only in the specified guild.
{
"guild_id": "123456789012345678",
"prefix": "abbybot_"
}
{
"success": "Changed prefix for guild 123456789012345678",
"status_code": 200
}
{
"info": "No update needed, the prefix value is already set",
"status_code": 200
}
{
"info": "No guild found with the provided guild_id",
"status_code": 404
}
URL: /set-birthday_channel
Method: POST
Parameters:
guild_id
: The ID of the guild who the language needs to be updated (required).birthday_channel
: The ID for the channel where AbbyBot greet users in their birthdays (required).
Updates the prefix only in the specified guild.
{
"guild_id": "123456789012345678",
"birthday_channel": 123456789012345678
}
{
"error": "Invalid value for birthday_channel. It must be a numeric value.",
"status_code": 400
}
{
"success": "Changed birthday_channel for guild 123456789012345678",
"status_code": 200
}
{
"info": "No update needed, the birthday_channel value is already set",
"status_code": 200
}
{
"info": "No guild found with the provided guild_id",
"status_code": 404
}
URL: /set-logs_channel
Method: POST
Parameters:
guild_id
: The ID of the guild who the language needs to be updated (required).logs_channel
: The ID for the channel where AbbyBot greet users in their birthdays (required).
Updates the logs_channel only in the specified guild.
{
"guild_id": "123456789012345678",
"logs_channel": 123456789012345678
}
{
"error": "Invalid value for logs_channel. It must be a numeric value.",
"status_code": 400
}
{
"success": "Changed logs_channel for guild 123456789012345678",
"status_code": 200
}
{
"info": "No update needed, the logs_channel value is already set",
"status_code": 200
}
{
"info": "No guild found with the provided guild_id",
"status_code": 404
}
URL: /privileges-info
Method: GET
Returns information about AbbyBot's privileges. Explaining its meaning, how to get it, XP multiplier and exclusive advantages.
privileges:
{
"exclusive_access": "TBA",
"id ": 1,
"privilege_name":"Normal User 🐱",
"rol_meaning": "Users who have just joined the server. No specific advantages but they earn 1.0 XP.",
"xp_multiplier": "1.00",
}
URL: /abbybot-themes
Method: GET
Returns information about all AbbyBot themes registered, with their ID, title and class themes.
{
"abbybot_themes": [
{
"theme_class": "abby-theme",
"theme_id": 1,
"theme_title": "Abby"
},
{
"theme_class": "d0z3r-theme",
"theme_id": 2,
"theme_title": "D0Z3R"
},
{
"theme_class": "masky-theme",
"theme_id": 3,
"theme_title": "Masky"
},
{
"theme_class": "nebulanight-theme",
"theme_id": 4,
"theme_title": "Nebula Night"
},
{
"theme_class": "lightone-theme",
"theme_id": 5,
"theme_title": "Light 01"
},
{
"theme_class": "mia-theme",
"theme_id": 6,
"theme_title": "MIA"
},
{
"theme_class": "python-theme",
"theme_id": 7,
"theme_title": "Python"
},
{
"theme_class": "node-theme",
"theme_id": 8,
"theme_title": "Node"
}
]
}
URL: /server-channels
Method: GET
Parameters:
guild_id
: Discord Server ID (required)
Returns the list of channels in a server, including their IDs and titles.
[
{
"channel_id": 1234567898232352134,
"channel_title": "misato-house",
"guild_id": 999999999999999999,
"id": 54
},
{
"channel_id": 12343458982323234134,
"channel_title": "rei-party",
"guild_id": 999999999999999999,
"id": 55
},
]
URL: /update-join-channel
Method: POST
Parameters:
guild_id
: The Guild ID (required).join_channel_id
: The ID for show kick card (required).
Updates the prefix only in the specified guild.
{
"guild_id": "123456789012345678",
"join_channel_id": 123456789012345678
}
{
"success": "Changed join_channel_id for guild 123456789012345678",
"status_code": 200
}
{
"info": "No update needed, the join_channel_id value is already set",
"status_code": 200
}
{
"info": "No guild found with the provided guild_id",
"status_code": 404
}
URL: /update-kick-channel
Method: POST
Parameters:
guild_id
: The Guild ID (required).kick_channel_id
: The ID for show kick card (required).
Updates the prefix only in the specified guild.
{
"guild_id": "123456789012345678",
"kick_channel_id": 123456789012345678
}
{
"success": "Changed kick_channel_id for guild 123456789012345678",
"status_code": 200
}
{
"info": "No update needed, the kick_channel_id value is already set",
"status_code": 200
}
{
"info": "No guild found with the provided guild_id",
"status_code": 404
}
URL: /update-ban-channel
Method: POST
Parameters:
guild_id
: The Guild ID (required).ban_channel_id
: The ID for show ban card (required).
Updates the prefix only in the specified guild.
{
"guild_id": "123456789012345678",
"ban_channel_id": 123456789012345678
}
{
"success": "Changed ban_channel_id for guild 123456789012345678",
"status_code": 200
}
{
"info": "No update needed, the ban_channel_id value is already set",
"status_code": 200
}
{
"info": "No guild found with the provided guild_id",
"status_code": 404
}
- The bot information is periodically updated in the local database, but real-time data is fetched from the Discord API.