#discord-bots

1 messages · Page 405 of 1

oblique laurel
#

still under-development but i'd like your opinions :33

unreal owl
#

Is there a way to get if a player ran a command from another bot? (listener)

unreal owl
sick birch
#

You could use sockets or a standalone message broker/queue

unreal owl
fast osprey
#

Interactions are sent directly to the bot. If you are interested in integrating with someone else's bot, you should contact them to establish a reliable api for doing so

oblique laurel
#

Idrk about bots much cuz I’m new to this type of stuff so. 🤔

stark ingot
fast osprey
#

This assumes that the other bot responds non-ephemerally, that it continues to do so, and that the structure/name/id of the command doesn't change

novel quest
#

What's the best way to learn discord.py package cuz yt tutorials so outdated

wanton current
#

reading the docs and examples

#

looking at code

#

and asking for help when ur stuck

#

either here or preferably in the d.py server

glad cradle
#

there's also a good guide around

vapid parcel
#

is there a way to upload images to the emoji area for the bot, through the bot?

#

idk if that makes any sense, but someone will understand hopefully lol

quick gust
#

Which library?

#

!d discord.ext.commands.Bot.create_application_emoji if dpy

unkempt canyonBOT
#

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

Create an emoji for the current application.

New in version 2.5.
quick gust
#

Doesn't exist yet for disnake

vapid parcel
#

yeah, i only use dpy

sterile eagle
#

how can i make a terminal discord client with discord.py-self that i can view my DMS, group chats and also send messages on them on terminal without using the discord app

fast osprey
#

This is against tos

naive briar
#

Why though

#

-# why would they make that, I mean

sick birch
#

always wanted to make a TUI client like that but discord is mean

timber dragon
#

why would you ask about that here

mental forge
#

Is this an area to test discord bots

tender bobcat
#

no

mental forge
#

Ok

tender bobcat
#

For questions and discussions relating to Discord bot development with discord.py and other relevant Python libraries.
To test discord bot, go to your own server :)

mental forge
tender bobcat
#

It would make the server inherently unsafe if bot were allowed
E.g. automod would be bypassed for bot, can perform more action in rapid succession etc.

#

Can also malicious purpose like message listener and store in database for idk what usage

hard fern
#

Yo @ancient temple, you receive my email?

#

Also, please dm me.

mental forge
#

How do I get the token

#

Where do I find the token?

fast osprey
#

What do you mean by the token

mental forge
fast osprey
#

Have you followed your library's getting started guide?

mental forge
#

yes i have the code all typed up and that line uses a token

fast osprey
#

What guide are you using

mental forge
mental forge
#

Token collected

quaint solstice
#

how should i name this tool

timber dragon
#

"Webhook Manager" maybe?

last cradle
#

this python bot has the option to show the users decoration on the avatar command how

#

also how to get the primary and accent of a nitro user

stark ingot
woeful hill
pure sequoia
#

!e import antigravity

unkempt canyonBOT
viscid hornet
#

what

viscid hornet
paper monolith
#

i dont understand something in making bots

#

can someone help

sick birch
paper monolith
pale zenith
#

If you need help, you need to ask for it. We aren't mind-readers so unless you tell us what you don't understand, we aren't going to be able to help you.

paper monolith
#

i dont understand how to make the bot i tried using discord.py in visual studio code but like idk

paper monolith
#

i really dont understand anything here

#

in that site

timber dragon
stark ingot
#

Discord bots are not a good first project for beginners. You should have a good understanding of the foundations of programming and preferably some knowledge of OOP concepts

frank osprey
#

^^oh and if you think after reading that you still want to ? well take it from me who did it and now im burned out and really struggling getting back in to python dont do it.

tepid comet
#

!e
while True:
print(hi)

unkempt canyonBOT
# tepid comet !e while True: print(hi)

:x: Your 3.12 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 2, in <module>
003 |     print(hi)
004 |           ^^
005 | NameError: name 'hi' is not defined
tepid comet
#

ops

#

!e
while True:
print('hi')

unkempt canyonBOT
# tepid comet !e while True: print('hi')

:x: Your 3.12 eval job has completed with return code 143 (SIGTERM).

001 | hi
002 | hi
003 | hi
004 | hi
005 | hi
006 | hi
007 | hi
008 | hi
009 | hi
010 | hi
... (truncated - too many lines)

Full output: too long to upload

timber dragon
#

Nice try

lapis lintel
#

How should I implement a webpage for my bot's settings? Post to a webhook the user settings to the bot? check the db for user settings on demand?

sick birch
tight obsidian
last cradle
#

how to go about making commands that convert a video to a audio file and making a image transparent

#

no asking to be spoonfeed

timber dragon
tight obsidian
#

(a 🦆 is a single Unicode codepoint, but two UTF-16 units)

timber dragon
#

Hm. I guess it's counted differently inside codeblocks

#

2000 ducks as plain text works fine

#

I never really questioned it shrug

tight obsidian
#

When I try pasting 2000 ducks in a plain message, Discord just freezes

timber dragon
#

🦆*2000

#

Works fine lol

tight obsidian
#

maybe let's not spam in this channel

timber dragon
#

Ome duck counts as 2 chars apparently

tight obsidian
#

(maybe you have nitro, hence the 4000 character limit)

timber dragon
#

Oh yeah

#

But I did the same thing via a bot

slate swan
#

Hello

unkempt canyonBOT
#
Virtual environments

Virtual environments are isolated Python environments, which make it easier to keep your system clean and manage dependencies. By default, when activated, only libraries and scripts installed in the virtual environment are accessible, preventing cross-project dependency conflicts, and allowing easy isolation of requirements.

To create a new virtual environment, you can use the standard library venv module: python3 -m venv .venv (replace python3 with python or py on Windows)

Then, to activate the new virtual environment:

Windows (PowerShell): .venv\Scripts\Activate.ps1
or (Command Prompt): .venv\Scripts\activate.bat
MacOS / Linux (Bash): source .venv/bin/activate

Packages can then be installed to the virtual environment using pip, as normal.

For more information, take a read of the documentation. If you run code through your editor, check its documentation on how to make it use your virtual environment. For example, see the VSCode or PyCharm docs.

Tools such as poetry and pipenv can manage the creation of virtual environments as well as project dependencies, making packaging and installing your project easier.

Note: When using PowerShell in Windows, you may need to change the execution policy first. This is only required once per user:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
fast osprey
#

Converting files isn't at all discord related

unkempt canyonBOT
#

Please react with ✅ to upload your file(s) to our paste bin, which is more accessible for some users.

silent olive
#

hey guys

#

I have a question im using visual studio code

#

my run button isn’t there anymore and im not sure what I should do

bright oasis
brave niche
#

Also does hitting F5 work?

silent olive
#

Lemme try

#

my f5 button is the mute button

brave niche
#

Function-F5 on your keyboard then perhaps?

#

F5 is 'run in debugger' by default in VS

silent olive
#

im new to coding

brave niche
#

Welcome to the jungle!

silent olive
#

thanks

#

I think it’s bc I downloaded the jupyter notebook

#

and then I deleted it then that’s when the runner got deleted

fast osprey
shell sinew
#

helloo i am super new to coding, and I am trying to connect my discord bot to my code on virtual studio code and for some reason it is giving me a syntax error when i ran python3 with the name on the file in my terminal

viscid hornet
#

and that makes me think you're probably not equipped enough to make a discord bot

shell sinew
shell sinew
viscid hornet
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.

viscid hornet
#

discord bots require some relatively advanced concepts (stuff like OOP, async programming, etc)

#

they are not intended for beginners

#

!projects - a few of these are, so i recommend those instead

unkempt canyonBOT
#
Kindling Projects

The Kindling projects page on Ned Batchelder's website contains a list of projects and ideas programmers can tackle to build their skills and knowledge.

shell sinew
#

ahhh true true but i think i could probably figure it out over time, ill do those in the meantime to learn as i do the bot as well, i have some friends helping me as well but they are busy so i sought out help here, thank you tho!! i

viscid hornet
#

no problem

#

if you ever get stuck,
feel free to make a help post

tender bobcat
#

Also for reference, the package I referenced there is certifi
But I don't think it install that either

rapid knoll
#

is there an event for when somone boots your discord server?

fast osprey
#

Nope

tender bobcat
#

Messages/role change listener? For announcement message/booster role

stark ingot
#

^^
Not 100% accurate as you might not have those things set up. But this seems like a case that it is the users fault if they don't have it set up, not the bots fault

fast osprey
#

You can listen for the system message, this is brittle and will give you false negatives. I have yet to see a use case for this that isn't just repeating what discord does but with cuter language

velvet jolt
#

Guys, I need help. I use wispbyte.com to host my discord bot, and I deleted a server there that has the code scripts of the bot, they contain slash commands, after i deleted the server, the slash commands are still there appearing when I type '/', any way to remove them?

woeful hill
#

You need to sync again to notify discord these dont exist anymore

stark ingot
fast osprey
#

I'm entitled to my opinion, as you are yours. Nobody is claiming tos or that people can't do things

#

Feel free to make your case of what the use cases are that aren't met, but trying to systemically shut me up isn't really a good look

tender bobcat
fast osprey
#

discord automatically grants and removes the booster role in the server settings

tender bobcat
#

Might just be my phone app ig

#

(I mean changing the role)

fast osprey
#

as in changing the role that's given/removed?

tender bobcat
#

Yes

#

If it exist, then have to check if bot can see which role is booster role

fast osprey
#

What are you trying to accomplish with your bot?

tender bobcat
unkempt canyonBOT
#
Available tags

» f-strings
» faq
» floats
» foo
» for-else
» fstring
» fstrings
» functions-are-objects
» global
» guilds
» identity
» if-name-main
» in-place
» indent
» inline

elder geyser
#

hello i keep getting
log(logging.WARNING, "Command", "Update command failed: No embed to update.") File "/home/container/bot/mtg_cogs/cog_mtg_manager.py", line 16, in MtgEmbedManager self, ctx: discord.Interaction, content: app_commands.Option(str, description="The initial embed content.")): ^^^^^^^^^^^^^^^^^^^ AttributeError: module 'discord.app_commands' has no attribute 'Option'

#

i have app_commands imported though

#

and yes ive tried ai to fix but that dumb thing cant fix it either

fast osprey
#

What library are you using?

brave niche
elder geyser
#

import discord
from discord.ext import commands
import logging
from bot.common.utils import log
import bot.common.mtg_database as db
import os
from discord import app_commands

brave niche
#

Maybe you want “choices”? Not sure, haven’t used this lib

fast osprey
stark ingot
brave niche
elder geyser
fast osprey
#

What library (and version) do you have installed

elder geyser
fast osprey
#

yeah

elder geyser
#

I have 2.5.2

fast osprey
#

of what library

elder geyser
#

idk wym

#

discord and discord ext

fast osprey
#

discord ext isn't a library what

#

discord is a mirror of discord.py though

#

Anywho, what are you trying to accomplish? This isn't how you do things in discord.py

elder geyser
#

main.py loads cogs in other directories, this is a cog that is supposed to create an embed in a specified channel then let me edit the embed from a second command

fast osprey
#

specifically what you're trying to do with option

elder geyser
#

it's in the command to give me the option to put content into the embed as well as create the embed

#

it has a database to store the message Id and channel ID

#

if u want I can give access on sparked host if you wanna look at it fully

fast osprey
#

are you just trying to declare a string parameter?

elder geyser
#

basically but I want it to show as an option

fast osprey
#

what do you mean by "as an option"

elder geyser
#

@app_commands.command(name="update_mtg_embed", description="Updates the persistent MTG embed.") @app_commands.guilds(discord.Object(id=int(os.getenv("GUILD_ID")))) async def update_mtg_embed( self, ctx: discord.Interaction, new_content: app_commands.Option(str, description="The new embed content.") ):

#

this is where it is being used

fast osprey
#

It's unclear what you're trying to do, in discord, that the user would see

brave niche
#

So you’re trying to prompt the user for a parameter named “new_content”?

elder geyser
#

but instead

#

whats shown above

elder geyser
# brave niche So you’re trying to prompt the user for a parameter named “new_content”?

im just trying to have it create the embed with this: @app_commands.command(name="create_mtg_embed", description="Creates a persistent MTG embed.")
@app_commands.guilds(discord.Object(id=int(os.getenv("GUILD_ID"))))
async def create_mtg_embed(
self, ctx: discord.Interaction, content: app_commands.Option(str, description="The initial embed content.")):
embed = discord.Embed(title="Persistent MTG Embed", description=content)
await ctx.response.send_message(embed=embed, wait=True) # Use ctx.response
db.store_ids(ctx.channel_id, ctx.channel_id)
await ctx.response.send_message("Embed created and IDs stored.", ephemeral=True) # Use ctx.response
log(logging.INFO, "Command", f"Embed created in channel {ctx.channel.id} with message ID from interaction")
where it asks for channel then stores message id and channel ID

#

then have the command before that edit it '

fast osprey
#

What do you want the user to input

elder geyser
#

for which one?

#

for create i want the channel id

fast osprey
#

You have one parameter

elder geyser
#

for the edit i just want it to edit the embed with what they type

fast osprey
#

called content

#

You want them to just type a string, like I asked earlier?

elder geyser
#

a string that goes into an embed

#

first command i want a channel

fast osprey
#

What you do with the parameter is irrelevant

#

you're having an issue just declaring the parameter

#

If you want the user to input a string, just typehint the parameter with str

#

nothing fancy, no Option or whatever

elder geyser
#

ok and what abt the channel ID one?

fast osprey
#

I have no idea what you're talking about

elder geyser
#

i want /create_mtg_embed (insert channel)

fast osprey
#

You want the user to specify a channel in the current guild?

elder geyser
#

then /update_mtg_embed (string)

fast osprey
#

What kind of channel?

elder geyser
#

normal text channel

fast osprey
#

Then you can typehint with discord.TextChannel

elder geyser
rapid knoll
#

I know discord has a form app like feature that discord bots can use, is there a way to use it in discord.py and if so whats the module for it or is it unavailable?

woeful hill
#

you meant modal?

rapid knoll
woeful hill
#

official example

rapid knoll
#

oh yeah another thing slightly off topic from what I asked but for some reason things like app_commands and ui dont show up in the list of modules. but I have latest version, is that just an editor bug or did I do something wrong

languid jungle
rapid knoll
#

oh and I have discord.py-message-components~=1.7.5.4 this installed too, I feel like this is the issue, but I wanted to ask before doing anything.

woeful hill
#

Likely

#

Can you do pip freeze

rapid knoll
#

ok I got it working discord.py-message-components uses an older version of discord.py and it replaces a bunch of stuff with its own stuff so I am now using a venv for my project and it all works now.

hearty basalt
#

t

jolly geyser
#

I find it interesting because many things that discord api provides requires authorization

fast osprey
#

Rather than us speculate what other devs are doing, have you tried asking them?

#

The discord api is pretty well documented, and while it does require authorization I'm not sure how that's relevant here unless you're assuming that they aren't authorizing

jolly geyser
#

Discord bot dev requires some interaction with the api ¯_(ツ)_/¯

jolly geyser
fast osprey
#

(however, the creation date of any snowflake id is baked into the snowflake itself)

jolly geyser
#

Yeah I was thinking to either find a way to get creation date via api or just reverse the snowflake id somehow

fast osprey
jolly geyser
#

I just wanted to know if it's possible to get creation date via api
And now I know it's not!
Looks like it's time to reverse the snowflake!!
I saw in discord api docs how the snowflake is generated etc.

#

Anyway that's all
Thank you very much and have a great time!

fast osprey
#

good luck 👍

jolly geyser
#

Thanks!

tender bobcat
jolly geyser
tender bobcat
#

The point is discord don't expect people to need it because it's literally in the id itself, which you would have or already have pithink

jolly geyser
#

yep

south shell
south shell
#

i dont even know if i'm allowed to tell you the api request

jolly geyser
#

oh

#

How does it even work by the way?

south shell
#

you mimic

jolly geyser
#

you mimic what? discord api?

south shell
#

discord api request

jolly geyser
#

so you mean spoofing?

south shell
#

just copying and if you do it with discord token i think its selfbot and with discord bot is user impersonation whioch is also bannable

jolly geyser
#

oh that

#

I already did that

jolly geyser
south shell
#

just forbidden

jolly geyser
#

I know what you mean now

south shell
#

as i look rn, discord does not give out the thing in the api and must ysue the snowflakes aswell

jolly geyser
#

link?

south shell
jolly geyser
#

oh you mean that
I though you were looking through docs

jolly geyser
south shell
#

not a flex

jolly geyser
#

I was messing with the api, did every possible thing I could and it ended up with ban

south shell
fast osprey
#

What are you all on about. This is a simple one line bit of math on the id. I even already linked the code to it

south shell
#

timestamp = (ID>> 22) + 1420070400000

jolly geyser
fast osprey
#

You shouldn't even want to use the api. Why would you want to wait for a network call when you already have the code written for you and it's instant

jolly geyser
south shell
jolly geyser
south shell
#

yes, that discord private api

#

need either bot token but could be considered

south shell
#

human impersonation

#

or account token and could be considered selfbot

tender bobcat
#

!rule 5 why we have discussion of self bot and why it even matter lmao

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.

jolly geyser
south shell
south shell
#

i think when discord ban a bot it ban the account

jolly geyser
jolly geyser
#

oh wait, yes yes

#

I remember I was fixing a bug in my discord bot, it was some kind of entertainment bot that I made for some people. it started spamming because I called a function inside a loop. and got my acccount banned, that was my second ban

#

since then I stopped developing such bots

#

ok enough bots and apis, and stuff against tos
math wins!!

fast osprey
flint cipher
#

hello i dont understand whats wrong with the code

fast osprey
#

You should reset your token

blissful crane
flint cipher
#

NOOOOO

#

sSHIT I FORGOT TO BLUR IT

blissful crane
#

it's fine bruh, just reset it

stark ingot
flint cipher
flint cipher
#

i reset it and it tells me that its not good

#

i pasted it into the code too

blissful crane
#

did you save the file?

flint cipher
#

what file

blissful crane
#

the file you're coding in

flint cipher
#

oh i didnt

#

ah yes working now

#

thx

fast osprey
#

Strongly consider putting your token in a separate config file so you don't have to remember to blur it out when sharing your logic

south shell
fast osprey
#

You're severely misusing "undocumented" here

#

It's not undocumented because they didn't feel like it, it's undocumented because they have specifically told you not to use it with automation

south shell
#

still undocumented

fast osprey
#

That is a misleading term to use

brave niche
#

"internal API" sounds more-correct to me

viscid hornet
south shell
#

idk either

jolly geyser
#

e.g.

{
  "username": "username",
  "discriminator": 0,
  "avatar:": "0123456789abcdefdeadbeef"
}
#

ok this is it from me
I do not want to continue talking about something that could be against ToS and/or server rules.

stark ingot
#

I am pretty sure you can get it without breaking TOS, i dont know why that user even brought it up

jolly geyser
#

guilds is mostly for servers, while api is for everything else

#

also if anyone here thinks that I shouldn't talk about those URLs
it's very well documented in discord documentation

stark ingot
jolly geyser
timber dragon
#

some users seem to think that anything that isn't supported by bots == userbot/bad/undocumented

slate swan
#

if you find any duplicates lmk ❤️

fast osprey
#

Are you looking for feedback or just sharing? There are several commands here if implemented as described are either harmful or violate TOS

tender bobcat
slate swan
fast osprey
#

I'd encourage folks looking over this list to think critically about the implications of some of these and to review the tos they have agreed to

tender bobcat
#

8, 350 name conflict

slate swan
fast osprey
#

I'm not sure why you'd put a disclaimer for things that violate the tos instead of just removing them

tender bobcat
#

purge duplicate

#

music potentially duplicates

#

I am done with checking this because probably ai gen anyway
Not worth the time

tender bobcat
fast osprey
#

Right, so you're fine with making recommendations that people could follow and get banned for and you don't care. Neat

tender bobcat
#

!rule ai sound appropriate for this rulepithink

unkempt canyonBOT
#

10. Do not copy and paste answers from ChatGPT or similar AI tools.

slate swan
fast osprey
#

Then maybe take it down and don't share it with people until you've done your due diligence

tender bobcat
#

There is a simpler solution: remove the link from the channelpithink

fast osprey
#

It's not a problem to make a mistake, it's a problem to be confronted with that mistake and dig your heels in when it can cause harm to others

slate swan
tender bobcat
#

Well clearly you are suggesting people to use your command list, which contain ToS breaking command

#

So don't post it here if it contain ToS breaking command?

south shell
#

People do whatever they want with there bot even if forbidden tho

#

He never said "make them"

tender bobcat
#

In the process of searching a moderator...

fast osprey
#

Just because you aren't going to their house and holding them at gunpoint to make these commands doesnt mean you don't hold responsibility for misleading people into losing their accounts (or harming their users with security flaws). You may have been unaware of that previously, which is fine, but now you are not unaware

tender bobcat
#

I mean pretty sure it's a form of providing help, passively

#

!rule 5 therefore

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.

south shell
#

But well

tender bobcat
#

I didn't even reply to you lmao

south shell
tender bobcat
#

Time to block one more person ig

south shell
#

Modified, by response is the cool dog sticker under

fast osprey
#

It's not something to freak out about, it's their call if they don't want to engage. Just worth mentioning when you see folks discussing things like that

south shell
tender bobcat
south shell
#

Poor moxxie and millie

south shell
timber dragon
slate swan
#

nvm they dont

slate swan
timber dragon
#

Oh nice

south shell
#

because of my bored ass i'll make all of them in a working bot

#

is your repo updated already?

#

you should maybe add "explanation" for each command

last cradle
#

where to find the badges for public flags/available badges

fast osprey
#

It's all documented in the relevant section in discord's docs

#

The wrapper library you're using should have it as well

stark ingot
stark ingot
stark ingot
last cradle
#

tyyyy

azure yew
#
@app_commands.command(name="ping", description="Ping the bot's shard.")
@app_commands.user_install()
@app_commands.guild_install()```

```AttributeError: module 'discord.app_commands' has no attribute 'user_install'```

istg i have tried everything but i cant get this to work 😭
brave niche
#

You're not saving the 'command' return value anywhere, I would have expected that to be what has 'user_install()' on it? Haven't used this library, sorry

fast osprey
#

Can you show the output of pip freeze on your environment

azure yew
# fast osprey Can you show the output of `pip freeze` on your environment
aiohttp==3.11.14
aiosignal==1.3.2
altgraph==0.17.4
annotated-types==0.7.0
anyio==4.9.0
asyncio==3.4.3
attrs==25.3.0
audioop-lts==0.2.1
beautifulsoup4==4.13.3
blinker==1.9.0
cachetools==5.5.2
certifi==2025.1.31
cffi==1.17.1
charset-normalizer==3.4.1
click==8.1.8
colorama==0.4.6
comtypes==1.4.10
DateTime==5.5
discord==2.3.2
discord.py==2.3.2
distro==1.9.0
dotenv==0.9.9
duckduckgo_search==7.5.5
exceptiongroup==1.2.2
ffmpeg==1.4
Flask==3.1.0
frozenlist==1.5.0
google-api-core==2.24.2
google-auth==2.38.0
google-cloud-vision==3.10.1
google-genai==1.8.0
googleapis-common-protos==1.69.2
groq==0.20.0
grpcio==1.71.0
grpcio-status==1.71.0
gTTS==2.5.4
h11==0.14.0
httpcore==1.0.7
httpx==0.28.1
httpx-ws==0.7.2
idna==3.10
itsdangerous==2.2.0
Jinja2==3.1.6
jiter==0.9.0
langdetect==1.0.9
lmstudio==1.2.0
logging==0.4.9.6
lxml==5.3.1
lyricsgenius==3.3.1
MarkupSafe==3.0.2
msgspec==0.19.0
multidict==6.2.0
mysql==0.0.3
mysql-connector-python==9.2.0
mysqlclient==2.2.7
openai==1.68.2
packaging==24.2
pefile==2023.2.7
pillow==11.1.0
primp==0.14.0
propcache==0.3.0
proto-plus==1.26.1
protobuf==5.29.4
psutil==7.0.0
py-dotenv==0.1
pyasn1==0.6.1
pyasn1_modules==0.4.1
pycparser==2.22
pydantic==2.10.6
pydantic_core==2.27.2
pygame==2.6.1
pyinstaller==6.12.0
pyinstaller-hooks-contrib==2025.2
PyNaCl==1.5.0
pynput==1.8.1
pypiwin32==223
python-dotenv==1.0.0
pyttsx3==2.98
pytz==2025.1
pywin32==310
pywin32-ctypes==0.2.3
PyYAML==6.0.2
requests==2.32.3
rsa==4.9
setuptools==77.0.3
six==1.17.0
sniffio==1.3.1
soupsieve==2.6
tk==0.1.0
tqdm==4.67.1
typing_extensions==4.12.2
urllib3==2.3.0
websockets==15.0.1
Werkzeug==3.1.3
wsproto==1.2.0
yarl==1.18.3
youtube-dl==2021.12.17
yt-dlp==2025.3.26
zope.interface==7.2```
#

oh for fucks sake

#

i see now great

azure yew
#

guys

#

in discord.py i have input as "@distant pawn" how do i replace this with the pinged user's username?

fast osprey
#

What do you mean by "input"?

azure yew
#

for example i ping myself the input is: @azure yew

#

i want to use a input.replace() to replace this with the displayname

#

but have it use regex or smth so it works with everyone

blissful crane
#

use re.sub

azure yew
blissful crane
#

!d re.sub

unkempt canyonBOT
#

re.sub(pattern, repl, string, count=0, flags=0)```
Return the string obtained by replacing the leftmost non-overlapping occurrences of *pattern* in *string* by the replacement *repl*. If the pattern isn’t found, *string* is returned unchanged. *repl* can be a string or a function; if it is a string, any backslash escapes in it are processed. That is, `n` is converted to a single newline character, `r` is converted to a carriage return, and so forth. Unknown escapes of ASCII letters are reserved for future use and treated as errors. Other unknown escapes such as `&` are left alone. Backreferences, such as `6`, are replaced with the substring matched by group 6 in the pattern. For example:
fast osprey
#

You shouldn't need to regex, you can use the mentions property on the message

#

though I really suggest you make a slash command instead

azure yew
#

how is that relevant

#

its an on_message to AI API

#

and it just sees the @orchid dock string

fast osprey
#

What AI?

azure yew
#

gemini 2.0 flash

#

from google

fast osprey
#

It is against tos to train ai on message content

azure yew
#

its not storing anything

fast osprey
#

And how are you guaranteeing that

azure yew
#

by seeing what google says about it

#

they claim it doesnt train

#

atleast the version im using

fast osprey
#

Paid version? Are users consenting to you sending their data to a third party?

azure yew
#

its an api??

#

legit every bot does this? what are you saying??

fast osprey
#

My bot doesn't do this

azure yew
#

so you are saying your bot uses no api's at all? that seems hard to believe

fast osprey
#

My bot doesn't send user data to third parties

azure yew
#

cool so explain to me how all those other AI bots arent getting banned?

fast osprey
#

Other people getting away with things doesn't mean you get to

#

or that it's acceptable to do

azure yew
#

opinions be opinions ig

fast osprey
#

It's not an opinion

azure yew
#

its not training on user data discord doesnt have a problem with it

fast osprey
#

this is a rule of this server

#

discord does have a problem if you are sending user data to third parties without recording their explicit consent

azure yew
#

their consent is adding the bot to the server and enabling the ai function

fast osprey
#

That isn't consent

#

server owners can't consent on behalf of individual users

azure yew
#

and enabling the ai function

#

this is a great first impression of the discord, i joined to ask a question because i needed help with someone and someone goes bitching about "wahhh you cant do this " and when i say its not doing what you say you contine, im outta here have fun!

fast osprey
#

👋

jaunty cape
#

Bro wtf is this conversation

stark pulsar
jaunty cape
fast osprey
#

if it's just general aiohttp calls, probably just a post in the help forum

#

The general examples in the aiohttp docs are good

jaunty cape
#

Mhm

#

Ok thanks man

fast osprey
tender bobcat
fast osprey
#

I didn't say they did. I even asked if they had the paid service or not

rocky stag
#

guys how can i hot my discord bot 24/7 for free ?

tender bobcat
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.

timber dragon
tender bobcat
#

Basically you cannot

tender bobcat
timber dragon
#

lol

tender bobcat
#

Hmm, can the bot not read message snapshot sourcepithink

tender bobcat
# rocky stag i was just asking

The answer is no because no one wants to pay for these for free and people just turn those machines into crypto miners if they were to ever exist

grave sandal
#

never a dull moment in this channel

timber dragon
#

I wonder if you can host something on a samsung smart fridge

glad cradle
finite salmon
#

i bet someone's already ported doom on a samsung smart fridge so hosting something on it shouldnt be impossible

wise mica
pulsar scarab
#

hey all im actually not sure if i can post / ask here, but uhm Im looking for a probot ish bot for my server , mainly that has a auto response option. Where u can put a command such as : " omw " , that wil trigger random chosen GIFs. Probot is down sadly, and after looking on the net its said that Python has a similar feature? So im here wondering how that works and if thats the case? My apologies in advance, if this isnt the right place for asking

brave niche
fast osprey
#

This channel is specifically for development of bots and presupposes you have the necessary skills. If you're looking for existing bots, there are better places.

You would have to implement this yourself, there's nothing out of the box in these libraries which does this

pulsar scarab
fast osprey
#

Best of luck on your search then

brave niche
#

Check out AxisBot or Carlbot maybe? Just from a quick google

spice carbon
#

how do yall typically structure your discord bots code

sick birch
#

this reminds me that i should migrate to uv for my template

stark ingot
#

Could you be a bit more specific?
I generally have a main.py and then a cogs folder with my commands, and other folders with my utility functions. I probably should put all of that stuff in a "bot" folder

#

Some people like to put their views and components in separate files but I personally like to keep them near where they are used

fast osprey
#

Yeah project structure is an incredibly opinionated and subjective topic. As long as you aren't introducing circular dependencies and you can quickly search for the thing you want, it doesn't really matter. This is something I prefer to evolve organically if (and only if) I ever run into tangible issues rather than trying to preemptively optimize

spice carbon
#

thing is: i got involved in a youtubers community and the server is relatively big, they got ~2.5k members and i got tasked with the task to create a bot for them. i am a hobbyist and never maintained a big codebase which this projects aims to be, so i am kinda lost here... which stack should i use, how do i keep myself organized and keep it manitanable by others aswell? ive created plenty of bots before but idk maybe its just the pressure thats making me overthink?

#

been programming for a whole lotta of time aswell, 3-4 years iirc

fast osprey
#

A well organized code base that doesn't do anything is worthless compared to a messy code base that actually creates value

#

if you spend too much time preemptively optimizing, you push your feedback loop further back

wanton current
#

there's nothing bad about organizing your codebsae

fast osprey
#

Didn't say it was bad, just that people waste a lot of time agonizing about how long their file is or how many vowels are in their class name while their users get bored and leave

wanton current
#

true

#

i'd just make some simple folders to sort correlated files like cogs, utils, etc.

fast osprey
#

Moving things around is easy

#

Losing opportunity cost because you weren't building the right thing, or worse yet losing your user base, is what's expensive. I prefer to keep things as simple as possible and rearchitect when there's an actual need. Refactoring isn't fun, it feels frustrating, but the alternative is worse imo

#

You make a one file bot, it looks like crap, but then you find out people actually didn't want the functionality in the first place. No harm done

spice carbon
#

thats wise lol

#

thanks

last cradle
#

is there anyway to determine if a user has nitro other than if there pfp is animated, if they have a banner or status contains a animated or custom emote?

#

also can u determine if they have boosted a server

merry cliff
#

oh this is new

#

you could try this property

fast osprey
#

Discord doesn't tell you if they have nitro. This is by design.

#

Any approaches are merely guesses and will give you either false positives or false negatives

young dagger
brave niche
#

You can buy a boost without having Nitro too though right?

young dagger
#

Mhm

jolly geyser
#

hello again

#

I have been here a couple days ago when I had some questions about discord user creation date, which can be extracted from ID.
I did it by doing (id >> 22) + discord epoch. I could even get the creation date from my discord token, tokens are made of three parts, base64 encoded id, base64url encoded timestamp, and the last part is just HMAC. then I wondered is it possible to reverse that second part of the token.
I tried by doing it in reverse, timestamp - epoch -> hex and then base64url encode
and didn't get exatcly the same, let's say my 2nd part of token is AbC-L and then if I reverse the process to encode it myself I would get AbC-A, why is that?
If I try to extract timestamp and other things from ID, I don't get the same as what I would get when I decode the token part. something's missing.

Does anyone here know better? I tried even with bot token,it's the same.

#

anyway, based on this, looks like discord tokens are almost just public information, the first two parts are just id and timestamp, while the last one is the critical one actually.

#

Good night

#

oh also, I forgot to mention, I was also playing with the token in this picture, and based on the numbers that are already written, I could reverse the process easily and get the exact results.

fast osprey
#

Why are you trying to manipulate tokens in the first place

midnight oracle
#

spicy

sick birch
fierce shoal
#

hey if any discord developers are trying to work on a discord boost related project please message me

full ether
#

you should further elaborate on what

a discord boost related project
means

fierce shoal
#

a discord boost bot with features like : automated boosts with sellauth and other common discord provider seller websites, boost multiple servers, tls spoofing, threading, a token checker, and much more

hearty basalt
#

defo not against ToS lmao

fast osprey
#

token checker

Want to elaborate where you're getting tokens from that you need to "check"?

fierce shoal
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.

tender bobcat
fast osprey
velvet solstice
#

I need help making a discord bot its really late for me so if anyone wants to help me out please dm me or put me in a ticket

woeful hill
#

Go fiverr if you want someone to code for you

#

In this server we help with your code

jolly geyser
# fast osprey Why are you trying to manipulate tokens in the first place

It looks interesting, and the way it works is interesting as well. Imagine it as lego bricks, you take one brick, and add details with other bricks, and you get a whole structure. And the second part of tokens puzzled me so I wanted to try to reverse it. I am just tinkering with that discord weirdness (offline of course, I don't want to do something against ToS)

fast osprey
#

If it's for curiosity go nuts, but you won't ever be making discord tokens yourself. It's helpful to describe your end goal with open ended questions like these (whether it's achieving a purpose or just understanding how something works for the fun of it) so the answers can be more tailored

grave sandal
fast osprey
#

Two separate threads, but yes I was trying to get them to admit that

#

Bro just rattled off a list of tos violations and then left 😂

charred estuary
#

Excuse me sir, I want to ask something. I'm currently using an RDP with Windows Server 2019, but when I try to run a Nextcord script, it gives an SSL error. What should I do about it, sir?

#

That's the error I'm getting, sir.

brave niche
#

Server has some fairly strict security defaults, any chance that's being blocked by the firewall settings?

charred estuary
brave niche
#

It SHOULD be in the Event Viewer, under uhh...

#

"Applications and Services Logs" > "Microsoft" > "Windows" > "Windows Firewall with Advanced Security" > "Firewall", I guess?

#

You might have to right-click on that and enable logging first, I can't remember if it's on by default

#

auditpol /set /subcategory:"Filtering Platform Packet Drop" /success:enable /failure:enable is apparently what you'd want to do to enable all the logging. I've always done it with the UI so I'm glad to learn that command.

charred estuary
brave niche
charred estuary
charred estuary
brave niche
#

You might need to run those two auditpol commands from a Command Prompt from that superuser.com link I dropped, I'd have to try it myself to be sure.

fast osprey
#

At this point it's not remotely python related

charred estuary
brave niche
#

Sure, open an administrator command prompt (one way is the WindowsKey-X, like right-clicking on the Start Menu)

#

Then run these two commands one after the other:
auditpol /set /subcategory:"Filtering Platform Packet Drop" /success:enable /failure:enable
and then
auditpol /set /subcategory:"Filtering Platform Connection" /success:enable /failure:enable

charred estuary
brave niche
#

When you're done later, you can reverse that by running these two:
auditpol /set /subcategory:"Filtering Platform Packet Drop" /success:disable /failure:disable
and
auditpol /set /subcategory:"Filtering Platform Connection" /success:disable /failure:disable

fast osprey
#

You could use that argument to do anything

#

"I have a discord bot that trades stocks, so in this channel help me with how stocks work"

#

I'd suggest getting help from windows/networking resources if it's a windows/networking issue

charred estuary
fast osprey
#

You're good, I'm not scolding you just suggesting that you go to places meant to help with the thing you're having the actual problem with

charred estuary
jolly geyser
charred estuary
fast osprey
#

I'm not a mod, I'm not saying you can't do anything

#

just that this isn't the place for windows server expertise

charred estuary
stark pulsar
#
        embed.add_field(
            name=f"{EMOJIS['CHAT']} **__Match Details__**",
            value=(
                f"Channel: {voice_channel.jump_url})\n"
                f"Partner: {user2.mention if user1.id != user2.id else user1.mention}\n"
                f"Started at {discord.utils.format_dt(datetime.now(), style='f')}"
            ),
            inline=False
        )

        embed.add_field(name="", value="\u200b", inline=False)
        
        embed.add_field(
            name=f"{EMOJIS['DISCONNECT']} **__Session End__**",
            value=(
                "> *The session will continue until someone leaves the channel.*\n"
                "> *When that happens, the remaining person will be moved back to the queue.*"
            ),
            inline=False
        )
        
        return embed```

embed.add_field(name="", value="\u200b", inline=False) is still causing too big of a gap, any suggestions? i can't use newlines since discord strips them which is annoying
brave niche
#

Does "\u2009" work interestingly differently?

stark ingot
#

I suggest putting everything in the description, that way you can put newlines between the text, which won't be stripped

vale anvil
#

does anyone know what the url format for the desktop app is (discord://) ? trying to add a link in an embed

viscid hornet
brave niche
viscid hornet
#

oh it opens the link with disord

#

thats kinda cool

brave niche
#

My last message got deleted, just in case that was for policy reasons I won't re-send it. Hmm.

#

(Pretty sure what I said was fine but you never know)

timber dragon
glad cradle
timber dragon
#

<protocol> instead of the full url works too in url buttons and text. Not sure about embeds.

smoky sinew
glad cradle
timber dragon
#

Hi mudkip

woeful hill
wheat summit
#

Hello! Does anyone know the command to edit a thread's name?

wise mica
#

in discord.py flags, is there a way to check if a flag is used without an argument?

shiny: bool = commands.flag(default=False, aliases=["sh"])

i have this bool that I want to be False (or None, doesnt really matter) as default, but if added to a command like --shiny without any arguments for it to then be True, without the user specifying it to be True

i also cant just check the message content for it since its also being added into the arguments of other flags when ran without an argument

fast osprey
#

There's probably a way to do this, but personally if your commands are getting complex enough to warrant flags I'd strongly recommend just migrating to slash commands. It's unambiguous to the user and vastly easier for them to fill out

wise mica
fast osprey
#

I see this a lot, people rolling over to stubborn users. Slash commands are the supported way to do this, they're better in pretty much every way and people only resist because they hate change. Up to you if you want to go out of your way writing messier code to end up with a worse experience

#

If you wanted to go ahead with this, you might need to look through what's available in the context. Though as a user, I'd find this frustrating and unintuitive if there were two different defaults

young dagger
limpid nexus
#

Hey folks, I'll start by saying this server is very useful: it's helped me a ton already!

Now, I have a huge issue: I've successfully embedded deepseek in my Discord bot, but holy moly if it's slow. 2 mins only for the reply to be "sorry I can't help".
How can I overcome this issue? I'm running it on my machine, and it clearly isn't the way to go. Where could I host the AI to get fast (not saying blazingly fast, but not more than 5 seconds, lol) responses? And how different would the implementation be from running it locally? I know nothing about this topic.

fast osprey
#

How are you "embedding" it?

limpid nexus
#

I might've used the wrong term? What I mean is that I'm using deepseek in my Discord bot.

#

Via Ollama.

fast osprey
#

But how?

limpid nexus
#

Do you want the API?
I am importing from the ollama library some packages (chat, ChatResponse, AsyncClient), defining an async function to ask the AI what the user asks (when an !ask command event is being fired) and send it back to the user in the channel.

fast osprey
#

You may wish to review the developer tos and policy

limpid nexus
#

What's up with it?

fast osprey
#

It is against policy to train models based on user message content (which it seems deepseek does), and it is against tos to send any user data to a third party without specifically getting the user's consent and publishing that in your privacy policy

limpid nexus
#

Lol.

#

Who even talked about training deepseek?

fast osprey
#

You talked about sending user data to deepseek. And a very cursory googling says that deepseek trains based on input

limpid nexus
#

I talked about sending the user message to deepseek.

fast osprey
#

That's exactly what I just said

limpid nexus
#

It's ran on my machine in any case.

#

What's the matter with it?

#

In the worst case it'd be collecting my data.

#

Isn't it the case?

fast osprey
#

If you can guarantee that no data goes to a third party and the model isn't being trained, you're fine

limpid nexus
#

And I believe that users are aware of what's happening, when they invoke a command to explicitly ask deepseek.

fast osprey
#

Being aware isn't consent

#

They also cannot consent to the training of models

limpid nexus
#

I don't think deepseek can get any data from users besides their messages, since it's all ran locally on my computer.

#

So I guess I'm safe.

fast osprey
#

Their messages are protected data

limpid nexus
#

Lol.

limpid nexus
#

Is this fr or you're trolling atp I don't know.

fast osprey
#

You can read the policy if you want to, which you should have already

limpid nexus
#

I don't think there's any violation going on.

stark ingot
limpid nexus
fast osprey
#

And again, it doesn't matter if there is consent or not, models cannot be trained based on user inputs period

limpid nexus
#

In the command description.

stark ingot
limpid nexus
#

Anyways, back to my question, lol.

fast osprey
#

Either way, this isn't the channel for how to make your ai faster

#

Doesn't seem to be any issue with the discord wrapper, so long as tos are being met

fast osprey
limpid nexus
#

Would I have to send https requests to the server to send and retrieve the data? I guess that's the only difference.

fast osprey
#

It's up to you if you want to farm that out to a separate process on different hardware

#

Could probably get better results, the actual process connecting to discord won't need many resources at all

#

You would have to factor in network latency at that point if it would offset any improvements

#

(Or just also host your discord process on that same faster hardware)

limpid nexus
#

Oh yeah.

#

Well thanks for the heads up.

#

Also for the tos thing.

fast osprey
#

Not being a dick here, data privacy is serious stuff so if you're going to be developing an app people use I highly suggest you read both the dev tos and dev policy very closely

limpid nexus
#

I understand it.

limpid nexus
#

😦

#

I definitely should.

sick birch
#

and yeah just make sure to do your due dilligence when it comes to data safety

limpid nexus
#

God bless.

sick birch
#

these AI companies usually have dedicated hardware and are running the max parameter count so it will usually always be faster and better than what you do locally

limpid nexus
fast osprey
#

4.3 In order to fulfill the requirements stipulated by laws and regulations or provide the Services specified in these Terms, and under the premise of secure encryption technology processing, strict de-identification rendering, and irreversibility to identify specific individuals, we may, to a minimal extent, use Inputs and Outputs to provide, maintain, operate, develop or improve the Services or the underlying technologies supporting the Services. If you refuse to allow us to process the data in the manner described above, you may provide feedback to us through the methods outlined in Section 10.

limpid nexus
#

Yeah I've chosen I'll stick with Claude tbf.

#

I like it more.

fast osprey
#

Our use of Materials. We may use Materials to provide, maintain, and improve the Services and to develop other products and services. We will not train our models on any Materials that are not publicly available, except in two circumstances:

If you provide Feedback to us (through the Services or otherwise) regarding any Materials, we may use that Feedback in accordance with Section 5 (Feedback).
If your Materials are flagged for trust and safety review, we may use or analyze those Materials to improve our ability to detect and enforce Acceptable Use Policy violations, including training models for use by our trust and safety team, consistent with Anthropic’s safety mission.

tight shard
#

I’m looking for people to give me feedback back on my new AI bot is this the right channel?

#

It’s a bot that analyzes bitcoin price trends and gives a detailed response about them and ends with a recommendation to buy/sell/hold

fast osprey
#

Aside from the horrible ethics of an AI giving financial advice on a volatile asset?

#

Depends if you're looking for critique on the code itself or the functionality

tight shard
tight shard
sick birch
#

you might have better luck trying in a crypto discord server

tight shard
tight shard
tight shard
#

But thank you for the help : )

fast osprey
#

Then how are you expecting feedback if you're not willing to share code? what

frail dust
#

people around here won't pay for that also

#

code review is a w

tight shard
tight shard
tender bobcat
#

Just in mind that people here care about code, not cryptocurrency

#

So if you want feedback on the "product", not code, you are probably in the wrong place

shadow vigil
tight shard
#

Not so much the content of the output more the structure

fast osprey
#

We aren't users of this thing you're making, and you refuse to share code. This isn't going anywhere

wise mica
#

There's also a myriad of other issues you have, like the AI forgetting or not fully taking into account a users current financial situation, the real life situation of a crypto (like if you're only reading, but not what the real life players like the various leaders of countries)

#

Or since we haven't seen your outputs the idea that you're not taking a users financials into account and having them invest into something more secure or take proper margins

timber dragon
#

A subscription for a Discord bot that gives AI-powered advice on which crypto to invest into is wild.

wise mica
#

And also finally, the majority of your code should be about the AI and your discord bot should really just be an output of that code, which is relatively easy

#

And you're going to be competing with the smartest people in the world when trying to create any sort of product that's reading financial graphs. If a model could simply tell you what are good investments, then everyone would be following them

#

But also a piece of advice I would give you that's not "please don't do this" is to have the bot run in DMs and only run in DMs and delete any user message that isn't the DMs (or honestly delete them from DMs too)

You don't want users putting their financial info just in random servers

wise mica
wise mica
timber dragon
#

I mean

#

Subclassing and extending the functionality isn't really editing the library

wise mica
tender bobcat
wise mica
timber dragon
wise mica
#

When I wanted them to be true when passed without an argument

#

But passing them without an argument gives you an intentional error

timber dragon
#

The library indeed doesn't have such option

#

That class allows for stuff like --shiny

wise mica
timber dragon
#

Yes and it seems like you ignored the solution

wise mica
#

i thanked them and said that I would try it today

tight shard
wise mica
tight shard
#

Haters gonna hate ig 🤷‍♂️

wise mica
#

I wrote you a paragraph on why what you were doing is whack and that's your response

fast osprey
#

as much as I'm sure I'd love to dunk on the combo AI+crypto bro, this really isn't the place IMO. You're not asking for help on how to specifically implement something in python relating to a discord wrapper

#

if you're just fishing for opinions on the product itself, that's better done elsewhere

crude tundra
#

@Deleted User @Deleted User

graceful gorge
#

Hii

scenic pike
#

Is possible to bypass this or remove bcs i set task.loop to edit an embed in specific channel on 30 seconds

sick birch
#

Though editing once in 30 seconds should be fine. maybe check that it is in fact running once per 30 seconds and not more

scenic pike
#

Kk thanks

#

But its gave same warning on 30 sec

#

I think if i remove the edit message warning will be removed ? @sick birch

stark ingot
#

The ideal solution is to not edit a message every 30 seconds. Why do you need to do this?

fast osprey
#

if you're trying to post updates on a timer, sending it to a webhook is a lot more forgiving than repeatedly editing a single message

warm stratus
#

i keep getting this error SyntaxError: 'await' outside function im not good at scripting can sm1 help me fix it

fast osprey
#

You'll need to understand asyncio if you want to use it here

warm stratus
#

what does this mean 🙏

fast osprey
#

it means you can't use await outside of a function...exactly what the error says

warm stratus
#

ok

fast osprey
#

awaits are only valid inside of async functions

warm stratus
#

yeah but

#

it is inside async function

fast osprey
#

that's not what your error says

twilit grotto
#

show your code @warm stratus

warm stratus
#

its literally inside async function what

twilit grotto
#

it is probably just an indentation issue then. shwo your code

fast osprey
#

errors don't lie

warm stratus
#

wait i think i fixedit holon

warm stratus
fast osprey
#

dunno why you're assuming I have an attitude shrug

warm stratus
fast osprey
#

whatever you say

warm stratus
#

om,,g this error is making me mad broeoa

fast osprey
#

The error should come with a traceback identifying the line that's an issue

hearty basalt
#

@warm stratus you from NY?

slate swan
#

Does forwarding a message have it's own event in discord.py? I didn't find anything like this in the docs

fast osprey
#

it just fires on_message no?

slate swan
#

Oh, okay

viscid hornet
#

wait how do you tell if a message is forwarded?

#

!d discord.Message - lets see pithink

unkempt canyonBOT
#

class discord.Message```
Represents a message from Discord...
slate swan
#

My bot is not behaving as expected with forwarded messages as opposed to normal messages, I guess it's worth trying to update dpy first

slate swan
viscid hornet
#

!d discord.Message.flags

unkempt canyonBOT
viscid hornet
#

!d discord.MessageFlags.forwarded

unkempt canyonBOT
slate swan
#

thanks for the help

warm stratus
young dagger
#

!d discord.MessageFlags.is_crossposted

unkempt canyonBOT
young dagger
#

How does this even work?

#

What is considered crossposting?

exotic hazel
#

Usually it means the same message is posted in multiple channels (could be spam, for example), not sure how exactly this flag gets triggered though

pliant minnow
#

is_crossposted is for when you have a channel that follows another channel, an update channel on another server for example, and when they post in theirs it gets crossposted into your channel.

orchid hemlock
#

let’s say in theory i’m doing something like mass adding emojis, how long would i have to sleep between emoji addition to make sure i don’t get the rl of eternity uhh

fast osprey
#

Discord sends you the rate limits, and most libraries will respect these limits and slow down accordingly

#

you shouldn't need to do any limiting yourself

tender bobcat
#

For guild add emoji, I think it is 50/1h (or 30mins) probably per guild

#

No idea about application add emoji

tender bobcat
fast osprey
#

Discord responds with the local limits. Modern libraries respect this. It's not a mystery

#

It just isn't a static limit that's true for everyone all the time, the API responds with the limits when you interact with it. The libraries read this response and throttle accordingly. You as the developer don't need to do that sleeping yourself

sick birch
#

does a tasks.Loop keep running the next iteration if an unhandled exception occurs? I have a loop error handler that logs out the error and does some extra stuff, but I want the loop to just run again the next time around, though I don't know if this is the default behaviour and I can't find more specific details about exception handling for tasks in https://discordpy.readthedocs.io/en/stable/ext/tasks/index.html

sick birch
#

ah, unfortunate. so I'd just start the task from my exception handler then?

loud socket
#

Yeah that’s the easiest way to do it

sick birch
#

wouldn't it run immediately after? I can add an asyncio.sleep in the error handler before starting it again but it feels hacky

loud socket
#

It would, but as you said it would be hacky

sick birch
#

are there any more idiomatic solutions?

loud socket
#

There are a few let me pull up a resource real quick

#

That’s what I would use atleast

sick birch
#

i've been referencing that, and i am using the loop decorators. I'm just looking for an idiomatic way to skip a run if there's an unhandled exception, but if there's none I'll just have to restart the task in the error handler

graceful gorge
#

@sick birchhii

warm stratus
#

im trying to use roblox api to fetch a users groups

#

but all of the apis i try just dont work

scenic tendon
#

Hi

#

I'm new here

steel aspen
#

This command instructs the bot to send a list of files from os.listdir
It for some reason doesn't like the letter L. how do i fix this?

burnt quiver
scenic tendon
burnt quiver
#

good, you?

steel aspen
scenic tendon
scenic tendon
#

I want to know how to code the following:

I am a student who is eager to learn

scenic tendon
burnt quiver
steel aspen
# burnt quiver code?
name_list = []
for file in file_list:
    if ".flf" in file:
     name_list.append(file.rstrip(".flf")
await message.channel.send(", ".join(name_list))```
blissful crane
#

the way .strip works is by removing any of the characters provided

"Hello".strip("Ho") will result in ell even tho there is no Ho at the start or the end

steel aspen
#

oh what i thought it was just from the eddge of the string

blissful crane
#

Yes that's what it does

#

But it checks if the character is in the string you provided and if it is, it removes jt

#

use str.replace or slice to remove the suffix

dreamy geyser
#

@bot.command()
async def babalarim(ctx):
em = discord.Embed(title = "Çağdaş", description =" ", color = #a11010)

em.add_field(name = "Babalarim", value = "@xDoly, @bigmac, @Emekli Padişah, @Omewii")

await ctx.send(embed = em) 

how to ping people here ?

#

doesnt ping here

woeful hill
#

use markdown or .mention if you have user objects

#

<@id>

dreamy geyser
#

so for example: em.add_field(name = "<@id>")

#

and it will ping the user?

woeful hill
#

it wont ping, it will just become a mention

#

also field name wont accept mention markdown

dreamy geyser
#

yeah wrong command sorry

#

em.add_field(name = "Babalarim", value = "<@id>")

steel aspen
#

Or use the user id
f"<@{userid}>"

dreamy geyser
#

em.add_field(name = "Babalarim", value = "f"<@{userid}>")

woeful hill
#

just the same as <@id>

dreamy geyser
#

like this?

woeful hill
#

one is you hardcode the ids to the field value, one is using f-string

#

both are still <@id>

dreamy geyser
#

alright

#

thanks

#

but it works inside the string too right?

woeful hill
#

they result the same

dreamy geyser
#

k thanks

sick birch
wise mica
#

Inside an embed it'll just be a mention

slate swan
slate swan
#

anyony

#

anyone send discord library doc

#

beginner - advanced

#

i need to start learn

main idol
slate swan
graceful gorge
burnt quiver
graceful gorge
burnt quiver
graceful gorge
graceful gorge
digital owl
#

I have made the bot recently and its working i think we can help you

burnt quiver
#

just send it here :)

#

?

digital owl
#

GOJO bot is name u can try it in my srvr

graceful gorge
digital owl
#

Okay DM me

graceful gorge
graceful gorge
fast osprey
burnt quiver
fast osprey
#

I'll never understand people who say they need help and then immediately that they can't share code.

slate swan
#

cuz they don't want you to use yourself code or someone else

fast osprey
#

More so talking about the people that say they're away and can't share any details at all besides "I need help"

dreamy geyser
#

it says this in the terminal but its there

slate swan
dreamy geyser
slate swan
dreamy geyser
#

its a TTS bot

fast osprey
#

What's your current working directory? Also are you trying to use a json file as a database?

dreamy geyser
#

wdym

fast osprey
#

wdym wdym

#

Can't really elaborate if I don't know what you don't understand

digital owl
#

Try to use .env file rather than json

dreamy geyser
digital owl
#

If u story ur token in json

fast osprey
#

It depends what this is being used for

digital owl
#

No just .env

fast osprey
#

How are you using this file

dreamy geyser
#

in VSS

fast osprey
#

The json file

digital owl
#

Okay keep it simple first tell me

fast osprey
#

What is is to being used for

digital owl
#

Json file is storing authtoken?

dreamy geyser
#

yes

digital owl
#

Use .env for storing

#

All this

#

Just open vs code make a file name .env

fast osprey
#

If it's just static config it doesn't matter what file type they use

#

Env isn't any better and in some cases is worse

digital owl
dreamy geyser
#

and it says no customvoices.json

fast osprey
#

Anyways the issue is probably with your current working directory

digital owl
#

Cuz I have made my bot recently

dreamy geyser
#

but there is customvoices.json

digital owl
#

And its working perfectly with env

dreamy geyser
fast osprey
#

Do you know what a current working directory is to begin with?

dreamy geyser
#

no

digital owl
#

See ur folder structure

#

I think that's the problem

fast osprey
#

How are you running the code?

digital owl
#

Cuz ur calling files but the error is not found files

#

Maybe some folder structure problem or calling files logic problem

dreamy geyser
#

if i run normal it says this in the terminal but if i run debug it works but when i do the tts command it doesnt work

fast osprey
#

how are you running the code

#

Describe what you're doing to get this code to run, step by step

dreamy geyser
#

just this

fast osprey
#

Do you know what that does?

dreamy geyser
#

no?

#

it runs the script?

fast osprey
#

So when you run python, you do so in a directory on your machine. That is your current working directory, and everything in your script runs relative to that.

If you aren't picking it yourself, then this button is picking it for you and you have no clue what it's picking

dreamy geyser
fast osprey
#

Either figure out what this button is doing and fix it to run python in the right directory, or just run your code yourself in a command line

slate swan
#

run

dreamy geyser
#

i did py bot.py because it doesnt recognize python

fast osprey
#

Just running it isn't sufficient. You need to do it in the right directory

dreamy geyser
digital owl
#

@fast osprey it's not a run related error🤦

dreamy geyser
#

if i press the run python file button it says this in terminal

fast osprey
#

You don't understand what that button does

dreamy geyser
fast osprey
#

What do you think your current working directory is in that terminal?

dreamy geyser
#

ohh

#

C:\Users\Hasan

fast osprey
#

Yes. And your file isn't there

dreamy geyser
#

ohh so cd (File) directory

#

right?

fast osprey
#

You need to get your current working directory to be wherever you want your code to run from, cd'ing into it would work

dreamy geyser
#

alright done thanks

fast osprey
# dreamy geyser can you explain it

This basically just invokes your selected python environment on your current file, and itll use whatever working directory you already have in your terminal afaik

slate swan
#

cuz idk very well about async funcs

#

and discord is using async funcs

fast osprey
#

You will need to understand the fundamentals of asyncio to use these libraries effectively

slate swan
#

oh ok

#

it takes 2h?

fast osprey
#

Depends on the person

#

There are good articles and tutorials on the topic

slate swan
#

i am learning very easy

#

cuz i have good math knowledge

#

and i learnt very easy and understood python fundamentals

fast osprey
#

Async concepts aren't too terribly confusing in my experience, just have to understand the terminology and what's happening under the hood. A lot of people just slap awaits everywhere to make the errors go away without actually learning what these things do

pallid meadow
# slate swan alr ty

you can get pretty far by just slapping await on everything a good rule of thumb is if it's making a request to an external service. I.e the discord api or a database. You use async await. There's obviously a lot more that goes into it especially if you wanna have a scheduler and other things like that but you will defiantly be able to get away with just slapping async await on functions that make a call to an external service.

#

I can give you a quick explanation though, it basically allows your program to do other things while it's waiting for idk a timer to finish, a server to respond, pretty much an io bound tasks.

So here's a code example

slate swan
#

ty

pallid meadow
#

lol hold on

#

lemme get this example working

slate swan
#

is it hard to do program yourself which responds any message different things like ai sometimes

pallid meadow
#

no worries at all, if I say anything too complex just lmk I can re explain

slate swan
#

i am interesting about ai

#

how it works and machine learning

pallid meadow
#

that takes years of experience and schooling because a lot of it is just applied math

#

but here's the asyncio example

slate swan
#

i learnt it myself from yt

pallid meadow
#

!e

import asyncio
import time

async def say_hello():
    await asyncio.sleep(1)
    print("Hello")

async def say_world():
    await asyncio.sleep(1)
    print("World")

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


asyncio.run(main())
unkempt canyonBOT