#discord-bots

1 messages Β· Page 406 of 1

pallid meadow
#

So as you can see

slate swan
#

basics to advanced logarithms and little bit geometry

pallid meadow
#

we are sleeping in 2 functions for 1 second

#

now let me show you the sync code that doesn't use async

slate swan
#

cool

pallid meadow
#

and you can see the difference in the total time

slate swan
#

if need i can learn async library i learnt some library already like request bs4 time, and little bit os

#

but if i don't need i don't want to learn it

pallid meadow
#

!e


import time

def say_hello():
    time.sleep(1)
    print("Hello")

def say_world():
    time.sleep(1)
    print("World")

def main():
    start = time.perf_counter()
    say_hello()
    say_world()
    stop = time.perf_counter()
    print(f"Total time: {stop - start:.2f} seconds")

main()
unkempt canyonBOT
pallid meadow
#

what's the difference here @slate swan ?

slate swan
#

it's without async library

pallid meadow
#

yes but what's the difference in the output

slate swan
#

total time 2 s

#

so asyncc is more faster funcs

pallid meadow
#

no not at all

slate swan
#

xd

slate swan
#

without dc library?

digital owl
#

No

#

How can u connect then?

#

Use async

slate swan
digital owl
#

It's best

slate swan
#

i said it

#

for theory

#

😭

#

you did not understand

#

i did not say "i don't need async i want to make dc using api)

pallid meadow
# slate swan so asyncc is more faster funcs

Not exactly. Async doesn’t make your functions faster. It just lets your program do more at the same time when it’s waiting on something so if you noticed we are using asyncio.sleep() which is asyncio version of the time.sleep() functions which allows for that first function to be called that sleep function is then called but since it's async your program keeps a tab there and moves on to the next thing which is the say_world() function.

#

so say_hello() is called it sees that there's the asyncio.sleep() and then moves on to the say_world() function it sees that there's another asyncio.sleep() so it's added to the queue

pallid meadow
#

when both of those sleeps expire

#

the print statement is executed

pallid meadow
pallid meadow
#

oh like can you create a bot without a discord library?

#

You can

slate swan
#

like is it against tos to make bot
gets your auth
connect to your dc acc
and responds random user in dm if you are afk instead of u
example: hi
my dc acc: hello, i am afk wait for me

#

it's interesting

pallid meadow
#

yes that's against tos because it's account automation

#

you would have to use a bot account for it to not be considered account automation

slate swan
#

i have seen same func on whatsapp and telegram

#

and it's usefull

pallid meadow
#

yes those use their api

slate swan
#

thanks, i understood:z

pallid meadow
#

discord doesn't like you using their api through regular user accounts

slate swan
#

they don't have any def against those bots

#

algorithm

#

so it's free to make but it's against tos

pallid meadow
#

there's just no reason on discord because you can do all of this with a bot account

#

like a bot is essentially just a discord user that you control with code

slate swan
#

ye

pallid meadow
#

that's grossly simplifying it but it's technically correct

slate swan
#

ik it's against tos but i want to make same bot so i need to learn first how normal bot works and dc library

#

it's usefull

#

you can run ur acc and reply every user who sends dm

#

if you are afk

pallid meadow
#

yeah but that's against tos?

#

I mean this is just going in circles now, yes it's possible no I don't condone doing it.

#

yes discord does ban for account automation

slate swan
#

then how

#

some user using this thing

#

and they are not gettings bans

pallid meadow
#

because if they see somoene making irregular reguests under a user account

#

it's gonna get flagged

digital owl
#

U can use the API key for the discord bot even I used it to make my bot responsive

slate swan
#

dc will not respond

#

if sometimes normal user is using his acc

digital owl
#

Like OpenAI key , openrouter

pallid meadow
#

Ok well we don't condone nor can we discuss that stuff here so please move on @slate swan

slate swan
#

ok

burnt quiver
#

uh

slate swan
blissful crane
#

lol

slate swan
#

anyone knows how can i display vs on my dc profikle

#

profile, i had it but it bugs sometimes

#

it removes from it automatically when i reset my vs

#

idk what does it means

#

nvm i did it

jaunty cape
#

Yeah you still got like 9 years before you can learn AI

burnt quiver
#

what kind of bot?

stark ingot
#

I’m ready to send you my bot token
Dont ever do this, your bot token is similar to a password, it should not be shared.
Also if you need help you should ask specific questions. This is not a place to try and find people to make code for you. It also sounds like a quite complex project.

burnt quiver
#

agreed

digital owl
upper gorge
#

how do I remove the gaps between these progress bar emojis

    def create_progress_bar(self, progress: float, next_rank: str) -> str:
        # Get the next rank's end emoji
        end_emoji = self.rank_data[next_rank]["bar_end"]
        filled_segments = int(progress // 25)
        
        # Build the bar parts - 4 segments total
        bar_parts = [
            self.bar_start if filled_segments >= 1 else self.empty_bar_start,  # Segment 1
            self.bar_middle if filled_segments >= 2 else self.empty_bar_middle,  # Segment 2
            self.bar_middle if filled_segments >= 3 else self.empty_bar_middle,  # Segment 3
            end_emoji  # Segment 4 (next rank's end emoji)
        ]
        
        return "".join(bar_parts) + f" {round(progress, 2)}%"
woeful hill
#

oh wait i am dumbn

#

can you show the bar_middle

#

your icons dont look like a square actually, it might be the problem there

upper gorge
#

oh wait could the size difference be causing this

upper gorge
woeful hill
#

Nah i was referencing my deleted question about the .join line

#

Obviously nothing wrong with that but my eyes are half open so i thought its your problem there

spring vine
#

Hello!
I've always coded bots in python (3.11) by putting the commands in the main.py file.

But as I keep adding commands, it gets complicated. I've tried to change my method by creating different files for each command, but nothing works...
I have a verification system that tells me when the file is loaded, but I also have another system that tells me all the synchronized commands.

# 🟒> LOAD
@bot.event
async def on_ready():
    print(f"{bot.user} is online!")

    # Sync
    synced = await bot.tree.sync()
    print(f"πŸ”— {len(synced)} cmd sync.")
    for cmd in synced:
        print(f"Cmd : /{cmd.name} | ID : {cmd.id}")

    # Load
    for file in os.listdir():
        if file.endswith(".py") and file not in ["main.py"]:
            try:
                await bot.load_extension(file[:-3])
                print(f"βœ… {file} load with succes!")
            except Exception as e:
                print(f"❌ Error in {file} : {e}")

This tells me that the file is loaded correctly, but it also tells me that 0 commands are not synchronized.

burnt quiver
#

breh

timber dragon
#

Think about it for a sec

burnt quiver
#

what the sheep is doing here

timber dragon
#

What is your code doing in order?

burnt quiver
#

seeing an on_ready event is like always a big red flag lol

finite salmon
timber dragon
burnt quiver
spring vine
finite salmon
burnt quiver
#

I didn't say sync on setup hook, I said load your cogs in setup hook

#

I would say commands

finite salmon
#

Oh

burnt quiver
#

all good lol

finite salmon
spring vine
#
import discord
from discord.ext import commands
import os
import json

# :low_brightness:> INTENTS
intents = discord.Intents.default()
intents.message_content = True
intents.guilds = True
intents.voice_states = True

bot = commands.Bot(command_prefix='$', intents=intents)

# 🟒> LOAD
@bot.event
async def on_ready():
    print(f"{bot.user} is online!")

    # Sync
    synced = await bot.tree.sync()
    print(f"πŸ”— {len(synced)} cmd sync.")
    for cmd in synced:
        print(f"Cmd : /{cmd.name} | ID : {cmd.id}")

    # Load
    for file in os.listdir():
        if file.endswith(".py") and file not in ["main.py"]:
            try:
                await bot.load_extension(file[:-3])
                print(f"βœ… {file} load with succes!")
            except Exception as e:
                print(f"❌ Error in {file} : {e}")

# :closed_lock_with_key:> TOKEN
with open("config.json", "r") as f:
    config = json.load(f)

bot.run(config["TOKEN"])
#

just that

spring vine
spring vine
timber dragon
#

Does that not make sense to you?

#

What you did:

  1. Sync commanda
  2. Load commands
spring vine
#

My mistake, and now that you mention it, it makes sense. But I confess I've never done this before, as I'm just starting to learn discord.py, so excuse me!

slate swan
#

Hey guys

#

Quick question, is it a problem if when I run a command, an error pops up in the console/output, but not in how the bot reacts/functions in the server? Is it okay if I just don't fix the error, will it have any consequences?

burnt quiver
slate swan
burnt quiver
#

Uh, there are probably some errors that dont (I'm not sure) but most of the time it can cause your bot to fail

#

so you should fix it or use try blocks

viscid hornet
#

!e With traceback:

def add_three(n):
    return n + 3

print(add_three("3"))
unkempt canyonBOT
viscid hornet
#

!e With no traceback:

def add_three(n):
    return n + 3

try:
    print(add_three("3"))
except Exception as e:
    print(f"Error: {e}")
unkempt canyonBOT
viscid hornet
#

see how the bottom says literally nothing about where the error is?

#

also guilds and voice_states are already enabled by .default()

outer violet
#

i'm having trouble figuring out how to fix my code. what's happening is when someone makes a new ticket and they try to close it, it doesn't close and shows this warning on my vps:

[WARNING] miru.client: Unknown component for interaction received for component: 'close_ticket_button'. Did you forget to start a view?
You can disable this warning by setting 'ignore_unknown_interactions' to True in the client constructor, or by setting an unhandled component interaction hook.

but when i restart the bot and try to close the same ticket, it closes the ticket. how do i fix this? it's supposed to close whenever someone presses it. here's a video for better understanding. i'm also using hikari-lightbulb and miru

here's the code: https://pastes.dev/y6jRL0N5b3

marsh lion
#

gotta get to those 50 messages so i can talk in vc

fast osprey
#

actual hikari user in the wilds

marsh lion
#

kdkdkdkdkekdjdkd

pearl pivot
#

Hi, real quick. I'm making a bot and I want to have it running on a server 24/7 without running it off my computer how do i do this and is it free?

brave niche
#

You'll need some 'hosting' for it, and it's usually not free, no. A bot is very small however so you can ideally find a solution on the cheap.

#

Like, Hetzner has a $4/month tier

pearl pivot
#

ah okay, thank you!

brave niche
#

There may be a place where you could pre-pay and get even less than that. Also Amazon AWS has a free usage tier that MIGHT be enough to get you rolling.

#

You get 750 hours of EC2 for free from Amazon

#

(per month)

young dagger
tender bobcat
sick birch
#

pretty much

brave niche
#

Yeah, I guess the idea is to be able to run a full-time 'micro' instance.

tender bobcat
#

How large is EC2 tbf

#

Oh well, very small

#

t2.micro / t3.micro
The only things that maybe better is the bandwidth compare to my raspberry pi

brave niche
#

Yeah, it's not really trying to compete with stuff like that.. but rather to get you familiar with their ecosystem so you'll use it at work

charred estuary
#

Excuse me, sir, may I ask if discord.py-self is still usable at this time?

#

I tried the latest version available on PyPI, but when I used the commands, nothing happened. I am puzzled because I have already followed the documentation.

wanton current
#

we dont help with self bots

charred estuary
finite salmon
#

e

timber dragon
#

a

glad cradle
#

b

shrewd apex
#

c

burnt quiver
#

what's after c?

#

ion know πŸ’”

timber dragon
burnt quiver
#

omg ty

burnt quiver
timber dragon
woeful hill
#

Isnt it C++ after C

burnt quiver
#

aww man

blissful crane
#

nah, holy c comes before c++

wanton current
#

Cβ™­

viscid hornet
ionic garnet
#

does anyone know how to make a bot super react to a message?

dapper ocean
#

not possible

ionic garnet
#

well its not a discord bot, but its a selfbot someone's using that super reacts to their messages

lapis ridge
#

Anyone up to teach me?

burnt quiver
#

if you have any questions, feel free to ask them

lapis ridge
#

I have done some coding before with a teacher.

#

But they left discord.

burnt quiver
#

I don't have the fulltime to teach someone, but I suggest reading the docs, joining d.py's support server

#

and of course ask questions

unkempt canyonBOT
#

5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.

lapis ridge
#

Not fulltime.

#

Just like an hour a day.

ionic garnet
timber dragon
# lapis ridge Just like an hour a day.

Here are some resources to learn python yourself:

https://docs.python.org/3/tutorial/ (official tutorial)
http://python.swaroopch.com/ (useful book)
https://automatetheboringstuff.com/ (for complete beginners to programming)
http://greenteapress.com/wp/think-python-2e/ (another decent book)
See also:
http://www.codeabbey.com/ (exercises for beginners)
https://realpython.com/ (good articles on specific topics)
https://learnxinyminutes.com/docs/python3/ (cheatsheet)

timber dragon
lapis ridge
#

So if I have any problems.

burnt quiver
#

do that

lapis ridge
#

Some people do.

#

My old teacher did.

timber dragon
#

That's something you get in school lol

burnt quiver
#

It's their free time, so just ask questions in support servers and they will answer when they can

timber dragon
#

You could look on fiverr or something

lapis ridge
#

As in a discord bot teacher.

lapis ridge
#

Kind people do it for free.

#

Mean people don't :<

timber dragon
#

Oh definitely not lmao

lapis ridge
#

my old teacher did it for free :<

timber dragon
#

Most don't gives their free time away like that

#

You got a lucky one then lol

lapis ridge
#

Can you just like show me you coding or something.

timber dragon
#

But it looks like they left discord when they realised /s

timber dragon
lapis ridge
timber dragon
timber dragon
burnt quiver
#

In short,

No one (most) people will not teach you one on one and you're gonna have to accept it

But what you can do is ask questions in support servers and people will answer when they can

lapis ridge
#

oh

#

:<

#

Can someone please just start me off?

#

anything, idrc

burnt quiver
lapis ridge
#

ok

burnt quiver
# lapis ridge How did you start coding?

I started through tutorials online, while I won't say they are all bad, but often times they are outdated/insufficient

And you end up doing things the way it was done when they are better ways

So, I strongly suggest the docs and asking questions

burnt quiver
#

i do not remember them

lapis ridge
#

oh

#

yt?~#

#

alr

#

well imma play some games

ionic garnet
burnt quiver
lapis ridge
#

i am using them

burnt quiver
#

Yt tuts are not recommended and outdated

woeful hill
#

i started of python with OOP and basic C++ knowledge, id say it is much easier

#

going from nothing to discord bot straight away will be hard

#

since discord.py is advance and require you to already know the basic of python and can debug some of the error yourself

tender bobcat
fast osprey
#

hikari is pretty niche tbh. You'll have better luck asking them directly. I literally haven't seen anyone in here ever use it

calm oyster
#

can someone teach me how to make discord bots pls? yt tutor doesn't work for me and outdated

fast osprey
#

youtube isn't a good educational resource to begin, especially not for this stuff

#

Are you having trouble learning python, or specifically how to use one of the discord libraries?

calm oyster
#

no i just want to learn how to make a simple discord bot

#

like everytime i use yt tuts its doesnt work always error on the line 4

fast osprey
#

But do you have the requisite python skills?

#

Have you made any scripts at all on your own?

calm oyster
#

nah bro this is my first time learning python

#

and i want to start with discord bot

fast osprey
#

I would suggest then that you take on much smaller, focused projects

#

This is like trying to start with building spaceships before you know how to make a wheel. You're not going to make much progress and get frustrated because bots layer on several concepts at the same time

calm oyster
#

hmm can you tell me where i should start??

fast osprey
#

The official python tutorial is quite comprehensive and layers on concepts one at a time: https://docs.python.org/3/tutorial/index.html

Python documentation

Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python’s elegant syntax an...

#

https://automatetheboringstuff.com/ is also a recommended resource for beginners. Once you have basics down, there's a bunch of sites out there with targeted practice problems/projects

ruby tapir
#

Hi guys I'm wondering if it is possible to create bots like mee6/sapphire using python?

Kindly lmk.

pale zenith
#

Mee6 is (or was, idk) written in discord.py unless that has changed recently. Same as many other popular bots

ruby tapir
#

Thanks

burnt quiver
drifting cedar
#

how need discord bot?
I am python expert so if you need, please feel free to reach out

fast osprey
brave onyx
#

Hello guys, im creating a discord bot in python, but i have an error can someone dm, for helping me please ??

Look this is my main.py :

import os
import json
import discord
from discord.ext import commands

config = json.load(open('config.json', 'r'))
bot = commands.Bot(command_prefix='!', intents=discord.Intents.all(), help_command=None)

commands_files = [f"commands.{filename[:-3]}" for filename in os.listdir("./commands/") if filename.endswith('.py')]
events_files = [f"events.{filename[:-3]}" for filename in os.listdir("./events/") if filename.endswith('.py')]

for file in commands_files:
    try:
        bot.load_extension(file)
    except Exception as e:
        print(f"failed to load {file}", e)

for file in events_files:
    try:
        bot.load_extension(file)
    except Exception as e:
        print(f"failed to load {file}", e)

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

bot.run(config["token"])
#

and here is my command :

import discord
from discord.ext import commands
from functions import embed_color, footer

class HelpCommand(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.slash_command(name="help", description="Show help panel")
    async def helpcommand(self, ctx):
        embed = discord.Embed(
            title="Help Panel",
            color=embed_color()
        )
        embed.add_field(name="/add-ping", value="Add ping per day for a slot owner", inline=False)
        embed.add_field(name="/backup", value="Backup your slot with backup key", inline=False)
        embed.add_field(name="/config-channel-reset", value="Configuration of reset ping announcement channel", inline=False)
        embed.add_field(name="/config-role", value="Configuration of role added for slot owners", inline=False)
        embed.add_field(name="/create-slot", value="Create a slot", inline=False)
        embed.add_field(name="/extend-subscription", value="Add time for a slot subscription", inline=False)
        embed.add_field(name="/hold", value="Hold a slot", inline=False)
        embed.add_field(name="/remove-ping", value="Remove ping per day for a slot owner", inline=False)
        embed.add_field(name="/unwl", value="Remove an user from whitelist", inline=False)
        embed.add_field(name="/wl", value="Add an user into whitelist", inline=False)
        embed.add_field(name="/wl-list", value="Show all users into the whitelist", inline=False)
        embed.set_footer(text=footer())
        embed.set_thumbnail(url=self.bot.user.avatar)
        await ctx.respond(embed=embed)

def setup(bot):
    bot.add_cog(HelpCommand(bot))```

there is no / commands on my bot
brave onyx
#

why please ? Like when i start the bot there is no command on it ???

brave onyx
viscid hornet
#

also dont do this

#

dont help_command = None and then make your own

viscid hornet
#

what library are you using?

viscid hornet
fast osprey
#

If this is dpy or a dpy fork, this is either raising a lot more errors or they're using a way deprecated version

brave onyx
#

Name: discord.py
Version: 2.5.2
Summary: A Python wrapper for the Discord API
Home-page:
Author: Rapptz
Author-email:
License: The MIT License (MIT)
ik i use that

brave onyx
viscid hornet
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.

brave onyx
#

@viscid hornet can u help me patch them

viscid hornet
brave onyx
viscid hornet
#

you'd need to learn the language first, then grasp principles like OOP and async programming

#

THEN you can start making bots

fast osprey
#

There isn't a shortcut. You're either going to have to put in the time to learn or pay someone who already has

viscid hornet
#

shortcuts will become setbacks shrug

brave onyx
viscid hornet
brave onyx
fast osprey
#

Well you can ask him to fix his own code

brave onyx
fast osprey
#

Well then either you or him need to learn

#

Or pay someone

brave onyx
#

the bot can be in javascript or no ?

fast osprey
#

Sure it could

brave onyx
#

okok

jaunty cape
#

Never a dull moment in this channel

brave niche
#

You'll pay for the whole seat, but you'll only use the edge.

lunar vine
stark ingot
#

Why are you brining up a message that is ~10 months old?

pale zenith
#

"sorry bad ping"

timber dragon
#

"I was scrolled up"

woeful hill
#

knowing legal things = nerd

lyric raft
#

omg the dpy people are here

#

discord.jsex release soon

finite salmon
#

Jsex

graceful gorge
#

hii i need some hlep regarding my bot

gleaming inlet
gleaming inlet
graceful gorge
gleaming inlet
burnt quiver
graceful gorge
#

Scrims View Error: 'Scrim' object has no attribute 'scrims'
2025-04-20 16:13:54 ERROR discord.client Ignoring exception in on_command_error
Traceback (most recent call last):
File "D:\bot.venv\Lib\site-packages\discord\client.py", line 441, in _run_event
await coro(*args, **kwargs)
File "d:\bot\quotient-main\src\cogs\events\errors.py", line 115, in on_command_error
raise err
File "D:\bot.venv\Lib\site-packages\discord\ui\view.py", line 427, in _scheduled_task
await item.callback(interaction)
File "d:\bot\quotient-main\src\cogs\esports\views\scrims_btns.py", line 432, in callback
if isinstance(self.view.record.scrims, list): # Replace 'teams' with the correct field
^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Scrim' object has no attribute 'scrims'

graceful gorge
fast osprey
#

You're looking for an attribute that doesn't exist

graceful gorge
fast osprey
#

It's your code though

#

This reads like template code that you're changing stuff inside it that you don't understand

graceful gorge
#

umm i have raw file

#

can you check it and tell me that attribute

fast osprey
#

If you don't understand the code someone gave you, I'm not going to fix it for you

#

Good first stop would be whoever gave you this code

graceful gorge
drifting arrow
#

@graceful gorge He's saying if you dont understand the code, you shouldnt be running it. How do you know it's not a virus?

graceful gorge
#

naah i know the code

#

but just the thing is i cant modify some things

fast osprey
#

You know the code, but you don't know what attributes your classes have

#

riiiiight

jaunty cape
#

LOOOOL

severe monolith
#

how do you create a discord bot in 2025? is still discord.py the go-to library? it's been a while since i made discord bots

full ether
#

the discord.py dev went on a hiatus for a bit a few years ago and it looked like it was gonna die as the king, but then he unleft 6 months later, so it remains crowned, yes.
the docs website has a quickstart guide for first-timers, which should help remember some stuff

severe monolith
full ether
#

most are still around, but momentum is a helluva thing. iirc, this server almost switched to disnake, but then rapptz came back just in time and rendered the idea moot

severe monolith
#

also idk, it feels to me that discord.py is sort of dead even if still receiving updates

woeful hill
#

Honestly just choose what you like

#

No one is forcing you to only choose this over that

severe monolith
#

i mean, discord.py was the "blind" choice for a lot of time, now i was wondering if it was still the same
i also would like to use a library that is well updated and has a good dev experience

woeful hill
#

Both has its pros and cons, i use discord.py personally and have no problem at all

#

Both getting updates fairly quickly

severe monolith
viral sand
#

Anyone know free discord bot free hosting 24/7 if yes then plz tell me in dm

woeful hill
woeful hill
#

Disnake is still alive? /j

full ether
timber dragon
#

There is also hata, which is different .

languid jungle
timber dragon
#

Iirc disnake has changed its design a bit and seems to have many qol first-party extensions

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.

stark ingot
wanton current
#

not the go-to "default" option
source?

viral sand
blissful jacinth
#

Hey

#

I am new here

#

Can anyone teach me how to make a discord bot plz??

fast osprey
#

Do you know python and OOP?

blissful jacinth
#

I know python

#

I have written a code for my bot

#

I have a discord module installed in my ide

#

But I don't know how to activate it in my own server

#

So I wanted help

fast osprey
#

The discord bot portal gives you an invite link to invite the bot

stark ingot
fast osprey
#

The existence of other options doesnt mean dpy isn't a default

#

That's the whole point of what "default" means

topaz basalt
#

Hello, I’m trying to make a Discord bot that sends a message whenever there’s new stock available in the Grow a Garden Roblox game including fruits, gear, and the Easter stock. I want it to say which items are in stock or out of stock in a format like:
NEW STOCK!
Apple - In Stock
Banana - Out of Stock
…
The thing is, the only way to see the stock is by going up to the NPCs in-game and opening the GUI that shows the items. The game doesn’t have a public API or website that lists the stock, and the items aren’t sold as gamepasses or developer products, so I can’t check the stock from outside the game. I wanted to know if it’s possible to automatically read the stock and send it to a Discord server. Since I can’t run Roblox scripts in someone else’s game, I’m now trying to make a tool that takes a screenshot of the stock GUI, uses OCR to read the item names and stock status, and sends that info to Discord. If there’s any better way to access the stock info (like through a hidden API, dev help, or webhook), I’d really appreciate any advice!

stark ingot
#

Default

a selection made usually automatically or without active consideration due to lack of a viable alternative

fast osprey
#

I'm not the one who said it wasn't, that's not how burden of proof works lol

fast osprey
stark ingot
stark ingot
#

OCR probably would be the best automatic option as like you said there is no API
-# I am assuming robox/the game allows this I dont feel like checking myself rn

fast osprey
#

You may wish to contact the developer and get a supported api or at least written consent that this is supported and not an exploit. Otherwise this could be against their wishes and violate community rules.

Using exploits to gain an unfair advantage anywhere on the platform

loud socket
#

well only for bloxfruits

analog swallow
robust fulcrum
#

(iirc it is not allowed to help with things against tos here)

young dagger
#

Web scraping isn’t illegal, Google does it literally every day

#

As long as you’re not scraping sensitive stuff that could be used badly, it’s fine

young dagger
fast osprey
robust fulcrum
woeful hill
#

google literally getting complains every day about its scraping so no one visit the actual website

tender bobcat
#

Two way it could be illegal:

  • Use/Distribution of copyright material without permission from the owner and not from fair use clause by applicable law
  • Cause of financial loss due to the the traffic cause by the scraper and reduction of revenue cause by the scraper or its directly corresponding reduction of quality of content cause by the scraper (e.g. increase in latency to access the website)
#

Maybe more but at least these 2

tender bobcat
fast osprey
#

That's moving the bar here. Illegality is irrelevant; the rules say not to help with TOS violating activities

tender bobcat
#

Even if it's legal, still not allowed here

severe monolith
#

since i'm making a musicbot, I don't know if hata, that's using v8 of the voice api, it's more suitable for my use case instead of dpy that still uses v4

stark ingot
severe monolith
stark ingot
#

I have never worked with sending events on the voice gateway so I cant offer much advice

granite citrus
#

hi im using the latest discord py from rapptz afaik and my code no longer works, and i was able to get it to at least start by doing the tiny fixes such as adding the bot.add_command() stuff. but now i can no longer run commands from cogs, gicing me an error about a missing ctx argument

#
@commands.command()
    async def flip(self, ctx):
        result = random.choice(["Heads", "Tails"])
        await ctx.send(f"The coin landed on: {result}")

simple command that i have, giving me the error:

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: BasicCommands.flip() missing 1 required positional argument: 'ctx'

did i miss something?

sick birch
granite citrus
# sick birch can you show the full code?

theres like a gazillion different files that each have a cog in them so ill just show one with the relevant code

basics.py

import discord
from discord.ext import commands
import random
class BasicCommands(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
    ...
    @commands.command()
    async def flip(self, ctx):
        result = random.choice(["Heads", "Tails"])
        await ctx.send(f"The coin landed on: {result}")

main.py

import discord
from discord.ext import commands
import json
import traceback

# import cogs from the cogs module because i love organization
from cogs import basic_cog, mod_cog, games_cog, music_cog

# initial bot stuff
intents = discord.Intents.all()
intents.message_content = True
bot = commands.Bot(command_prefix="h/",intents=intents)
bot.remove_command("help")


# barebone events
@bot.event
async def on_ready():
    print(f"online in {[x.name for x in bot.guilds]}")

cogs = [
    basic_cog.cog,
    mod_cog.cog,
    games_cog.cog,
    music_cog.cog
    ]
for cog in cogs:
    bot.add_cog(cog(bot))
    commands = cog.get_commands(cog)
    for c in commands:
        bot.add_command(c)
@bot.event
async def on_command_error(ctx, error):
    form = f"{error}"
    await ctx.send(form)
    traceback.print_exception(error)


with open("token.json","r") as token_file:
    token = json.load(token_file)
bot.run(token)
jaunty cape
#

So you’re actually supposed to do add_cog on the Class

timber dragon
#

Why are you adding the commands to the bot manually

jaunty cape
#

It’s more like await bot.add_cog(basic_cog.BasicCommands(bot))

#

Rather than basic_cog.cog

#

Because that doesn’t even exist

#

Yo how about you turn those cog programs into extensions instead

#

Just add a setup function in there

burnt quiver
granite citrus
fast osprey
#

What they told you has nothing to do with file structure. It's how you actually get the commands into the bot

#

putting commands into a cog, then extracting those commands out and adding them manually yourself is pointless

granite citrus
#

would i add the commands within the cog class itself then? and not outside it?

fast osprey
#

No

#

Calling bot.add_cog(your_cog_object) automatically registers all commands within the cog to the bot. That's the entire purpose of using a cog

#

otherwise you could just declare floating commands and add them yourself

granite citrus
#

oh right, but if i havent done that then the commands simply just dont seem to exist apparently

#

that was the issue i had before the ctx argument thing

fast osprey
#

right...which is why you want to use add_cog if you're using cogs

#

either use add_cog, or don't use cogs

granite citrus
#

but i did use add_cog

fast osprey
#

no you didn't

#

not in the code you showed

#

Or, rather, you're trying to use it in addition to adding the commands apparently?

granite citrus
#

for some reason doing that worked yesterday

fast osprey
#

Because it worked doesn't mean it's right or makes sense

#

Or that you didn't also change something else

granite citrus
#

erm i fixed the issue somehow, i did ditch the manual command adding and it was some problem with how the cog object wasnt a Cog object

#

not sure what i did it was piss late at night, thanks all for bothering to help!!

fast osprey
#

If you're going to store stuff in external files, I highly suggest you make them extensions instead of this direct loading you have but it's up to you

rotund flame
#

Thats great, I feel so unmotivated to add new features to my bot bcs of legacy code but I also feel unmotivated to rewrite it

#

pithink I wonder when we will get these changes

stark ingot
rotund flame
stark ingot
rotund flame
#

Some stuff for league of legends modding, notting too extraordinary like getting 3d model file from the web

sick birch
jaunty cape
#

Yikes dude that’s the entire program

viscid hornet
#

finally better UI

jaunty cape
#

I need to figure out how buttons and stuff work

jaunty cape
ember ibex
#

can I host 2 or more seperate bots on the same server or will discord start ratelimiting after a while

fast osprey
#

Unlikely but we have no idea what your bots do and discord intentionally doesnt publish the limits

stark ingot
# ember ibex can I host 2 or more seperate bots on the same server or will discord start rate...

It depends on IP. If the combined requests stay under the IP ratelimits then you will be fine. So smaller bots that make less requests are easier to do this with. As long as you control both of the bots and follow proper practices you should not run into many issues. What gets lots of people tho is using cheap shared IP hosting where a different customer has a bot on the same IP as you and gets everyone on that IP rate limited because of their bad code (intentional or not)

tender bobcat
#

I think 3 bot is running on the same server and IP on my machine
It work fine

jaunty cape
fast osprey
#

"unoptimized" is a really funny way of phrasing "attempted ddos"

jaunty cape
#

Har har har

ember ibex
fast osprey
#

No

#

discord sends events to your bot and doesn't rate limit itself

stark ingot
#

There is no ratelimit on events that discord sends as they choose to send them

fast osprey
#

The limit is on api calls you send back to discord

#

You may also want to consider automod for the use case you described

ember ibex
#

Thank you!

ember ibex
fast osprey
#

🀨

ember ibex
#

a social credit system kinda similar to china's mass surveillance

fast osprey
#

riiiight

#

Sure hope that's in your privacy policy

wheat summit
#

Greetings! Is anyone available to resolve my issue? The bot is saying that ctx.send takes up from 1 to 2 positional arguments, but three were given. py @bot.command() async def owner(ctx): await ctx.send(f"The current owner of the server is @", ctx.guild.owner)

dapper ocean
#

You should replace that , with + ctx.guild.owner.mention and remove @ in the string

jaunty cape
#

Smh my head

dapper ocean
#

peak attitude

fast osprey
stark ingot
bright oasis
#

Hello, I have a problem with my on_message function. When I mark the words in the server, the bot does not send anything, and with the debugging tools that I coded, it marks an empty message or spaces when there are none.

#

`@bot.event
async def on_message(message: discord.Message):

if message.author.bot:
    return


print(f"Message debug : {message}")
print(f"Message contenu : {repr(message.content)}")  # Utilisez repr() pour afficher les caractères invisibles
print(f"Message type : {message.type}")
print(f"Message auteur : {message.author}")


if not message.content or message.content.strip() == "":
    print("Message vide ou contenant uniquement des espaces reΓ§u.")
    return


if message.content.lower() == "showstaff":
    try:
        # Charger les utilisateurs du staff
        staff_users = load_staff()

       
        if str(message.author.id) in staff_users:
            embed = discord.Embed(
                title="Membre du staff",
                description=f"**{message.author.name}**, vous faites partie du staff.",
                color=discord.Color.green()
            )
          
            sent_message = await message.channel.send(embed=embed)
            await asyncio.sleep(10)  # Attendre 10 secondes
            await sent_message.delete()
        else:
           
            print(f"L'utilisateur {message.author.name} n'est pas dans le staff.")
    except Exception as e:
        print(f"Erreur lors de l'exΓ©cution de .showstaff : {e}")`
fast osprey
#

what intents are you requesting?

#

also if you're trying to implement commands (user says do something, bot does the thing) you should strongly consider implementing these as app commands instead

south shell
#

is leaking the discord shard id dangerous?

fast osprey
#

afaik no. Every bot has a shard id 0 for example

south shell
#

so showing it on stream is okay

fast osprey
#

🀨

#

I'd really recommend not streaming anything regarding the back end of your bot

south shell
#

nah its just coding peopels ideas

#

so nothing really

fast osprey
#

you are still responsible for what happens with a bot you have registered

#

you do you but you're just asking to slip up and fuck something up

#

The token is really the sensitive thing, not shard id, but you have to ask yourself if the internet clicks are worth the risk

south shell
fast osprey
#

Again, the bot itself doesn't matter. If you do accidentally show the token or put in some way for someone to get the token, they can abuse it and discord will blame you

jaunty cape
#

That’s like very archaic code

#

Which internet tutorial did you follow dude

#

You should not be following tutorials in the big 25

loud socket
#

~~ What’s wrong with tutorials some are great ~~

stark ingot
#

Discord bot tutorials are generally pretty bad. I looked at the top 10 results on google a while back and only one even mentioned slash commands (but did not use them). The only tutorials that are any good are the ones made by active community members of the libraries. Sites that just post one off tutorials will lead to you having issues (4 of the top 10 did not include intents which would lead to an error when running the code)

jaunty cape
loud socket
fast osprey
#

Even if a good unofficial tutorial did exist (which they don't)

a) it would be rare and
b) noobies aren't going to be able to tell the difference, they're just going to click whatever mouthbreather uploaded something on youtube

jaunty cape
#

I just stated exactly what he did

timber dragon
young dagger
#

Saves two lines of code

bright oasis
blissful jacinth
#

Hi guys

#

I am thinking of making a discord bot

#

But can you all give me a topic for my bot??

#

I meant, what all can that bot do

fast osprey
#

If you don't have an idea you want to implement, start by just making a hello world bot

haughty quest
#

can someone join my bot dev team (dm if you want to)

ember ibex
#

Is there some kind of ORM I can use with SQLite? My code is not clean at all because I have to write a bunch of functions that talk to the database with raw SQL.

fast osprey
#

"Clean" is a pretty subjective thing that you could very well be psyching yourself out over

#

ORMs can often abstract away meaningful decisions and result in suboptimal queries

ember ibex
#

I got like 100 rows millisecond differences aren't gonna kill me

fast osprey
#

Neither is some raw query text

ember ibex
#

But I suppose nothing's wrong with raw sql

fast osprey
sick birch
haughty quest
#

anyone want to join my discord bot dev team

finite salmon
#

no

tender bobcat
#

!rule ad

unkempt canyonBOT
#

6. Do not post unapproved advertising.

lyric raft
#

do yall think the ro-cleaner bot ban was fair

timber dragon
#

Do yall think the <insert name of random bot here> ban was fair

fast osprey
finite salmon
tender bobcat
timber dragon
#

indeed

opal vortex
#

Afaik it was deserved

jaunty cape
#

has anyone actually used the user-installable commands yet

burnt quiver
#

yes why not?

hard jay
#

Command not recognized ( when the button is clicked on a embed )

#

can someone help me> I am using @discord.ui.button

#

@azure tendon

timber dragon
hard jay
# timber dragon Full traceback? Code?

@discord.ui.button(label="Product Terms", style=discord.ButtonStyle.grey, custom_id="product_terms", emoji=discord.PartialEmoji.from_str(""))
async def product_terms(self, interaction: discord.Interaction, button: discord.ui.Button):
await interaction.response.send_message(
"Product Terms\nProducts are provided as-is. Refunds or replacements are only given under our warranty terms.",
ephemeral=True
)

fast osprey
#

Clicking a button isn't a command though what

hard jay
#

thats what i mean

#

its confusing me

fast osprey
#

But what is the exact error and what is showing it?

hard jay
#

it should display a message that i added for test

#

but its not

fast osprey
#

That's your bot sending that

hard jay
#

what should i do?

#

am using chatgpt to help me but its clearly not haha

fast osprey
#

You should stop doing that

#

And find where in your code is sending that message

fast osprey
#

It could potentially also be in some library you're using

lyric raft
lyric raft
bright oasis
#

Hi bg, I have a problem with my ticket code. When I configure it in one server, it works, but in another, it returns an interaction failure.

burnt quiver
bright oasis
solar coyote
#

Is there some detailed docs on clustering and sharding

open cobalt
#

can someone explain what sharding is? Is it if a single bot is on alot of servers and the connections are multiple or what exatcly is sharding?

#

what if a robot is on 1.2 mil guilds?

bright oasis
#

No, I don't have any errors

open cobalt
#

@fast osprey can you explain please. you seem expert on discord api, so your opinion and experience is key for all of us.

woeful hill
#

Don't nest class

blissful crane
#

It's really ugly and serves no real advantage

woeful hill
#

first of all it looks ugly

#

second of all are you gonna tab/space that much time

#

this is nested nested class

#

also this code looks like from 2 different people

#

cuz one view use the tutorial style of making ui components

class SubclassedView(View):
    def __init__(...):
        ...
        select = Select(...)
        async def callback(...):
            ...
        select.callback = callback
        self.add_item(select)
#

the code is next level impossible to read for me cuz of super indentation it has

gleaming inlet
#

@dense moon if you're interested in discussing or learning more about Discord Bots, feel free to ask here πŸ™‚

dense moon
gleaming inlet
gleaming inlet
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.

gleaming inlet
#

I personally like "Automate the Boring Stuff" ebook

dense moon
#

Oh so you want to say..
That if I learn something else. From python.. My python knowledge will extent

gleaming inlet
dense moon
gleaming inlet
jaunty cape
#

Get a load of this guy

sick birch
sick birch
#

go to processes sort by memory usage in descending order

viscid hornet
#
class MySelect(Select):
    pass

class MySelectView(View):
    def __init__(self) -> None:
        super().__init__()

        self.add_item(MySelect())
#

or even just View().add_item(MySelect())

stark ingot
hard jay
#

And also when i use a command it sends it 2x ( Embeds )

tender bobcat
#

*It never specified whether it suggested or suggested not doing so in official docs

sick birch
stark ingot
sick birch
#

resource usage would be pretty much the same between not sharding and sharding and running it on the same machine

#

the idea is to enable developers to spawn many bot instances across many machines to split the load

tender bobcat
#

Well, sharing required the machine to be largely coordinated with is difficult for multi-machine
Also it's probably for multi threading imo to take advantage of access to more CPU core to process differently, while easily coordinated

sick birch
sick birch
#

discord bots are generally more memory intensive than CPU intensive because you're expected to cache of stuff yourself, and most of the actions that you do are IO bound

tender bobcat
sick birch
#

i meant that sharding is not necessary to take advantage of multiple cores

tender bobcat
#

So that's why so many library implementation just make so the shard doesn't exist and library handle the rest

hard jay
tender bobcat
#

But probably discord want to encourage such? Idk

sick birch
#

i'm almost certain discord means for shards to be deployed on multiple machines. but its designed so that you could still deploy it on a single machine - but you really don't get anything out of it

tender bobcat
#

Ye

#

Also idk why they set to 2.5k because most likely when you are at that point, you probably still don't have the infrastructure for multi machine

sick birch
#

i'm pretty certain that even at 2.5k servers your CPU utilization wouldn't be as bad as your memory usage - sharding on the same machine wouldn't fix this

tender bobcat
#

Because I do have one running

sick birch
#

your CPU utilization is worse than memory?

tender bobcat
#

I mean both isn't bad
CPU ~10% and memory ~700-800MiB

sick birch
#

how many servers?

tender bobcat
#

4k or 4.5k now

sick birch
#

yeah 10% CPU with that much is really good

#

your CPU is barely doing anything

tender bobcat
#

4511 now

sick birch
#

this is what i mean

tender bobcat
#

As part of the bot

sick birch
#

background tasks every 2 minutes is negligible

tender bobcat
#

If it doesn't run for at least 30s or to probably 90s where it send many of network request and db operation

#

Ok according to monitoring software, avg CPU is 6-8%

sick birch
#

if a task is running at an interval more than like 5 seconds its basically negligible just because modern cpus do literally billions of cycles per second

#

and especially discord bots are so IO bound that it literally just does not matter to a CPU

tender bobcat
#

Well, ye, tbf mostly network IO

#

but some old dumb thing before cause 100% CPU 10s every 2mins

sick birch
#

usually when you have heavily cpu bound stuff you need to do occasionally it could be a good idea to make a separate microservice to handle that and use message queues

tender bobcat
#

Because when I get stuff from db, it looks up dpy cache too many time to get structure response

sick birch
#

like if you've got an image processing service. you can scale up and down your workers based on demand

tender bobcat
#

So I fix it to not get the actual object

tender bobcat
stark ingot
stark ingot
#

Yes

dark heron
#

Hello
I build an ai discord bot, basically it's powered by gemini pro
And hosted by render.

My question is there not much discord bot building tutorials available on youtube in in depth detail,so only reading discord.py documents is the only way to improve my bot or is there any other way too?

patent hull
#

You can use the examples on the Discord.py repository, or any bot that has β€œgood dpy practices ”, as the Python bot, RoboDanny (by Rapptz, owner of Discord.py) and others

#

And with that you can check how they build things and how you can improve the ones you’ve made in base of that

fast osprey
#

You may wish to review the developer tos and policy when you implement an "ai bot". A vast majority of the people I see in here doing that violate the policy in one way or another

stark ingot
dark heron
#

Ah late response sorry,Thanks for answers

fast osprey
#

The main parts are

  • No using message content to train models, which gemini does unless you're using their Paid Services and
  • No sending user data to third parties without explicitly capturing their consent to do so*

(*unless you are treating google as a Service Provider, in which case you need them to agree in writing that they are following discord's terms on your behalf)

fast osprey
#

Are you guessing event names?

jaunty cape
#

Yes bro it’s called documentation

fast osprey
#

You shouldn't guess things, and you shouldn't rely on randos on the internet

jaunty cape
#

Tbh I guess my own method/function names too

#

Sometimes I forget what my function is called and I just guess what it is and deal with it later

fast osprey
#

Any number of reasons why

#

could be that listener isn't being registered, could be you aren't subscribed to the relevant intent, or that you aren't doing the thing in a place the bot can see it happen

#

Your bot should never have admin

#

and you never need all intents

jaunty cape
fast osprey
#

I have yet to see a bot use the typing intent

jaunty cape
#

Yeah that’s true

fast osprey
#

Which is also the one that by far fires the most

jaunty cape
#

Probably the most useless intent

tender bobcat
tender bobcat
#

So it ends as a small experiment

tender bobcat
fast osprey
#

Maybe read the dev tos

#

it specifically says if you want to use a provider as a service provider, meaning you give them user data without the user's consent, they have to submit in writing to agree they are acting on your behalf

#

Before using a Service Provider, you will require them to first agree in writing to only access and use the APIs and API Data for you and at your direction to provide you services to develop or operate your Application in compliance with the Terms, and for no other purpose (including their own). For the avoidance of doubt, Service Providers are acting on your behalf. You will ensure that each Service Provider complies with the Terms as if they are in your place, and you are solely responsible and liable for their acts and omissions, including noncompliance. When you stop using a Service Provider, you will ensure they immediately cease using the APIs and API Data and promptly delete all API Data in their possession or control. Upon notice, we may prohibit your use of any Service Provider if we reasonably believe that they have violated the Terms or they are negatively impacting us, the APIs or our other services, API Data, or the users, and you will promptly stop using them.

#

And the relevant paragraph of why you'd care if they were officially a Service Provider:

You will not share API Data with any third party, except in the following circumstances, subject to compliance with the Terms and applicable laws and regulations: (i) with a Service Provider; (ii) to the extent required under applicable laws or regulations; and (iii) when a user of your Application expressly directs you to share their API Data with the third party (and you will provide us proof thereof upon request).

tender bobcat
#

I would argue it meant they are only acting on your behalf and you need to make sure they are only acting on your behalf to operate (your application which compliance to the term)

#

E.g. their Term of Service and Privacy Policy say that they wouldn't do this that ... which is compliance to what discord term of service is enough, instead of individual written that they would compliant compliance to discord term

fast osprey
#

that's not what the discord terms say

#

they don't give a damn what google's tos are

#

either a) you get user's permission to send their data to a third party or b) you treat google as a service provider, which requires written acknowledgement to comply with discord terms.

tender bobcat
#

That read to me only written acknowledgement on whether they only act on your behalf

fast osprey
#

there's no other way to read this.

#

Before using a Service Provider, you will require them to first agree in writing to only access and use the APIs and API Data for you and at your direction to provide you services to develop or operate your Application in compliance with the Terms, and for no other purpose (including their own)

tender bobcat
#

there nothing require the written statement to said specifically it compliance with discord term, as long as it comply with the term, as far as I can read it.
You can call me stupid if you want, idc

#

and also act on your behalf

stark ingot
fast osprey
#

please point at where google puts, in writing, that things you submit to it will follow discord's terms

tender bobcat
#

the fact that e.g. said No data is being collected/stored for the service or used in any other way than the required would be compliance to the term discord specified, even thought they didn't specify discord (which is very logical)

#

also, I didn't specify google specifically, just the general idea on how you describe it

fast osprey
#

that is one thing

fast osprey
#

you can't just handwave it and say "nah google's fine"

tender bobcat
# fast osprey This says that a service provider has to comply to **all of discord's terms** wh...

specifically
Where it comes from (*Misread I thought you say it means they have to specifically writing to you)
All of discord's terms when processing data on your behalf
Yes I can find an example of that, without saying it specifically compliance to discord
Idk, maybe: We don't store anything after the request?, You are the sole person that can access the machine unless you give the password to other people for the VPS provider?

tender bobcat
#

I am pretty sure it wouldn't violate any terms of discord from my memory by not storing anything and not sharing it to any further third party

#

It's very low power

#

But how did you get 0.9 from, only running the bot on the machine?

#

But basically, it's good if it's usable in such way

#

Oh well
What do you used to host the bot?

#

Lmao

#

And it also somehow run Linux?

#

I recommend to have something to also monitor the system status
If it can fit in it

#

What does it run

#

More CPU issue imo

#

It's running 1/30 the max power of my raspberry pi

#

Do you know what OS it run // Did you even use a library, python or just some other code

#

Library that help you make a discord bot

unkempt canyonBOT
tender bobcat
#

Oh ye

#

So what system is this lol

fast osprey
#

what library you're using is such a tiny, tiny thing in the scheme of the power your hardware draws lol

tender bobcat
#

But what system does it use?...

tender bobcat
#

Oh well

tender bobcat
#

Nah, tbf, mainly interested in the hardware

tender bobcat
#

I cannot calculate exactly because it's running many things but the power supply is 27W for a raspberry pi

fast osprey
#

Seems like a pretty random tangent and nothing to do with python

#

Meaning "should/why does my hardware use X electricity" isn't really a topic for this channel imo

rustic rune
#

can someone help me adding a function to my discord bot, can pay in crypto

fast osprey
#

may wish to review the rules

stark ingot
quiet horizon
sick birch
timber dragon
#

Literally two different languages

fast osprey
#

asks python or not python in official python server

unkempt canyonBOT
#

9. Do not offer or ask for paid work of any kind.

rustic rune
#

can someone do it for free πŸ’°

jaunty cape
#

Make it yourself first then ask people to help fix it

rustic rune
#

πŸ˜‚

meager rock
#

returning to bot dev after lowkey 2years, best lib rn? except dpy and hikari

sick birch
#

discord.py is still pretty much the "default". though you have a lot more options now, and discord.py is not as actively maintained as it once was

jaunty cape
#

Yeah

quiet horizon
#

he said except lmao

jaunty cape
#

Why would you want to exclude it

tender bobcat
#

Crazy

meager rock
quiet horizon
jaunty cape
#

he's obviously talking about serenity-rs

quiet horizon
#

ah

quiet horizon
fast osprey
#

and there's going to be an equally biased answer in both

jaunty cape
#

bro it's literally the same thing in different languages

#

just work with the one you know best

quiet horizon
fast osprey
jaunty cape
#

i'm tired of these linear-thinking websites that only teach beginners

fast osprey
#

"a concept"?

jaunty cape
#

yeah, like arrays, loops and such like that

#

i don't need to go through learning those concepts again because i know them

#

is there a way to just skip straight to the syntax

fast osprey
#

can just look at implementations of hello world type stuff

#

look at repos, reverse engineer

stark ingot
brave niche
#

If the language has outright new concepts (e.g. dependent types), expect to take much longer to 'get' it.

last arrow
#

hello, i've made a discord user app for dm usage purposes with slash commands, it contains multiple commands but mainly the vouch command that i can use with someone in their direct messages after a service, the problem is i have /my-vouches command which displays vouches taken from vouches.json in a format like this:

    {
        "voucher_id": id,
        "voucher_name": "username",
        "stars": 5,
        "feedback": "review text"
    }```
when i display the list using the command /my-vouches it only displays my vouches, it takes the voucher_id and if it's valid it displays and since i'm the person using the ocmmand it'll only display mine not someone else's vouches.
I want to change it so that it uses voucher_name and always displays from vouches.json but whenever i try i just break my code i tried chatgpt but it just makes things worse.
i can send the full code in dms if anyone is willing to help.

as for the other things:

vouchme.py (saves the vouches after someone vouches me)
```python
       new_vouch = {
            "voucher_id": self.user.id,
            "voucher_name": self.user.name,
            "stars": stars,
            "feedback": self.comment
        }

        try:
            with open(VOUCH_FILE, "r") as f:
                vouches = json.load(f)
        except json.JSONDecodeError:
            vouches = []

        vouches.append(new_vouch)

        with open(VOUCH_FILE, "w") as f:
            json.dump(vouches, f, indent=4)```
myvouches.py:
```python
        user_id = interaction.user.id
        user_vouches = [vouch for vouch in vouches if vouch['voucher_id'] == user_id]
        vouches_per_page = 3
        total_pages = (len(user_vouches) + vouches_per_page - 1) // vouches_per_page```

but the confusing part is that the part that displays the voucher's name inside the my-vouches command's embed has voucher_name...
```python
            embed.add_field(
                name=f"{vouch['voucher_name']} | {star_emojis}",
                value=f":CutseyTalk: {vouch['feedback']}",
                inline=False
            )```

i'm so lost.
#

uh sorry for the big text but i don't understand how to change it without my code breaking

fast osprey
#

you shouldn't be using a flat json file as a database. Use a proper database

#

sqlite is a good lightweight starter db with minimal setup

#

also chatgpt is stupid as hell. It doesn't know that 3 is a prime number sometimes. You shouldn't use it to fix code

last arrow
fast osprey
#

no, no flat files are good

#

not only are they hideously slow, one bad write and all of your data gets corrupted and lost randomly and there's nothing you can do about it

last arrow
fast osprey
#

You can put a database wherever you want

#

including right next to where your bot is

#

sqlite is literally just a file

last arrow
#

and how do i make it work? my code is a complete mess

fast osprey
#

I'm not sure what you're expecting me to say here

#

"change the a on line 56 to a b"

last arrow
#

half of it is chatgpt's help i understand the code but i don't know how to change to the database

fast osprey
#

It's a debugging process of isolating the behavior you want to change, finding the part of your code that's generating it, and changing that

#

chatgpt is a crutch and it's going to lie to you. You need to stop using it entirely if you want to get better

last arrow
#

im trying but this code was pain to build up

fast osprey
#

well it ain't gonna get any easier

finite salmon
#

any errors?

fast osprey
#

Maybe do a little debugging to see if you're running the code you think you are

#

you're not doing any debugging. You don't know how your code is behaving

#

Also why is this a loop?

open cobalt
#

I thought discord.py library does that when an event occurs like msg sent

#

or what you trying to do exactly?

#

@slate swan

fast osprey
#

Yes but your else deletes confirmation. Confirmation never changes

#

The loop serves no purpose

open cobalt
#

I assume tak means yes and nie no?

#

ok, mhh treaky one. maybe sosticeshard can respond to this problem, he seems expert on discord.py

#

but a while loop is kinda weird for this problem, there is a better solution to this

#

@slate swan I think whenever you want to detect messages there is an event in discord py that catches them

timber dragon
#

Or just use buttons

fast osprey
#

Any kind of interaction flow will be easier to implement and simpler for users than expecting messages with specific content

woeful hill
#

if you want some kind of classy message "conversation" wait_for is better than a while True loop
but using ui is recommended and way way better
for choice, you have buttons or selects, for confirmation/cancel use buttons, for text input use modal

fast osprey
#

You can get user input from modals, which is part of the ui kit

fast osprey
rare hare
#

anyone can code a discord boost bot / tuul?jam_cavedude

fast osprey
#

If they could, they sure wouldn't just do it and give it you

rare hare
#

duh $ ready

fast osprey
#

Well then I'd refer you to the rules

jaunty cape
rare hare
jaunty cape
#

Then use that instead lil bro

#

Ibn kalb

serene robin
#

why

jaunty cape
serene robin
rare hare
#

dropped his glasses

viscid hornet
#

how?

#

i gotta see this

#

ooh

#

awesome thumbsup

#

well

#

!d discord.MessageInteractionMetadata

unkempt canyonBOT
#

class discord.MessageInteractionMetadata```
Represents the interaction metadata of a [`Message`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Message) if it was sent in response to an interaction.

New in version 2.4...
viscid hornet
#

i gotta see this

jaunty cape
#

Bro stop guessing module names

fast osprey
#

....okay?

jaunty cape
#

This guy has gotta be using ChatGPT to write most of his code

#

Cuz how are you β€œguessing” event names and random parts of the discord.py library

#

That makes no sense

young dagger
#

Looks clean ThumbsQ

fast osprey
#

It's a little weird to spend time making a user facing UI for information literally no user would ever care about but pop off I guess

stark ingot
#

Trevixis seems to care quite a bit about it...

tender bobcat
sick birch
#

i don't think building something pretty that you're proud of just for enjoyment should really be such a foreign concept

fast osprey
#

"A little weird" is pretty far off from "foreign concept"

stuck meteor
#

hi is it possible for a discordbot to run another apps command?

the other app has a made /getrap function and then itemnames

fast osprey
#

bots cannot perform interactions

jaunty cape
#

NO bro

jaunty cape
#

The frick

stuck meteor
#

my guy it for a game rap checker i dont have access to their api

#

it so i can check every items rap and see what went up

#

alr, ill try that, ty!

fast osprey
#

If they're not giving you access to their api, maybe they don't want you doing this?

stark ingot
#

This would be considered a self bot, which is not allowed

drifting arrow
#

lol

#

@stuck meteor The reason they didn't release the API to the public is because of people like you who want to create automated programs

#

That being said doesnt mean I can't help you find work arounds simply for the challenge.

I assume all the data is only available on discord and not a website?

jaunty cape
#

Bro write your own rap checker

drifting arrow
#

What even is a rap checker

jaunty cape
#

Roblox attack points or some shit

drifting arrow
#

oh

burnt quiver
#

what, hows it support

stark ingot
#

Self-bots are explicitly disallowed for the safety of the discord platform and its users

#

You still had to hit enter, no? That is somewhat of a grey area. But automating slash command execution is not a grey area.

drifting arrow
#

Since I am too lazy to think for myself or google it, I asked our favorite companion, ChatGPT.
So basically any automation on a discord account is considered a self bot.

stark ingot
#

I am not trying to be rude, it is just that self bots can cause a lot of harm so I don't want them to be suggested/normalized regardless of the TOS

drifting arrow
#

Besides @slate swan, if you used some intelligence, some time, an excel spreadsheet, you could easily figure out what's worth monitoring and what's not. You'd even figure out when the high's and lows are for certain things

#

Just study economics and you'll learn everything you need to know to easily manipulate the market. You don't need a program to do it for you

stuck meteor
#

recent average price lol

#

and ye the only thing their bot does is give the rap which i can find in game, i just wanted to see huge changes without individually searching everything

jaunty cape
#

Ibn hmar

stuck meteor
#

Nah your just dumb in general

jaunty cape
#

This is why you won’t just write your own RAP checker πŸ’”

copper flume
#

hi, when a guild member deletes a channel why is the member considered a User (in audit logs)? whereas the user is still a member of that guild

#

no, im troubling with discord audit logs and python here

jaunty cape
#

Send code

copper flume
#

code isn't the matter here

#

logic is

jaunty cape
#

Idk what to tell you other than it shouldn’t tbh

languid jungle
burnt quiver
#

If you attempt to get a member object when the user isn't in the server anymore, it would fail

fast osprey
#

and how do you think you get logic? By implementing code. Which we haven't seen, so we don't know what logic you're actually creating.

stark ingot
sick birch
jaunty cape
#

It’s supposed to return a Member object if they’re still in the server

opal vortex
#

thank you for the token

#

(just kidding, you gotta reset it tho.)

dusty violet
#

Hey everyone!
I wondered, does anyone else find the discord.py UI module kind of cumbersome to work with when developing complex ui behaviours with buttons, embeds?
I found it becomes a mess when you want to combine embeds + view interactions, and have complex flows where one view instantiates another, or things like undo, redo, etc
I see that most of the times you end up injecting the callback into the components in some way, or pass around references

woeful hill
#

no?

#

i made a wordle minigame with only ui module

dusty violet
#

do you have the code public?

woeful hill
#

my system only have 1 view for handling the game tho

dusty violet
#

I'm not saying that it's not possible but I often ended up passing variables around. Let's say you have a button that shows a modal
you want to create a flow like this
click button -> show modal
submit modal -> disable all components in the message and send a confirmation ephemeral message with confirm / cancel
confirm -> proceed with other stuff
cancel -> confirmation message deletes itself and enables all components in the og message

#

this becomes a mess pretty easily

dusty violet
#

but when you're talking about multiple views knowing about each other it becomes cumbersome

woeful hill
#

the first step, does the message actually have anything else other than the button itself

#

cuz you can spawn a modal with InteractionResponse

dusty violet
#

yeah i often combine messages with embeds

#

yeye i know

#

the fact is that im building a pretty complex bot and ended up building my own UI library on top with a Model View presenter approach
i was wondering whether this is a common problem, maybe there are other libraries around

#

or I could share my own as soon as its battle tested

stark plank
opal vortex
#

on their discord client using dev tools

#

so make sure to reset it

vapid parcel
#

does self.check not work on interaction cmds? I have it setup, but its not working anymore. Just curious on how or why its broken.

#

this would be the code if you need it.

class Bot(commands.AutoShardedBot):
    def __init__(self, intents: discord.Intents) -> None:
        super().__init__(
            command_prefix="/",
            intents=intents,
            help_command=None,
            tree_cls=MentionTree,
            owner_ids=OWNER_IDS,
            chunk_guilds_at_startup=False,
        )
        self.tree: MentionTree

        @self.check
        async def global_check(interaction: discord.Interaction) -> bool:
            is_blacklisted_result = await is_blacklisted(
                interaction=interaction
            )
            if is_blacklisted_result:
                embed = ErrorEmbed(
                    title="Sorry...",
                    description="You are blacklisted from using this bot.",
                )
                embed.add_field(
                    name="Appeal",
                    value=f"You may appeal this decision by visiting our website and clicking [this link]({APPEAL_URL}). Please provide a detailed explanation of your situation.",
                    inline=False,
                )
                embed.add_field(
                    name="More Information",
                    value=f"If you think this is a mistake, please join our [support server]({BotData.SUPPORT_SERVER}).",
                    inline=False,
                )
                await interaction.response.send_message(
                    embed=embed, ephemeral=True
                )
                raise commands.CommandError("User is blacklisted.")
            return True```
brave niche
vapid parcel
#

Yeah i see that, I forgot abt that. Is there a way to do it for interaction?

brave niche
#

I think once you have an interaction happening you'd need to add any other logic you need directly in your function that's getting called, but I'm not a discord.py expert?

vapid parcel
#

Well its either they have another option or we make our custom decorator

#

We had to make a custom decorator for checking if a owner is running the cmd. Cuz they only do context n not interaction

brave niche
#

Hmm, there's an extension package called discord-py-interactions that looks like it has some tricks

vapid parcel
#

Yeah we just gonna make a decorator ig

#

Very stupid that dpy doesn't handle interactions a lot.

fast osprey
#

huh what. It absolutely does

#

interaction_check exists on the CommandTree, not the Bot itself

vapid parcel
#

Alr.

#

Well ty, check it out when I'm home

fast osprey
#

!d discord.app_commands.CommandTree.interaction_check

unkempt canyonBOT
#

await interaction_check(interaction, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

A global check to determine if an [`Interaction`](https://discordpy.readthedocs.io/en/stable/interactions/api.html#discord.Interaction) should be processed by the tree.

The default implementation returns True (all interactions are processed), but can be overridden if custom behaviour is desired.
brave niche
#

Aha, there you go.

#

It seemed funny that none of those functions wanted an Interaction arg

vapid parcel
#

Alr

vapid parcel
fast osprey
#

what is a mention tree?

vapid parcel
fast osprey
vapid parcel
#

?

fast osprey
#

You either subclass CommandTree and implement interaction_check in it, or use the @bot.tree.interaction_check decorator on the check

vapid parcel
fast osprey
#

huh

#

the whole point of a check is to check before you run the command

#

checking after you run the command doesn't really make any sense

vapid parcel
#

if that makes sense

fast osprey
#

does that really fire on autocompletes? You could always check the raw interaction data to find the interaction type

vapid parcel
#

Yes, it does trigger on autocompletes. It will return the error of Invalid Form Body and say its not valid as an option.

fast osprey
#

what's the full error and tb?

timber dragon
#

It shouldn't fire for autocomplete thonkG

hushed galleon
vapid parcel
#
    async def interaction_check(
        self, interaction: Interaction[ClientT], /
    ) -> bool:
        """Override the interaction check to handle blacklisted users."""
        if interaction.data:
            print(interaction.data)

        if await is_blacklisted(interaction):
            if not interaction.response.is_done():
                # if interaction.type not in {
                #     discord.InteractionType.application_command
                # }:
                #     return False
                embed = ErrorEmbed(
                    title="Sorry...",
                    description="You are blacklisted from using this bot.",
                )
                embed.add_field(
                    name="Appeal",
                    value=f"You may appeal this decision by visiting our website and clicking [this link]({APPEAL_URL}). Please provide a detailed explanation of your situation.",
                    inline=False,
                )
                embed.add_field(
                    name="More Information",
                    value=f"If you think this is a mistake, please join our [support server]({BotData.SUPPORT_SERVER}).",
                    inline=False,
                )
                await interaction.response.send_message(
                    embed=embed, ephemeral=True
                )
            return False
        return True```

Thats the code right.
#

Here is the error:

{'type': 1, 'options': [{'type': 1, 'options': [{'value': '', 'type': 3, 'name': 'tag', 'focused': True}], 'name': 'generate'}], 'name': 'sfw', 'id': '1309562961051914294'}
[2025-05-01 17:12:16] [ERROR   ] asyncio: Task exception was never retrieved
future: <Task finished name='CommandTree-invoker' coro=<CommandTree._from_interaction.<locals>.wrapper() done, defined at F:\python-projects\Disutils-Team\PrivateEyes-NSFW\.venv\Lib\site-packages\discord\app_commands\tree.py:1149> exception=HTTPException('400 Bad Request (error code: 50035): Invalid Form Body\nIn type: Value must be one of {8}.')>
Traceback (most recent call last):
  File "F:\python-projects\Disutils-Team\PrivateEyes-NSFW\.venv\Lib\site-packages\discord\app_commands\tree.py", line 1151, in wrapper
    await self._call(interaction)
  File "F:\python-projects\Disutils-Team\PrivateEyes-NSFW\.venv\Lib\site-packages\discord\app_commands\tree.py", line 1272, in _call
    if not await self.interaction_check(interaction):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "F:\python-projects\Disutils-Team\PrivateEyes-NSFW\core\mention_tree.py", line 84, in interaction_check
    await interaction.response.send_message(
  File "F:\python-projects\Disutils-Team\PrivateEyes-NSFW\.venv\Lib\site-packages\discord\interactions.py", line 1004, in send_message
    response = await adapter.create_interaction_response(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "F:\python-projects\Disutils-Team\PrivateEyes-NSFW\.venv\Lib\site-packages\discord\webhook\async_.py", line 226, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In type: Value must be one of {8}.```
vapid parcel
#

Now what I have done is,

                if interaction.type not in {
                    discord.InteractionType.application_command
                }:
                    return False```

it will prevent that error from happening or showing up.
#

Now I have no CLUE if that is the correct way of doing it. But thats what I am doing currently

hushed galleon
vapid parcel
timber dragon
#
if interaction.type is discord.InteractionType.autocomplete:
    return True

...
#

But you do want to let the autocomplete interaction through tho

vapid parcel
#

so yes, it would be returning True, then handling the Blacklist interaction.

#

You were right mb

vapid parcel
jaunty cape
#

What even is a command tree

#

I just do @app_commands.commands

timber dragon
#

You can add checks to the autocomplete callback using the check decorator.. not sure why it's still calling the global check as the autocomplete interaction is basically useless

vapid parcel
#

Even if they do an autocomplete option, it will still return False for them if they are Blacklisted, then sends the embed and I am good.

#

thank you guys for the help. I am used to Hybrid cmds vs just straight interaction. So still getting used to Interaction cmds.

timber dragon
# jaunty cape I just do @app_commands.commands

That still adds them to the tree at bot.tree upon adding the cog lol

The CommandTree basically holds all your application commands (slash, context). Subclassing it allows you to implement things like a global check (interaction_check) or an error handler (on_error).

vapid parcel
#

we have a whole subclass for it. Its actually nice.

timber dragon
#

Yup

dusk pelican
#

hello, I am learning python. What is a discord bot?

vapid parcel
dusk pelican
jaunty cape
vapid parcel
#

Now, should I only be doing checks on the autocomplete, or should I do all? Just incase?

stark ingot
dusk pelican
#

I looked on the web and there is a documentation on the official discord webpage how to make a automated discord user

stark ingot
#

Yes, if you are learning python though you should probably not use the raw API as descibed in the discord api docs. Rather, finish learning the basics of python then choose an api wrapper library

dusk pelican
stark ingot
#

Yes, all of the API requests are abstracted into a python module instead of you having to call https://discord.com/api/v10/guilds yourself for example

dusk pelican
stark ingot
#

Yeah, I have never looked into the gateway closely but libraries will handle that for you as well

fast osprey
#

All of these libraries are open source too so you can poke in if you want to see how they implement that

stark ingot
#

My #1 bit of advice is do not follow any of the tutorials that you find when searching for "python discord bot tutorial". Only use tutorials that are recommended by the library you choose

young dagger
atomic otter
#

I don't know how to set this up properly. I'm trying to make a cog file so that I can upload this bot for Discord on a free hosting server on render.com.

#

ModuleNotFoundError: No module named 'cogs'

timber dragon
#

Full trackback?

jaunty cape
#

Anyways good night I can’t help much here