#discord-bots

1 messages · Page 401 of 1

pallid plank
#

Just making sure he knows that's technically breaking rules

slate swan
quick gust
#

this channel is for discord bots not telegram bots, you might receive some help in #1035199133436354600

viscid hornet
drifting arrow
#

Hello all. What's we all working on

viscid hornet
#

not made much progress

drifting arrow
#

as a discord bot?

quick gust
drifting arrow
#

What you having difficult with?

#

I assume you're stuck somewhere.

#

Coz no way you're procrastinating.

viscid hornet
#

its ok i just started

#

and did a bunch of other projects beforehand

drifting arrow
#

Oh okay then

#

Keep your secrets.

manic gull
#

!CODE

unkempt canyonBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

young dagger
#

Is command_prefix required with slash commands?

quick gust
young dagger
#

Parameter 'command_prefix' unfilled

import discord
from discord.ext import commands
import os
from dotenv import load_dotenv

# Load env file
load_dotenv()


class Bot(commands.Bot):
    def __init__(self):
        super().__init__(
            intents=discord.Intents.default(),
            activity=discord.Game(name='League of Legends'),
            status=discord.Status.online
        )
young dagger
#

So the argument is required even with slash commands?

viscid hornet
#

if you have no use for text commands, opt for discord.Client instead

#

!d discord.Client

unkempt canyonBOT
#

class discord.Client(*, intents, **options)```
Represents a client connection that connects to Discord. This class is used to interact with the Discord WebSocket and API.

async with x 

Asynchronously initialises the client and automatically cleans up.

New in version 2.0...
young dagger
viscid hornet
#

Client doesn't support extensions

#

i say have a command prefix for commands like ?sync, then you can swallow the CommandNotFoundError in your error handler

timber dragon
#

You can set the command_prefix to something empty like ()

#

commands.Bot still supports prefix commands so

young dagger
#

I still need to import in every cog
from discord import app_commands from discord.ext import commands

timber dragon
#

sucks

woeful hill
#

what do you expect lol, a import *?

timber dragon
#

technically could do that.. if you import them in one file

# cogs
# - __init__.py
    from discord import app_commands
    from discord.ext import commands
# - ext.py
  from . import app_commands, commands
woeful hill
#

that seems sacrifice some readabilities for me

#

maybe im just bad

viscid hornet
slate swan
#

Probably not ideal if you have the message content intent

timber dragon
#

yeah

upper gorge
#

Is it possible to make a bot that adds users directly to any server with the help of a command? e.g if users verify themselves on the bot and give consent would it be possible ?

blissful crane
#

the simple way would be... Give the user an invite and then they click the "Join server" button

fast osprey
#

Bots cannot add users to servers directly except through the guilds.join oauth scope

drifting arrow
#

I personally don't think that should even be a feature at all

timber dragon
#

They asked about a bot specifically tho. You cannot use the guilds.join scope with the bot one

drifting arrow
#

The bot specifically cannot. However if you get the user to authorize an app, the bot should be able to run api requests to make people join servers

timber dragon
#

Ah, true

drifting arrow
#

TBH, if you have to rely on people being forced into a discord server for it to be popular then you're doing something wrong

timber dragon
#

All you need is that code

fast osprey
#

From what I understand the flow they're describing is an actual reasonable use of the guilds.join scope

drifting arrow
#

My comment still stands. However there are ways.

fast osprey
#

They didn't describe anyone being "forced" to do anything though

drifting arrow
#

The only way I think it could be used properly is if it was used as some sort of game where you solve puzzles or something

drifting arrow
fast osprey
#

You are not if they asked you to and you consented to it

#

How is that forcing

drifting arrow
#

Then just send them an invite link.

fast osprey
#

What they're asking allows them to perform validation before allowing this person into the server

#

Which is entirely valid

quick gust
drifting arrow
#

I mean technically but people are idiots

quick gust
#

Still does not mean they're being forced into any guild

#
  • they never really said anything about trying to make the server more popular or anything, that's just an assumption.
    This could totally be for a specific feature they're trying to implement, we don't know.
vale herald
#

Anyone know why my bot continuously posts raw userid’s in embeds? I’ve even added caching to my code to try and stop it but it just keeps happening. User.mention never mentions the user or rarely does

wanton current
#

It has nothing to do with your bot, it's the Discord client not having it cached because you don't share a server or something

shadow vigil
young dagger
#

What is the different between tree.command, slash_command and app_command?

#

And is app_commands the recommended way to create slash commands?

wanton current
green jacinth
#

How can i create my bot to become an authorized app to the user similar to this?

fast osprey
#

What are you trying to accomplish?

green jacinth
fast osprey
#

Verify? Verify what? And at what point are you doing that? Are they already in a guild the bot is in?

green jacinth
fast osprey
#

Then your bot already has access to all of that information

#

but if all they're doing is clicking something, you're not actually verifying anything

#

except their ability to click something (which selfbots can do just fine)

green jacinth
#

The whole point is for them to be able to use commands outwside the server

fast osprey
#

oh like user install app commands?

green jacinth
#

Like this create commands

fast osprey
#

you don't need this flow (oauth) to do that

#

you can publish user install commands just fine without oauth

green jacinth
#

then where can i publish my tos, privacy policy, etc

#

the whole point of authorizing it is for ease of access on their dash

fast osprey
#

you would still have all that in your bot's about section

#

you don't need oauth to have that

fast osprey
#

Or wait squint . Is this the window for deauthorizing a user install app? Haven't seen it in a bit and might be mistaking that for the oauth deauthorize window

tiny ibex
#

hey so this is my code and I was wondering if its possible so that if the user picks one role from a dropdown then the other roles of that dropdown (if any) gets removed

fast osprey
#

FYI I'm pretty sure you can do self-service exclusive roles from the onboarding menu without needing a bot at all

smoky quiver
smoky quiver
drifting arrow
#

Aside from editing the message view, how can I reset a select menu?

#

Because currently I am editing the message view and it causes errors for me

drifting arrow
#

🤔 I think I fixed it

#

only time will tell I guess ¯_(ツ)_/¯

young dagger
#

So are the tree.commands only used to sync and group app commands? I'm still new to app commands

tiny ibex
#

btww does anyone know any free options to host a bot?

#

i tried oracle but they dont accept my card

fast osprey
#

!hosting

unkempt canyonBOT
#
Discord Bot Hosting

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

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

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

fast osprey
#

tl;dr free hosts are shit, scams, or both

tiny ibex
woeful hill
#

Then find youself one

#

There are countless of free host websites, but be careful of your data

fast osprey
#

You won't know it's also a scam until you get scammed

#

Do a little bit of work and rent a legitimate vps

cunning briar
#

why do i keep getting this error

slate swan
#

disable requires code grant in the dev dashboard

vital monolith
#

i run this code:

import discord

class MyClient(discord.Client):
    async def on_ready(self):
        print(f'Logged on as {self.user}!')

    async def on_message(self, message):
        print(f'Message from {message.author}: {message.content}')

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

client = MyClient(intents=intents)
client.run('my token goes here')

and it outputs:

#
2025-02-18 21:14:29 INFO     discord.client logging in using static token
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/discord/http.py", line 801, in static_login
    data = await self.request(Route('GET', '/users/@me'))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/discord/http.py", line 744, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/decentrala/bot.py", line 77, in <module>
    bot.run('token')
  File "/usr/lib/python3/dist-packages/discord/client.py", line 860, in run
    asyncio.run(runner())
  File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/discord/client.py", line 849, in runner
    await self.start(token, reconnect=reconnect)
  File "/usr/lib/python3/dist-packages/discord/client.py", line 777, in start
    await self.login(token)
  File "/usr/lib/python3/dist-packages/discord/client.py", line 612, in login
    data = await self.http.static_login(token)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/discord/http.py", line 805, in static_login
    raise LoginFailure('Improper token has been passed.') from exc
discord.errors.LoginFailure: Improper token has been passed.
#

how can i fix this error?

wanton current
#

make sure the token is the correct one

vital monolith
#

how do i make sure

wanton current
#

by going to the dev portal and getting a new one

vital monolith
#

well i did make a bot

wanton current
#

from which page did u get the token?

stark ingot
#

also please use a .env

stark ingot
#

I dont think they ever said they were using discord.py

wanton current
#

highly likely since the code they provided is almost a carbon copy of the code example in the discord.py README

stark ingot
#

TBH that is not super complex code so that does not necessarily prove anything either

wanton current
#

i suppose

ancient spire
#

i need some help

#

i want to create a system where i give a folder with photos and videos and the bot to automatically post in on a channel, is that possible?

#

like pfp and banner command

#

but my own photos

stark ingot
#

yup

#

you would just upload the files as attachments to the message

ancient spire
stark ingot
#

You should probably learn python before making a discord bot.

ancient spire
#

like if u see a command i know what to change at it to make it better for me

#

but have no idea to create it myself

#

for example i managed to make a system that deletes photos and videos that have a discord link hidden in them

fast osprey
#

The pattern of "I can only edit code" generally is a signal that someone doesn't fundamentally understand it. They don't understand why the code was made the way it was, or more importantly have the ability to question it when there is a ton of really shitty discord bot code out there. This process is going to be very slow and painful, and you will wind up with brittle code that you will struggle to fix or diagnose unless you take time to learn the fundamentals

frank osprey
#
  • learn python
  • make simple programs
  • keep going over the basics
  • learn more and go over that
  • keep on coding till you can code in python
  • look up any api wrapper and choose one
  • learn discord.py (or one of the others)
  • code simple bots
  • add more functions to the bot, keep you code clean
  • keep at it and try everything you can do
  • make a decent bot
  • profit maybe?
cunning briar
#
import discord
import openai
import os

openai.api_key = os.getenv("OPENAI_API")
TOKEN = os.getenv("MY_API_TOKEN")

intents = discord.Intents.default()
intents.messages = True
client = discord.Client(intents=intents)

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

@client.event
async def on_message(message):
    if message.author == client.user:
        return

    response = openai.ChatCompletion.create(
        model="gpt-4",
        messages=[{"role": "user", "content": message.content}]
    )

    reply = response["choices"][0]["message"]["content"]
    await message.channel.send(reply)

client.run(TOKEN)
#

output:

wanton current
#

shouldnt send ur api keys

cunning briar
#
ImportError: DLL load failed while importing jiter: The specified procedure could not be found.
cunning briar
slate swan
#

somebody can easily gain acess to your account and rack up a bill

#

under your card + name

#

be careful

cunning briar
#

i swear its wrong

slate swan
#

you sent your API keys

#

the key that says, hello openai im a user i want to use your service

#

if you pay for it then somebody can use your API key and rack up bills under your anem

cunning briar
#

done

fast osprey
#

Also you may want to read the terms of service and dev policy more closely before shipping user data to openai

stark ingot
#

Who says they did not?

fast osprey
#

Given that they're violating it and asking for help in a server that tells you not to violate tos, it's a fair assumption

stark ingot
#

Not quite sure how you came to that conclusion?

fast osprey
#

Because they are sending user data to a third party without capturing the user's consent?

#

(potentially also violating the the ai training clause depending on the openai settings on their key, but that's been defaulted off)

drifting arrow
# stark ingot Who says they did not?

I don't understand your questioning. If he read the TOS he'll either ignore what @fast osprey said or respond with "I did." and if he didn't he'll go read it or ask questions.

Alternatively he could just not read it and not give a damn and just do what he wants anyway until it all goes wrong.

#

But it's a fair assumption that if someones sharing their API key they probably didnt read the TOS

smoky quiver
stark ingot
stark ingot
smoky quiver
manic gull
hollow night
quick gust
#

Your user variable is a int, (most likely the user id)
You need to use that ID to fetch the User object

quick gust
#

!d discord.ext.commands.Bot.fetch_user

unkempt canyonBOT
#

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

Retrieves a [`User`](https://discordpy.readthedocs.io/en/stable/api.html#discord.User) based on their ID. You do not have to share any guilds with the user to get this information, however many operations do require that you do...
hollow night
quick gust
#

how you normally set a variable...?

hollow night
#

just do user = await fetch_user(user, /)?

hollow night
#

also what is the /

#

just an empty tuple?

quick gust
quick gust
hollow night
#

i cant get this to work either though 😭

#
            for i in range(len(lbIDs)):
                userID, points = lbIDs[i]
                print(f"LB Position: {i+1} User ID: {userID} Points: {points}")
                user = await Client.fetch_user((userID))
                role = discord.utils.get(user.guild.roles, name="🌍Geoguessr Expert")
                await message.author.add_roles(role)
            embed = discord.Embed(description="Success", color=discord.Color.green())
            await message.channel.send(embed=embed)```
#

Traceback (most recent call last):
File "C:\Python\Python311\site-packages\discord\client.py", line 449, in _run_event
await coro(*args, **kwargs)
File "c:\main.py", line 5766, in on_message
user = await Client.fetch_user(int(userID))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Client.fetch_user() missing 1 required positional argument: 'user_id'

quick gust
#

Are you using discord.Client or discord.ext.commands.Bot as your bot?

hollow night
#

discord.Client

quick gust
#

an on_message event?

hollow night
quick gust
#

and are you storing discord.Client in a client variable?

hollow night
#

i dont know what that means

quick gust
#

how are you defining your bot/client's instance

hollow night
#

uhh

#

i still dont know what means sorry

quick gust
#

does any of this seem familliar to you

client = discord.Client()
bot = discord.Client()```
hollow night
#

client: Client = Client(intents=intents)

#

is that it

scarlet tiger
hollow night
#

maybe? i dont even know anymore

quick gust
#

yeah so in your code switch the line

                user = await Client.fetch_user((userID))

to

user = await client.fetch_user(int(userID))```
#

Client is the class, client is your instance of that class
you cannot call methods on the Class itself but on the instance

scarlet tiger
hollow night
# quick gust yeah so in your code switch the line ```py user = await Client.f...

Traceback (most recent call last):
File "C:\Python\Python311\site-packages\discord\client.py", line 449, in _run_event
await coro(*args, **kwargs)
File "c:\main.py", line 5767, in on_message
role = discord.utils.get(user.guild.roles, name="🌍Geoguessr Expert")
^^^^^^^^^^
AttributeError: 'User' object has no attribute 'guild'

quick gust
#

so you want the member object not the user object

hollow night
#

okay

#

what does that mean lol

#

oh

#

what is the difference?

quick gust
#

facepalm
do

member = message.guild.get_member(userID)```
scarlet tiger
quick gust
#

and do member.guild.roles

hollow night
#

replace user with member?

quick gust
#

I dont see why you can't just do message.guild.roles but I don't have any context so sure

hollow night
#

Traceback (most recent call last):
File "C:\Python\Python311\site-packages\discord\client.py", line 449, in _run_event
await coro(*args, **kwargs)
File "c:\main.py", line 5767, in on_message
member = await message.guild.get_member(userID)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: object NoneType can't be used in 'await' expression

quick gust
#

I had already edited my message

#

please check again

hollow night
#

oh my bad

quick gust
#

also its returning None

#

so either the user id is invalid

hollow night
#

the user id is this 550825436800876556

#

@hollow night

#

so...

scarlet tiger
#

also get_member() is not an asynchronous method

quick gust
#

yeah I know I edited my message after like 5 secs

drifting arrow
#

:D

ornate trail
#

Can someone help me?

woeful hill
#

don't ask to ask, just ask the question

fresh swan
#

Guys, what discord library you think is the best?

ornate trail
woeful hill
#

It will auto invalidate it for you

#

Discord works with github to invalidate tokens

#

Your token will be auto reset

ornate trail
#

So I don't worry.?

#

Ok thankssssss

fresh swan
#

I need help with choosing the library

woeful hill
ornate trail
#

Yo thanhz

timber dragon
#

Look at them all and see which one you like. There is also Hikari, which is completely different from dpy and its forks.

ornate trail
#

Idk rlly what i do to someone post my privacy on github but Everything will be fine.

timber dragon
ornate trail
#

Ok

ornate trail
#

Does github have a server?

#

On discord

woeful hill
#

Are you expecting live support

#

Most companies now don't have that

ornate trail
#

Ok

fresh swan
fast osprey
#

What support do you think it doesn't have?

woeful hill
#

Did you ask an AI and then it show you a discord.py 1.7 code??

timber dragon
#

They said "doesn't have good" not "doesn't have"

#

Some people dislike OOP (CommandTree), they say it's "complicated" but never actually explain why or what they struggle with lol

woeful hill
slate swan
viscid hornet
stark ingot
viscid hornet
quick gust
#

open their examples directory on github

timber dragon
#

Gotta mention that you're a moderator* in the pycord server and friends with the maintainers of the others lol

#

But I do agree that it's easier to use them in the forks for ""beginners"", as it's only one conveniently named decorator away shrug

timber dragon
fresh swan
pale zenith
#

You can take the nextcord and disnake examples, replace bot.slash_command with bot.tree.command (and a few other things) and they're mostly the same lol

pale zenith
fresh swan
#

It's not discontinued, yeah?

pale zenith
#

no

#

literally got a major version update (v2.5.0 release) yesterday

scarlet tiger
#

In discord.py the application commands are very confusing for me, the other libraries do it better

fresh swan
#

And it supports slash commands, UI dialogs, etc.?

pale zenith
#

everything yes

fresh swan
#

Also I'm thinking about pycord - is it better?

scarlet tiger
#

And your guide is better

pale zenith
#

better is subjective. I dislike it but you should use what feels better for you

fresh swan
#

I've heard that it's unstable

stark ingot
fresh swan
#

They have some releases that break the whole library

pale zenith
#

well they've had... some issues... but they are functional

stark ingot
fresh swan
#

So, is pycord reliable?

#

I've found it easier to work with slash commands in pycord

scarlet tiger
stark ingot
#

As reliable as a open source volunteer run project will be

scarlet tiger
#

Other libraries do everything automatically.

fresh swan
#

But current release is stable?

stark ingot
#

Yeah

viscid hornet
#

!d discord.Message

unkempt canyonBOT
#

class discord.Message```
Represents a message from Discord...
viscid hornet
#

oh im stupid

#

have to rebuild my documentation for the next release, WOOOO YEAHHH

pale zenith
#

Syncing every time you restart just adds extra startup time (because syncing has some kinda strict rate limits) and you're just making unnecessary requests to the API to change - quite literally - nothing

#

Unless these libraries keep track of the previous commands pre-restart and compare before syncing, I don't think syncing should be done automatically at a library level

scarlet tiger
stark ingot
#

^ automatic syncing is not the same as syncing everything on startup

pale zenith
#

Yes, the act of syncing inherently does that. That's what the bulk edit app commands endpoint does

#

But it still fucks it up sometimes. It's real inconsistent and that actually annoys me lol

#

"Oh but it adds extra complication" - ok sure, you need to run one command whenever you update one of a set of specific things, but like, once you learn you need to do that, it ain't that deep lmao

#

Anyway as I said before, people should try each library and use what feels best

blissful crane
#

I've seen this conversation a couple times, and whenever I look at the slash commands examples provided by different frameworks. They all literally look the same to me and then I get confused on why people call one better or easier to use/understand

stark ingot
#

The main difference is when you want to do anything more than add the command. IE options and command description/name.
Pycord, nextcord, and disnake are more similar than discord.py

young dagger
#

I'm working on adding new features and enabling slash commands for the bot. Any help or feedback is greatly appreciated 👍

quick gust
#

I feel the whois commands are really pointless because 95% of the time they do not display more information than what I can see by just clicking on ur profile

young dagger
#

Unexpected error: Failed to convert moneyyyyyyyyyyyyyyyyyyyyyyyyyyyy to Member

#

Do app commands always try to convert discord.Member to a User if the user is not a member?

#

discord.app_commands.errors.TransformerError

#

Not the same as discord.ext.commands.errors.MemberNotFound

#

How can I handle errors that are related to Member conversion?

fast osprey
#

Code?

#

App commands don't try to convert anything with native supported types. You tell discord what that type is, and that's what discord gives you

young dagger
# fast osprey Code?
    @app_commands.command(name="whois")
    async def whois(self, interaction: discord.Interaction, member: discord.Member = None):
#

So my idea is to catch it with

        elif isinstance(error, app_commands.errors.TransformerError):
            embed = discord.Embed(
                description=f"{custom_emojis['x_emoji']} I could not find the user `{error.value.id}`.",
                color=discord.Color.red()
            )
#

But wouldn't app_commands.errors.TransformerError cover more than just member conversion?

#

Is there any way to specify to only catch member conversions?

fast osprey
#

How are you even passing in a member it can't transform?

young dagger
#

User ID

timber dragon
#

I think you need use an union of User and Member for that to work

#

Or it just breaks when you don't select from the autocomplete list idr

young dagger
#

Unexpected error: Command 'whois' raised an exception: AttributeError: 'User' object has no attribute 'roles'

#

So if the user ID is not a member, we want to catch the error and say that we can't find the member

timber dragon
unkempt canyonBOT
#

discord%2Fapp_commands%2Ftransformers.py lines 616 to 624

class MemberTransformer(Transformer[ClientT]):
    @property
    def type(self) -> AppCommandOptionType:
        return AppCommandOptionType.user

    async def transform(self, interaction: Interaction[ClientT], value: Any, /) -> Member:
        if not isinstance(value, Member):
            raise TransformerError(value, self.type, self)
        return value```
timber dragon
#

Not sure why discord sends invalid data instead of throwing a client error

young dagger
timber dragon
#

Oh, true

#

Need a member option type then

young dagger
#

Why am I getting:
Unresolved attribute reference 'transformer' for class 'AppCommandError'
Unresolved attribute reference 'value' for class 'AppCommandError'
'MemberTransformer' is not declared in __all__

#

My code:

from discord.app_commands.transformers import MemberTransformer

    @staticmethod
    async def on_app_command_error(interaction: discord.Interaction, error: app_commands.AppCommandError):

        elif isinstance(error.transformer, MemberTransformer):
            embed = discord.Embed(
                description=f"{custom_emojis['x_emoji']} I could not find the user `{error.value.id}`.",
                color=discord.Color.red()
            )```
sick birch
young dagger
elfin peak
#

how can I make a discord bot?

viscid hornet
stark ingot
young dagger
# sick birch can you paste the full traceback

I fixed it with

        elif (isinstance(error, app_commands.TransformerError)
              and error.transformer.__class__.__name__ == "MemberTransformer"):
            embed = discord.Embed(
                description=f"{custom_emojis['x_emoji']} I could not find the user `{error.value.id}`.",
                color=discord.Color.red()
            )
#

without having to import anything

#

But it looks ugly

wanton current
#

couldnt u just use isinstance

#

to make it look better

young dagger
wanton current
#

from discord.app_commands.transformers import MemberTransformer if u wanna import it directly from the file

young dagger
wanton current
#

u can ignore that warning

wanton current
young dagger
#

I'm getting these ugly warnings in Pycharm

wanton current
#

¯_(ツ)_/¯

#

could # noqa it

#

idk what pycharm uses

wintry rose
#

how would i set an event to happen at midnight

#

like optimally

stark ingot
#

you can pass a datetime.time into tasks. Look at the docs for the library you use to find the argument name

elfin peak
timber dragon
#

Might aswell list them all at once for future referencing

Known Python Library Guides

Known Python Libraries

Remember that all of them implement the same API, each in its own way, and there is no good or bad; it is a matter of personal preference.

See more libs at https://libs.advaith.io/#python

sick birch
#

of course you may want to change the date or timezone based on what you want, but that's that general idea

undone kiln
#

How to Use Markdown Escape in Discord? If Discord Used HTML, I'd Use Telegram Bot's Formatter

#

-# for some reason the translator wrote all the words with a capital letter

#

Is there a ready-made formatter, similar to how I did TeleBotPlus.HTML?

stark ingot
#

\ is the escape character
\*\*hi\*\*
with backslash **hi**
without backslash hi

undone kiln
pale zenith
#

!d discord.utils.escape_markdown

unkempt canyonBOT
#

discord.utils.escape_markdown(text, *, as_needed=False, ignore_links=True)```
A helper function that escapes Discord’s markdown.
pale zenith
#

!d discord.utils.remove_markdown

unkempt canyonBOT
#

discord.utils.remove_markdown(text, *, ignore_links=True)```
A helper function that removes markdown characters.

New in version 1.7...
stark ingot
#

ignore the \ above the formatting does not want to work

wintry rose
#

is there any way to tell when someone votes on a poll

coral flax
#

if your looking for a telegram casino full source with lots of game modes and custom ones dm me i will showcase you. i also have miniapps for the casino incase your wondering.

sick birch
#

!d discord.on_poll_vote_add

unkempt canyonBOT
#

discord.on_poll_vote_add(user, answer)``````py

discord.on_poll_vote_remove(user, answer)```
Called when a [`Poll`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Poll) gains or loses a vote. If the `user` or `answer`’s poll parent message are not cached then this event will not be called.

This requires [`Intents.message_content`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Intents.message_content) and [`Intents.polls`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Intents.polls) to be enabled...
verbal vine
velvet compass
#

Its in JS, so I have no idea

glad cradle
#

they both implement all the features of the API

stark ingot
#

If you want to us JS you will be much more successful using discord.js

verbal vine
stark ingot
#

API latency is generally going to be the most significant factor in speed. And this won't differ for different languages or libraries

blissful crane
#

personally, I really dislike the way you make commands in djs (both slash and prefix) and I love the way you make components in dpy (and forks)
for those two reasons alone, I'd use dpy over djs and recommend dpy over djs

verbal vine
#

So based on the criteria of speed and performance I have to choose, any suggestions?

fast osprey
#

As a meta suggestion, you will not get an unbiased answer to "is X or Y better?" in the official support server for X

sick birch
#

speed and performance will matter on your app more than it will on the library

#

discord bots are fairly IO heavy and usually dwarf whatever CPU bound stuff the library is doing

fast osprey
#

Bots are extremely IO bound, you're not mining bitcoin here you're sending a bunch of network requests and waiting on them

sick birch
#

so usually what ends up happening is people start doing like, image generation which is CPU bound and can take some time (relatively speaking) on the same event loop as their bot. but you can have the same problem in JS, though I assume it would be less common because unlike in Python, JS is by default async and most libraries are built around callbacks or async

verbal vine
glad cradle
verbal vine
scarlet tiger
verbal vine
#

But it won't affect performance right?

fast osprey
#

Try it and see

glad cradle
vapid parcel
#

Anyway to do a custom of this in a way, but without removing the Discord one so you can have your own warning about something else related to something else?

#

Imma assume its not possible, but still gonna ask tbh

blissful crane
#

indeed not possible

vapid parcel
#

alright, ty

#

kinda figured, just looking a way to give a warning when they open up the modal, but in a more formal way like discords way. But I think there is no way besides doing a confirm message in the modal or just saying a message where they open the modal.

muted karma
#

ModuleNotFoundError: No module named 'discord'

#

help

fast osprey
#

You're not installing a discord library into the python environment you're running

sick birch
muted karma
#

i got python 3.8.64

#

thats the interpreter

sick birch
#

If not you can omit the version part

muted karma
muted karma
fathom wind
#

hi, can anyone help me remove my linkvertise system into my code?

fast osprey
#

remove into?

fathom wind
#

a captcha idk#

fast osprey
#

What are you trying to accomplish and where are you having trouble

fathom wind
#

i am trying to accomplish a credit feature into my bot but instead of link vertise (the original one) i would like it to be a captcha or like a math question idk

fast osprey
#

what does a credit feature mean?

fathom wind
fast osprey
sick birch
#

then you'll want to py -3.8.10 bot.py to run a python file

#

it's important that the versions match up otherwise your interpreter won't be able to find the package (since it was installed for a different version)

verbal vine
glad cradle
smoky quiver
woeful hill
#

Module not found is the error you get from the import line lol

fast osprey
#

You would get a name error if you missed an import

smoky quiver
warm pecan
#

anyone able to help me here?

fast osprey
#

You should reset your token immediately, firstly

warm pecan
#

OH SHIT

#

jesus im so stupid

fast osprey
#

a) you're on windows, sudo isn't a thing
b) you shouldn't be running pip commands raw on windows, it's ambiguous which python installation you're installing into. Use py -m pip and pick which version you want to install into or
c) use a venv instead

#

and no worries happens to all of us

warm pecan
#

im so new to like all of this so im just trying whatever i read

fast osprey
#

well whatever you're reading is geared for linux lol

gusty talon
warm pecan
fast osprey
#

if you're watching a video, these videos are shit across the board

#

I'd strongly recommend reading vetted articles from the basics and working your way up

warm pecan
#

you got any suggestions?

fast osprey
#

Depends on what you're trying to learn

warm pecan
#

well

fast osprey
#

Have you set up and run a python project at all?

warm pecan
#

i mod for a virtual reality football game

gusty talon
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.

warm pecan
#

but i want to make a bot that can display and update a football league table

fast osprey
#

Presumably some of those things required you to install pip packages yeah?

warm pecan
#

yeah KIVY requires pips and .kv files

gusty talon
fast osprey
#

so installing whichever discord package you want to use (there are several) will follow the same theory. Not whatever this video is telling you to do

warm pecan
gusty talon
warm pecan
gusty talon
#

what ?

gusty talon
#

empty callable

smoky quiver
#

I'm assuming he will be web scraping from his own site or another online source for his table

warm pecan
#

sorry i got interrupted by a chore haha

#

i edited my message

#

its a league table for a Virtual Football game

#

as people create their own teams and play against each other

fast osprey
#

Probably start with getting a hello world bot working before you get carried away in details

warm pecan
#

thats my goal

gusty talon
warm pecan
#

i always set a final product for myself

warm pecan
gusty talon
#

make it

warm pecan
#

well time to learn

#

lets find some articles online

#

i assume IONOS will have some good info as they are a web hosting company

fast osprey
#

There's plenty of resources on fundamentals like installing pip, running your code, etc. Whichever discord library you choose will also have documentation and examples

gusty talon
#

whats ionos?

#

onions are better

warm pecan
warm pecan
fast osprey
#

Which discord library are you using?

gusty talon
# gusty talon whats ionos?

ugh wtf how can i write a function that takes gibbrish and a list of words and check if that gibbrish manages to be one of that word?

warm pecan
gusty talon
#

i thought that was a middlefinger 😭

#

but then i hovered

warm pecan
#

what is a intent? it doesnt say on the website

gusty talon
#

thats rude willi

fast osprey
#

Also the search bar(s) are helpful for finding things and navigating on your own

gusty talon
#

😭

warm pecan
#

Sorry hahah im a pain I know

fast osprey
#

nw it's a learning exercise

warm pecan
#

So from what I gathered intents are like user access levels but in discord bot form?

gusty talon
#

wor, owr, row, <- just 3 for three words?

#

no

#

wro, rwo

#

😭

fast osprey
warm pecan
warm pecan
fast osprey
#

"My bot needs to know when someone reacts to a message, and when someone sends a message, but doesn't need to know when someone joins a voice channel" etc etc

#

There's a full list of the intents linked on that page

warm pecan
#

OH

#

thats so much easier to understand

#

thanks for putting it like that, that actually makes sense in my head

gusty talon
#

nvm its just factorial ducky_skull

fast osprey
warm pecan
#

But im now getting a problem whilst running it

fast osprey
#

This says you're trying to declare a class called client but that's not in your code I can see

warm pecan
#

it has been called but its got my token so i hid it

viscid hornet
warm pecan
viscid hornet
viscid hornet
warm pecan
#

that screenshot is from before attempting to run it

viscid hornet
warm pecan
#

the error im getting now doesnt even fit on my screen

unkempt canyonBOT
#
Pasting large amounts of code

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

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

warm pecan
wanton current
#

by selecting it with your mouse cursor and pressing ctrl + c

warm pecan
#

where it says 'token' is just a placeholder as i removed mine

#

it doesnt say that in my code

fast osprey
#

You've got something wonky in your python environment

warm pecan
#

NO I THOUGHT I FIXED THIS

viscid hornet
# warm pecan where it says 'token' is just a placeholder as i removed mine

you can also just move your token to another file, say token.txt:

<your token here>
``` ```py
bot = ...

bot.run(open("token.txt").read())

or set up a .env file: $ pip install python-dotenv ... TOKEN="..." ```py
from os import getenv
from dotenv import load_dotenv

load_dotenv()

...

bot.run(getenv("TOKEN"))

warm pecan
#

I HATE VENV

wanton current
#

what did env do to you 😔

warm pecan
#

i might cry

#

im fed up off pips, IDEs, venvs

#

i genuinly cannot get this to work at all

#

ive been doing this for 4 hours now

fast osprey
#

You most likely are just layering stuff videos tell you to do on top of each other

#

rather than starting from a blank slate

warm pecan
#

i might honestly just uninstall and reinstall VSC

fast osprey
#

and since you don't understand what you're doing when you do it, you have no clue if that's hurting you later when you try to do something else

#

this isn't a vsc thing

warm pecan
#

anyway to just like reset?

fast osprey
#

VSC is just a text editor

#

that isn't going to change how your program actually works

warm pecan
#

i might just delete my files and restart everything

#

okay right im getting a fresh USB drive

#

and making a new folder

warm pecan
#

can you run me through how to properly set things up

fast osprey
#

Before you even think about vsc, what matters first is your python environment

warm pecan
#

okay im listening up, ready to do this

fast osprey
#

vsc is literally just an editor on top of text files. The python installation is what actually runs the code

warm pecan
#

so what should i do first

warm pecan
fast osprey
#

Either go into it, see what you've installed and adjust, or just reinstall python entirely

#

up to you

warm pecan
#

oh for god sake not this problem

#

yay i fixed it

muted karma
#

class Client(discord.client):
TypeError: module() takes at most 2 arguments (3 given)

#

????????????

wanton current
#

discord.Client

smoky quiver
slate swan
#

or a text editor like VSC

warm pecan
slate swan
#

You just shouldn't make a bot as your first ever programming experience, will be demotivating

warm pecan
#

It’s not my first experience

slate swan
#

Learn at least the basics off a course or something

warm pecan
#

I’m just not familiar with how venv’s work.

slate swan
#

That's for what google is

#

We help you code bots, not setup a dev env here

warm pecan
#

That’s why I didn’t ask for venv help in here

smoky quiver
slate swan
#

You can open up a thread in #1035199133436354600 if you wish, though learning by doing and researching yourself is also nice

slate swan
#

We help you with specific issues that are actually related to bot code

warm pecan
#

Having a ‘shit’ product gives me motivation, thanks.

muted karma
smoky quiver
warm pecan
fast osprey
#

Dang, y'all can disagree with their learning method and suggest other things without insulting them

warm pecan
#

I’m getting one when running my code, can’t find any fixes online. I’m so stuck

Apparently my SSL is the wrong version number?

#

Don’t even know what an SSL is to be honest with you

#

Something to do with Network Protocols

fast osprey
#

Yeah it's a security protocol for signing requests using certificates. What version of python are you using?

warm pecan
#

3.13 I believe, downloaded from the python website

warm pecan
fast osprey
#

It's not the certificates, it's the version of ssl your python environment is using

smoky quiver
warm pecan
#

Okay, how should I go about fixing this?

fast osprey
#

And you reinstalled python?

warm pecan
#

I reinstalled it earlier today yeah, but I did have 3.13 from the website and 3.12 from the microsoft store installed at the same time. Maybe that’s the problem

#

I might completely uninstall all instances of python and redownlos 3.13 from the website again

fast osprey
#

I would recommend that, and not installing any packages

#

except for the discord package you want

warm pecan
#

Okay got you. I’ll do it now

warm pecan
#

SOLSTICE SHARD I CANNOT EXPLAIN HOW GRATEFUL I AM FOR YOU

#

I WILL FOREVER PRAISE YOU MY FRIEND

#

ITS WORKING

fast osprey
#

you did something pretty fundamentally screwy on your previous environment

#

glad it's working though prettythumbsup

warm pecan
#

I have no clue what I did

But i’m grateful it’s fixed

#

It’s only up from here. Thank you very much my friend

#

All working too!

#

6 hours on 😂

fast osprey
#

I will say that bots layer on several concepts at once, including but not limited to OOP + asyncio + network + callbacks etc. If you try to learn all of these at once, you will have difficulty

warm pecan
#

What one do you suggest I learn first

fast osprey
#

OOP concepts are incredibly important in almost any language and any framework you will find yourself using

warm pecan
#

Sorry let me rephrase: Where should I go after completing the quickstart page

warm pecan
fast osprey
#

In my opinion, you should do focused learning on the base concepts before trying to build a bot. You can elect to not do that, which is your call. The library fully documents all of the methods available to it, and there are examples in the repo too depending on what you want to do

warm pecan
fast osprey
#

Even if all you want to do is brain surgery, you still need to learn how to hold a scalpel first

warm pecan
#

Don’t even know where to start though to be honest, python has so much too it

fast osprey
#

There aren't any shortcuts, these frameworks build on top of lots of things and if you try to skip those things you will be in way, way deeper just copy pasting code you don't understand

#

You can learn those things while building a bot, but you do have to stop to understand them independently or you'll just layer on more copy pasting

warm pecan
fast osprey
fast osprey
#

https://docs.python.org/3/tutorial/classes.html for example is the official resource for learning about classes and objects, which frameworks like dpy use incredibly heavily

warm pecan
fast osprey
#

The chapters in https://docs.python.org/3/tutorial/index.html are a good start for general concepts to think through, in order

#

if things like data types/structures are rusty, then yeah advanced concepts will be super painful

drifting arrow
cinder walrus
#

Hiii, ive made a discord bot recently ive coded the bot to send a word from a words.json file and scramble it now i want the bot to track if the user sends the correct answer or reacts with a certian emoji witch will skip the game and start a new one displaying the answer when the user gets it correct it should say they did and then start a new game this worked before after no chances of the code just bot restarts and now its not working correctly is anyone able to support me?

cinder walrus
#

The tracking part and the skip part, before i had the bot codes just to track messages and wasnt doing anything to with the skip part now ive added the skip part aswell it doesnt seem to be tracking the message or allowing the user to skip

fast osprey
#

It's unclear what you want by "tracking" or "skipping"

drifting arrow
#

I assume he's tracking using the "on message"?

#

🤔

fast osprey
#

Well "track" is ambiguous

drifting arrow
#

His entire thing is confusing

fast osprey
#

You get message events sure, but what are you trying to do when you get a message

cinder walrus
#

Soo let me explain better sorry,
the bot will start a game this game gets a random word from words.json file and scrambles it the bot then replys with the scrambled word and adds the 🔄 react to it the aim is for the user to unscramble the word so say the world is Hello the bot will send for the game unscramble the word Elhlo now the user needs to either correctly guess it this can be done by replying simply with Hello, hello, HELLO ect, or the user has the option of reacting to the 🔄 and after one reaction it will skip it and output the answer allong with sayinng it was skipped and starting a new game.

#

@fast osprey @drifting arrow dont know if thats easier to understand ^

fast osprey
#

You're doing to have difficulty doing this with reactions. Reactions are severely antiquated for user flows

#

You should use a ui button

cinder walrus
#

ive just recently learnt ui buttons ill try implementing that then

fast osprey
#

With the button, you declare what happens when someone clicks it directly

cinder walrus
#

i wanted to make it adventurly so say 2 people had to react for it to skip hence why didnt do the button

fast osprey
#

You can do that with buttons, it's just tracking state

cinder walrus
#

okay

fast osprey
#

Otherwise if you want to do reactions, you will need to make a global reaction listener and then figure out if that's on a message you care about and then what you want to do. People can react to any message and your bot gets that event

cinder walrus
#

defo confusing for my brain ahah it also tracks the streak and stuff but ill see how it goes

#

ahh ok

fast osprey
#

You can also use buttons for things like this hint, or even for users to submit guesses directly to the bot rather than through a message

cinder walrus
#

ok

smoky quiver
verbal vine
wanton current
#

there are few cases where you're not going to be I/O limited

cinder walrus
fast osprey
#

You can edit the containing message within a button callback via interaction.response.edit_message

slate swan
#

I need help with my bot command: It is saying that there is no bot command called snus

drifting arrow
#

isn't there suppose to be a paramater in bot.command()?

@bot.command(name="snus")
async def snus(ctx, *, query:str = None):
slate swan
#

it isnt

#

slash commands

#

but i will try that

wanton current
slate swan
#

still doesnt work

fast osprey
#

Make sure you're running the code you think you are, then send us the full code

fast osprey
#

Full code. Not just this command

slate swan
#

i have alot of more stuff

#

with different apis

fast osprey
#

If you don't know where the problem is then you need to send all of it

slate swan
#

all my other cmds work

#

its just that cmd

fast osprey
#

Then send all the code

drifting arrow
#

Are all functions uniquely named?

fast osprey
#

You can use a paste service if needed

slate swan
drifting arrow
#

well i got nothing

#

Is there other commands on this specific file and do they work as well?

slate swan
#

its not a file

viscid hornet
unkempt canyonBOT
#
Pasting large amounts of code

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

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

drifting arrow
# slate swan its not a file

yes it is. you have to save your code onto a .py file.
thus, it's a file.
On this .py file, is there other commands? and do those commands work?

slate swan
drifting arrow
#

Assuming all commands on that specific .py file that holds this "command" work.

And assuming you're following the same format for other commands,

do me a favor and rename the function snus to "gnome" and run your code.

#

and attempt to run the command "gnome"

slate swan
#

.

drifting arrow
#

Just do it u tit

#

you arent sharing your code so I have to blindly test

slate swan
#

ok

fast osprey
#

There's an infinite number of things that could be wrong here. We can either waste our time guessing them one by one, or you can just send the code

drifting arrow
#

ATM I am assuming it's a naming issue.

slate swan
#

@drifting arrow

drifting arrow
# slate swan <@197979859773947906>

Alright then the only answer is you compare the differences between a command that does work and this command and figure out what's wrong.

you only need to check the @bot line and the function line

fast osprey
#

gl guessing I suppose. Takes 2 seconds to copy paste

drifting arrow
fast osprey
#

And you've already wasted what 10+ minutes taking screenshots of tiny chunks

drifting arrow
#

I don't use text commands anymore, nor do I use "@bot.command" is that correct?

#

Btw @slate swan is your other "commands" the on message event?

slate swan
#

i need to check

drifting arrow
#

lol

slate swan
drifting arrow
#

I can't help you troubleshoot any further since I've now concluded you have NFI

slate swan
#

Ima send screenshots of everything but the api keys

drifting arrow
#

You should be using a .env file..

slate swan
#

Enable necessary intents

intents = discord.Intents.default()
intents.message_content = True # Required for reading messages

Use commands.Bot for prefix-based commands

bot = commands.Bot(command_prefix=PREFIX, intents=intents)

@bot.event
async def on_ready():
print(f'✅ Logged in as {bot.user}! Prefix commands are ready.')

@bot.event
async def on_message(message):
"""Ensures commands still work if on_message() is defined."""
if message.author == bot.user:
return

await bot.process_commands(message)  # ✅ FIX: This ensures commands like `.snus` work!

@bot.command()
async def snus(ctx, *, query: str = None):
"""Fetches data from Snusbase API based on user input."""
if not query:
await ctx.send("❌ Please provide a query. Usage: .snus example@gmail.com")
return

try:
    url = "https://beta.snusbase.com/api/search"
    headers = {
        'Authorization': API_KEY,
        'Content-Type': 'application/json'
    }
    payload = {"query": query}  # Adjust based on API requirements

    response = requests.post(url, headers=headers, json=payload)

    if response.status_code == 200:
        data = response.json()

        if not data:
            await ctx.send(f"🔍 No results found for `{query}`.")
            return

        formatted_data = json.dumps(data, indent=2)
        response_message = f"📊 **Results for `{query}`:**\n```json\n{formatted_data[:1900]}\n```"
        await ctx.send(response_message)
    else:
        await ctx.send(f"❌ Error {response.status_code}: {response.text}")

except Exception as e:
    await ctx.send(f"⚠ An error occurred: {str(e)}")
drifting arrow
#

or if you're lazy like me, a .json or similar file..

#

use !paste

unkempt canyonBOT
#
Pasting large amounts of code

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

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

slate swan
#

Enable necessary intents

intents = discord.Intents.default()
intents.message_content = True # Required for reading messages

Use commands.Bot for prefix-based commands

bot = commands.Bot(command_prefix=PREFIX, intents=intents)

@bot.event
async def on_ready():
print(f'✅ Logged in as {bot.user}! Prefix commands are ready.')

@bot.event
async def on_message(message):
"""Ensures commands still work if on_message() is defined."""
if message.author == bot.user:
return

await bot.process_commands(message)  # ✅ FIX: This ensures commands like `.snus` work!

@bot.command()
async def snus(ctx, *, query: str = None):
"""Fetches data from Snusbase API based on user input."""
if not query:
await ctx.send("❌ Please provide a query. Usage: .snus example@gmail.com")
return

try:
    url = "https://beta.snusbase.com/api/search"
    headers = {
        'Authorization': API_KEY,
        'Content-Type': 'application/json'
    }
    payload = {"query": query}  # Adjust based on API requirements

    response = requests.post(url, headers=headers, json=payload)

    if response.status_code == 200:
        data = response.json()

        if not data:
            await ctx.send(f"🔍 No results found for `{query}`.")
            return

        formatted_data = json.dumps(data, indent=2)
        response_message = f"📊 **Results for `{query}`:**\n```json\n{formatted_data[:1900]}\n```"
        await ctx.send(response_message)
    else:
        await ctx.send(f"❌ Error {response.status_code}: {response.text}")

except Exception as e:
    await ctx.send(f"⚠ An error occurred: {str(e)}")
slate swan
viscid hornet
drifting arrow
#

lol

viscid hornet
drifting arrow
#

That's what an AI would say

viscid hornet
#

cuz you seem to be incapable of following any instructions

drifting arrow
#

Calm down.

viscid hornet
#

@drifting arrow should i tell mods peepo_kekw

drifting arrow
#

Give him a chance

viscid hornet
#

nevermind

inner rivet
#

We don't allow/appreciate ableist slurs. And, everyone should chill.

#

Don't need to antagonize them.

drifting arrow
#

@slate swan, use the command !paste, go to that link, and paste your code there. It's easier for us to read.

inner rivet
drifting arrow
#

You will need to send us the link as well

slate swan
fast osprey
#

This is still just this command and two other unrelated lines

slate swan
#

but i dont think there is a api for beta.snusbase

#

so i cant use it for my bot

fast osprey
#

rip

timber dragon
#

An api for snus is wild

wanton current
slate swan
#

yo i need help with this code, it says ❌ No results found for {query} or invalid response but it showes all the information found in the py but doesnt send through the discord bot https://paste.pythondiscord.com/P5XQ

viscid hornet
slate swan
viscid hornet
slate swan
#

the 1st image

#

i did .snus and the email

#

but it showes in termnial instead of pasting in discord

viscid hornet
slate swan
#

what line

#

@viscid hornet

fast osprey
#

You might want to a) log the response itself and b) not use requests in an asyncio application

viscid hornet
#

line 47

viscid hornet
slate swan
slate swan
viscid hornet
#

dude

viscid hornet
viscid hornet
slate swan
#

@viscid hornet

viscid hornet
#

ima let someone else take over this

proud lark
#

Using commands doesnt work, asked chatgpt multiple times and didnt help at all.

fast osprey
#

chatgpt thinks 3 isn't a prime number sometimes

#

don't use it for anything you don't personally understand. It can and will repeatedly lie to you

proud lark
#

dang

#

so what should i do

fast osprey
#

will need some code

proud lark
#

wym

fast osprey
#

Like your code

proud lark
#

actually wait

#

its invite rewards bot

fast osprey
#

There isn't a reliable way to find what invite someone used

proud lark
#

how so

fast osprey
#

What do you mean how so

proud lark
#

cuz like if you do !createinvite, the bot creates an invite linked to the user

#

do you mean that thats the problem

fast osprey
#

No, discord doesn't tell you what invite someone used

#

period

proud lark
#

oh

#

so its not possible

fast osprey
#

Not reliably, discord doesn't tell you this by design

lofty crag
#

Hey umm my chatpacker is working fine but the imports is having a problem i installed everything

#

i had all of these packages installed when i first had pip

#

And i have it imported

fast osprey
#

The heck is a chatpacker

slate swan
#

is it or not

lofty crag
#

to users

#

anyway how do i fix that problem cuz i have the dependcies installed

fast osprey
#

What happens when you run your code

#

also you shouldn't be using requests in an async application

#

use aiohttp

lofty crag
#

my code doesnt include async

fast osprey
#

So you're making a synchronous discord bot...how?

viscid hornet
unkempt canyonBOT
#
Pasting large amounts of code

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

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

lofty crag
#

the code has 91 lines

#

ill try to fit it if not ill try to paste it into there

unkempt canyonBOT
lofty crag
#

ok WHY

fast osprey
#

Why are you hitting discord pretending to come from a user browser

lofty crag
#

wdym

fast osprey
#

wdym wdym

#

it's your code, it's right there

#

either you're intending to do this, or you copy pasted it from someone who is

#

this isn't how bots behave and it is super sketchy

pallid plank
#

That's interesting content you got in that link on line 10

#

But it looks like it just spams pings with messages from given link

pallid plank
#

It contains racist stuff

#

Did you copy the code from the internet, replace the original link with this one, and ignore the comment on the same line?

fast osprey
# lofty crag

Yeah <@&831776746206265384> this stuff is pretty sketchy, they get a token from some unseen place that they feel the need to test against a user endpoint, then send a bunch of racist/homophobic stuff to a channel pinging someone

inner rivet
# lofty crag wdym

!ban 1274466637202067509 We don't allow mass DM bots, nor racist & hateful speech, on this server. Nor do we help with projects that contain this type of content.

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied ban to @lofty crag permanently.

drifting arrow
#

🤔

hollow night
#

i'm trying to get a list of members with a specific role, here is what i'm attempting

            await discord.Guild.get_role(1334390638120276010)
            print(discord.Role.members)```
i keep getting this error:
Traceback (most recent call last):
  File "C:\Python\Python311\site-packages\discord\client.py", line 449, in _run_event
    await coro(*args, **kwargs)
  File "c:\main.py", line 5771, in on_message
    await discord.Guild.get_role(1334390638120276010)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Guild.get_role() missing 1 required positional argument: 'role_id'
woeful hill
#

yeah because discord.Guild.get_role() first argument is self and not role_id

#

you need an instance of discord.Guild, not the class

#

and the second line you also print the members from the class discord.Role

#

seems like you need basic OOP knowledge first

#

@hollow night

sleek meteor
#

How do i make pages of modals with disnake

#

Or send 2 modals in one message?

quick gust
#

You can only send a single modal at a time.
You can maybe send two buttons each of which open a different modal, if that's what you want

sick birch
#

i believe you can send buttons as response to modal submits

drifting arrow
#

Or can you just do buttons? never done straight buttons

sick birch
drifting arrow
#

I wonder if I could respond a modal to a modal? 🤔 BRB testing something

#

:( nope just buttons

slate swan
#

components v2 might be something interesting for later

slate swan
#

discord never gives that tbh

#

could be tomorrow or in a year

shrewd apex
#

lmao fair

stark ingot
timber dragon
#

^ I don't get why people are excited for this

#

Instead of improving existing components and taking suggestions serious, they are adding new components to replace embeds

slate swan
#

the day when discord listens to people will be a miracle

#

nothing new

#

though iirc some people mentioned that this update was sort of "blocking" modals/components updates

#

to be proven though, i don't really trust/believe it

timber dragon
#

Oh, interesting

dense dove
#

hey I'm new to python, and came here idk if asking for help is allowed but if someone can slide in my dms and help me. I have the script just need some help please 😭

slate swan
#

Channels are made for help, ask your questions in the appropriate channel, asking random people to go in DMs is weird

dense dove
slate swan
#

!paste

unkempt canyonBOT
#
Pasting large amounts of code

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

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

dense dove
#

I'm mobile emoji_175

wary sluice
#

im trying to change server vanity using api but it asking for password verification, and when i put pass for mfa it said incorrect pass, but when i use that same pass for vanity change manually then it works

viscid hornet
slate swan
wary sluice
wary sluice
#

wait lemme show you code

slate swan
quick gust
wary sluice
#

hmm

carmine osprey
#

who know how to work discord.js? im trying to make an ,fortnite shop command that uses https://fortnite-api.com/ shop endpoint to get the fortnite shop data so i can see whats in the fortnite shop in the chat using the command

#

I already have my api and its keep giving me errors

#

I could try to make it in python

#

im using the https://fortnite-api.com/v2/shop endpoint

#

is that my issue?

timber dragon
carmine osprey
#

Alright thank you, ima see if the links you have provided will help. I'll text here if i get an error again

#

@timber dragon Hi, im back i did my command ,fortniteshop and it said "Failed to fetch Fortnite shop data." ima show u my code for fortniteshop.js

const { Client, Language } = require('fnapicom');
require('dotenv').config();

const API_KEY = process.env.FORTNITE_API_KEY;

if (!API_KEY) {
    console.error('Error: Missing FORTNITE_API_KEY in .env file');
    process.exit(1);
}

const client = new Client({
  language: Language.English,
  apiKey: API_KEY,
});

module.exports = {
    name: 'fortniteshop',
    description: 'Get Fortnite Item Shop data!',
    async execute(client, message, args) {
        try {
            const shopData = await client.shop.entries();

            if (!shopData || shopData.length === 0) {
                return message.channel.send('No items in the shop today.');
            }

            const shopItems = shopData.map(entry => {
                const itemName = entry.name || 'Unknown Item';
                const price = entry.price || 'N/A';
                return `• **${itemName}** - 🪙 ${price} V-Bucks`;
            }).join('\n');

            const embed = new EmbedBuilder()
                .setTitle('🛒 Fortnite Item Shop (Today)')
                .setDescription(shopItems)
                .setColor('Blue')
                .setTimestamp();

            return message.channel.send({ embeds: [embed] });
        } catch (error) {
            console.error('Fortnite Shop API Error:', error);
            return message.channel.send('Failed to fetch Fortnite shop data.');
        }
    }
};
timber dragon
#

is it now a good time to mention that I've never used the API

#

Sorry lul

carmine osprey
#

😭 😭 😭

vital yoke
#

Using py-cord, for some reason the bot claims it can't ping everyone for my cross server system yet it has the permissions for the channel, but not the role at that would be considered unsafe. If I turn it on for the role, it says it has the permissions. Any ideas on what's wrong here? This is being ran in a slash command.

permissions = channel.permissions_for(ctx.guild.me)
                required_permissions = [
                    permissions.send_messages,
                    permissions.view_channel,
                    permissions.mention_everyone if role_id != -1 and not ctx.guild.get_role(role_id).mentionable else True
                ]
                print(required_permissions)
            
                if not all(required_permissions):
                    missing_perms = []
                    if not permissions.send_messages:
                        missing_perms.append("Send Messages")
                    if not permissions.view_channel:
                        missing_perms.append("View Channel")
                    if not permissions.mention_everyone and role_id != -1 and not ctx.guild.get_role(role_id).mentionable:
                        missing_perms.append("Mention Roles/Everyone (You have a role ID attached but I can't ping it!)")

                    missing_perms_string = '\n'.join(missing_perms) #this is so bad, can't have new lines in f strings directly.
                    return await ctx.respond(
                        f"I don't have the required permissions in {channel.mention}. Missing: ``{missing_perms_string}``",
                    )
latent jay
#

How does @tasks.loop(seconds=30) handle errors? For example, if I run a separate function within that task, if that function errors will the task be terminated or only until the next 30 seconds goes by it will re-run?

quick gust
#

i believe if a task errors, it is completely destroyed

sick birch
#

IME it doesn't get re run

drifting arrow
#

It's an absolute disaster if it errors

#

Please do not error your tasks.loop.

#

🤔 Im in a bit of a sticky wicket

sick birch
drifting arrow
#

My bot sends a "question" with an attached button.

How do I detect who has pressed the button and update the parent script that sent the button so my on_message event knows?

#

!paste

#

The command is "test_question" for now. It will send the question, I need to find out who has pressed the button so that main script knows, so my on_message event also knows lol

#

I dont particularly want to put the on_message event inside of the butons file

sick birch
#

you can wrap this up into a little function that sends a view, and returns who clicked a button

drifting arrow
sick birch
drifting arrow
sick birch
drifting arrow
#

And I need to be able to detect if someone has viewed the hints or not.

sick birch
#

sounds like it'd be easier to just handle all of that inside the view callbacks than trying to propagate it up

woeful hill
#

How about a hint button just do the exact same but with the hint

#

Just with the hint and edit the score

#

Well you still need a way to store who pressed what exactly

drifting arrow
#

Alright I came up with a hacky sacky solution

#

:D

#

!paste

#

And there's no way this will ever cause me issues at any point in the future. Yep. I see no issues being caused by this whatsoever

desert rock
#

Is it possible to use a image i have download on my pc for a embed logo?

#

if so what url do i use for the logo?

slate swan
desert rock
desert rock
#

i belive that. Still new so im not 100% sure

#

thx

#

Also is there a way to call a embed without a slash command?

slate swan
#

You can send embeds any time in any channel you want (where your bot has permissions ofc)

#

Not sure what you mean with "call a embed"

desert rock
#

Like i want my bot to brodcast a embed every 20 min for example. How can i do that without using a slash command?

desert rock
#

thanks.

#

Getting an error here not sure what it is...

#

Line 34

viscid hornet
#

thats also

#

dont do that

#

just dont do that

woeful hill
#

why did you define your command inside a function

drifting arrow
timber dragon
#

Python code

timber dragon
#

Enabling the perm in the channel means all roles can be mentioned; the specific role permissions are overridden in that case.

viscid hornet
# desert rock

also the reason for your error is that it needs to be a raw string or the path needs to be POSIX

vital yoke
glacial cliff
timber dragon
cinder walrus
#

Just wondering if i could get a suggestion regrading this im making multipurppose bot one of its features it it tracks messages sent in chat and gives the user xp for that and xp is used to rank up this is amazing but this is global and the only way i know of making it server based is structing a json file like this:
Server SERVERID
User USERID
Xp Serverxp
and ive realised when were tallking over 10k people it quickly becomes a very big file, i already have a file called userdata and that has around 10 lines of data per user is there a simpular way i can do this?

fast osprey
#

You shouldn't be using a json file to track application data, period

fast osprey
#

Yes

cinder walrus
#

i did look into using mongodb i dont really know what the best one is to use ive always used json files

wanton current
#

we usually recommend SQL databases such as SQLite and PostgreSQL

fast osprey
#

any database is better than json, and any other database is better than mongo

#

Asterisk before the mongo apologists @ me, there's nuance

wanton current
slate swan
#

never heard of such a db

cinder walrus
#

okay ill look into it thanks

cedar acorn
#

idk postgresql but imma try it

wanton current
cedar acorn
#

idk python tho imma try soon

wanton current
#

that doesn't say a lot but ok

viscid hornet
viscid hornet
#

!pip asqlite - there's even async versions of it too

unkempt canyonBOT
#

A simple and easy to use async wrapper for sqlite3.

Released on <t:1719317735:D>.

keen niche
#

Whats the best way to format a dataframe for display on discord, since discord doesnt have complete markdown support?

slate swan
fast osprey
#

what's the question?

slate swan
#

the cmd keeps having a error code

fast osprey
#

which is?

slate swan
#

wait i fixed but

#

there is a new issue

#

its saying that there is no email found even tho in the site, it sends the info