Files
bot.py
config.json
requirements.txt
Code
3 49
bot.py
import discord
from discord.ext import commands
import json
import os
from dotenv import load_dotenv
load_dotenv()
with open('config.json', 'r') as f:
config = json.load(f)
bot = commands.Bot(command_prefix=config['prefix'], intents=discord.Intents.all())
@bot.event
async def on_ready():
print(f'Bot is ready! Logged in as {bot.user}')
@bot.command()
async def vouch(ctx, member: discord.Member, *, reason):
if config['vouch_channel'] and ctx.channel.id != config['vouch_channel']:
await ctx.send(f'Vouches can only be sent in <#{config["vouch_channel"]}>')
return
if config['required_role'] and not any(role.id in config['required_role'] for role in ctx.author.roles):
await ctx.send('You do not have permission to vouch.')
return
embed = discord.Embed(
title=config['embed']['title'],
description=config['embed']['description'].format(user=member.mention, reason=reason),
color=config['embed']['color']
)
embed.set_footer(text=config['embed']['footer'])
channel = bot.get_channel(config['vouch_channel'])
await channel.send(embed=embed)
await ctx.send('Vouch submitted!')
bot.run(os.getenv('DISCORD_TOKEN'))