#discord-bots

1 messages · Page 413 of 1

fast osprey
#

That's your first problem

wheat summit
#

It just won't run the other lines.

wheat summit
fast osprey
#

Your priority should be fixing your error handling otherwise you're just guessing

wheat summit
#

Got it.

wheat summit
#

The same exact thing that you said.

#

No attributes to send_message.

fast osprey
#

If you want to send messages after the initial response, you should use interaction.followup.send(...)

wheat summit
wheat summit
fast osprey
#

You would need to make them user install

wheat summit
neon veldt
#

I have a few Questions ❓
Is it possible to connect a discord bot to a chrome extension ?

If so then would it be better to try and get AI to generate the code for me and I will in blanks or pay someone ?

If I were to pay someone make it for me do you have recommendations ?

jaunty cape
#

And I’m not even going to bother with the other questions

fast osprey
#

What does it even mean to "connect" a bot to an extension? What do either of these things do?

neon veldt
neon veldt
#

Or show what new mods come out for latest version of Minecraft

jaunty cape
#

I thought the discord bot would be embedded into the extension itself lmao

#

Well idk how to implement that so good luck

fast osprey
#

So what's the end goal? You have some bot monitoring something on discord and then putting it in your face via your browser?

neon veldt
neon veldt
fast osprey
#

Then where does discord play into this at all?

jaunty cape
neon veldt
#

The bot will store information in the correct channels

fast osprey
#

So this website, whatever it is, is the source of the information.

  • You can have a discord bot that monitors it, ideally using a RSS or pubsub feed or whatever, so long as it's within that site's TOS
  • You can have an extension that does the same in your browser
  • There's really no reason for these things to talk to each other
neon veldt
#

Idk, I got invested into making a discord bot that download stuff like videos and post information after doing some research I found out I can't just have bot do all that by itself,

fast osprey
#

You're being incredibly and suspiciously vague here

#

"download stuff"

neon veldt
#

My troubles is that I need to keep postnet note because I very forgetful

jaunty cape
#

😭 nah im playing

neon veldt
#

What's torrent client?

jaunty cape
#

Something that lets people share stuff online, anyway let’s get back on topic

fast osprey
#

This will be a lot more productive if you actually give specific examples. "When X happens on specific site Y, I want a bot to do Z"

neon veldt
#

Sounds like that thing that is virus but makes it looks it's a normal file

radiant shuttle
#

                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "C:\Users\pirat\Desktop\Roulette 1\python\.venv\Lib\site-packages\discord\app_commands\tree.py", line 1187, in _get_app_command_options
    raise CommandNotFound(name, parents)
discord.app_commands.errors.CommandNotFound: Application command 'help' not found
[2025-07-23 22:18:53] [WARNING ] discord.http: We are being rate limited. GET https://discord.com/api/v10/channels/1395556685644562512/messages responded with 429. Retrying in 0.78 seconds.
[2025-07-23 22:18:54] [ERROR   ] discord.client: Ignoring exception in on_ready
Traceback (most recent call last):
  File "C:\Users\pirat\Desktop\Roulette 1\python\.venv\Lib\site-packages\discord\client.py", line 481, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\pirat\Desktop\Roulette 1\python\cogs\admin\admin.py", line 954, in on_ready
    await self.post_panel(channel)
  File "C:\Users\pirat\Desktop\Roulette 1\python\cogs\admin\admin.py", line 805, in post_panel
    await self._update_status_panels(channel)
  File "C:\Users\pirat\Desktop\Roulette 1\python\cogs\admin\admin.py", line 783, in _update_status_panels
    msg = await find_embed_message(channel, panel_title)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\pirat\Desktop\Roulette 1\python\cogs\admin\admin.py", line 61, in find_embed_message
    async for msg in channel.history(limit=200):
    ...<5 lines>...
            return msg
  File "C:\Users\pirat\Desktop\Roulette 1\python\.venv\Lib\site-packages\discord\abc.py", line 1890, in history
    data, state, limit = await strategy(retrieve, state, limit)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\pirat\Desktop\Roulette 1\python\.venv\Lib\site-packages\discord\abc.py", line 1832, in _before_strategy
    data = await self._state.http.logs_from(channel.id, retrieve, before=before_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^```
jaunty cape
radiant shuttle
#

i changed a /command and its never dissaprearing its there for ever

neon veldt
#

I want bot to download videos, models assets, news article, Minecraft mods

fast osprey
#

From where

neon veldt
#

Form selected websites

fast osprey
#

Then select them and tell us what they are

#

you being vague about it isn't a good look

jaunty cape
#

Man we know it’s selected 😭 you don’t need to restate that it’s selected

neon veldt
#

Hang a minute I need to find them

fast osprey
#

To save you trouble, a vast majority of established sites specifically have clauses in their TOS to prevent you from doing what you described unless they have a published API/feed

stone frigate
#

wait

neon veldt
#

News article: IGN, Crunchyroll, the guardian.

Models assets: open3Dlab, renderhub, VRmodel.store.

Videos: from the mentioned news articles, YouTube, tiktok, and other social medias.

Mods: nexus

#

Sorry if I been to vague, I don't mean to be, let me know if you want to me to try again

jaunty cape
#

It’s ok bro I get it

#

I like to watch anime illegally too

fast osprey
#

IGN (Ziff Davis) Terms of use:

(ii) use any robot, spider, site search and/or retrieval application, or other device to crawl, scrape, database scrape, screen scrape, harvest, gather, extract, retrieve or index any portion of the Services,

#

Crunchyroll Terms of use:

Attempt to access, search or meta-search the Site with any engine, software, tool, agent, device or mechanism other than software and/or search agents provided by Crunchyroll or other generally available third party web browsers (such as Microsoft Internet Explorer, Mozilla Firefox, Safari or Opera)

#

Guardian terms of use:

Other than as expressly set out in these terms and conditions, or otherwise approved in writing by the Guardian, you shall also not use, or facilitate, authorise or permit the use of, any (i) “robot”, “bot”, “spider”, “scraper”, “crawler” or (ii) other automated device, program, technique, tool, process, algorithm or method (whether for data gathering, mining, collection, reading, scraping, extraction or other purposes), in each case, on or in relation to the Guardian Site and/or the Guardian Content.

#

Hopefully you see the pattern here

neon veldt
#

Even just to gather for information on the latest news they provide ?

fast osprey
#

If they don't make an exception for your use case, which they don't, then it's against their TOS

#

The guardian though, for example, has an RSS feed

#

not all sites will

neon veldt
fast osprey
#

This isn't about tricking them

#

this is about you using a bot to violate TOS, which is against this server's rules to help you with

neon veldt
#

Well I just wasted a punch of paper

fast osprey
#

iirc there are some decent RSS bots, and you're welcome to make your own within the terms

neon veldt
#

If you didn't know or couldn't tell, I'm autistic, dyslexic, with short term/ repetitive memory.

#

If that helps to understand why I'm a bit clumsy and vague when I was trying to ask for help

fast osprey
#

You're good, it's just useful to read the terms of systems you're using (or ask for advice)

neon veldt
fast osprey
#

There isn't a reasonable interpretation of what you told me that would be within their TOS

#

unless you contacted each of these companies and got an exemption

neon veldt
#

Well that's a bummer, it would mean I have to it all manually and here I was thinking I could automate things to free up my time

neon veldt
fast osprey
#

If it's purely for your personal and only personal use, they might make exceptions

#

Crunchyroll also has an RSS feed apparently, worth looking into how those work

#

IGN too

neon veldt
#

I will write that down on my important notes

fast osprey
#

RSS is really common, there are loads of extensions and bots to subscribe to them

neon veldt
remote kayak
#

Hey anyone have any idea why my commands won't work? I've tried resetting stuff, kicking it only to reinvite, changed the symbol, changed the name, looked at hierarchy, and changed the token. Any ideas?

ivory turret
#

dm me we can fix on call !

remote kayak
burnt quiver
#

just send it here, no need to call...

remote kayak
#

class MyMenuView(discord.ui.View):
def init(self):
super().init()
# Define your select menu options
options = [
discord.SelectOption(label="Option 1", description="Description for Option 1"),
discord.SelectOption(label="Option 2", description="Description for Option 2"),
discord.SelectOption(label="Option 3", description="Description for Option 3"),
]
self.add_item(discord.ui.Select(placeholder="Choose an option...", options=options, custom_id="my_select_menu"))

@discord.ui.select(custom_id="my_select_menu")
async def select_callback(self, interaction: discord.Interaction, select: discord.ui.Select):
        # This function is called when a user selects an option
    selected_value = select.values[0]
    await interaction.response.send_message(f"You selected: {selected_value}", ephemeral=True)

@bot.command()
async def showmenu(ctx):
await ctx.send("Here's your menu:", view=MyMenuView())

#

That didn't work the way I thought, but I'm not sure what's wrong with it

burnt quiver
#

any errors?

remote kayak
#

nope. Runs fine just doesn't work when I type the command in discord

burnt quiver
#

oh nvm lol

#

Wait what lib are you using?

remote kayak
#

Not sure what lib stands for. I'm still new to this so I'm kind of building as I learn sort of thing

#

Been messing with the auto fill thing

burnt quiver
#

library?

remote kayak
#

I'm using PyCharm if that's a library. I also use Visual Studio for my other things

burnt quiver
remote kayak
burnt quiver
#

okay then I don't believe @discord.ui.select(custom_id="my_select_menu") is a valid decorator, where did you get this from?

#

if you're thinking about discord.ui.button decorator, then sadly it won't work the same

remote kayak
#

I was. Should I take it out or replace it

burnt quiver
#

yes remove it

#

then in your

async def select_callback(self, interaction: discord.Interaction, select: discord.ui.Select):
```You don't need the the `select` parameter and rename the function to `callback`
remote kayak
#

okay now its throwing errors at me

burnt quiver
#

feel free to send it here

remote kayak
#

This way you can see the errors

burnt quiver
#

erm

#

remove the select parameter and rename the function to callback

#

y'know what are parameters and functions right?

remote kayak
#

yes

burnt quiver
#

oke then just do that and it should work

remote kayak
#

more errors. Did I miss a parameter?

burnt quiver
#

yeah no you're changing the parameter, not function

#

a function is def function_name a parameter is def function(parameter1, parameter2)

remote kayak
#

AHHHHHH I was mixing them up

#

Should I change the add_item function as well? Or does the self portion not count as a function?

burnt quiver
#

add_item is a function yes, why?

remote kayak
#

cause it's throwing an error

burnt quiver
#

that's just your syntax

#

you need to remove that extra bracket

remote kayak
#

I did that. Now it runs, no errors, but still isn't working in my server I have my bot in. I try my command and nothing pops up

fringe pier
#

What's your logging like? Maybe get it to send a message in a specific channel when it comes online so you know it's working properly

If it's not responding it could be it's not getting the commands

remote kayak
#

I don't remember how to do that and I seem to be missing my notes for how to show if the bot is online in the channel

fringe pier
#

Do you have logs set up?

remote kayak
#

yes

slate swan
#

Hello

tender bobcat
unkempt canyonBOT
#

@discord.ui.select(*, cls=discord.ui.select.Select[typing.Any], options=..., channel_types=..., placeholder=None, custom_id=..., min_values=1, max_values=1, disabled=False, default_values=..., row=None)```
A decorator that attaches a select menu to a component.

The function being decorated should have three parameters, `self` representing the [`discord.ui.View`](https://discordpy.readthedocs.io/en/stable/interactions/api.html#discord.ui.View), the [`discord.Interaction`](https://discordpy.readthedocs.io/en/stable/interactions/api.html#discord.Interaction) you receive and the chosen select class.

To obtain the selected values inside the callback, you can use the `values` attribute of the chosen class in the callback. The list of values will depend on the type of select menu used. View the table below for more information.
tender bobcat
#

Basically, the decorator create a new select menu, and you need to put the options, placeholder etc. there
Also I am not sure how well custom id would work there

#

So therefore if you don't have any reason to have a custom id, you should remove it

fast osprey
#

You really only need to declare custom id if you're doing persistence (so that the persistence tier can pick up later interactions)

#

otherwise the library generates a random one and then assigns it on the handling object too

tender bobcat
mental hollow
#
import tracemalloc
tracemalloc.start()

import discord
import traceback
import os
import asyncio
import aiohttp

from dotenv import load_dotenv
from discord.ext import commands
from utils import checks
from utils import constants as c
from discord import Webhook
from utils.mongo import init_db

load_dotenv()

class Bot(commands.Bot):
    def __init__(self):
        
        super().__init__(
            intents = discord.Intents.all(),
            case_insensitive = True,
            strip_after_prefix = True,
            help_command = None,
            command_prefix = '!'
        )
        self.persistent_views_added = False
        
    async def setup_hook(self):
        for filename in os.listdir('./cogs'):
            if filename.endswith('.py'):
                await self.load_extension(f'cogs.{filename[:-3]}')
                print(f"Loaded cogs.{filename[:-3]}")
        await init_db()
    
    async def on_ready(self):
        print(f"{self.user.name} is online - all services available.")
        
    async def on_command_error(self, ctx, error):
        if isinstance(error, commands.CommandNotFound):
            return
        elif isinstance(error, commands.NotOwner):
            return
        else:
            raise error
         
    async def on_application_command_error(self, ctx, error):
        if isinstance(error, discord.errors.CheckFailure):
            return
        else:
            raise error
          
    async def on_message(self, message: discord.Message):
        try:
            if message.author == self.user:
                return
            await self.process_commands(message)
        except Exception as e:
            print(f'Error in on_message: {e}')
        
        
if __name__ == "__main__":
    bot = Bot()
    bot.run(os.getenv('TOKEN'))```

my setup hook isn’t being called? im not getting any errors but im not getting my print either - im only getting 1 print from on_ready
tender bobcat
#

What's the folder structure

fast osprey
#

Also consider using pkgutil to discover modules rather than looping over the file system yourself. This is going to be really brittle depending on what your cwd is

potent light
# mental hollow ```py import tracemalloc tracemalloc.start() import discord import traceback im...

No, your setup_hook() is called but either one of the conditions isn't getting fulfilled:

  • os.listdir('./cogs') is empty.
  • or if filename.endswith('.py'): is None.

Try to debug it this way:

    async def setup_hook(self):
        print("Loading setup hook")
        for filename in os.listdir('./cogs'):
            print(filename)
            if filename.endswith('.py'):
                print("loading", filename)
                await self.load_extension(f'cogs.{filename[:-3]}')
                print(f"Loaded cogs.{filename[:-3]}")
        await init_db()
timber dragon
#

Or it's not called because they aren't using discord.py

mental hollow
#

whoops

#

thanks everyone though!

tender bobcat
#

I hate py-cord so much on their design choice of using the discord name...

fast osprey
#

afaik that decision was made at a time when it was believed discord.py was permanently discontinued, so it was meant to be a drop in replacement

vagrant depot
#

Anyone knows how i can make a reload command for my bot without pulling it offline that can free resources and displays "an under maintenance message" when its being done

woeful hill
#

why you need to take it down for updating tho

#

cant you just keep it on and either make the changes on 2 different instances

#

or from one using a test guild

#

or use another bot for dev

vagrant depot
#

Its just that i have seen other bot owners do it. Just curious how to pull it off

fast osprey
#

Python natively lets you reload modules with importlib

woeful hill
#

i dont see other bots do the "maintenance" part, i see them reload the extensions to apply changes

tender bobcat
#

Those messages are more likely for database migration

#

Than changing the bot code

vagrant depot
vagrant depot
tender bobcat
#

Basically they update the database schema for some change so they need to migrate all the database data to the new schema

#

They might take some time and you don't want any other operation on the bot at the same time

vagrant depot
woeful hill
#

in case it slows down
because of mem leak or something like that? then you should find the cause and fix it

fast osprey
#

When you say reload "everything", what is this "everything"

vagrant depot
fast osprey
#

Why do you think reloading a library will free resources?

#

What resources?

vagrant depot
#

yeah i have no idea what i am doing

#

mb bro

fast osprey
#

You're good. It just helps to dig into the motivation behind questions

woeful hill
#

if you want to "free your resources" whatever just restart the bot

fast osprey
#

Any meaningful conversation starts with actually having a tangible resource constraint, then running a profiler to find the specific thing that is consuming those resources

vagrant depot
fast osprey
#

That's good, start in steps. My big recommendation here is to solve problems you actually hit, not ones that you think you might. Preemptive optimization is a massive time sink especially for the inexperienced.

Also if "tuts" means unofficial YouTube "tutorials", all of those are garbage

vagrant depot
fast osprey
#

Learn to become comfortable with the docs rather than relying on some random youtuber in their basement to do it for you (they do it horribly wrong)

vagrant depot
#

I see. So its just break it and make it for now

fast osprey
#

Reading docs and translating that into code is probably the most important skill in development imo

stark ingot
vagrant depot
#

also what do i use to save user data? I looked up and postgresSQL seemed like a good option since ik basic SQL and queries.

#

dunno abt mongodb honestly

woeful hill
#

mongo is pretty bad

#

sqlite or postgres would be my recommendations

neat copper
#

oh yeah

vagrant depot
fast osprey
#

It's worth understanding what relational and nonrelational data means when making that decision, but there's like a 90% chance your data is relational

white citrus
#

Hey guys, my bot is not answering anymore.

#

The application is not responding

stark ingot
#

Is your code running? You are going to have to give a bit more information if you want help.

fast osprey
#

||Well you better go catch it||

white citrus
timber dragon
#

||Ask it why it's running and what it needs||

white citrus
#

I tried to go back too a commit that worked, but the application is still not responding

fast osprey
#

Code?

white citrus
fast osprey
#

all of it ideally

white citrus
#

Whe should start with the main file ig

potent light
# white citrus Whe should start with the main file ig

Best way to fix it is to try to debug it by adding print("something") to the main functions that should run. For example one in your on_ready()to make sure the bot is running. Then pick a command that you're testing, then add another print on its first line to see if the bot is actually running it. You should also try the events like on_message() if they are running. Then there are two possibilities:

  • if you see the prints, it means the bot runs perfectly but there are issues with the commands or likely with your intents that you have to enable on the developer portal but that's an issue that you should see on your cmd/log.
  • if you don't see the prints, then that means whatever function that didn't run the print wasn't ran by the bot. In this case there are a few possibilities why it's doing this.
white citrus
fringe pier
#

It's better to write your logs to a file especially for something like a bot you might not want to be staring at.

Open a file in append mode and write to it whenever something notable happens making sure to include the current time. There are libraries that offer better functionality but that would be enough at first

potent light
fast osprey
#

There's a lot to cover in this code. A good bit of things that are not good practice or will straight up break. But the main one is that you're overridding on_message, which you really should not ever do unless there are specifically cases where you don't want commands to be processed Strike that, it is a listener. Nothing I can see in here would intercept commands, but that's not to say nothing else anwywhere in your code wouldn't

fast osprey
#

You're not running the bot you think you are, you're sending messages somewhere the bot can't see, or there's something in the rest of your code interfering

white citrus
#

Before the commit all was working, but i rolled back and it is still not working

fast osprey
#

Putting a log in on_message would be a good first start

white citrus
#

I can let you look at the repo if u want.

white citrus
fast osprey
#

Just a print

#

Put a basic print, send your command and see if your bot sees it at all

white citrus
#

In the on message listener?

fast osprey
#

Yup that's a good first debugging step

#

Right at the top

white citrus
#

Thats strange

fast osprey
#

Then either you're running a different bot or you are sending messages somewhere the bot can't see

white citrus
#

The bot as all perms on the server. And i am running only 1 bot

#

I also reseted the token

fast osprey
#

What exactly does "all perms" mean

white citrus
#

Administrator

fast osprey
#

You absolutely shouldn't be doing that

white citrus
#

And i send the commands in a public channel

#

It is a testbot

#

It worked perfectly before

fast osprey
#

Why would you test something you don't want to do

#

Either way, this probably means you aren't running the bot you think you are

white citrus
#

But how? The console is giving me the bot back that i am running

fast osprey
#

The console doesnt give anything by default, that's your code

#

Also I have no idea about nextcord or if their syntax is supposed to be this

#

But you should ensure you're doing a message listener properly

white citrus
fast osprey
#

So now the possibilities are that you aren't actually getting message events at all, or that you've registered a listener incorrectly

#

Can you show your listener code now? After this change

white citrus
fast osprey
#

!paste

unkempt canyonBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

fast osprey
#

Can you change the bot.listen to bot.event to see if your print triggers?

fast osprey
#

Are any of your other events or listeners triggering?

white citrus
#

Yeah

fast osprey
#

At this point I'm inclined to guess it's a quirk of nextcord

#

Might want to ask them for help

timber dragon
#

Does the bot even run?

fast osprey
white citrus
shrewd pasture
#

is there a way to detect when players get your servers guild tag and when they remove it?

timber dragon
#

Not sure

#

Try checking the primary_guild field in the on_user_update

white citrus
white citrus
fast osprey
#

I guess just wait or review the rest of your code to see if anything would remove or otherwise interfere with that listener

#

You can also use get_channel and pass in the channel id to triple check if your bot has the permissions you think it does on the channel you're sending messages to

white citrus
#

@brazen raft i am here

brazen raft
#

Where are your slash commands defined

#

Let's check one

white citrus
fast osprey
#

Wait when did slash commands have anything to do with this

white citrus
fast osprey
#

What is your initial problem? What are you doing, very specifically, and what are you seeing

white citrus
fast osprey
#

What are you doing

#

specifically

white citrus
#

What do you mean?

fast osprey
#

Like what are the buttons you are pushing

#

"Command" is ambiguous here

white citrus
#

/ping for example

white citrus
fast osprey
#

When you type that, do you see the popup with that command?

white citrus
#

The application is not responding

fast osprey
#

Show the code for that command

white citrus
# fast osprey Show the code for that command
    #Ping_Command (V5.1)
    @nextcord.slash_command(name="ping", description="Checks for a response from the bot",
                            description_localizations={Locale.de: "Prüft auf eine Antwort vom Bot", Locale.en_US: "Checks for a response from the bot"})

    async def ping(self, interaction: Interaction):
        latency = int(round(interaction.client.latency * 1000))
        p = ""
        c = ""
        if latency < 150:
            p = self.trans["commands"]["ping"]["p"]["e"][interaction.locale]
            c = config.green

        elif 150 <= latency <= 300:
            p = self.trans["commands"]["ping"]["p"]["g"][interaction.locale]
            c = config.yellow

        elif latency > 300:
            p = self.trans["commands"]["ping"]["p"]["u"][interaction.locale]
            c = config.red

        information_icon_png = File("pictures/information-icon.png", filename="information-icon.png")
        information_icon_url = "attachment://information-icon.png"

        r = Embed(title=self.trans["commands"]["ping"]["r"]["title"][interaction.locale], description=f"**{p}**:  {latency}ms", colour=c)
        r.set_thumbnail(url=information_icon_url)
        await interaction.response.send_message(embed=r, file=information_icon_png, ephemeral=True)```
fast osprey
#

Put a print at the top of this method and see if you get that

white citrus
#

Thats wierd

fast osprey
#

Then you have an error in here you're swallowing

#

Check or remove your error handling

white citrus
fast osprey
#

I would recommend removing it, or stepping through it and ensuring there aren't any paths that errors could be swallowed

#

Bad error handling is way worse than no error handling

potent light
# white citrus ```py #Ping_Command (V5.1) @nextcord.slash_command(name="ping", descript...

information_icon_png = File("pictures/information-icon.png", filename="information-icon.png") may be taking too long to load and that will cause the bot to not respond.

Try to use await interaction.response.defer(ephemeral=True) at the start of your code then replace await interaction.response.send_message(embed=r, file=information_icon_png, ephemeral=True) with await interaction.followup.send(embed=r, file=information_icon_png)

woeful hill
#

Instantiate an object aint really take that long

fast osprey
#

We won't know if it's a timeout or something else until they fix their error logging

hardy reef
#

How hard is it to get approved for message content priv

fast osprey
#

5

stark ingot
#

Its not really a difficulty thing. If you have a valid use case according to discord -> you get approved. If your usecase is invalid according to discord -> you get denied

hardy reef
#

I just wasn’t sure if they were super strict or whatever. Believe mine is a valid use case

fast osprey
#

There are exceedingly few valid use cases that are deemed novel enough

quick gust
hardy reef
#

I know there is already a bot for this but I wanted to make one where someone can go ! With a command and they store the information to the command

#

Would that be something that discord normally approves?

stark ingot
#

Do you mean a message content based command? (aka prefix command) Discord explicitly says those are not a valid use case for the message content intent

hardy reef
#

Yeah that type of thing

#

Is there documentation on valid use cases?

fast osprey
#

Things that you can't functionally accomplish without message content. They're not going to enumerate all use cases

stark ingot
hardy reef
#

Got it ty guys

white summit
fast osprey
#

It's discoverable afaik, you can go to it from the tag

fast osprey
#

odd. It's linked on the home page of the docs though

white summit
timber dragon
#

But weird that it isn't showing the button to join it via the tag though

white summit
neon veldt
#

Is there a way for a bot to know if I already posted the same blender model in a channel ?

#

.
Example :
If I mode a post with my blender model download
It not let me repost the same model unless changes were made.

abstract beacon
quick gust
#

yeah, the one you see 5 messages up

abstract beacon
#

ty

fast osprey
#

You need to fix your error handling and get the actual error before trying random things and hoping it'll fix it

stark ingot
potent light
fast osprey
#

Because your error handler is bad

#

Like I said, you either need to exhaustively go through it and ensure you receive errors in all cases, or get rid of it

white citrus
fast osprey
#

Huh

white citrus
#

so that a file is not included in the commit

fast osprey
#

Just don't stage it for commit?

drifting spade
fast osprey
# drifting spade <https://github.com/youkononame/ekonn> this might be a lot to ask but if anyone ...

Don't have time for a full code review of everything, but can stream of consciousness bullet point out some things.

  • Don't do anything in on_ready. It doesn't work like you think it does. especially don't sync in it, syncing is highly rate limited and should be done only when you have decided specifically that you want to. Briefly looking through you have at least one on_ready listener that also does this.
  • Don't ask for default intents. You don't need all of them, I guarantee it. You should review the intents and pick out the ones you do need.
  • Use pkgutil to find python modules rather than looping over the filesystem yourself. It will be a lot more condensed and robust.
  • You can use GroupCog to simplify cogs that only contain a single group rather than needing to declare the Group manually inside of the cog
  • SimplePageSource.format_page doesn't need to be async, there's nothing async in it.
  • You don't need to defer -> immediately edit_original_response. You can save a call by just responding with edit_message. ex line 50 of pagination.py
  • I'm unsure why some of your cogs have staticmethods seemingly randomly? You can use bot.get_cog to get the instance of that cog.
drifting spade
#

thx for the advice <3

drifting spade
fast osprey
#

Depends when you want that thing to happen

#

if you just want it to happen once at startup, you can create an asyncio task during startup

#

(that task can use await bot.wait_until_ready() if it relies on a discord connection or populated cache)

#

Things that you want to happen during startup can be put in your bot's setup_hook, which is automatically called for you once (between login and connect)

drifting spade
#

okie :D

white citrus
#

@fast osprey i got it

fast osprey
#

what did it wind up being?

#

Did you ever get any errrors

white citrus
#

and ping dependency

hollow kraken
#

is there an abstractive way to deal with emojis with discord py?

#

i want to deal with unicode emojis and user-made emojis in the same way

white citrus
#

@fast osprey did you know anything about autocomplete

fast osprey
#

I use it in a few places yeah

fast osprey
white citrus
fast osprey
#

What is your latest error

white citrus
#
Ignoring exception in on_interaction
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.10/site-packages/nextcord/client.py", line 504, in _run_event
    await coro(*args, **kwargs)
  File "/home/container/.local/lib/python3.10/site-packages/nextcord/client.py", line 2087, in on_interaction
    await self.process_application_commands(interaction)
  File "/home/container/.local/lib/python3.10/site-packages/nextcord/client.py", line 2176, in process_application_commands
    await app_cmd.call_autocomplete_from_interaction(interaction)  # type: ignore
  File "/home/container/.local/lib/python3.10/site-packages/nextcord/application_command.py", line 1131, in call_autocomplete_from_interaction
    await self.call_autocomplete(self._state, interaction)
  File "/home/container/.local/lib/python3.10/site-packages/nextcord/application_command.py", line 1153, in call_autocomplete
    await self.children[option_data[0]["name"]].call_autocomplete(
  File "/home/container/.local/lib/python3.10/site-packages/nextcord/application_command.py", line 1200, in call_autocomplete
    value = await focused_option.invoke_autocomplete_callback(
  File "/home/container/.local/lib/python3.10/site-packages/nextcord/application_command.py", line 1099, in invoke_autocomplete_callback
    return await self.autocomplete_callback(
  File "/home/container/modules/voice/cog.py", line 117, in radio_autocomplete_handler
    await inter.response.send_autocomplete(choices)
  File "/home/container/.local/lib/python3.10/site-packages/nextcord/interactions.py", line 738, in send_autocomplete
    choice_list = [{"name": choice, "value": choice} for choice in choices]
TypeError: 'NoneType' object is not iterable```
timber dragon
#

Arent you supposed to return anything from the autocomplete function

timber dragon
#

So do that

#

You don't return anything from your radio_autocomplete function

fast osprey
#

yeah you just set a local variable and that's it

drifting spade
#

chat any discord bot ideas youd enjoy using? im looking for some fun simple pet projects, id host it so youd acc be able to use it

white citrus
fast osprey
#

well, return x = ... isn't valid syntax

#

just return [...] is fine

stark ingot
celest pelican
hushed ridge
#

oh my bad wrong channel

#

Sorry

white citrus
fast osprey
#

You probably have blocking code then

white citrus
#

either a 404 or a timeout error occurs

white citrus
fast osprey
#

Do you have much experience with asyncio or async programming generally?

whole shoal
whole shoal
# white citrus Wjat do ypu mean with blocking code

In Asyncio all the coroutines (the async functions) run in an event loop. These coroutines can be paused and can resume execution again. This is what allows concurrency. If you run something like time.sleep(4) within the functions, this is considered blocking code, that means the entire event loop will freeze for 4 seconds. So basically you cannot use standard blocking code like time.sleep requests.get etc in your functions. If there exists blocking code then you need to use asyncio.to_thread

fast osprey
#

ideally you would use natively asyncio friendly versions wherever possible and lean on to_thread as a last resort

#

(also to_thread won't help with cpu bound operations)

whole shoal
#

Yea it's best to offload cpu bound tasks such as image processing on a different python process altogether

frosty glen
#

Anyone know any free good discord bot hosts

#

that will keep my discord bot on 24/7

#

without me having to interact or anything

fast osprey
#

Who is going to pay their money to run your stuff for you for free

#

!hosting

unkempt canyonBOT
#
Discord Bot Hosting

Using free hosting options like repl.it for continuous 24/7 bot hosting is strongly discouraged.
Instead, opt for a virtual private server (VPS) or use your own spare hardware if you'd rather not pay for hosting.

See our Discord Bot Hosting Guide on our website that compares many hosting providers, both free and paid.

You may also use #965291480992321536 to discuss different discord bot hosting options.

sick birch
frosty glen
#

ig lol

sick birch
#

see the embed above. there are some options

frosty glen
#

alr thanks

sick birch
#

you can also search up "free discord bot hosts" on google but most of them are bad. but you pay for what you get

fast osprey
#

If you can't identify the product being sold, you are the product being sold. These aren't charities

frosty glen
sick birch
#

well, that's just how it be

fast osprey
#

It's very basic economics if you stop to think about it.

If there existed a free product that people could use to make money off of indefinitely, why wouldn't they. And how would that product sustain itself if nobody was ever forced to pay for it.

frosty glen
#

discloud is good but thing is that u gotta say .rw everydsy

#

everyday*

sick birch
#

never heard of it

fast osprey
#

I have plenty of times and none of it good

sick birch
#

sounds about right

distant willow
#

Hi everyone,

I'm looking for a Python module (or library) that can query multiple types of game servers — ideally something that supports most popular games like:

  • FiveM (GTA V)
  • DayZ (Steam Query)
  • MTA:SA (Multi Theft Auto)
  • Minecraft (Java/Bedrock)
  • ARK, Rust, CS:GO, etc.
stark ingot
#

You will probably need to find a separate library for each game. Also it depends on what you mean by query. If it is simple enough you might just be able to use requests. Although you should probably ask in a non discord bot channel

white citrus
white citrus
fast osprey
#

I would recommend starting there and learning asyncio more deeply

#

you should be able to describe what blocking code is and identify it in what you write

whole shoal
fast osprey
#

Defering doesn't help at all if the defer itself takes 3 seconds due to blocking code elsewhere

whole shoal
#

Just defer at the top of every command

fast osprey
#

no

#

that is not a good idea

whole shoal
#

Why not

#

(as long as the command logic doesn't crash)

#

I mean not literally every single command but the command where you expect the no found error

fast osprey
#

That error should not be expected, it's indicative of a problem somewhere else in this case

#

defer should only be used if you reasonably believe it will take 3+ seconds of processing on that interaction. It shouldn't be a reaction to time being wasted where you don't know why or where it's being wasted

young dagger
#

Will Discord handle this by retrying to give the role?

white citrus
tender bobcat
white citrus
#

@fast osprey is it possible that I should use aiomysql instead of mysql?

tender bobcat
white citrus
jaunty cape
tender bobcat
#

!pypi aiomysql

unkempt canyonBOT
tender bobcat
#

Fair

jaunty cape
#

Apparently asyncmy exists

#

!pypi asyncmy

unkempt canyonBOT
stark ingot
#

but mysql will work differently then sqlite

white citrus
white citrus
jaunty cape
#

That’s gotta cause some kind of dependency hell

white citrus
#

And i have knowlage of aiomysql. I dont know anything about asyncmy

jaunty cape
white citrus
stark ingot
#

Last release is only 2 years ago, that is not even that old, if it works there is no reason to change

white citrus
#
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.10/site-packages/nextcord/application_command.py", line 955, in invoke_callback_with_hooks
    await self(interaction, *args, **kwargs)
  File "/home/container/modules/voice/cog.py", line 102, in voice_radio
    voice_client = await voice_channel.connect()
  File "/home/container/.local/lib/python3.10/site-packages/nextcord/abc.py", line 1830, in connect
    await voice.connect(timeout=timeout, reconnect=reconnect)
  File "/home/container/.local/lib/python3.10/site-packages/nextcord/voice_client.py", line 362, in connect
    await utils.sane_wait_for(futures, timeout=timeout)
  File "/home/container/.local/lib/python3.10/site-packages/nextcord/utils.py", line 570, in sane_wait_for
    raise asyncio.TimeoutError
asyncio.exceptions.TimeoutError

I just got an error that i triggered like 10 minutes ago

#

So it is caused do the blocking code right?

#

but I've never had the problem

#

Since 2 years and now puff

stark ingot
#

That might be due to the issue where the port for voice connections is ignored by discord.py and anything that reused some of discord.pys code. I would ask nextcord if they have a fix released for that.

white citrus
stark ingot
#

then it is probably the blocking database calls

white citrus
stark ingot
#

Nothing in that file seems to be async

white citrus
#

So thats the blocking code?

stark ingot
#

Any request to the database, so pretty much every function in that file. I am not super good at async stuff tho so I cant explain it anymore

jaunty cape
white citrus
#

Bit i had a other db before that could not handle aiomysql

jaunty cape
#

Yo why is your naming so inconsistent in the modules directory lol

jaunty cape
queen pond
#

gei guys, im currently self-studying ML and wanna get into it deeper i just started recently. But to making koney with ML in any way is hard so it will take years before i can even start. I already know python so is learning to make discord bots a good idea to make some level of income(300-500 bucks) while not being fully invested in it?

fast osprey
#

Absolutely not

#

This is such a saturated market where like 99% of the user base refuses to pay anything

jaunty cape
#

Fr!

queen pond
fast osprey
#

If you want to make money? Go on a freelancing site, see what people are hiring for. Probably mostly web dev id imagine

whole shoal
whole shoal
jaunty cape
frail quail
#

hi everyone

hushed ridge
#

Does discord.py is not used anymore and changed to Py-Cord?

celest pelican
#

No, discord.py is still the most popular framework AFAIK.

hushed ridge
#

Or do I have to learn Py-Cord too?

celest pelican
hushed ridge
celest pelican
fast osprey
#

It's very subjective

#

They are all more similar than they are different though unless you choose hikari

hushed ridge
fast osprey
#

It's another discord library that was made with very different design principles

celest pelican
hushed ridge
celest pelican
#

Python Discord is this server. discord.py is a Python library.

hushed ridge
#

oh nvm

#

I misread

hushed ridge
#

As I saw some videos on it and it seems easy

fast osprey
#

Those videos are all horrible

#

The people who know what they're doing contribute to the library documentation, they don't make videos

hushed ridge
fast osprey
#

Up to you what you do but these videos aren't reviewed and say objectively wrong things. Id suggest getting comfortable with reading because that's where the actually correct info is

woeful hill
#

reading is required for any dev works

#

if you just watch videos without reading into any of the documentations, its just copying and not learning

#

if you encounter any other problem that has no video that has code inside youll just get stuck

stark ingot
#

You should be using tutorials specifically recommended by the library you choose. The top 10 "python discord bot tutorial" by SEO are all outdated, bad, or both

wise mica
fast osprey
#

No they really shouldn't. These people aren't being paid

#

they're not going to waste their time producing in a medium that takes more time to produce and more time to edit when a perfectly capable medium already exists (documentation). They shouldn't cater to people with bad attention spans

wise mica
#

It's something in demand that people are currently using inferior substitutes for. If correcting that is a waste of time then that's certainly a perspective to have

#

Though I can sympathise with not wanting to make explanation for idiots videos for free

fast osprey
#

People can demand things all they want, that doesn't mean it's a good idea especially if they're not willing to pay for it

whole shoal
#

You can use that or the other library recommended by a user above

white citrus
fast osprey
#

I would personally recommend spending the time migrating off of mysql entirely, it's pretty shit

whole shoal
#

It's the exact same syntax (mostly) and a little better performance so go ahead

fast osprey
#

Haven't used maria personally, I mostly use postgres or sqlite but #databases talk I suppose

fast osprey
#

For?

white citrus
#

The mirhration from pymysql

fast osprey
#

Well you'd have to pick a db to migrate to, which is largely dependent on your personal needs

white citrus
#

aiomysql or asyncmy

fast osprey
#

I don't have opinions on any mysql libraries because I don't use mysql

#

well, not in a while after I had firsthand experience with its issues

whole shoal
#

You can go with asyncmy for maximum performance, but if you are super familiar with pymysql (eg it's errors) then go with aiomysql since it's built on top of pymysql

whole shoal
fast osprey
#

not full syntax support, multiple vulnerabilities. Would eventually run into scaling issues

young dagger
tender bobcat
#

Btw the fact that it error means it doesn't take care for you

white citrus
#

@fast osprey @whole shoal i changed it to the asyncmy but still no responding

fast osprey
#

Use asyncio debug mode to determine what exactly is blocking

white citrus
#
    @test_c.subcommand(name="send_a")
    async def send_a(self, inter: Interaction):
        await inter.response.send_message("A")
        ```

the application is still here not responding
#

it is an easy command

fast osprey
#

are you getting an error?

white citrus
fast osprey
#

That's your first issue

white citrus
fast osprey
#

Did you put any debugging in? Are you getting into that function at all?

white citrus
fast osprey
#

If you put a print at the start of that command and you don't get it, there's something else wrong

white citrus
#

Oh wait

#

I got prints, like 20s after the command

fast osprey
#

Then asyncio debug mode

fast osprey
white citrus
ocean bridge
#

How do I make a bot?

fast osprey
#

pick a library, follow that library's getting started guide

ocean bridge
#

I just found out bot ghost is getting shutdown

fast osprey
#

Think it already happened

ocean bridge
#

Oh

#

Is thare another website that will make a bot?

fast osprey
#

Unlikely

ocean bridge
#

Oh

fast osprey
#

they shut it down for exactly that reason

white citrus
fast osprey
#

You should be getting asyncio debug information about a method blocking for too long. How are you enabling debug mode?

fast osprey
#

No like what method are you using to enable debug mode

jaunty cape
#

It locks basic features behind a paywall

ocean bridge
jaunty cape
#

Your own programming skills, duhhh

ocean bridge
#

.

jaunty cape
#

What else do you use?

ocean bridge
#

I'm asking for help Bc idk how to........

jaunty cape
#

You don’t put “discord bot dev” in your bio and then be completely unable to write one yourself

fast osprey
#

No need to berate them.

fast osprey
topaz stratus
#

they obviously cannot use programming skills, botghost is for users who don't know how to program

topaz stratus
#

well, there isn't an alternative; botghost was like squarespace of discord bots lmao

#

since you're not going to bother coding--just like the last person i interacted with who also used botghost--you'll have to use a combination of AI (chatgpt, gemini, claude etc), some Python knowledge, and a free hosting service for a discord bot

#

coding would be the best method; you're probably not doing anything complex with the bot
learning the basics of python and slapping the bot on a free host recommend using orcale cloud free tier is all it takes

woeful hill
#

there should be a specific use case that existing bots cant do that you would want one

#

if you want something you will try to make it
if you dont bother making it you dont really want it

whole shoal
topaz stratus
#

well yeah

white citrus
hushed ridge
#

Anyone knows a good source to learn from?

deft osprey
hushed ridge
#

If someone is explaining will be better but send the pdf

fast osprey
#

It completely depends on what skills you're coming in with

floral bobcat
#
  • most bots are pretty basic and dont have insane amounts of features like bleedbot
hushed ridge
floral bobcat
fast osprey
#

There are no good videos on this topic. This isn't a visual concept

hushed ridge
deft osprey
hushed ridge
deft osprey
hushed ridge
deft osprey
#

Can't send pdf in this server

hushed ridge
#

Send it in my dms

deft osprey
#

Yah I'll send

slate swan
#

Hello

#

Anyone interested in creating discord bots programming team?

white citrus
fast osprey
#

Your error handling here is pretty rudimentary. You won't get any output in some cases

white citrus
fast osprey
#

You're passing None into fetch message, but you really should never need to fetch messages especially if it's one your bot sent

white citrus
#

so whats the fix

fast osprey
#

Why are you trying to fetch a message in the first place?

white citrus
#

to edit it

fast osprey
#

You don't need to fetch a message to edit it

white citrus
#

okay so just get_message

fast osprey
#

That's not a method either. But either way, the value you're passing into it is None which is going to be a problem

white citrus
fast osprey
#

that's not what your error says

#

!d discord.TextChannel.get_partial_message

unkempt canyonBOT
#

get_partial_message(message_id, /)```
Creates a [`PartialMessage`](https://discordpy.readthedocs.io/en/stable/api.html#discord.PartialMessage) from the message ID.

This is useful if you want to work with a message and only have its ID without doing an unnecessary API call.

New in version 1.6...
fast osprey
#

you can use this with a channel + message id to get a partial message (which you can edit) without needing to do a full message fetch

white citrus
# fast osprey you can use this with a channel + message id to get a partial message (which you...

still

ERROR:root:Unexpected error processing giveaway 13910610: 400 Bad Request (error code: 50035): Invalid Form Body
In message_id: Value "None" is not snowflake.
Traceback (most recent call last):
  File "c:\Users\domin\Downloads\Antonio-2\bot.py", line 473, in check_giveaway_ending
    await message.edit(embed=embed, view=None)
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\message.py", line 2072, in edit
    data = await self._state.http.edit_message(self.channel.id, self.id, **fields)
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\http.py", line 370, in request
    raise HTTPException(response, data)
nextcord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In message_id: Value "None" is not snowflake.
fast osprey
#

code now?

white citrus
fast osprey
#

is it possible you're exceeding the character limit? Also what is printing out the whole "Value None is not a snowflake"? That appears entirely disconnected from the error

fast osprey
#

there's a limit to how long messages can be

#

you will get that 400 error if you try to send a message longer than that

fast osprey
#

You're sending a message, yes? That message has content

#

do you know how long that content is?

white citrus
#

It worked before i added the New db and the error handler for it

fast osprey
#

that wasn't my question thonk

white citrus
#

i aksed chatgpt and he says this

✅ Solution:
Replace:

message = channel.get_partial_message(message_id)```
With:

```py
message = await channel.fetch_message(message_id)```
This properly fetches the full message object from Discord, including its ID and content, so you can safely edit it.
fast osprey
#

chatgpt is stupid and this is factually wrong

white citrus
#

Okay

fast osprey
#

yeah just used get_partial_message to edit a message and no problems at all

#

what's the length of prize?

white citrus
#

(datetime.datetime(2025, 7, 30, 16, 4, 11), 1400131879524503553, 900100165397008465, 1398399119453851828, 84390392, 'Test1', None, 1)

quick gust
#

That looks like the entire row

white citrus
#

Prize is test 1

#

Wait

fast osprey
#

how about winner_mentions

white citrus
#

I had previously stored time as bigint and now as timestamp Maybe it is because of this change

fast osprey
#

how would that impact the embed you're trying to send?

white citrus
fast osprey
#

Don't see anything in the code you sent that sets timestamps on the embed

white citrus
#

Ohh see

#

But what can it be

#

I have no clue

fast osprey
#

You are crafting a message that discord is saying is badly formatted. I'm about fairly certain it's a problem with that embed specifically

white citrus
#

giveaway_end_time 2025-07-30 14:04:11+00:00
message_id 1400131879524503553
guild_id 900100165397008465
giveaway_id 84390392
channel_id 1398399119453851828
prize Test1
participants_data None
finished 1```
fast osprey
#

that's not what I asked thonk

white citrus
#

oh winners mention is not in there

fast osprey
#

what is "there"?

white citrus
#
winner_mentions = ', '.join(f"<@{winner_id.strip()}>" for winner_id in selected_winners)```
jaunty cape
#

Why do you have a random for each loop that just does nothing

fast osprey
#

If it works, then it proves that the embed you're trying to edit in is what's causing the problem

jaunty cape
#

What are you stripping here

jaunty cape
#

You can’t strip an integer

left geyser
#

I am French and on Visual Code Studio I cannot install Selenium in my terminal. Could someone translate everything into French in a private message please?

white citrus
# fast osprey Try this. On this specific line, `473` , change `embed=embed` to `content="a"`
ERROR:root:Unexpected error processing giveaway 33514827: 400 Bad Request (error code: 50035): Invalid Form Body
In message_id: Value "None" is not snowflake.
Traceback (most recent call last):
  File "c:\Users\domin\Downloads\Antonio-2\bot.py", line 472, in check_giveaway_ending
    await message.edit(content="a", view=None)
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\message.py", line 2072, in edit
    data = await self._state.http.edit_message(self.channel.id, self.id, **fields)
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\http.py", line 370, in request
    raise HTTPException(response, data)
nextcord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In message_id: Value "None" is not snowflake.```
fast osprey
#

And you are positive that message_id isn't none

fast osprey
#

No, not in your db. In this variable at the time you're calling get_partial_message

white citrus
#

print(message_id)
message = channel.get_partial_message(message_id)```
fast osprey
#

I get that exact same error when I pass None into get_partial_message

white citrus
#

but i printed it for you

fast osprey
#

I don't think you're running the same code path you think you are

slate swan
#

@fast osprey can i start earning anything with python i learaned alr all basics

white citrus
#

but he will end this giveaway to early

fast osprey
#

I am fairly certain you have some edge case where you're pulling in a None message_id. Not all the time, but some fringe condition

white citrus
fast osprey
#

You're probably running into race conditions yes

white citrus
#
        await inter.client.db.insert_giveaway(giveaway_id, dt_end, self.prize.value, self.channel.id, inter.guild.id, None, self.winners.value, self.requirement, value_str)
        
        if str(self.requirement).lower() == "role":
            mention_text = f"<@&{self.value}>"
        elif str(self.requirement).lower() == "user":
            if isinstance(self.value, list):
                mention_text = ", ".join([f"<@{u}>" for u in self.value])
            else:
                mention_text = f"<@{self.value}>"
        else:
            mention_text = "Alle"
            
        giveaway_embed = Embed(title=f"{config.giveaway} {self.prize.value} {config.giveaway}", description=f"Endet am <t:{int(epochEnd)}:f> oder <t:{int(epochEnd)}:R>", colour=config.green)
        giveaway_embed.add_field(name=f"Gewinner: {self.winners.value}", value="Drücke den Button um teilzunehmen!\n\uFEFF")
        giveaway_embed.add_field(name="Teilnahmebrechtigt:", value=f"{mention_text}\n\uFEFF", inline=False)        
        giveaway_embed.add_field(name="Anzahl der Teilnhemer:", value="0\n\uFEFF", inline=False)
        giveaway_embed.set_footer(text=f"Verlosungs-ID: {giveaway_id}")
        giveaway_embed.set_author(name=f"{inter.user.name} hat eine Verlosung gestartet")
        giveaway_started = Embed(title=f"{config.giveaway} Verlosung gestartet! {config.giveaway}", description=f"Verlosung wurde in {self.channel.mention} gestartet")
        
        await inter.response.send_message(embed=giveaway_started, ephemeral=True)
        view = join_giveawy_de(inter.guild.id, giveaway_id)
        msg = await self.channel.send(embed=giveaway_embed, view=view)
        view.message = msg  
        
        embed_data = msg.embeds[0].to_dict()  # Convert the Embed object to a dictionary
        embed_json_string = json.dumps(embed_data) # Convert the dictionary to a JSON string

        await inter.client.db.update_giveaway(msg.id, inter.guild.id, giveaway_id)```
#

mayby that was the case

fast osprey
#

You're inserting a record for a giveaway and then updating the message id later?

hushed ridge
#
intents = discord.Intents.default()

token = token()
client = discord.Client(intents=intents)
client.run(token)```
Is this code still used? the `client.run()` and is it professional to use it with intents?
burnt quiver
jaunty cape
hushed ridge
#

From token.txt file

#

Also which is better run the function or a variable has the function?

fast osprey
#

Worth considering what intents you actually need rather than just grabbing all the defaults

hushed ridge
fast osprey
#

That's still asking for defaults you don't need

hushed ridge
#

Isn't default() line for discord.py intents must be typed?

fast osprey
#

It's not

#

You can, and should, pick the intents you actually need

hushed ridge
#

I set it to default cuz I am still new to the field

hushed ridge
#
import discord

def my_token():
    with open("token.txt", "r") as f:
        return f.read().strip()

intents = discord.Intents.default()
intents.message_content = True
intents.guilds = True
intents.members = True

token = my_token()
client = discord.Client(intents=intents)

CH_ID = 1400396865647677471

@client.event
async def on_message(message):
    if "users" in message.content and message.guild.id == CH_ID:
        if message.guild:
            await message.channel.send(f"Number Of Users In The Server Is {message.guild.member_count}")


client.run(token)```
Could someone tell how to fix this code here? I want to display members count in the server in a specific channel called `commands` with the `CH_ID`
jaunty cape
hushed ridge
jaunty cape
#

Ok whatever, what errors are you getting, if any?

#

Can you try typing any message with the content “users” in that channel?

fast osprey
#

Does the bot have read message perms on that channel?

hushed ridge
hushed ridge
#

And the bot has Administrator

fast osprey
#

Your bot should never have administrator

hushed ridge
#

Why?

fast osprey
#

Because it doesn't need it

hushed ridge
#

Maybe if I add ban mute etc

fast osprey
#

Then you can add the specific permissions it does need

hushed ridge
#

Like I don't want to select all the perms

#

Just 1 perm can do all

fast osprey
#

It doesn't need all perms

hushed ridge
#

Btw is there a way to fix my code?

jaunty cape
#

Do you have privileged message intents enabled on your developer portal

fast osprey
#

If they didn't, there would be an error on login

young dagger
quick gust
#

it could very well not be a channel ID

#

but it doesn't make sense to check if message.guild is None or not after doing id on it

young dagger
quick gust
#

Ah I missed that

young dagger
#

If you want to compare the channel with the CH_ID, yes

fast osprey
#

Channels and guilds are different things, yes

hushed ridge
#

IT WORKS

young dagger
#

Congrats

hushed ridge
#

I am dumb ;-;

#

Btw I didn't know that guild means server xd

young dagger
#

Don't be too hard to yourself

hushed ridge
#

or 3

#

oh

#

ok

quick gust
#

if you've changed message.guild.id to message.channel.id then you don't need to check if the message was in a guild or not

but if you wanna compare guild IDs you need to check if the message was in a guild or not BEFORE you actually compare the IDs

young dagger
#

@hushed ridge Use this instead

if message.guild and "users" in message.content and message.channel.id == CH_ID:
hushed ridge
#

Alright

#

Btw I changed to client = commands.Bot(command_prefix="!", case_insensitive=True, intents=intents) cuz the one I was using was old version

fast osprey
#

I wouldn't recommend naming a variable client when it stores a completely different type

young dagger
#

!d discord.ext.commands.guild_only

unkempt canyonBOT
#

@discord.ext.commands.guild_only()```
A [`check()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.check) that indicates this command must only be used in a guild context only. Basically, no private messages are allowed when using the command.

This check raises a special exception, [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.NoPrivateMessage) that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.CheckFailure).

If used on hybrid commands, this will be equivalent to the [`discord.app_commands.guild_only()`](https://discordpy.readthedocs.io/en/stable/interactions/api.html#discord.app_commands.guild_only) decorator. In an unsupported context, such as a subcommand, this will still fallback to applying the check.
hushed ridge
fast osprey
#

There is not a single good video on YouTube. They're all bad

shut stirrup
#

Or frequently used important commands

fast osprey
#

People who actually know what they're doing contribute to the official documentation, not slap together a video for internet points

timber dragon
#

-# so glad that YouTube is getting restricted to 18+ soon /s

hushed ridge
fast osprey
#

And what experience are you drawing on to make that assessment?

hushed ridge
fast osprey
#

If they don't even know how to name variables I don't have much faith in the rest of their practices

hushed ridge
#

huh

timber dragon
#

YouTube is only going to teach you the bad practices...

young dagger
fast osprey
#

client = SomethingThatIsNotAClient is classic textbook someone copy pasting stuff they don't understand

hushed ridge
#

I want to understand how to code a discord bot then read advanced things

#

I want the basics

fast osprey
#

The documentation is the basics

hushed ridge
#

But not a good choice for beginners

fast osprey
#

No it's a fantastic choice for beginners

#

Because this other thing is lying to you

woeful hill
#

youre watching how to slap random things in python and make it works, not how to code a discord bot

hushed ridge
#

Some experts here told me not to start with docs

fast osprey
#

Experts, or people who just told you what you wanted to hear

timber dragon
#

Oh man

hushed ridge
woeful hill
#

there are code examples on the official repo btw

hushed ridge
young dagger
#

The docs are always a good source, even if they're boring sometimes

hushed ridge
timber dragon
fast osprey
#

You're talking to at least two people right now who are contributors to the library you're using, and you're calling these other random people "experts" because they're giving you snake oil

woeful hill
hushed ridge
#

I only watch YouTube to see what's this function or what's this word and what does it do

#

Like that not the code to copy paste

young dagger
fast osprey
#

"And I will call this variable 'client' because the other youtuber im copy pasting from called it that too" 10/10 tutorial

woeful hill
#

luckily, we have many resources to learn python

#

!res

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

hushed ridge
#

I don't call it client I will name it something else

#

But yeah I am learning

fast osprey
#

You are learning from the wrong place

timber dragon
#

I doubt the video is explaining what each thing is or even telling you the actual definition

hushed ridge
fast osprey
#

But if you want to ignore people who clearly know what they're talking about just to do it easier, that's your prerogative

hushed ridge
#

not only client

fast osprey
woeful hill
#

you can name it whatever you want but i name this wrongly

definitely a good tutorial

hushed ridge
#

My main goal is to know the definition of words and fn

#

I hate reading btw

#

That's why I don't start with docs

#

I know I have to read docs

woeful hill
#

sadly reading will be half your work

hushed ridge
#

Once I finish basics I will Inshallah

hushed ridge
#

I will hate the field

fast osprey
#

"I want to be a doctor, but I hate humans"

hushed ridge
fast osprey
#

If you want to grow and build stable, extensible things you will need to become comfortable reading. I'm sorry that tiktok fried your generation but this is the truth. You need to work on your attention span or you're going to be recycling garbage

hushed ridge
#

Tiktok?

#

fuk tiktok

hushed ridge
fast osprey
#

Insert your short form media of choice

#

I didn't say you said that

timber dragon
#

You don't have to read the whole docs, that's dumb… you usually read the "getting started" part and then go from there to the parts you want to use in your code. Or search for it.

Reading the docs from the top isn't going to help with anything.

hushed ridge
#

ok

slate swan
#

Anyone interested in developing team?

fast osprey
#

What's the team mascot?

hushed ridge
#

@client.command()
async def clear(ctx, amount=5):
    await ctx.channel.purge(limit=amount+1)```
Why here when I do !clear if there're 3 reply messages it clears 1 and clear the rest of the normal messages?
fast osprey
#

Could you rephrase?

#

What is the behavior you're expecting

hushed ridge
fast osprey
#

What do you mean by "reply messages"?

hushed ridge
fast osprey
#

Purge would not delete messages any differently

hushed ridge
#

I typed !ping then the bot .reply() me

#

Lemme screenshot

hushed ridge
#

Red messages are the cleared

#

Why it didn't remove the Pong! 178ms

#

And also it doesn't remove old messages

fast osprey
#

Probably getting rate limited on those

#

!d discord.TextChannel.purge

unkempt canyonBOT
#

await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=None, bulk=True, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.

You must have [`manage_messages`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.manage_messages) to delete messages even if they are your own. Having [`read_message_history`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.read_message_history) is also needed to retrieve message history...
fast osprey
#

And from your screenshot this is probably a race condition on your client

#

Not a bug in purge

hushed ridge
#

Wdym?

woeful hill
#

looked like you were spamming the commands so the message the bot reply is technically before your last command but the discord app chose to display your message first

hushed ridge
#

oh

#

it's like a visual message?

fast osprey
#

The order you see your messages on your client is not necessarily the order they are stored on discord

hushed ridge
fast osprey
#

What is "them"?

#

The parameters?

timber dragon
#

ctrl r to reload your client, send the commands with a slight delay, and then run the clear command again

#

Also client mods are against the ToS

hushed ridge
fast osprey
#

A parameter with = ... means it's optional, just like you declaring a parameter yourself in your own function

slate swan
#

PYTHON

#

In future, c++, js, java, ts

timber dragon
#

so what's the mascot

stark ingot
jaunty cape
fast osprey
#

"myth"

hushed ridge
#
@client.command()
async def ban(ctx, member: discord.Member, time: int, unit: str = "s", *, reason=None):
    if unit.lower() == "s":
        seconds = time
    elif unit.lower() == "m":
        seconds = time * 60
    elif unit.lower() == "h":
        seconds = time * 3600
    elif unit.lower() == "d":
        seconds = time * 3600 * 24
    else:
        await ctx.reply("Please choose a valid unit 's,m,h,d'")
        return
    await member.ban(reason=reason)
    await ctx.reply(f"User {member.id} Has Been Banned For {time} {unit}! \nReason: {reason if reason else 'No Reason Provided.'}")
    await ay.sleep(seconds)
    await ctx.guild.unban(member,reason="Ban Expired")
    await ctx.send(f"{member.id} Has Been Unbanned After {time} {unit}!")```
Can you guys rate my ban code and tell me what to add or remove?
#

ay.sleep() I imported import asyncio as ay

fast osprey
#
  • What is the purpose of banning someone temporarily? Are they necessarily going to reform themselves in that time? Why not just time them out, which is already built in and far less disruptive?
  • What happens if your bot restarts during that interval?
hushed ridge
fast osprey
#

Why not just ban them then

#

do you think they're going to stop threatening people after x seconds

tulip relic
#

Tbh its kinda useless

hushed ridge
#

Temp ban adds weight It sends a stronger message sometimes the person cools off and apologizes after a day or two it's also useful for staff to take time before making a permanent decision

fast osprey
#

then you can unban them if they cool off

#

rather than assuming they will after an arbitrary period of time

tulip relic
#

it would ruin the fear of getting banned, wouldnt it

fast osprey
#

If someone is so problematic that it's a risk to let them simply exist in the server (not being able to talk), then I don't see why that would change in a short period of time

hushed ridge
#

But they can send messages to members in the server

fast osprey
#

which isn't your problem

#

you can't moderate what people do in dms, you can't even see it

hushed ridge
fast osprey
#

cogs have nothing to do with files. Cogs are classes

hushed ridge
#

I mean which one do I use?

fast osprey
#

which one of what?

hushed ridge
#

Cogs or single files

fast osprey
#

again, cogs have nothing to do with files

hushed ridge
#

Like this

hushed ridge
fast osprey
#

Whoever told you that is wrong and misled

hushed ridge
#

No one told me that

fast osprey
#

so you made it up from your brain, you conjured the term "cog"

tulip relic
#

😭

tulip relic
hushed ridge
fast osprey
#

Cogs are, again, classes. A file can have 0, 1, 2, 500 classes. Cogs have nothing to do whatsoever with your file structure

tulip relic
fast osprey
#

You can split up your bot between files if and when it is valuable to do so. There is not a hard and fast rule, but newbies tend to heavily skew towards doing this when they have no reason to

hushed ridge
tulip relic
#

"beginner"

fast osprey
#

"long" files are not inherently bad. Poorly organized ones are

hushed ridge
fast osprey
#

Making a separate file per command is egregiously bad

hushed ridge
#

BRO

#

Just tell me the good way??

tulip relic
hushed ridge
fast osprey
#

No, I was looking it up chill

#

I don't owe you shit

tulip relic
#

i vouch

#

@fast osprey I'm guessing you make dc bots?

fast osprey
fast osprey
#

Generally you want to group together definitions (classes, methods, constants) that share dependencies and are interdependent/reloadable together

wise mica
fast osprey
#

Might wanna review the #rules there

mental marten
#

im good g

potent fox
#

!warn 1392915121637953656 We don't allow advertising in our server or recruiting/hiring/asking for paid work. Please re-read our #rules

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied warning to @mental marten.

mental marten
#

shivering my fucking timbers

hushed ridge
#

I was learning about ChatGPT

#

Then I coded my first Linux Distro

#

openSUSE

drifting tangle
#

why is the emoji not popping up

#

ive tried :Checkmark:

#

as well with the numbers version

#

<:Checkmark|1400679741543022794>

slender kiln
#

i'm not suree sry i'm not great with discord/discord bots

gleaming inlet
drifting tangle
gleaming inlet
deft sundial
earnest mantle
#

hey

#

i need help

#

how did this bot get an invisible accent color that works on all appearance modes

deft sundial
deft sundial
# burnt quiver Nope, that’s components v2

you're right in some ways. according to the discord.py issue tracker, components v2 does have an "option to completely eliminate the side color bar of an embed." so even though the color field behavior for regular embeds is still there, components v2 lets you get rid of that colored sidebar completely. means the whole invisible/default color discussion would be pointless for those message types 🤷‍♂️

burnt quiver
#

Huh

#

What’s wrong about it being cv2

deft sundial
# burnt quiver What’s wrong about it being cv2

nothing's wrong with it being v2. just saying that v2 gives you the option to completely remove the colored sidebar that normal embeds have. so when you use that feature, there's no color bar to worry about at all lol

#

so ye that's still the default fallback color behavior same as it's always been. components v2 just gives you the option to remove the color bar entirely if you want. the "invisible" accent you're seeing isn't from v2, it's discord using the default embed color when no custom color is set

burnt quiver
burnt quiver
deft sundial
timber dragon
#

You indeed mixed up embeds with the new container component for some reason

last cradle
#

hi whats the cog version of this

#

i forgot pls

#

the client part

#

@self.tree.command?

burnt quiver
velvet rover
#

@bot.event
async def on_message(message):

logs_channel = bot.get_channel(1400865565580726376)

if message.author == bot.user:
return

if any(word in message.content.lower() for word in bad_words):
    await message.delete()
    msgkerby = await message.channel.send(f"{message.author.mention}:\n\tYour message was deleted for containing a blacklisted word!")
    await logs_channel.send(f"A message from {message.author.mention} in {message.channel.mention} was deleted for containing one or more blacklisted words.")
    embed = discord.Embed(title="Message Content:", description=message.content)
    await logs_channel.send(embed=embed)
    time.sleep(2)
    await msgkerby.delete()
await bot.process_commands(message)
#

I have this here code which is the code for my automod system.

#

(the bad words list is located elsewhere)

#

I tecgnically works a treat. I wish I could put everything in embeds, but I'm having trouble with mentions and stuff in embeds.

#

Anyway, I'm trying to figure out how to call out which specific words were blacklisted. Help would be very much appreciated.

#

Here's this in case it's easier to see it in colour.

fast osprey
#

Have you considered using the native automod for this?

velvet rover
#

Native automod?

fast osprey
#

Discord has automod built in

velvet rover
#

huh

#

Looking at that page, there is no such thing in my server settings.

#

But also, I think I'd prefere my own.

fast osprey
#

If you're on mobile I think it's only supported on desktop

#

And the code you've shown is just strictly less reliable and feature rich than the built in one

velvet rover
#

I'm on desktop

velvet rover
fast osprey
#

Works for me on latest official client. I'm always going to recommend using native stuff that works as it's just going to be more stable and reliable. You're not going to code better than the entire discord team

velvet rover
#

fair I suppose.

#

But I'm set in my ways XD

#

(And, again. It isn't showing up.)

#

Ah, there it is.

fast osprey
#

Worth playing around with. You could just change your any to a for loop, but there are some pretty substantial edge cases I can see already in your logic

velvet rover
#

hmm

#

okay

#

thanks.

fast osprey
#

prettythumbsup gl

velvet rover
#

👍

fast osprey
velvet rover
#

huh

#

I'll look into that.

#

(Only partly know what that means.)

#

Back to the topic of embeds, I now find myself with this problem.
I knew that it would be a little tricky, but I'm going to need it several other places in the bot so I'm going to have to figure it out anyway. This- technically works? Except- not at all.

#

oh actually

#

i think i have a really simple fix, even if it's temporary.

fast osprey
#

You can't mention in embeds (and cause a ping) afaik

#

And it won't render at all in titles iirc

velvet rover
#

You can mention from them, but yeah looks like you can't do it in the title.

#

thanks

#

Whuch really just means I'm using their username instead of display name, which is fine.

#

I'll probably build something that grabs the display name at some point.

fast osprey
#

It's just member.display_name

velvet rover
#

Oh I see what you mean.

#

It 'pings' them without actually pinging them.

fast osprey
#

Ya it suppresses the notification, only notifies of its in the content

velvet rover
#

even better actually.

velvet rover
fast osprey
#

If you don't want to notify, there's also the allowed_mentions param when sending a mention just for future reference

velvet rover
#

ok

topaz stratus
# velvet rover Here's this in case it's easier to see it in colour.

is there a reason why you put ur entire program to sleep for 2 seconds?
since discord bot code is async, do use async sleep function asyncio.sleep() --that way the entire program isn't put to bed

do note that censoring words is like a whack-a-mole, you can't handle every possible case

the reason you may not have access to discord auto-moderation features is because 1) the server isn't large enough to have access to the community server designation, 2) the community server designation has not been enabled by a staff member

topaz stratus
velvet rover
#

I- didn't think about the fact that I put the entire thing to sleep. Also didn't know that was a thing thanks.

I'm just censoring 2 to 3 single words. It's just f_ck, b_tch, and every couple weeks a random letter cause my mod team and members are ridiculous. I'm not really concerned with anyone getting around the automod.