Initial commit: Discord automation tools

This commit is contained in:
2026-01-27 10:13:41 +01:00
commit 7f5d3c2ca7
41 changed files with 983407 additions and 0 deletions

47
scripts/dm_opener.py Executable file
View File

@@ -0,0 +1,47 @@
# discord_tools/scripts/dm_opener.py
import os
import sys
# Add the parent directory to the Python path
script_dir = os.path.dirname(os.path.abspath(__file__))
project_root = os.path.dirname(os.path.dirname(script_dir))
sys.path.insert(0, project_root)
from discord_tools.utils.api_utils import make_discord_request
from discord_tools.config.settings import ERROR_MESSAGES
def open_dm(recipient_id):
"""
Opens a Discord DM channel using the recipient's user ID.
:param recipient_id: The user ID of the recipient
:return: The channel ID of the created DM, or None if the request failed
"""
url = "/users/@me/channels"
data = {
"recipient_id": recipient_id
}
response = make_discord_request('POST', url, json=data)
if response:
channel_data = response.json()
channel_id = channel_data["id"]
print(f"DM channel created successfully: {channel_id}")
return channel_id
else:
print(ERROR_MESSAGES["api_error"])
return None
def main():
recipient_id = input("Enter the recipient's user ID: ")
channel_id = open_dm(recipient_id)
if channel_id:
print(f"Opened channel: {channel_id}")
else:
print("Failed to open DM channel.")
if __name__ == "__main__":
main()