#discord-bots

1 messages · Page 400 of 1

frank osprey
#

no reason other than i found there's more support like rapptz and that ...

fast osprey
#

code may not be identical, either, depending on what you're doing

frank osprey
#

well im still learning the basics atm so i think i can get a way with a change of wrapper but yeah ill just have to learn whats different and all that

last cradle
#
@commands.hybrid_command(name="jumbo")
    async def jumbo(self, ctx, emoji: str):
        """Enlarges an emoji from a server or Unicode emoji"""
        custom_emoji = re.search(r"<a?:\w+:(\d+)>", emoji)
        
        if custom_emoji:
            url = f"https://cdn.discordapp.com/emojis/{custom_emoji.group(1)}.png"
            await ctx.send(url)
        else:
            codepoints = "-".join(f"{ord(char):x}" for char in emoji)
            url = f"https://twemoji.maxcdn.com/v/latest/72x72/{codepoints}.png"
            await ctx.send(url)

this doesnt embed, why?

woeful hill
#

ask twemoji

thorn imp
#

I wondering how could i use other flies like a variable

Like i make a flies name tokenbot.py and have variable, token = "bot token"
And i need transfer the variable to bot.py

woeful hill
#

Just import it like you did with other library

thorn imp
#

I still learning how to use env because i hear is very usefull to hold storage

woeful hill
#

You can just make a config.py file and then add it to .gitignore to avoid uploading credentials to github

If you use env it's the same story but you need dotenv package

quick gust
#

there's absolutely no reason to use a .py file to store environment variables, thats literally what .env is for

thorn imp
bright oasis
#

I marked the same name but the file cannot be loaded

woeful hill
#

Your token need to be a string

viscid hornet
unkempt canyonBOT
#
Traceback

Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.

A full traceback could look like:

Traceback (most recent call last):
  File "my_file.py", line 5, in <module>
    add_three("6")
  File "my_file.py", line 2, in add_three
    a = num + 3
        ~~~~^~~
TypeError: can only concatenate str (not "int") to str

If the traceback is long, use our pastebin.

viscid hornet
#

you're comparing boeing 767s and oranges

viscid hornet
#

!pypi dotenv

unkempt canyonBOT
viscid hornet
#

hm nvm thats valid

bright oasis
woeful hill
#

Traceback then?

viscid hornet
bright oasis
quick gust
#

your .env needs to be in the root folder

#

outside src/

bright oasis
quick gust
#

restart terminal and run the python file again

bright oasis
thorn imp
bright oasis
thorn imp
#

My friend told me "just use env" and i was confused why my variable token .env didn't work at all

bright oasis
thorn imp
#

Probaby need install something, i saw a tutorial video and i still don't understand

timber dragon
#

You need to actually load the env variables into your system

#

A package called python-dotenv can do that

#

But you might aswell use a json or python file for this

thorn imp
#

pip install python-dotenv

timber dragon
#

Yes

thorn imp
timber dragon
#

It installed the package to the global python installation yes

timber dragon
#

Also, an env file is usually just called .env not cool.env lol

timber dragon
#

Idk? It's your code

quick gust
# bright oasis

Its not my code, I'm just saying I think they are loading the dotenv here

timber dragon
#

Just creating a file called .env doesn't automatically load them if that's what you're asking

quick gust
#

i know that 🫠

timber dragon
#

They may need to specify the path in the load call

thorn imp
bright oasis
#

ok

thorn imp
#

I trying bebugging my code😭🙏

#

Is so hard

bright oasis
thorn imp
#

You gotta use import and other stuff too

timber dragon
bright oasis
hybrid jungle
timber dragon
#

Welp

#

Final try: What if you pass the full path to load_dotenv

hybrid jungle
timber dragon
#

Loading

bright oasis
timber dragon
hybrid jungle
#

Reload your terminal if you are using Venv

#

Dotenv requires usually the use of venv

timber dragon
#

Til

hybrid jungle
#

And when you change a var you need to reload the venv by closing and reactivating which VS Code does automatically on terminal launch.

woeful hill
#

It looks like the last changes are not saved

bright oasis
#

so should I record?

woeful hill
#

Save the files and run the bot again

#

What do these prints print

hybrid jungle
#

If you get a error send it in here so we can see

bright oasis
#

Current directory : C:\Users\User\Documents\discord-bot Loaded .env file Token chargé: None Type du token: <class 'NoneType'> Traceback (most recent call last): File "c:\Users\User\Documents\discord-bot\src\bot.py", line 39, in <module> raise ValueError("No tokens found. Please set DISCORD_TOKEN environment variable in .env file") ValueError: No tokens found. Please set DISCORD_TOKEN environment variable in .env file

hybrid jungle
#

Put a print token statement before your if statement

woeful hill
#

What happen if you quote your token in the .env file

hybrid jungle
#

Check and see if you are getting the token passed

woeful hill
#

Aka make it a literal string

hybrid jungle
viscid hornet
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.

woeful hill
viscid hornet
#
print("""You can do

multiple lines

at once,

and have cool

syntax highlighting

too.""")
hybrid jungle
bright oasis
#

I will try to record and see

hybrid jungle
#

with if not token

#
token = os.getenv('DISCORD_TOKEN')
print(f"Current Token: {token}")
if not token:
  raise ValueError("A Token was not supplied in the .ENV File")

bot.run(token)
bright oasis
#

@hybrid jungle @woeful hill thank you very much I had to save the files

bright oasis
#

I spent 3 hours for this little problem lol

woeful hill
#

Enable autosave in settings

bright oasis
#

ok

woeful hill
#

Literally a life saver sometimes

bright oasis
#

also a small question when I mark the file help.py the terminator tells me that there is already a file called help how could I do it?

woeful hill
#

You mean rename?

#

Can you close vsc and rename the file with windows explorer

viscid hornet
#

also what is the "terminator"

bright oasis
#

@thorn imp It works for me, is there still the problem?

thorn imp
last cradle
#

is there anyway or anything that can block nsfw links

#

like all, like without making a list myself? im going to make a cmd that screenshots a website

fast osprey
#

"nsfw" isn't a globally objective term. Maybe someone out there curates a list but these pop up all the time

last cradle
#

mmm

fast osprey
#

Also consider things like Twitter, which can absolutely have nsfw content and you wouldn't know unless a human looked at it. If you care about making this distinction, you need a human to enforce it and review this content. Or you just let people post it and others report them

timber dragon
#

"explicit content"

thorn imp
#

Anyway can teach me how bebug Define error

slate swan
#

Can someone tell me what’s going on here?

stark ingot
#

Can you show your pip list

slate swan
stark ingot
#

Also your code has a lot of unnecasary stuff.
Intents.default() includes all intents except the 3 privileged intents so intents.guild = True and intents.messages = True are uneeded
You also just have intents.all() sitting there not being assigned to anything.
You also create a permissions object but then immediately overwrite it
-# Note this is assuming py-cords intent system which is similar to but not gurenteed to be the same as other libraries

stark ingot
# slate swan What’s a pip lis-

It shows all the packages you installed. You have probably done pip install ... at some point. If you run pip list in your console it will show everything that you have installed

slate swan
stark ingot
#

uninstall discord and discord.py then reinstall discord.py

slate swan
#

Done

stark ingot
#

same error?

slate swan
#

Lemme try

#

Same error

stark ingot
#

Also I just noticed the error you sent if from a different part in the code.
If you could look at the line number of the error and send that chunk of the code as text that would help

slate swan
#

intents = discord.Intents.default()
intents.all()
intents.guilds = True
intents.messages = True
intents.message_content = True
permissions = discord.Permissions()
permissions.manage_channels = True
permissions.manage_messages = True
intents.members = True
permissions = Permissions()
permissions.administrator = True
client = discord.Client(intents=intents)

stark ingot
#

that is still the wrong lines. In the error is shows the line intents.message_content = False that is not in the code you provided

slate swan
#

It is

#

Line 23

stark ingot
#

Have you saved your code?

slate swan
#

Yeah

stark ingot
#

Can you post the full traceback here. You can take out the foldername of your user but you blacked out to much in the first image.

unkempt canyonBOT
#
Traceback

Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.

A full traceback could look like:

Traceback (most recent call last):
  File "my_file.py", line 5, in <module>
    add_three("6")
  File "my_file.py", line 2, in add_three
    a = num + 3
        ~~~~^~~
TypeError: can only concatenate str (not "int") to str

If the traceback is long, use our pastebin.

slate swan
#

ape sequence '\L'
await ctx.channel.send
Traceback (most recent call last):
File "C:\Users\User\Downloads\Collecter-Hat\Hat-Collecter\main.py", line 23, in <module>
intents.message_content = False
^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Intents' object has no attribute 'message_content'

stark ingot
#

Can you show from the top to line 31
Also are you sure you saved the code, the error still says that you are setting message_content to False but in the code you provided you are setting it to True

slate swan
stark ingot
#

What do you mean you forgot? If you set it to true and it is false in the error that means that
A. You did not save the code
B. You did not rerun the code
C. You are running different code than what you are editing

stark ingot
#

Can you paste your code into the pastebin, make sure to remove your token

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
#

C:\Users\User\Downloads\HatCollecter-HatCollecter\HatCollecter-HaterColle\HatCollecter.py:52: SyntaxWarning: invalid escape sequence '\W'
hwid = subprocess.check_output('C:\Windows\System32\wbem\WMIC.exe csproduct get uuid', shell=True,
C:\Users\User\Downloads\HatCollecter-HatrCollect\HatCollecter-HarCollect\HatCollecter.py:668: SyntaxWarning: invalid escape sequence '\L'
await ctx.channel.send Traceback (most recent call last):
File "C:\Users\User\Downloads\Hatellecter-Haterllecter\HaterCo/Hat\HaterColle.py", line 23, in <module>
intents.message_content = True
^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Intents' object has no attribute 'message_content'

#

That’s the full error

stark ingot
#

Where did you get this code?

slate swan
#

GitHub

stark ingot
#

What is your goal with this project

slate swan
#

Just a discord bot that can control my pc for me

young dagger
#

Are you sure you imported discord correctly?

stark ingot
#

I suggest that you build that from scratch if that is actually your reason for using this code. The code overall is terrible anyways

#

!rule 5

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.

stark ingot
#

We will not help you further with this specific code

slate swan
#

Boo

young dagger
#

Where is the code?

stark ingot
#

I am not going to share the link to the github but it was for a RAT (Remote Access Trojan) virus

grave sandal
stark ingot
#

That should not make a difference, I think I know what the issue is but I am not going to share it as like stated above they were trying to get malicious code working.

grave sandal
stark ingot
#

@rare nymph Please delete your message. You leaked your webhook URL (which is sensitive information) You should remove the webhook from your server so that you dont get random messages.

You can repost your code, but you should ask a question. Just giving your code will not get you any help

full ether
#

you do realize their message is a malware component?

stark ingot
#

Yeah just saw that now
<@&831776746206265384> ^

wise jewel
#

@rare nymph, I see you've just joined the server. Do check #rules and #code-of-conduct again. We don't sharing or discussion of malicious code

analog swallow
#

My code:

import requests
import asyncio

YOUR_CHANNEL_ID = 1335475367145902172

def load_users():
    with open('users.txt', 'r') as file:
        return [line.strip() for line in file.readlines()]

async def check_users_status(channel, users):
    online_users = {user: None for user in users}
    
    while True:
        for user in users:
            response = requests.get(f'https://api.roblox.com/users/get-by-username?username={user}')
            data = response.json()

            if data and 'id' in data:
                user_id = data['id']
                game_response = requests.get(f'https://api.roblox.com/users/{user_id}/onlinestatus')
                game_data = game_response.json()

                if game_data['IsOnline']:
                    if online_users[user] is None:  # User just joined
                        online_users[user] = True
                        embed = discord.Embed(title=f"{user} has joined the game!", color=discord.Color.green())
                        await channel.send(embed=embed)
                else:
                    if online_users[user] is not None:  # User just left
                        online_users[user] = None
                        embed = discord.Embed(title=f"{user} has left the game.", color=discord.Color.red())
                        await channel.send(embed=embed)

        await asyncio.sleep(30)  # Check every 30 seconds

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

client = discord.Client(intents=intents)

@client.event
async def on_ready():
    print(f'Logged in as {client.user}')
    channel = client.get_channel(YOUR_CHANNEL_ID)
    users = load_users()
    client.loop.create_task(check_users_status(channel, users))

client.run('')```

my error: 
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.roblox.com', port=443): Max retries exceeded with url: /users/get-by-username?username=darkpalidin (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x0000021BE2DFB170>: Failed to resolve 'api.roblox.com' ([Errno 11001] getaddrinfo failed)"))
#

Can anyone help me?

sick birch
# analog swallow My code: ```import discord import requests import asyncio YOUR_CHANNEL_ID = 133...

this isn't necessarily a discord bot issue, but here's what I found: https://devforum.roblox.com/t/action-needed-sunsetting-apirobloxcom/1796897

rare nymph
analog swallow
sick birch
analog swallow
sick birch
analog swallow
quick gust
woeful hill
#

while True in async environment will make your bot stuck

#

Even with asyncio sleep afterward

#

If you want a code that will trigger every certain amount of time, use task

pale zenith
#

That's an oversimplification. If you are awaiting things inside that loop, it won't block. If the loop takes a short time, it won't block.

#

Discord.py's main logic (listening for gateway events) is just a big while loop. One just needs to be aware of the nuance.

viscid hornet
pale zenith
# viscid hornet leo, does putting a `while True` in a coroutine make it non-blocking?

You are either asking the wrong question, or I am misinterpreting you because putting a while True loop inside a coroutine function could make it blocking, not make it non-blocking. As I said, what matters is what you put inside that while block.

async def block():
    # This would block
    while True:
        pass
    # This would not
    while True:
        data = await session.get(...)
        print(data['key'])
    # this *could* block if the condition isn't met.
    while True:
        thing = get_thing()
        if isinstance(thing, GoodThing):
            break
```Top block would never yield control back to the event loop, and just run forever- not allowing other queued coroutines to run. The middle loop wouldn't, since it's awaiting stuff, hence allowing other scheduled coroutines to run in the meantime. The bottom loop could block, depending on (a) how long `get_thing` takes to run and (b) if that condition is ever met. 
-# And by *to block* I mean to block the event loop for a considerable amount of time. Blocking calls are inevitable,**everything** blocks the loop to a certain degree, since asyncio is single-threaded. The problem is if you're blocking it for enough time that it disrupts the rest of the code from running smoothly.
slate swan
#

yo

#

How can i make my bot send a message to a specific channel?

#
@commands.has_role("Customer")
async def review_command(ctx, stars: Literal['⭐️', '⭐️⭐️', '⭐️⭐️⭐️', '⭐️⭐️⭐️⭐️', '⭐️⭐️⭐️⭐️⭐️'], product: Literal['Gfx', 'Video editing', 'unknown']):
    await ctx.response.send_message(f"Successfully send your feedback of {stars} star(s) and the product {product}", ephemeral=True)

    bot.get_channel(1335576680869400648) 
    embed = discord.embed(
        title="**New feedback!**",
        description="**![heart](https://cdn.discordapp.com/emojis/1335580498633949194.webp?size=128 "heart") {ctx.author.name} left a feedback!**",
        color=discord.Color.blue
        )
    
    embed.add.field(name="![x_](https://cdn.discordapp.com/emojis/1335560113641099318.webp?size=128 "x_")**Stars:**", value="the customer left a review of {stars} star(s).")
    embed.add_field(name=":package:**Product:**", value="the custom bought the product {product}")
    embed.timestamp = discord.utils.utcnow()
    embed.set_footer(
        text=Footer,
        icon_url=FooterImage)
    embed.set_thumbnail(url=thumbnail)
    await channel.send(embed=embed, ephemeral=False)```
#

this my code

slate swan
#

yh

viscid hornet
slate swan
#

Alrighty

stark ingot
bright oasis
#

hello I have a problem with a command the bot cannot put the id of a room in a json file

fast osprey
#

You shouldn't be using a flat json file as a database if that's what you're doing

viscid hornet
amber flare
#

in discord py, any way to get nicknames, of people who installed your app?

#

not to server, but to their apps

timber dragon
#

Nope you cannot get a list of users that installed your app

#

Also "user" apps aren't part of any guild

amber flare
timber dragon
#

You install an app to your profile

amber flare
#

yea

timber dragon
#

So, where does a guild come in?

amber flare
stark ingot
#

You get a member object in your interaction objects when the interaction was invooked in a guild. You can get the members nickname from that member object.

amber flare
#

so not to server

stark ingot
timber dragon
#

Or track it via command uses using the events provided by the library you use

stark ingot
#

These are separate from gateway events so I dont know if discord.py supports it but it is likly you will have to set up the webserver yourself.

amber flare
#

i see, thanks

last cradle
#

how to like do commands group but like hybrid

slate swan
#

!d discord.ext.commands.hybrid_group

unkempt canyonBOT
#

@discord.ext.commands.hybrid_group(name=..., *, with_app_command=True, **attrs)```
A decorator that transforms a function into a [`HybridGroup`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.HybridGroup).

This is similar to the [`group()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.group) decorator except it creates a hybrid group instead.
slate swan
#

Sometimes worth searching/scrolling through the docs

slate swan
#

Can someone help me fix an issue?

C:\Users\User\Downloads\New folder>python3 new.py
pygame 2.6.1 (SDL 2.28.4, Python 3.12.8)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
File "C:\Users\User\Downloads\New folder\new.py", line 38, in <module>
bot = commands.Bot(command_prefix="!")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: BotBase.init() missing 1 required keyword-only argument: 'intents'

fast osprey
#

You need to declare intents when creating a bot

fast osprey
#

Whatever tutorial/docs you're using are outdated

#

You have not

slate swan
fast osprey
#

You have not

#

The traceback shows your code where you're creating the bot and not telling it what intents you're requesting

slate swan
#

intents = discord.Intents.default()
intents.messages = True
intents.guilds = True
intents.voice_states = True

bot =
commands.Bot(command_prefix="!", intents=intents)

fast osprey
#

That's not what the traceback says

slate swan
#

I have updated the code and it’s still doing it

slate swan
fast osprey
#

The traceback doesnt lie about the code python is running

viscid hornet
slate swan
# slate swan Show the entire file (redact the token obv)

Never mind, I have fixed it but now it is saying

C:\Users\User\Downloads\New folder>python3 new.py
pygame 2.6.1 (SDL 2.28.4, Python 3.12.8)
Hello from the pygame community. https://www.pygame.org/contribute.html
[2025-02-02 19:59:37] [WARNING ] discord.ext.commands.bot: Privileged message content intent is missing, commands may not work as expected.
[2025-02-02 19:59:37] [INFO ] discord.client: logging in using static token
[2025-02-02 19:59:38] [INFO ] discord.gateway: Shard ID None has connected to Gateway (Session ID: f04918ee390ce17a5095f7d700642c1e).
Bot is online as Rover MP#9917

#

nothing wrong

#

What about the warning?

young dagger
#

message content intent is missing

slate swan
#

read it, you don't have the intent enabeld so prefix commands won't work

young dagger
#

!mcintent

unkempt canyonBOT
#
Discord Message Content Intent

The Discord gateway only dispatches events you subscribe to, which you can configure by using "intents."

The message content intent is what determines if an app will receive the actual content of newly created messages. Without this intent, discord.py won't be able to detect prefix commands, so prefix commands won't respond.

Privileged intents, such as message content, have to be explicitly enabled from the Discord Developer Portal in addition to being enabled in the code:

intents = discord.Intents.default() # create a default Intents instance
intents.message_content = True # enable message content intents

bot = commands.Bot(command_prefix="!", intents=intents) # actually pass it into the constructor

For more information on intents, see /tag intents. If prefix commands are still not working, see /tag on-message-event.

fast osprey
#

*may not work as intended

safe stag
#

hi guys, I have a question for you, I made a language system, e.g. the bot supports two languages, it works so far, but I always have to restart the bot, but I have no idea why, can you help me, I actually saved the language in the database, that's why I don't understand ```py
await self.set_lang_cache()

async def set_lang_cache(self):
    result = await self.all("SELECT guild_id, language FROM guilds")
    LanguageSettings.languages = {guild_id: lang for guild_id, lang in result}```
fast osprey
#

You have to restart to do what?

thorn imp
#

can anyone help me with this issue, i can't host my bot

viscid hornet
#

not the folder

thorn imp
fresh swan
viscid hornet
thorn imp
#

I'm sorry if i borther, i don't know how this work

viscid hornet
#

also why the two .env files?

thorn imp
#

'src' > 'foad discord bot'

#

i combine the two folder into one because i was trying fix the issue

viscid hornet
#

just discovered you can have a __main__.py file that runs when you try to run a folder

#

thats pretty cool

viscid hornet
thorn imp
#

I was trying fixed the problem but made it worse🙏

viscid hornet
thorn imp
#

Let me move the bottestout from the foad discord bot

viscid hornet
thorn imp
viscid hornet
thorn imp
#

isn't this correct

viscid hornet
#

move the files out of __pycache__ and into foad discord bot

thorn imp
#

Oh wait i get it

viscid hornet
#

but if you must, then add a main.py file that just imports from your bot.py file (causing it to run) and then run that file instead as a proxy

thorn imp
#

I able to restored my old script, thank for your help thumbs_up

cobalt nexus
#

I'm working on a Discord bot using discord.py and app_commands. I want to make sure that certain commands in my dev_group are only accessible to the bot owner.

i tried

def is_owner(interaction: discord.Interaction) -> bool:
    return interaction.user.id == YOUR_OWNER_ID

@app_commands.check(is_owner)
.....

but it doesn't seem to work. I also considered @commands.is_owner(), but I'm not sure how to properly apply it to app_commands.Group.

How can I make sure that only the bot owner can use and see these commands

fast osprey
#

You should not use app commands at all for this, IMO. The entire point of app commands is to publicize and democratize them, which is the exact opposite of what you're trying to do

#

If you don't want a random guild owner to decide who gets to use it in their guild, don't make it an app command

#

(or if you do, only sync it to a private guild and apply permissioning there)

thorn imp
#

I also have one quick guestion
I wanted use testing.py for something but i also want use bot.py for other project but i can't enter both of them into one "c:flies/testing.py/bot.py "

I only can use testing.py or bot.py one at a time

fast osprey
#

"use" is a pretty vague goal here. Python runs with one file as its entry point/__main__

#

So it depends on what exactly you want to happen when when you run python ...

thorn imp
fast osprey
#

If using discord.py (and probably in most forks), there's a concept of extension which allows you to load external files and make your bot object available to them (such as for the purpose of attaching listeners/commands/cogs/whatever)

thorn imp
thorn imp
stark ingot
cobalt nexus
#

thanks i just convert them to normal command found it the best solution

stark ingot
#

You get to make your own decisions but in the long run "normal" commands (which I am assuming you are talking about prefix commands) are worse.

  1. You need message content intent approval once you pass 100 servers unless you want to mention the bot every time
  2. You need the message intent which just uses a bunch of bandwidth for the 0.001% of the messages you will actually care about. This also means that you cant have an interactions/http only bot.
  3. You never know if discord will make message content even more restricted (it is magnitudes less likely discord will restrict app commands)
fast osprey
#

You do not need message content intents to run prefix commands

#

You receive message content when the bot is mentioned and in dms, both of which are reasonable for owners/dev teams to do

timber dragon
#

Huh they added a lot more to that post since I last read it

stark ingot
fast osprey
#

Debatably, I'm just challenging that prefix commands are worse as they work perfectly fine and in fact better than slash commands for my workflow without the message content intent

sick birch
#

slash commands are nice but sometimes it's lacking for a specific feature you want to implement

stark ingot
#

I have only ever been able to come up with 3 reasons that prefix commands would be better in niche circumstances

  1. Accepting a variable number of attachments is annoying

  2. /tag and /tag edit cant coexist

  3. You cant have discord side permissions checks for subcommands

  4. Can be fixed by just appending whatever the main feature of the base command would be IE /tag get

  5. Is kind of a non-issue because prefix commands dont have discord side permissions checks at all.

rough ridge
#

Should I use discord.client or discord.ext for my discord bot

finite salmon
finite salmon
#

👴🏿🙏🏿👍🏿

fallen kettle
#

Does anyone know how to fix this?

viscid hornet
fast osprey
#

sir this is a wendys

viscid hornet
#

!d sqlite3 IS a database

unkempt canyonBOT
#

Source code: Lib/sqlite3/

SQLite is a C library that provides a lightweight disk-based database that doesn’t require a separate server process and allows accessing the database using a nonstandard variant of the SQL query language. Some applications can use SQLite for internal data storage. It’s also possible to prototype an application using SQLite and then port the code to a larger database such as PostgreSQL or Oracle.

The sqlite3 module was written by Gerhard Häring. It provides an SQL interface compliant with the DB-API 2.0 specification described by PEP 249, and requires SQLite 3.15.2 or newer...

young dagger
viscid hornet
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
#

I mean, the error is pretty clear

stark ingot
young dagger
#

Provide some code @fallen kettle

#

As of now, we can only speculate

fallen kettle
#

I will when i’m home

tawny junco
#

Would it be good in production? Is another question

fast osprey
#

"good in production" downplays how horrid flat files are everywhere

viscid hornet
young dagger
unkempt canyonBOT
#

A simple and easy to use async wrapper for sqlite3.

Released on <t:1719317735:D>.

manic gull
#

yo

sick birch
finite salmon
#

Yaml on top

timber dragon
#

toml >>

manic gull
#

hi can anyone help me make a discord bot?

thorn imp
#

i wondering is this correct because i trying learn how use extensions

#

I kinda confused how to use extension

viscid hornet
#

it has its use cases like in sending data over a network through HTTP requests and static data like config files, loot tables, etc. but for more complex things, constantly loading and dumping JSON is an awful idea in production

viscid hornet
viscid hornet
viscid hornet
thorn imp
quick gust
#

move ur bot.py file out of __pycache__
show the contents of ur main.py and bot.py file
show the contents of ur button.py and testing.py file

only then we'll be able to tell if ure using extensions properly

manic gull
thorn imp
# viscid hornet mange?

Well yesterday i trying learn how use extension because i can't execute other commad in button.py because i was running python "c:flies\testing.py" and one of my friend told me to use extension so unload testing.py and reload button.py and discord python library wasn't clear about it

viscid hornet
viscid hornet
thorn imp
manic gull
viscid hornet
#

and do you want to learn how to make one or do you just want someone else to make one for you

manic gull
#

or help a lil

viscid hornet
manic gull
#

oh

viscid hornet
quick gust
manic gull
#

i wanted like a command

viscid hornet
viscid hornet
manic gull
#

like if i said !payments or something it would show what i wanted

#

kk

thorn imp
viscid hornet
# manic gull kk

keep in mind the library is massive so you might have a hard time

#

but its relatively simple at the same time

thorn imp
manic gull
#

help

quick gust
#

Just try to follow the guide I linked, it'll be good to get u started neatly

manic gull
#

nvm i got it im pro

#

infernum what does it mean when it says .env

viscid hornet
manic gull
#

how do i make that

#

in pycharm

quick gust
viscid hornet
#

just use a txt file

manic gull
#

ok

viscid hornet
#

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

manic gull
#

do i use client or using bot

#

the bot right

quick gust
#

depends

#

if u dont want commands then use discord.Client

manic gull
#

i want like /payment or sum

#

bc ima tryna make a server

quick gust
#

then use Bot

manic gull
#

ok

#

i did slash command

#

where it says token do i put my bots token there?

quick gust
#

where does it say token

#

you need to provide more context about your existing code

manic gull
#

TOKEN = os.getenv("TOKEN")

quick gust
#

now make a .env file in the root directory of ur project

TOKEN = your_discord_token```
manic gull
#

she said a txt file is fine bc idk how to make .env

quick gust
#

.env is better practice

woeful hill
#

Youre skipping thru the guide so slow down and read it again

quick gust
#

^

manic gull
#

man this to hard

#

ima go pro wait

#

yea i give up ima go watch yt

thorn imp
#

@quick gust I also have one main guestion, should i go for @bot.command or MyClient

quick gust
#

not a good idea

quick gust
thorn imp
woeful hill
quick gust
#

"MyClient" is the name of your discord.Client subclass (according to the code above)
@bot.command() is a decorator for registering specific functions as commands

woeful hill
#

If you find all this thing is so difficult and you don't understand one bit, you should learn python first, really

quick gust
#

!res ^

unkempt canyonBOT
#
Resources

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

manic gull
thorn imp
#

Can you tell me how to do this part because i'm fear of messing up again

woeful hill
#

The extension path is similar to python's import mechanic

thorn imp
# manic gull yea i give up ima go watch yt

Isn't that really hard, the problem is, is very hard to understand few day ago i was struggling how to use env and i end up learning by doing few mistake and corret it and asking the commuity for help

manic gull
#

im new to python its hard

thorn imp
#

That the issue i'm getting

#

I end up making the problem worse if i trying mange the flies and end up putting like 5 folder in one

woeful hill
#

Tbh you can just put everything in the working directory

thorn imp
thorn imp
woeful hill
#

Do you know what a directory is

#

In windows world it is called "folder"

#

Your working directory is where your, usually, main.py file is

#

And if you create another file, namely config.py

#

You simply do import config

#

Because they are in the same directory/folder

#

However if you create a directory/folder, say ext and you put your config.py there instead

#

If you want to import config.py to your main.py, you now do from ext import config

#

or import ext.config

#

Because the path is ./ext/config.py

thorn imp
woeful hill
#

no

#

One working directory is one project

#

However, if you want to make small files for small projects in the same directory, you can

#

They are still in the big project

#

well, my wording is bad

thorn imp
#

Could we dm because i have guestion

woeful hill
#

No

#

Just ask here

thorn imp
woeful hill
#

What does it have to do with how you import

#

unless you cause a circular import

thorn imp
# woeful hill What does it have to do with how you import

He told me do something like this

import discord
from discord.ext import commands
import os

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

bot = commands.Bot(command_prefix="!", intents=intents)

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

# Load all cogs in /cogs
for filename in os.listdir("./cogs"):
    if filename.endswith(".py"):
        bot.load_extension(f"cogs.{filename[:-3]}")

bot.run("your_token_here")
woeful hill
#

Out dated code

#

That's why your cogs are not loaded

#

Hence the command inside it won't work

#

Oh wait i didnt read the message before codeblock

#

The code is still outdated tho

woeful hill
#

When you load extension you give it a path

thorn imp
woeful hill
#

cogs.filename = ./cogs/filename.py

#

In the case of load extension

#

os.listdir will list all the files inside the folder

#

And you wrap it in a for loop to iterate thru the list

thorn imp
#

Oh i see now, i understand

woeful hill
#

So filename variable will be filename1.py in the first loop

#

Since it ends with .py, the if statement passed

#

to load_extension

#

The load_extension finds a file inside the cogs folder, named filename1.py and try to load it

thorn imp
slate swan
#

How can i make it that if i execute a command it is not replying to my message just sending for example an embed?

pale zenith
#

@calm vector ^

stark ingot
#

I suggest you re-read the Discord terms of service that you agreed to when you made an account.
https://discord.com/terms/#4

You agree not to license, sell, lend, or transfer your account... without our prior written approval.

slate swan
#

Its just an example doesnt mean thats mine?

#

I am just curious how to make a command like that and not how to sell accs or sum

stark ingot
#

It is yours, it is on the server that you have linked in your status. The server linked in your status is owned by you. You have asked for help with this bot before

slate swan
#

I have never asked help for this bot before i asked for an other bot but not this bot you can see in the picture the bot in the picture is not coded by me so i never asked for help abt this bot.

fast osprey
analog swallow
#

!slash

#

!slashcommands_discord.py

young dagger
#

Do webhooks trigger on_message? I was trying to add this code, but it doesn't add the reactions to the embed

        if message.channel.id == self.appeal_channel_id and message.webhook_id:
            await message.add_reaction(self.check_mark_emoji)
            await message.add_reaction(self.x_emoji)
            return
fast osprey
#

does the if clause pass?

young dagger
#

Wait my bad

#

I forgot I had added this condition before 😭

        if message.author.bot or not isinstance(message.author, discord.Member) or any(
                role.id in self.staff_roles for role in message.author.roles):
            return```
#

Webhooks are technically considered bots

sick birch
#

i don't think so

#

oh on the client side

#

yeah maybe

#

it might be clearer to use discord.Message.webhook_id

night hound
#

Hi

drifting arrow
#

Is sending audio files the same as sending regular files?

#

Webhooks are indeed technically bots

#

Why you using webhooks?

#

@young dagger

#

This is an open question to anybody who has experience or wants to opinionate (anything is welcome)

I am creating my own trivia bot because I can and one of the features I want to have is the ability to just send small audio files. Like a "What is this sound?" kind of thing. Would it be better to send the file as a direct file to discord, therefore I'd have the files on my local machine or should I upload them to youtube and send a youtube link?

golden portal
#

shouldnt the bot just use the voice channel to play sounds

drifting arrow
#

Na I dont want to do that

#

I don't want to force users to have to join a voice channel

#

They should be able to participate anywhere.

#

Also the users should be able to replay the sound as many times as they want

blissful crane
#

I'd rather be forced into a vc than opening yt for smth like this

quick gust
#

and then u get a 15s ad lemon_sentimental

drifting arrow
#

Alright so local audio files and send those

drifting arrow
#

;-; I dont want it to send like that. I want it to send like an actual audio file

#

Like this lol

drifting arrow
#

I think it was my code not the file

#

hold up.

viscid hornet
#

when you make a File instance, change the filename to be "whatever.mp3"

#

!d discord.File

unkempt canyonBOT
#

class discord.File(fp, filename=None, *, spoiler=..., description=None)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.abc.Messageable.send) for sending file objects.

Note

File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.abc.Messageable.send)s.
viscid hornet
#

filename kwarg

slate swan
#

who can help me make SSF USER INSTALL BOT also known as self bot ill pay 25$

drifting arrow
#

Yeah it was my filename

unkempt canyonBOT
#

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

drifting arrow
viscid hornet
#

!rule tos also

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.

woeful hill
#

2 rules broken with 1 message

viscid hornet
woeful hill
#

and he left the server

viscid hornet
#

no hes still here, i'm pretty sure

woeful hill
viscid hornet
drifting arrow
#

🤔 can discord bots not delete ephemeral messages they've sent?

#

or edit apparently?

#

:( Apparently not according to ye ol' google

slate swan
#

they can

drifting arrow
#

well I cant D:

#

I tried interaction.message.edit and interaction.message.delete coz im using buttons in the ephemeral message

timber dragon
#

only via an interaction

drifting arrow
timber dragon
#

aka using interaction.delete/edit_orginal_response

young dagger
#

Is there any way to add multiple reactions in a single call?

timber dragon
#

Nope

#

Use buttons :)

drifting arrow
stark ingot
drifting arrow
#

IMO there's no reason to rely on reactions anymore to determine a persons response to something

#

You can also respond with the dropdown menu thingy

drifting arrow
#

25 buttons per message?!

#

Buttons are lit yo

#

So really. If you're using reactions, you're using outdated tech. Move to buttons.

stark ingot
#

You can have 5 action rows per message. Each action row can have 1 select menu or 1-5 buttons

drifting arrow
#

So I can have many select menu and many buttons in 1 message?!

#

I am blessed.

#

It honestly amazes me how much of discord is still free and not hidden behind a paywall lol

#

Like discord does such a great job to put stuff behind a paywall but only if you absolutely need it while the rest is free.

woeful hill
#

5 rows of ui elements per message

stark ingot
#

You can have 25 buttons OR 5 select menus OR 3 select menus and 10 buttons OR 1 select menus and 20 buttons, and more combos

#

By the looks of it you might be able to add up to 10 action rows per message soon™️ leading to 50 buttons

drifting arrow
#

Discords like "Hold my free shit. lets go deeper."

#

Also is there even a reason to need that many action rows or buttons or menus?

#

like at what point do you say it's too many?

#

I've tested it and for me personally I have 2 rows at any given time (except for my above trivia bot thing) and 2 of the buttons are dedicated to pagination just to try and keep it neat

#

I tried doing 3 and 4 rows and even with a few characters per button it just felt too cluttered. I can't imagine having 50 buttons

#

I cant really see a reason to have 25 lol

woeful hill
#

if they add more buttons i can use buttons to display a wordle letter status even

drifting arrow
#

wordle in discord?!

woeful hill
#

there are multiple ways

quick gust
woeful hill
#

mine is using bot emojis currently

#

some other uses image

drifting arrow
#

hhmm

#

If I were to make wordle in discord using buttons i'd be limited to just 5 word max. right?

#

Coz having it on multiple lines is weird

#

Coz I could display the 3 or 4 colors needed using default button colors.

woeful hill
#

my current implementation

drifting arrow
#

hhmm

#

Can you have more than 5 letters?

#

Coz a lot of the fun words are like 10

woeful hill
#

yeah

#

3 to 8

#

like wordless

drifting arrow
#

I assume the attempts button opens a modal?

woeful hill
#

nah the you won button is a guess button

drifting arrow
#

I see

#

So why have a button for attempts?

woeful hill
#

attempts just there cuz i think disabled button looks nicer than a field text in embed

drifting arrow
#

Perhaps for alignment you could put it on a separate row?

#

And you could even change the color as you get fewer attempts.

#

Green at start. yellow by 3rd. red on last

#

Or maybe green, blue blue, yellow red

#

You could also do the same for the embed color. Change its color based on number of guesses remaining

sick birch
#

but its mostly situational

drifting arrow
#

better than say buttons or select menu

unkempt canyonBOT
#
Command Help

Big Brother
!bigbrother
Monitors users by relaying their messages to the Big Brother watch channel.
!bigbrother unwatch <user> <reason>
Stop relaying messages by the given user.
!bigbrother watch <user> <reason>
Relay messages sent by the given user to the #big-brother channel.

Bot
!echo [channel] <text>
Repeat the given message in either a specified channel or the current channel.
!embed [channel] <text>
Send the input within an embed to either a specified channel or the current channel.

BotSource
!source [source_item]
Display information and a GitHub link to the source code of a command, tag, or cog.

Branding
!branding
Control the branding cog.

sick birch
#

well, for these we probably should have buttons. but assume it was just the trash icon

#

i prefer having a small trash emoji than an obnoxious big red button

#

especially when the embed is fairly small. at that point the delete button is almost the same size as the embed itself

drifting arrow
#

If buttons are not viable you could move to select menu instead?

#

Select menu imo would be more ideal as it would allow us to jump directly to a specific page instead of having to scroll

stark ingot
#

Reactions seem to be more buggy though. I also find it anoyying when the text shifts because it took a second to start adding reactions. Plus reactions cant be disabled. And it is unintuitive for the user because anyone could add a reaction to a message, it can be unclear that it is actually part of the bots functionality

viscid hornet
drifting arrow
viscid hornet
drifting arrow
#

lol

viscid hornet
drifting arrow
#

Thanks. You can put them on the floor over there

viscid hornet
woeful hill
#

the problem with using emoji is that...

#

i have the whole ~150 lines of code saving the emojis

drifting arrow
#

lol

#

Surely there has to be a better way to do it

woeful hill
#

yeah, better way is to automatically do that using discord.py 2.5 feature

#

it will be shorter but the emojis need to be sorted when upload for easy iterating thru

drifting arrow
#

I mean, assuming the pattern for emoji names remains the same, it wouldnt be too difficult

woeful hill
#

i did that, im just lazy updating to discord.py beta

woeful hill
drifting arrow
#

Yes but the sorting part would be easier if u went by name

viscid hornet
#

16

woeful hill
#

fetch_app_emojis or something

#

and you can also upload app emoji using code

viscid hornet
#

dude holy fuck

#

THANK YOU

#

@slate swan i gotta show you these results

slate swan
#

Lets see

viscid hornet
#

the first one is no resampling. the second one is with Resampling.NEAREST

slate swan
#

That’s great!

slate swan
#

Just ask your questions here or in #1035199133436354600.
People won't randomly join calls for basic things and questions.

fast osprey
#

If you're looking for a human to do for free what an AI used to do for you, that's not a good mindset. AI holds your hand, doesn't teach you anything, and lies through its teeth.

If you aren't comfortable reading documentation, understanding the concepts, and trying out code yourself, you are setting yourself up for failure.

#

json files are not a database, too

#

ai doesn't write the code

basic things that was wrote by ai

slate swan
#

free all day basically

We're not your personal assistants

#

As mentioned, if you have clear questions we can help

#

We won't code for you as it's contra productive

#

We'll give guidance and resources for you code it yourself

#

Humans are humans, AIs are machines.
Treat a human like AI and nobody will help you.

drifting arrow
#

He's gone :( I wish I got to see the original questions.

drifting arrow
#

You can use a json file as a database but it presents its own issues that you will encounter almost immediately lol

fast osprey
#

they got upset and deleted all their messages

drifting arrow
#

lol the walk of deletion

sick birch
drifting arrow
sick birch
#

they don't even do the bare minimum like containerize it so it's easy for their clients to run

fast osprey
#

My favorite one is "give me your token and I'll run the bot just trust me bro"

drifting arrow
#

lol

#

The amount of trust some people have in me when I build discord bots for them... I could destroy their entire life in like 2 seconds flat if programming wasn't fun lol

#

I'm often given complete access to not only their discord servers but their gaming servers as well. One script could delete everything.

#

But alas. That'd be lame lol

fast osprey
#

People are uneducated, don't care, or both. The amount of bots that request admin and people just grant it is obscene

drifting arrow
#

Well unfortunately the bots I make actually require some high level permissions. I create discord bots for gaming servers and usually it's to help them catch cheaters and what not. So this requires the bot to be able to ban people and get some data etc. Which unfortunately requires a specific set of permissions which could cause a great deal of harm.

#

It would be nice if the systems I use had better management over permissions so it wouldnt require such access

stark ingot
#

The main problem is when a bot specifically requests the "admin" permission because that just means that the owner put no thought into what permissions the bot actually needs

grave sandal
drifting arrow
#

And that's why most of my friends who once regularly asked me for help, now know how to program

sick birch
#

$9 for one line of code is wild

#

thats a whole meal

blazing beacon
#

thats a whole dollar short of 10 dollars

viscid hornet
viscid hornet
slate swan
#

So i made a /review which should be only for my customers so they can give my service a review but for some reason even if i dont got customer role i can just bypass it and execute the command how can i fix this bc i tried everything

fast osprey
#

Is the bot only in servers you control? Otherwise people can just grant whatever roles they want

slate swan
#

yes

#

Only in 1 tho

fast osprey
#

Then just use the built in permissioning

#

Guild settings -> integrations

slate swan
#

yh i was thinking of that but i want it to be like when you dont have the required role and try to execute the command it will say smth like ,,Hey! You dont have permissions to use this command."

quick gust
fast osprey
#

Why do you want people to be able to see and bother running a command that does nothing

#

And that you have to redeploy code if you want it to change

slate swan
#

yh

#

Wait i can show you my command

#
@bot.tree.command(name="review", description="Give the Service a Review")
@commands.has_role("Customer")
async def review_command(ctx, stars: Literal['⭐️', '⭐️⭐️', '⭐️⭐️⭐️', '⭐️⭐️⭐️⭐️', '⭐️⭐️⭐️⭐️⭐️'], product: Literal['Gfx', 'Video editing', 'unknown']):
    await ctx.response.send_message(f"Successfully send your feedback of {stars} star(s) and the product {product}", ephemeral=True)
    channel = bot.get_channel(1335696976096002150) 
    embed = discord.Embed(
        title="**New feedback!**",
        description=(f"**![heart](https://cdn.discordapp.com/emojis/1335580498633949194.webp?size=128 "heart") {ctx.user.name} left a feedback!**"),
        color=discord.Color.green()
        )
                   
    embed.add_field(name="![x_](https://cdn.discordapp.com/emojis/1335560113641099318.webp?size=128 "x_")**Stars:**", value=(f"**the customer left a review of {stars} star(s).**"))
    embed.add_field(name=":package:**Product:**", value=(f"**the customer bought the product {product}**"))
    embed.timestamp = discord.utils.utcnow()
    embed.set_footer(
        text=Footer,
        icon_url=FooterImage)
    embed.set_thumbnail(url=thumbnail)
    await channel.send(embed=embed)```
fast osprey
#

If you want to limit access to a command by role, use the permissioning system already given to you

fast osprey
fast osprey
#

It's not, but it's the most correct one

#

@commands decorators don't work on app commands, entirely different packages. You need the @app_commands decorators. There's one for a local role check, but this is worse in every way than just using the permissions discord gives you. Users will be presented and cluttered with a command you don't want them to use anyways, and your bot wastes bandwidth processing a command that shouldn't have been run in the first place

slate swan
#

yh true that makes sense thank you, i will use the discord Integrations permission instead.

fast osprey
#

!d discord.app_commands.checks.has_role

unkempt canyonBOT
#

@discord.app_commands.checks.has_role(item, /)```
A [`check()`](https://discordpy.readthedocs.io/en/stable/interactions/api.html#discord.app_commands.check) that is added that checks if the member invoking the command has the role specified via the name or ID specified.

If a string is specified, you must give the exact name of the role, including caps and spelling.

If an integer is specified, you must give the exact snowflake ID of the role...
fast osprey
#

This is the check if you do decide to use it, but it's your call

slate swan
#

Okay thanks

empty cobalt
winter sentinel
#

Hello ,i want to learn discord bots do anyone recomand some tutorials?Even tho i have a few bots i want to learn them better

woeful hill
fast osprey
#

Or downgrade to python 3.12. You should be in the habit of checking your library deps support

stark ingot
empty cobalt
#

How I can host my discord free boot

fast osprey
#

You don't

#

!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.

remote raptor
#

hello, im just here to ask if pycode is a good idea to keep the bot online, im trying to use pycode since termux takes quite a while to edit the codes in my opinion, since it has quite a messy interface. of course, im only a beginner at this type of stuff, so im just here to test out some opportunities, and not create famous bots.

#

so that means the bot doesnt necessarily needs to be online 24/7

#

im going to be using pycord by the way.

sick birch
shrewd apex
verbal pollen
#

Hello, can anybody help me with a bot I am working on for a server called Arcadia. I am an beginner-intermediate, looking for those who can help keep up the work or help maintain it. I am also looking to work on it and make it a bot which actually makes the server unique. Looking for assistance, please help.

viscid hornet
#

i wanna see this

wheat summit
#

What's wrong with this?

@bot.tree.command(name= "send_results", description=("Sends R/A results!"))
@discord.app_commands.choices(results=[
    discord.app_commands.Choice(name= "Passed", value= "1"),
    discord.app_commands.Choice(name= "Failed", value= "2")])

async def results(interaction = discord.Interaction, results = discord.app_commands.Choice[int]):
    await interaction.response.send_message(f'Results: ',{results.name})```
viscid hornet
#
from enum import Enum

class Outcomes(Enum):
    Passed = 1
    Failed = 2

@bot.tree.command(...)
async def results(..., results: Outcomes):
    ...
#

oh wait @wheat summit you're supposed to typehint results to ...Choice[int], not set it as a default

#

(as an example) instead of doing a: int, you're doing a = int

wheat summit
viscid hornet
wheat summit
viscid hornet
wheat summit
#

I'm not that good, I'm still a beginner.

#

Watching a video but I don't understand the error.

viscid hornet
wheat summit
viscid hornet
#

python is dynamically typed so typehints are stripped at runtime

#

but they're used to annotate what types variables, parameters and functions / methods involve

#
def mul(a: int, b: int) -> int:
    return a * b
#

this is the same as ```py
def mul(a, b):
return a * b

#

but we see that it takes two integers and then returns an integer

wheat summit
#

I see.

viscid hornet
#

this can be useful for more complex code

#

this is just a basic example

#

assignment and typehinting are two completely different things

#

like i said, typehints are stripped at runtime, so weird stuff like this works

wheat summit
#

Alright.

viscid hornet
#

!e ```py
a: int = "hello world"
print(a)

unkempt canyonBOT
wheat summit
#

So, how should I implement it in my code?

viscid hornet
#

we said a is an integer, but we can put a string there instead

#

because python is dynamically typed

#

variables can change types

wheat summit
viscid hornet
#

and after you fix that, change it to an enum

#

or use a Literal if the integers mean nothing to you

indigo blaze
#

anyone knows how to make discord bots?

#

i need help

slate swan
#

ask concrete questions

solar path
indigo blaze
slate swan
fast osprey
#

Pick a library -> follow that library's getting started guide

solar path
slate swan
#

there's a getting started section

#

other libs have other guides

solar path
#

!res checkout discord resources on here

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.

vapid parcel
#

Is there anything for this?

#

on_member_join and check for this value and if true, just kick / ban?

stark ingot
#

No, I dont have an official source but I have heard that it is not available to bots to prevent that specific thing. They dont want servers to trust those indicators 100% so you should not take automated action on them.

timber dragon
#

!d discord.PublicUserFlags.spammer

unkempt canyonBOT
timber dragon
#

That?

#

Or maybe it's the undocumented "unusual_dm_activity_until" field in the member object, if it still exists

shrewd apex
glad cradle
#

ty so I don't need to review it

shrewd apex
glad cradle
#

still waiting for that result

#

ik it's crazy

timber dragon
#

Soo many lines crii

#

So you just copypasted the whole ext.commands help implementation and changed everything to HybridCommand / app_commands.Command and added a paginator

shrewd apex
shrewd apex
wintry rose
#

figured it out 👍

drifting arrow
viscid hornet
#

makes them clickable, so it would be pretty neat if you used that instead of the blank /help

slate swan
viscid hornet
zealous wave
#

hello

frail raven
#

@viscid hornet

#

did you use pillow?

viscid hornet
#

!d PIL.Image

unkempt canyonBOT
#

Image Module

The Image module provides a class with the same name which is used to represent a PIL image. The module also provides a number of factory functions, including functions to load images from files, and to create new images.

viscid hornet
#

ooh they do have it

viscid hornet
unkempt canyonBOT
#

Image.resize(size: tuple[int, int] | list[int] | NumpyArray, resample: int | None = None, box: tuple[float, float, float, float] | None = None, reducing_gap: float | None = None) → Image```
Returns a resized copy of this image.
viscid hornet
#

so it's im.resize((new_width, new_height), Resampling.NEAREST)

proper bough
#

Thank you for sharing!!

frail raven
#

thank you so much for real this is super useful!

viscid hornet
wintry rose
#

yall is there a way with slash commands to only allow a specific list of strings as input

wintry rose
#

thx idk how to find stuff in the documentation

stark ingot
#

Note that this is limited to 25 options

#

And is only able to be updated by syncing your command again

quick gust
wintry rose
#

no i mean when im looking for something

wintry rose
#

why is my on_member_remove event sending multiple embeds when theres only one instance```py

member leave

@client.event
async def on_member_remove(member):
print(f"{member.display_name} left.")

embed = embeds.leave_embed(member)

leave_channel = client.get_channel(Config.Leave_Channel_ID)
_ = await leave_channel.send(embed=embed)```
static bramble
#

idk if its going to be the same for you, but i just restarted whatever program I was using. I was using Visual Studio Code and i had two tabs open in the terminal thingy at the bottom, with the same code. so when I ran it, it ran both

#

i know jack shi about coding, so idk if that was the real issue but, yeah, closed the second tab and restarded my app, and it fixed it

stark ingot
#

2 instances of the bot running could cause this

#

Also if it happens only every few times it could just be discord.

wanton current
#

never had it happen randomly

unique sand
#

can someone help me

#

idk why coding isnt working for me

#

tried it all and nothings working

#

(dm me pls)

feral timber
feral timber
unique sand
#

i’ve tired nothing helped

fast osprey
#

sooo maybe make a post describing what you tried, what your goal is, and what the problem is?

trail maple
#

is there a partial channel class?

#

some way of sending a message into a channel but only having the guild and channel id

fast osprey
#

PartialMessageable

trail maple
#

nice, thanks

slate swan
#

When New User Join -> [DISCORD BOT] (Sends Request to User Bot) -> [THIS USER BOT IS IN A SERVER EXAMPLE ADOPTME] (IT WILL CHECK IF NEW USER WHICH JOINED YOUR MAIN SERVER IS IN ADOPTME) -> {IF YES} -> {IT WILL SEND MAIN BOT TRUE (MAIN BOT WILL KICK THAT USER)} || {IF NO} NOTHING HAPPENS

#

who can help?

unkempt canyonBOT
#
Sending images in embeds using discord.py

Thanks to discord.py, sending local files as embed images is simple. You have to create an instance of discord.File class:

# When you know the file exact path, you can pass it.
file = discord.File("/this/is/path/to/my/file.png", filename="file.png")

# When you have the file-like object, then you can pass this instead path.
with open("/this/is/path/to/my/file.png", "rb") as f:
    file = discord.File(f)

When using the file-like object, you have to open it in rb ('read binary') mode. Also, in this case, passing filename to it is not necessary.
Please note that filename must not contain underscores. This is a Discord limitation.

discord.Embed instances have a set_image method which can be used to set an attachment as an image:

embed = discord.Embed()
# Set other fields
embed.set_image(url="attachment://file.png")  # Filename here must be exactly same as attachment filename.

After this, you can send an embed with an attachment to Discord:

await channel.send(file=file, embed=embed)

This example uses discord.TextChannel for sending, but any instance of discord.abc.Messageable can be used for sending.

blissful crane
slate swan
#

its proctetion

#

bot

pale zenith
#

Why would that matter at all? Rules are rules

slate swan
#

You can write your question without it being IN BOLD AND ALL UPPERCASE, painful to read.

#

Because of you using "user bot" it implies it's a selfbot, which is not allowed as per ToS - though protection can be done with normal discord applications/bots. You just need to invite the bot in both servers. Kind of like a global ban bot.

stark ingot
#

There is no point to have 2 bots that communicate when one bot can do the work

young dagger
pseudo saffron
#

this somehow dont add a application command for me

    @app_commands.command(name="verification",description="der command für die verifikation")
    @app_commands.choices(option=[
        app_commands.Choice(name="zeig den code",value="zeig"),
        app_commands.Choice(name="gib den code ein",value="gib")
    ])
    async def verification(self,i : discord.Interaction,option: app_commands.Choice[str]):
        if option.value == "zeig":
            self.bot.vercursor.execute(f"Select * where Discord_ID = {i.user.id}")
            x = self.bot.vercursor.fetchall()
            print(x)

#

can someone help me

pseudo saffron
#

no it works now

slate swan
novel scaffold
#

it looks like it is missing a table

sleek shale
#

how can i make bot press button?

fast osprey
#

Bots can't perform interactions

sleek shale
fast osprey
#

Bots cannot perform interactions

#

if it's a url button, you can read that and hit that url sure

sleek shale
#

i just need to know how can i fire that logged user will press button

fast osprey
sleek shale
fast osprey
#

what is a logged user, and what is fire

sleek shale
fast osprey
#

ah yes, insult the people helping you for free

#

pro strat prettythumbsup

sleek shale
#

it was a question

#

insult would be as if i would start swearing on you

fast osprey
#

Questions can be an insult, which that was

sleek shale
wanton current
#

is that another question

sleek shale
sleek shale
fast osprey
#

<@&831776746206265384>

sleek shale
#

💀

#

☠️ ☠️ ☠️

blissful lagoon
#

@sleek shale using "gay" as an insult is not acceptable
please make sure you read and understand our #code-of-conduct if you want to remain here

sleek shale
#

tell me you're not after lgbt

#

tell me you have b4lls

blissful lagoon
#

!ban 1330643318471790617

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied ban to @sleek shale permanently.

grave sandal
#

Ban much deserved, it's not like anyone was gonna help him here after that. 😂

severe rampart
viscid hornet
young dagger
#

There's too much hate in this world. If you want to be special, spread some positivity

pallid plank
#

What's wrong with this world (aside from everything

#

)

manic gull
#

hello

#

can anyone help me make a discord bot

#

like this but without the worrds

#

when i click the green one i want it to make a support ticket

pallid plank
manic gull
#

oh well i want like a ticket bot

pallid plank
manic gull
manic gull
slate swan
slate swan
pallid plank
manic gull
slate swan
slate swan
slate swan
#

any paid offerings must be done via their monetization feature

#

not some random paypal transaction (only)

manic gull
#

dude it was an example

#

i want a discord bot that makes a ticket

slate swan
#

i mean some of the biggest bots have their own websited that ppl pay on so

manic gull
#

i linked a ticketbot

slate swan
#

well, that example is against the rules of this server

slate swan
slate swan
#

can't say "!rule paid"

slate swan
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.

slate swan
#

take mee6 as an example

manic gull
#

user i think we have dms still can u dm me and help me ima go make some pizza rq

#

ill be back soon

slate swan
#

mee6 and dyno are bad examples either way, they're somehow excluded from any restrictions of discord

slate swan
#

wouldn't be the first time

slate swan
#

its mainly for donations

#

Enjoy the reading ^^

slate swan
#

ty

stark ingot
#

For what its worth this seems to only apply to bots (which is true in this case)

Beginning on October 7, 2024, in regions where Discord supports monetization through its Premium Apps products, all developers who offer paid features or capabilities for their Application will be required to:

(i) support purchase of such features or capabilities through Discord’s Premium Apps products; and,
(ii) offer such features or capabilities at prices on Discord that are no higher than the prices at which they are offered through other payment options.
Only paid features or capabilities that are offerings supported by Discord’s Premium Apps products will be subject to these requirements.
Currently I think only US, EU, and UK support these features. Also I do not know if discord supports exactly what this user needs. Discord left the door open with that last term. I think you could easily set up a system that is unsupported just to get around the requirement.

With that said, it is more than likely that the user is breaking TOS with whatever thing they are selling.

drifting arrow
#

TL;DR - Give discord some of yer money :D

woeful hill
#

Not just some, more like half

drifting arrow
timid smelt
#

Bruh, I'm so bored... Does anyone have any project?

fast osprey
#

Make a project that generates projects to do

viscid hornet
# fast osprey Make a project that generates projects to do

speaking of projects to do, i'm making a fishing minigame for my discord bot. would it be better to have a single coins value or the common pocket and bank values instead? i'm leaning more towards coins, simply because it's not really an economy bot: it's moreso fishing at this point in time, but what do you think?

blissful crane
#

the bank feature was made in the first place to implement a rob command too

viscid hornet
viscid hornet
#

break into someone's showcase, steal their rare items

slate swan
#

SLI, when you finally make that game, can others also play it?

stark ingot
viscid hornet
#

what does 'sli' mean?

quick gust
#

Slowly Losing It

viscid hornet
#

updated name now

quick gust
#

how's the progress on the fishing minigame going, axo

viscid hornet
#

only today did i actually commit to it

quick gust
#

mm, atleast you started

viscid hornet
#

i have some good ideas tho

#

it's gonna be good lemon_swag

#

(then flop)

#

(then get left in a drawer)

#

the cycle of life

quick gust
viscid hornet
pallid plank
#

Sounds interesting 🤔

viscid hornet
#

like what even is this??

viscid hornet
viscid hornet
quick gust
#

is the bot based around fishing or something else?

viscid hornet
slate swan
viscid hornet
#

easier that way

slate swan
#

Axo it is, deal.

slate swan
viscid hornet
#

usage times, used commands, profiles, names - everything

#

data farmer

sick birch
viscid hornet
#

whats the benefit of this?

sick birch
#

probably not much for a small project

#

but its fun to make visualizations and a good thing to learn

viscid hornet
sick birch
#

sure

viscid hornet
#

could get enough of working code in an hour that would've been spent setting up and integrating what you sent me

indigo blaze
viscid hornet
indigo blaze
viscid hornet
crisp glacier
viscid hornet
indigo blaze
viscid hornet
indigo blaze
#

but i'm just finaly in a server when i can roast pepole

quick gust
#

such good roasts damn frog_shocked frog_shocked these people crying right now for real

indigo blaze
viscid hornet
#

then when i'm done, i'll make another one

indigo blaze
#

sorry for making you cry

pallid plank
#

!rule 1

unkempt canyonBOT
pallid plank
#

It was always there

indigo blaze
quick gust
pallid plank