Created
February 18, 2025 16:47
-
-
Save dellybot/42f98944ed7866c1d66d4366d16bf3da to your computer and use it in GitHub Desktop.
api-delpy-example.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import delpy | |
import logging | |
from discord.ext import commands, tasks | |
from logging.handlers import RotatingFileHandler | |
logger = logging.getLogger('del.py') | |
logger.setLevel(logging.DEBUG) | |
handler = RotatingFileHandler( | |
filename='path/to/prefered/log_dir/del.log', | |
encoding='utf-8', | |
mode='w', | |
maxBytes=10 * 1024 * 1024, # 10 MB | |
backupCount=5, | |
delay=0 | |
) | |
handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s')) | |
logger.addHandler(handler) | |
class discordextremelist(commands.Cog): | |
def __init__(self, bot): | |
self.bot = bot | |
self.update_stats.start() | |
# you can get the bot's token from your bot's page on DEL | |
self.delapi = delpy.Client(bot, "DELAPI_32chartoken-userid") | |
self.delapi.start_loop(wait_for=1800) # wait_for argument is optional and defaults at 1800. | |
def cog_unload(self): | |
self.delapi.close_loop() | |
def setup(bot): | |
bot.add_cog(discordextremelist(bot)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment