pybot-f/pybot-f.py
2022-05-26 16:26:08 +02:00

51 lines
1.3 KiB
Python

# pybot-f by freakyy85 (freaky@freakyonline.de)
import os
import configparser
import discord
from discord.ext import commands
description = '''Testing this bot stuff :)'''
intents = discord.Intents.default()
intents.members = True
intents.message_content = True
# Config loading
config = configparser.ConfigParser()
config.read('bot.ini')
bottoken = config['General']['bottoken']
bot = commands.Bot(command_prefix='?', description=description, intents=intents)
@bot.event
async def on_ready():
print(f'Logged in as {bot.user} (ID: {bot.user.id})')
print('------')
@bot.command()
async def repeat(ctx, times: int, content='repeating...'):
"""Repeats a message multiple times."""
for i in range(times):
await ctx.send(content)
@bot.command()
async def joined(ctx, member: discord.Member):
"""Says when a member joined."""
await ctx.send(f'{member.name} joined {discord.utils.format_dt(member.joined_at)}')
with os.scandir('./ext/') as dirs:
for entry in dirs:
if entry.name.endswith('.py'):
try:
print(entry.name)
await bot.load_extension('ext.' + entry.name)
except Exception as error:
print(f'Error loading {entry.name}: {error}')
bot.load_extension('ext/test.py')
bot.run(bottoken)