matter_melon2020

make a discord bot that when a person with permissions does /accept in someones forum it gives that owner of the forum the role id 1516099861169176576 and make it say succesfully accepted <owner of forum>

Kodari AI
KodariJun 18 at 4:45 pm 6
ForumAcceptBot
A Discord bot that adds a /accept slash command usable inside forum post channels. When a user with the Manage Roles permission runs /accept in a forum thread, the bot automatically assigns role ID 1516099861169176576 to the owner of that forum post and replies with a success message mentioning them. Built with discord.py using slash commands via app_commands.

Setup steps:

  1. Install dependencies:

    Shell
    pip install -r requirements.txt
    
  2. Add your token to .env:

    Plain Text
    DISCORD_TOKEN=your_actual_token_here
    
  3. Bot permissions required — make sure the bot has these in your server:

    • Manage Roles

    • Send Messages

    • Use Slash Commands

    • The bot’s role must be above role 1516099861169176576 in the role hierarchy

  4. Run:

    Shell
    python bot.py
    

How it works:

  • /accept only works inside forum post threads

  • The user running it needs Manage Roles permission

  • It fetches the forum post’s owner, assigns the role, and replies ✅ Successfully accepted @user!

  • All errors (wrong channel, missing role, no permission) are sent as ephemeral messages only visible to the caller

matter_melon2020

bot procces crashed my key is <redacted>

Kodari AI
KodariJun 18 at 5:06 pm 1

⚠️ Reset That Token Immediately

You just publicly shared your bot token. Anyone can now take full control of your bot. Reset it right now:

  1. Select your application → Bot tab

  2. Click “Reset Token” → confirm

  3. Copy the new token and put it in your .env file


As for the crash — share the error message/traceback from your terminal and I’ll fix it. The token itself doesn’t cause crashes; it’s likely a code or dependency issue.

matter_melon2020

reset the code and dont use emojis and put the token <redacted>

Kodari AI
KodariJun 18 at 5:07 pm 2

⚠️ That token is already compromised — it was posted publicly. Anyone could be using your bot right now. Reset it at discord.com/developers/applications before doing anything else, then use the new token below.

This token is burned. Reset it immediately, then replace the value in .env with your new token. To run:

Shell
pip install -r requirements.txt
python bot.py
matter_melon2020

i reset it and still crashes

Kodari AI
KodariJun 18 at 5:10 pm 1

Share the full error/traceback from your terminal and I’ll fix it.

matter_melon2020
📎 1 file 1,604 chars
📄
pasted-code-1781802656546.txt
txt 27 lines
▶

Loading bot files...
Creating a super duper secure sandbox...
Sandbox created, starting bot...
[2026-06-18 17:10:52] [INFO ] discord.client: logging in using static token
Traceback (most recent call last):
File "/root/bot.py", line 62, in 
bot.run(os.getenv("DISCORD_TOKEN"))
File "/usr/local/lib/python3.12/site-packages/discord/client.py", line 929, in run
asyncio.run(runner())
File "/usr/local/lib/python3.12/asyncio/runners.py", line 195, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 691, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/discord/client.py", line 918, in runner
await self.start(token, reconnect=reconnect)
File "/usr/local/lib/python3.12/site-packages/discord/client.py", line 847, in start
await self.connect(reconnect=reconnect)
File "/usr/local/lib/python3.12/site-packages/discord/client.py", line 771, in connect
raise PrivilegedIntentsRequired(exc.shard_id) from None
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.
Bot process crashed
Kodari AI
KodariJun 18 at 5:11 pm 2

The bot is requesting privileged intents that aren’t enabled. Fix is to only use the intents actually needed.

intents.members = True is a privileged intent. Since fetch_member is used as a fallback, members intent isn’t strictly required. Remove it:

That’s it. The bot only needs default intents — fetch_member will pull the forum owner from the API when needed. Run python bot.py again.

matter_melon2020

how do i use it without the .env but just the token working in the bot.py file

Kodari AI
KodariJun 18 at 5:23 pm 2

Replace YOUR_TOKEN_HERE with your actual token. You can also remove the from dotenv import load_dotenv and load_dotenv() lines at the top and delete the .env file entirely — they’re no longer needed.

matter_melon2020

add command /deny and it gives no role but just say Sorry <forum owner> you have been denied to the SMP

Kodari AI
KodariJun 20 at 9:14 am 7

/deny added. When used in a forum post it sends Sorry @user you have been denied to the SMP with no role changes. Same permission requirement as /accept — needs Manage Roles.

matter_melon2020

and make /sorry and it makes it say "sorry <forum owner> we are full at the moment maybe next Season!"

Kodari AI
KodariJun 20 at 9:15 am 3

/sorry added. When used in a forum post it sends Sorry @user we are full at the moment maybe next Season!. Same Manage Roles permission requirement as the other commands.

matter_melon2020

it doesnt start

Kodari AI
KodariJun 20 at 9:18 am 1

Share the full error traceback from your terminal.

Kodari can make mistakes. Review important code before using.
Files
bot.py
requirements.txt
Code
2 111
bot.py
import discord
from discord import app_commands
import os
from dotenv import load_dotenv

load_dotenv()

intents = discord.Intents.default()

class Bot(discord.Client):
    def __init__(self):
        super().__init__(intents=intents)
        self.tree = app_commands.CommandTree(self)

    async def setup_hook(self):
        await self.tree.sync()

bot = Bot()

ROLE_ID = 1516099861169176576

@bot.event
async def on_ready():
    print(f"Logged in as {bot.user} (ID: {bot.user.id})")

@bot.tree.command(name="accept", description="Accept a forum post owner and assign them a role.")
@app_commands.checks.has_permissions(manage_roles=True)
async def accept(interaction: discord.Interaction):
    channel = interaction.channel

    if not isinstance(channel, discord.Thread) or not isinstance(channel.parent, discord.ForumChannel):
        await interaction.response.send_message("This command can only be used inside a forum post.", ephemeral=True)
        return

    owner = channel.guild.get_member(channel.owner_id)
    if owner is None:
        try:
            owner = await channel.guild.fetch_member(channel.owner_id)
        except discord.NotFound:
            await interaction.response.send_message("Could not find the forum post owner.", ephemeral=True)
            return

    role = channel.guild.get_role(ROLE_ID)
    if role is None:
        await interaction.response.send_message("The configured role could not be found.", ephemeral=True)
        return

    try:
        await owner.add_roles(role)
    except discord.Forbidden:
        await interaction.response.send_message("I do not have permission to assign that role. Make sure my role is above it.", ephemeral=True)
        return

    await interaction.response.send_message(f"Successfully accepted {owner.mention}")

@accept.error
async def accept_error(interaction: discord.Interaction, error: app_commands.AppCommandError):
    if isinstance(error, app_commands.MissingPermissions):
        await interaction.response.send_message("You do not have permission to use this command.", ephemeral=True)

@bot.tree.command(name="deny", description="Deny a forum post owner from the SMP.")
@app_commands.checks.has_permissions(manage_roles=True)
async def deny(interaction: discord.Interaction):
    channel = interaction.channel

    if not isinstance(channel, discord.Thread) or not isinstance(channel.parent, discord.ForumChannel):
        await interaction.response.send_message("This command can only be used inside a forum post.", ephemeral=True)
        return

    owner = channel.guild.get_member(channel.owner_id)
    if owner is None:
        try:
            owner = await channel.guild.fetch_member(channel.owner_id)
        except discord.NotFound:
            await interaction.response.send_message("Could not find the forum post owner.", ephemeral=True)
            return

    await interaction.response.send_message(f"Sorry {owner.mention} you have been denied to the SMP")

@deny.error
async def deny_error(interaction: discord.Interaction, error: app_commands.AppCommandError):
    if isinstance(error, app_commands.MissingPermissions):
        await interaction.response.send_message("You do not have permission to use this command.", ephemeral=True)

@bot.tree.command(name="sorry", description="Let a forum post owner know the SMP is full.")
@app_commands.checks.has_permissions(manage_roles=True)
async def sorry(interaction: discord.Interaction):
    channel = interaction.channel

    if not isinstance(channel, discord.Thread) or not isinstance(channel.parent, discord.ForumChannel):
        await interaction.response.send_message("This command can only be used inside a forum post.", ephemeral=True)
        return

    owner = channel.guild.get_member(channel.owner_id)
    if owner is None:
        try:
            owner = await channel.guild.fetch_member(channel.owner_id)
        except discord.NotFound:
            await interaction.response.send_message("Could not find the forum post owner.", ephemeral=True)
            return

    await interaction.response.send_message(f"Sorry {owner.mention} we are full at the moment maybe next Season!")

@sorry.error
async def sorry_error(interaction: discord.Interaction, error: app_commands.AppCommandError):
    if isinstance(error, app_commands.MissingPermissions):
        await interaction.response.send_message("You do not have permission to use this command.", ephemeral=True)