Quote:
Originally Posted by NoblePopulaceOfficial
Hello developers,
My name is Noble and I am looking for an experienced developer to create a Discord bot that mashes bot the Carl bot and a ticket bot together. Please message me on discord for any that are interested but please have prior work ready and expect me to verify who you are. Thank you and I hope to work with one of you fine people!
|
Code:
import discord
from discord.ext import commands
from discord.ui import Button, View
TOKEN = "YOUR_BOT_TOKEN"
GUILD_ID = YOUR_GUILD_ID # Replace with your Discord server ID
intents = discord.Intents.default()
intents.messages = True
intents.guilds = True
intents.reactions = True
intents.members = True
intents.message_content = True
bot = commands.Bot(command_prefix="!", intents=intents)
ticket_category_id = YOUR_TICKET_CATEGORY_ID # Replace with your ticket category ID
# Reaction Role Command
[MENTION=352789]bot[/MENTION].command()
async def reactionrole(ctx, emoji, role: discord.Role):
embed = discord.Embed(title="Reaction Role", description=f"React with {emoji} to get {role.mention}", color=discord.Color.blue())
msg = await ctx.send(embed=embed)
await msg.add_reaction(emoji)
[MENTION=352789]bot[/MENTION].event
async def on_reaction_add(reaction, user):
if reaction.message.id == msg.id and not user.bot:
await user.add_roles(role)
[MENTION=352789]bot[/MENTION].event
async def on_reaction_remove(reaction, user):
if reaction.message.id == msg.id and not user.bot:
await user.remove_roles(role)
# Ticket System
class TicketView(View):
def __init__(self):
super().__init__()
self.add_item(TicketButton())
class TicketButton(Button):
def __init__(self):
super().__init__(label="Open Ticket", style=discord.ButtonStyle.green)
async def callback(self, interaction: discord.Interaction):
guild = bot.get_guild(GUILD_ID)
category = discord.utils.get(guild.categories, id=ticket_category_id)
overwrites = {
guild.default_role: discord.PermissionOverwrite(view_channel=False),
interaction.user: discord.PermissionOverwrite(view_channel=True, send_messages=True)
}
ticket_channel = await guild.create_text_channel(name=f"ticket-{interaction.user.name}", category=category, overwrites=overwrites)
await interaction.response.send_message(f"Ticket created: {ticket_channel.mention}", ephemeral=True)
await ticket_channel.send(f"{interaction.user.mention}, staff will assist you shortly.")
[MENTION=352789]bot[/MENTION].command()
async def ticket(ctx):
embed = discord.Embed(title="Support Tickets", description="Click below to open a ticket.", color=discord.Color.green())
await ctx.send(embed=embed, view=TicketView())
# Moderation Commands
[MENTION=352789]bot[/MENTION].command()
[MENTION=5292767]commands[/MENTION].has_permissions(kick_members=True)
async def kick(ctx, member: discord.Member, *, reason=None):
await member.kick(reason=reason)
await ctx.send(f"{member.mention} has been kicked.")
[MENTION=352789]bot[/MENTION].command()
[MENTION=5292767]commands[/MENTION].has_permissions(ban_members=True)
async def ban(ctx, member: discord.Member, *, reason=None):
await member.ban(reason=reason)
await ctx.send(f"{member.mention} has been banned.")
bot.run(TOKEN)