#discord-bots

1 messages · Page 308 of 1

heady tree
#

👀

shrewd fjord
#

demn

quick brook
#

To me I will always be vested in mentoring others within this field, but this server isn't the best place to do so. Long story short, I'm taking a break from this server

young dagger
#

@quick brook Namecheap or Hostinger, good choice for VPS?

glad cradle
#

lmao, she said she is done with this server, it's 1 message above

burnt coral
slate swan
#

How can i add it so only a user with a specific role can run a specific command?

glad cradle
#

!d discord.ext.commands.has_role

unkempt canyonBOT
#

@discord.ext.commands.has_role(item)```
A [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.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.

If the message is invoked in a private message context then the check will return `False`.

This check raises one of two special exceptions, [`MissingRole`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingRole) if the user is missing a role, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.NoPrivateMessage) if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure).

Changed in version 1.1: Raise [`MissingRole`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingRole) or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.NoPrivateMessage) instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure)...
slate swan
#

so

#

?

#

@glad cradle

glad cradle
#

also read the docs

slate swan
#

i forgot to delete the "so"

#

so

#

so

glad cradle
#

so so

slate swan
#

why did it say only the first word?

shrewd apex
#

it didn't wanna speak more

slate swan
#

really?

shrewd apex
#

really

slate swan
#

it got tired of it

shrewd apex
#

show ur command code

slate swan
#
async def say(ctx, message=None):
    await ctx.send(message)
#

this is actual solution ^

shrewd apex
#

ctx, *, message = ""

slate swan
shrewd apex
#

i mean i don't have doc links in my pocket loooli

slate swan
shrewd apex
#

yeah

slate swan
#

you cant use self outside class methods

hasty pike
#

Not even in decorator inside class?

slate swan
#

no cause decorator is not inside a method

#

its above it

final iron
hasty pike
slate swan
#

if you need something from class as button name or else you need to create a custom button for that

hasty pike
#

Anyway I'll see

slate swan
#

or whatever it is if not button

hasty pike
#

Ohkay

nova vessel
#

How can I use the webhook.incoming URL generator to send webhooks to my bot directly and then process them?

slate swan
#

JSON is mostlikely used to exchange data

nova vessel
#

You can use Google Translate API?

#

There's quite a few ways to do it I believe

meager rock
#

use JSON to store translations

nova vessel
#

You can do a JSON like Down suggested but it will take time to translate everything your bot outputs into those languages

final iron
#

You’re going to write down every word?

#

Why not just use google translate?

#

Honestly, I find it pretty unlikely you’ve translated an entire language, and accounted for different contexts/tenses

#

For English apparently there’s 1m words alone, and English is one of the simpler languages

#

Then you have past tense, future tense and present

#

You also have plural and singular

#

And if it’s a language with different conjugations like French it gets even more complicated

turbid condor
#

Using Google translate or some other api is way better

#

What will you do incase of complex languages

final iron
#

Doing it manually is just not feasible

#

I’d rather have a few poor translations than just completely missing words

turbid condor
#

Wdym by translate features?

shrewd fjord
#

purrrfect

glad cradle
turbid condor
#

Rather than number I'm more impressed by the question

glad cradle
#

i18n

shrewd fjord
#

:3

#

so like
(prefix)setlang japanese

#

then u do prefix(help)

#

the texts it sends after u do help it gets translated to japanese or smthng?

lunar vine
#

@quick brook

#

how do i make a new class 😃

slate swan
#
class YourClass:
    # stuff
idle lantern
slate swan
#

Yeah that's some discord issue people have been reporting

#

Nothing you can really do about

slate swan
pale zenith
#

"That sign can't stop me because I can't read!"

upbeat mason
#

why does it show it isnt found?

slate swan
upbeat mason
#

alr ty

lunar vine
slate swan
#

I mean, worst is not that

#

worst is that it's just a pointless ping KEK

bitter knoll
#

Can anyone tell few discord bot games

fiery girder
#

is there anygood package and server than is free and i can use to transfer data from computer to it using python

fiery girder
turbid condor
fiery girder
#

yes

turbid condor
#

U can use google drive for that

fiery girder
#

no

turbid condor
#

They have an api to interact with it

fiery girder
#

anything else?

fiery girder
#

api docs for google sucks

final iron
fiery girder
#

cause its not for python only its for all

slate swan
fiery girder
slate swan
fiery girder
#

ik

slate swan
#

maybe there is a wrapper in python for google apis

turbid condor
fiery girder
#

hmm

#

can someone get my token even if i turn it in exe?

slate swan
fiery girder
#

they still suck

slate swan
#

maybe you just cant read them?

fiery girder
#

yea cause they suck

slate swan
#

properly

turbid condor
#

Afaik google gives examples in multiple languages including python

fiery girder
#

anyway is there any other one cause i dont want my google token to be access from the exe i make

turbid condor
#

You can access nothing from .exe file

#

It's used to run a compiled file

#

Try opening a .exe in your notepad or ide

bitter knoll
bitter knoll
turbid condor
bitter knoll
#

Oh

turbid condor
#

You can try creating an rpg

bitter knoll
#

RPG ?

fiery girder
fiery girder
slate swan
turbid condor
#

You can check the web for those

bitter knoll
bitter knoll
#

Thanks for the suggestion

turbid condor
#

There are many other options like a chess game, match 5

#

You can use images for those

cold oyster
#

Error handling a command when someone dosent have a role, Any idea how to do that

slate swan
#

Use decorators, handle the error according to docs

turbid condor
#

It's similar to other errors

cold oyster
# slate swan Use decorators, handle the error according to docs
@sg.error
async def sg_error(ctx, error):
    if isinstance(error, commands.MissingRequiredArgument):
        await ctx.send("MXNKEY! You did not provide the game number!")
        print(error)
    if isinstance(error, commands.MissingRole):
        await ctx.sendE("MxNKEY! You do not have enough permissions to run this command!")
        print(error)```
this does not work it gives out some other error
slate swan
#

Then handle the other error bigbrain

cold oyster
#

huh?

slate swan
#

what if the error is not one of those two?

#

Also "sendE" doesn't seem correct

#

then it will just get through

cold oyster
cold oyster
#

wait yeah nvm

slate swan
cold oyster
#

this SendE is confusing

slate swan
#

🤦

turbid condor
#

You are using sendE instead of send as simple as that

slate swan
#

Nothing confusing, just wrong function 🧠

cold oyster
#

nah bro fr i feel embarrased now

mighty pilot
#

What's the concern with having your token in your code? I understand that it's safer to put it in a seperate file like .env but I never knew why, just pushed the I believe button

brazen raft
#

If you ever need to share the bot's files you won't have to worry about leaking the token

#

.env files are usually ignored by Git, or you can set it so if you're using Git

final iron
mighty pilot
#

Ah I see. Just an extra layer of protection to stop you from doing something dumb

brazen raft
#

I think replit has environment variables as a side tab thing though

final iron
#

It’s also easier to hold all your tokens/api keys in one file

cold oyster
#

What error is this
Command raised an exception: NotFound: 404 Not Found (error code: 10008): Unknown Message

It sends runs the command twice

Any idea why this is happening?

Its for all the commands too

naive briar
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.

cold oyster
naive briar
#

Then I won't know where the error came from

slate swan
cold oyster
cold oyster
naive briar
#

That's what happens when you're printing the error, not raising

slate swan
#

you have any error handler?

naive briar
#

Which you shouldn't do

slate swan
#

cause you are most likely doing print(error)

cold oyster
lunar vine
#

syndrome

cold oyster
# slate swan cause you are most likely doing print(error)
@sg.error
async def sg_error(ctx, error):
    if isinstance(error, commands.MissingRequiredArgument):
        await ctx.send("MXNKEY! You did not provide the game number!")
    if isinstance(error, commands.MissingRole):
        await ctx.send("MNKEY! You do not have enough permissions to run this command!")
    else:
        print(error)```

I am- how do I fix that
naive briar
#

Re-raise the error instead of printing it

slate swan
#

raise the error not print it

cold oyster
naive briar
#

It's a statement, but that works

cold oyster
# naive briar It's a statement, but that works
Traceback (most recent call last):
  File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\client.py", line 705, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\bot_base.py", line 629, in on_message
    await self.process_commands(message)
  File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\bot_base.py", line 626, in process_commands
    await self.invoke(ctx)
  File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\bot_base.py", line 593, in invoke
    await ctx.command.dispatch_error(ctx, exc)
  File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\core.py", line 525, in dispatch_error
    stop_propagation = await injected(ctx, error)
  File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\core.py", line 157, in wrapped
    ret = await coro(*args, **kwargs)
  File "c:\Users\HP\OneDrive\Desktop\pass-2\Mxnkek-scrims-bot\main.py", line 122, in sg_error
    raise(error)
  File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\bot_base.py", line 589, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\core.py", line 914, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\core.py", line 182, in wrapped
    raise CommandInvokeError(exc) from exc
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: NotFound: 404 Not Found (error code: 10008): Unknown Message```
slate swan
cold oyster
lunar vine
#

do you have the messages content or whatever it was enabled

naive briar
lunar vine
slate swan
#

show your on_message event

#

nvm

cold oyster
#

Its doing this for all the commands

lunar vine
#

that error?

cold oyster
#

Also If I did not mention Im using disnake and if this is useful

lunar vine
#

u dont have the thing enabled i think bro

cold oyster
cold oyster
lunar vine
#

in ur code and dev portal?

cold oyster
#
intents = disnake.Intents.default()
intents.message_content = True
client = commands.Bot(command_prefix="!", intents=intents)```

If this is the right way
slate swan
#

yes thats good

lunar vine
#

okay then uh

#

what line is giving that error code

cold oyster
#

Bro everything was going good until now, I do not remember me changing anythingf

lunar vine
#

is it the print error from before or wut

cold oyster
#

so basically all..?

lunar vine
#

the bot may or may not be running two times

#

are u running it on two code editors or vps

#

@cold oyster

cold oyster
lunar vine
#

shut that down

#

and try a cmd

cold oyster
#

just did but didnt work

lunar vine
#

okay sir

#

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

cold oyster
#

@naive briar @slate swan any help?

cold oyster
lunar vine
#

paste da governmental information there

#

aka ur code

cold oyster
#

alr

naive briar
#

I have no idea, maybe it's disnake's problem

slate swan
#

@glad cradle

lunar vine
#

top ten disnake users

cold oyster
cold oyster
slate swan
cold oyster
lunar vine
#

bluddd

#

what are we raising

#

a boy or a girl lmk

slate swan
#

...

warm vigil
#

.

cold oyster
slate swan
lunar vine
#

idk i dont use raise but i thought we needed to print the error

cold oyster
lunar vine
#

raise*****

cold oyster
#

it still raises error

slate swan
lunar vine
#

all the other rest are print tho

warm vigil
cold oyster
cold oyster
naive briar
#

!e

try:
    0 / 0
except:
    print("Re-raising")
    raise
slate swan
unkempt canyonBOT
#

@naive briar :x: Your 3.11 eval job has completed with return code 1.

001 | Re-raising
002 | Traceback (most recent call last):
003 |   File "/home/main.py", line 2, in <module>
004 |     0 / 0
005 |     ~~^~~
006 | ZeroDivisionError: division by zero
lunar vine
slate swan
cold oyster
unkempt canyonBOT
lunar vine
#

ur username is downie

#

myb tho

cold oyster
slate swan
lunar vine
#

I*; and I didn't know it would offend u

cold oyster
#

Brooooo just help meee

lunar vine
cold oyster
lunar vine
#

two msgs each cmd or was it the big thing

cold oyster
lunar vine
#

do u use client.run more than once in ur code

lunar vine
#

are u 100% sure no any other enviorments are running

cold oyster
lunar vine
#

did u try restarting it

cold oyster
lunar vine
#

what was the last thing u added before hand when it was working b4*

cold oyster
lunar vine
#

what was the last thing u added

#

before it was wurkin

cold oyster
naive briar
lunar vine
cold oyster
lunar vine
#

?

late reef
#

The Discord.py documentation tells me how to create an embed thumbnail from a URL, but is there a way to do it from a file on the PC, or in the project folder? IE: photo.png?

lunar vine
late reef
#

tyty

lunar vine
#
file = discord.File("path/to/my/image.png", filename="image.png")
embed = discord.Embed()
embed.set_image(url="attachment://image.png")
await channel.send(file=file, embed=embed)
#

okay @cold oyster good luck on your journey thru python!

upbeat mason
#

should i use .json if i want to make a database?

upbeat mason
# lunar vine how did u do that

See [How do I use a local image file for an embed image?](https://discordpy.readthedocs.io/en/stable/faq.html#how-do-i-use-a-local-image-file-for-an-embed-image)

upbeat mason
slate swan
#

cause json is not a database?

upbeat mason
#

still works though

#

i means theres sqlite3

slate swan
#

if something works doesnt mean its good

upbeat mason
#

tell me why not to use it

slate swan
lunar vine
#

it works but its not that good

upbeat mason
#

god yall have a page for everything lmao

lunar vine
#

i think a txt file may or may not be better

slate swan
upbeat mason
#

i think a txt file would be even worse

slate swan
#

ah yes, a database in a text file

upbeat mason
#

okay then what do you recommend

slate swan
#

I'd make a database in a PowerPoint document

lunar vine
#

works at the end of the day tho

slate swan
#

Sounds better to be fair

#

use a tool that is designed to store data ❌
use a text file ✅

#

🤦

lunar vine
#

^

upbeat mason
#

sqlite3?

slate swan
#

mysql, sqlite, mongodb, postgresql, redis

lunar vine
#

use a csv file 😋

upbeat mason
#

ight thanks

slate swan
#

whatever you like and suits you the most

lunar vine
slate swan
#

there are not better ones

#

I wouldn't go for redis to be fair

sick birch
#

Postgres is my go-to

#

But SQLite is also good for smaller projects

slate swan
#

and redis for cache

lunar vine
#

whats swiss armed forces

#

sorry offtopic

slate swan
lunar vine
#

@lunar fulcrum how may i help u today

#

can you stop offending me?

sick birch
lunar fulcrum
#

Hi guys , I am new to Python and programming .

Any tips on how I can become a better learner/programmer?🫶

slate swan
lunar vine
lunar fulcrum
lunar vine
#

10-4

slate swan
#

And you can go on the resources page

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.

lunar vine
slate swan
#

oh no

#

youtube tutorials oh boy

lunar vine
#

its programming with mosh

slate swan
#

People in this channel should know to not listen to that person KEK

lunar vine
#

ive seen people recommend it in this server before, many times

late reef
#

Put a thumbnail for my discord bot, but it seems to have this strange little line around it. I know for a fact that line is not there in the regular img file, so is this a normal thing?

slate swan
#

your image is low quality

#

Thumbnail?

#

embed thumbnail

#

And yeah, it's actually in the image

late reef
#

Hm

slate swan
slate swan
late reef
#

Yeah I'm pretty new lol

lunar vine
#

do u guys know how

#

to wait for a butto to be clicked

#

because i have to sleep(20) seconds so my interaction isnt f'd up

#

someone pls give docs or something man

slate swan
#

There's an examples folder

#

and in there, there's a view folder iirc

sick birch
unkempt canyonBOT
#

class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.

len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.

bool(b) Returns whether the embed has any data set.

New in version 2.0.

x == y Checks if two embeds are equal.

New in version 2.0...
sick birch
#

It has a set_thumbnail method

late reef
#

ty! I got it figured out

slate swan
#

Yeah won't solve their issue of the image having a white border

late reef
#

When trying to have the bot react to a message, what is the best way to do so? I figure something like:
message.add_reaction(emoji="\:peach:")
or something along those lines, but keep getting the error PartialMessage.add_reaction() got some positional-only arguments passed as keyword arguments: 'emoji'

any help?

buoyant quail
#

!e

def f(x, /):
    print(x)
    
f(123)
f(x=321)
unkempt canyonBOT
#

@buoyant quail :x: Your 3.11 eval job has completed with return code 1.

001 | 123
002 | Traceback (most recent call last):
003 |   File "/home/main.py", line 5, in <module>
004 |     f(x=321)
005 | TypeError: f() got some positional-only arguments passed as keyword arguments: 'x'
buoyant quail
#

!d discord.Message.add_reaction
It accepts only positional args

unkempt canyonBOT
#

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

Adds a reaction to the message.

The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Emoji).

You must have [`read_message_history`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.read_message_history) to do this. If nobody else has reacted to the message using this emoji, [`add_reactions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.add_reactions) is required.

Changed in version 2.0: `emoji` parameter is now positional-only.

Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError) instead of `InvalidArgument`.
sick birch
late reef
#

I made a mistake

sick birch
late reef
clever bronze
#
#https://discordpy.readthedocs.io/en/stable/ext/commands/commands.html#invocation-context
import discord
from discord.ext import commands

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

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

client = discord.Client(intents=intents)

@client.event
async def on_ready():
    print('We have logged in as {0.user}'.format(client))

token = ''
client.run(token)

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

    if message.content.startswith(f'{prefix}hello'):
        await message.channel.send('Fuck you, this is not what I wanted.')

    if message.content.startswith(f'{prefix}command'):
        await message.channel.send('Shut the fuck up!')


#

bot wont respond to the messages at all

#

even though its online

#

no error messages

sick birch
final iron
#

Using on_message to create commands is also fundamentally flawed

#

Use the commands extension

#

You shouldn't be mixing video tutorials, or using them at all

upbeat mason
#

if you make your discord bot generate invites for every server it is in, is it against tos?

#

not really to do with code but still yk

final iron
#

If they're private servers, and the users didn't agree to this beforehand Discord wouldn't be too happy

upbeat mason
#

its complicated

#

cause like, i dont think its against tos to see how many servers your bot is in or which

#

but making invite links might be, what do you think?

final iron
#

No, but creating invites is a privacy issue

#

Private servers are private for a reason

upbeat mason
#

okay thanks

late reef
#

Going of of my question from earlier, I'm now trying to make the bot react with a green_square emoji. Except when I copy the emoji directly into the code, it ends up returning an enknown emoji error ):

late reef
austere vale
#

Is there a channel or location anywhere here to hire a dev to help you make a bot?

harsh orbit
#
class ticket_button(discord.ui.View):
    def __init__(self):
        super().__init__()
        self.Value = None

    @discord.ui.button(label="🎫 Buy Now.", style=discord.ButtonStyle.gray)
    async def open(self, interaction: discord.Interaction, button: discord.ui.button):

Why when I make a Button like this
after some minutes the buttons stop working

slate swan
naive briar
unkempt canyonBOT
#

class discord.ui.View(*, timeout=180.0)```
Represents a UI view.

This object must be inherited to create a UI within Discord.

New in version 2.0.
harsh orbit
meager rock
#

set it to None

harsh orbit
#
  File "C:\Users\Hadi\PycharmProjects\resellers-3\main.py", line 1709, in <module>
    class ticket_button(discord.ui.View(timeout=None)):
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Hadi\PycharmProjects\resellers-3\venv\Lib\site-packages\discord\ui\view.py", line 192, in __init__
    self.__stopped: asyncio.Future[bool] = asyncio.get_running_loop().create_future()
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: no running event loop ```
meager rock
#

you do that while initialising it, not there

naive briar
#

There's something similar to that 🫠

class AClass(Something, arg=value): ...
harsh orbit
naive briar
#

No, I just realized that discord.py doesn't implement that

harsh orbit
#

So, how do I disable timeout?

naive briar
#

Just set it in super().__init__() of the subclass 🤷

late reef
#

strange request: anyone happen to know where I can find a full list of the Discord emojis in their string-form? IE: [":whale", ":airplane"...]

slate swan
#

It's on Google somewhere

#

And considering discord is using twemoji, you can get that list easily

slate swan
#

is status only retreivable through a member object?

golden portal
#

Yes

idle lantern
cold oyster
#

@lunar vine @naive briar @slate swan

Yesterdays issue which I don't think yall could figure out which was bot is running every command twice, I did not have 2 consoles running but still it had that behavior. I simply just reset the bot token and updated it in the codeand it worked. Sorry for the pings just wanted to give out the solution

#

!d status

nova vessel
#

How would I go about sending webhooks to my Discord bot?

cold oyster
#

So how do I set a presence of a bot and also how do I make it change over time like after 1 minute it says watching over mxnkey scrims and after that it says listening to commands

nova vessel
#
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="mxnkey scrims!"))

Where activity is, change that to either listening, streaming or gaming (not to sure about that one) and then name is what you want it to say after, so for example, this would say: "Watching mxnkey scrims!

#

To change, I would just create a while True loop, make it sleep using time and then change it as you see fit.

#

@cold oyster

cold oyster
#

Hi

naive briar
cold oyster
naive briar
#

Call the function again and again with while-loops or discord.py's task loops

naive briar
#

!d discord.Webhook.from_url - you can use this function to create a webhook object, then use the send method of the object

unkempt canyonBOT
#

classmethod from_url(url, *, session=..., client=..., bot_token=None)```
Creates a partial [`Webhook`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Webhook) from a webhook URL.

Changed in version 2.0: This function will now raise [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError) instead of `InvalidArgument`.
nova vessel
#

So from this webhook it creates, I can send payloads to it and process it?

naive briar
#

You can send a webhook message to Discord, yes

marble rampart
#

is there anyway for me to get live data about what user is typing in a SlashOption and then change the choises ?

nova vessel
naive briar
#

That is called autocomplete

#

!d discord.app_commands.autocomplete - you can use this decorator to create one (assuming that you're using discord.py)

unkempt canyonBOT
#

@discord.app_commands.autocomplete(**parameters)```
Associates the given parameters with the given autocomplete callback.

Autocomplete is only supported on types that have [`str`](https://docs.python.org/3/library/stdtypes.html#str), [`int`](https://docs.python.org/3/library/functions.html#int), or [`float`](https://docs.python.org/3/library/functions.html#float) values.

[`Checks`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.check) are supported, however they must be attached to the autocomplete callback in order to work. Checks attached to the command are ignored when invoking the autocomplete callback.

For more information, see the [`Command.autocomplete()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.Command.autocomplete) documentation.

Warning

The choices returned from this coroutine are suggestions. The user may ignore them and input their own value...
marble rampart
#

ok but can i get the live data that the user is typing

#

because lets say the user searchs for other users in a website and i cant add all the users to that

naive briar
#

discord.py will call your autocomplete function once the user changed their input

marble rampart
#

ok ty

#

love u ❤️

naive briar
#

🐈

marble rampart
#

🐕

cold oyster
twilit grotto
naive briar
#

If you're talking about asyncio.Task, that involves the while-loops option

#

If you're talking about discord.ext.tasks.task, I already mentioned that 🫠

twilit grotto
#

oh sorry i didn't see that 😭

naive briar
#

Don't worry about it

naive briar
#

🤭

cold oyster
#

In a modal class, in the on_submit thing how do I send a message to a custom channel?

#

@naive briar @slate swan help :)

slate swan
#

!d discord.ext.commands.Bot.get_channel

unkempt canyonBOT
cold oyster
#

what does this mean

  File "c:\Users\HP\OneDrive\Desktop\pass-2\Mxnkek-scrims-bot\main.py", line 7, in <module>
    class StaffApplicationModal(ui.modal, title="Mxnkey Scrims Staff Application"):
  File "c:\Users\HP\OneDrive\Desktop\pass-2\Mxnkek-scrims-bot\main.py", line 8, in StaffApplicationModal
    name = ui.TextInput(label="What is your real name", placeholder="My name is First Name Last Name", )
TypeError: TextInput.__init__() missing 1 required keyword-only argument: 'custom_id'```
#
class StaffApplicationModal(ui.modal, title="Mxnkey Scrims Staff Application"):
    name = ui.TextInput(label="What is your real name", placeholder="My name is First Name Last Name", )```

This is the line which is getting the error
#

@slate swan

slate swan
#

Help!

#

I never faced the following error before

turbid condor
#

Can't see any error

slate swan
slate swan
# turbid condor Can't see any error
Traceback (most recent call last):
  File "d:\Shrey\Projects\S-Bot\code\__main__.py", line 6, in <module>
    bot.load_extensions("code/cogs/")
  File "C:\Users\welcome\AppData\Local\Programs\Python\Python311\Lib\site-packages\disnake\ext\commands\common_bot_base.py", line 638, in load_extensions
    self.load_extension(extension)
  File "C:\Users\welcome\AppData\Local\Programs\Python\Python311\Lib\site-packages\disnake\ext\commands\common_bot_base.py", line 519, in load_extension
    spec = importlib.util.find_spec(name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib.util>", line 94, in find_spec
ModuleNotFoundError: No module named 'code.cogs'; 'code' is not a package
#

Sending code.

#

i guess you want to import something from folder code

#
bot = commands.InteractionBot(owner_id=1113345631017254973, test_guilds=[1158032926500462613])
bot.load_extensions("code/cogs/")
#

i did this

turbid condor
#

But that something doesn't exist

slate swan
#

leme send the file tree also

slate swan
#

code.cogs

#

what

#

so i dont include the /

#

i write code.cogs in load_extensions

#

yes.

#

doesnt work

turbid condor
#

But u will need to loop through each file

slate swan
#

show the error :D

#
Traceback (most recent call last):
  File "d:\Shrey\Projects\S-Bot\code\__main__.py", line 6, in <module>
    bot.load_extensions("code.cogs")
  File "C:\Users\welcome\AppData\Local\Programs\Python\Python311\Lib\site-packages\disnake\ext\commands\common_bot_base.py", line 637, in load_extensions
    for extension in disnake.utils.search_directory(path):
  File "C:\Users\welcome\AppData\Local\Programs\Python\Python311\Lib\site-packages\disnake\utils.py", line 1271, 
in search_directory
    raise ValueError(f"Provided path '{abspath}' does not exist")
ValueError: Provided path 'D:\Shrey\Projects\S-Bot\code.cogs' does not exist
#

show file tree

#

yeah wait

slate swan
twilit grotto
#

you have to load each cog individually

slate swan
# slate swan

you dont include code since you are already in that folder

#

so it will only be cogs

#

cogs.basic actually

#

das the problem, i couldn't do that it would just say that cogs doesnt exist

slate swan
turbid condor
#

I don't think that will work

slate swan
#

you cant just imagine methods

#

wtf

#

something like this does not exist

#

you need to loop over each file in that directory

#

are you sure about that

#

and load it

#

im using disnake

#

then i dont know maybe in disnake there is such method

turbid condor
#

!pip disnake

unkempt canyonBOT
slate swan
#

it exist, i did it many times before

#

only now its not working

#

well then show error you get now

slate swan
# slate swan well then show error you get now

On removing code/cogs and doing cogs:

Traceback (most recent call last):
  File "d:\Shrey\Projects\S-Bot\code\__main__.py", line 6, in <module>
    bot.load_extensions("cogs")
  File "C:\Users\welcome\AppData\Local\Programs\Python\Python311\Lib\site-packages\disnake\ext\commands\common_bot_base.py", line 637, in load_extensions
    for extension in disnake.utils.search_directory(path):
  File "C:\Users\welcome\AppData\Local\Programs\Python\Python311\Lib\site-packages\disnake\utils.py", line 1271, 
in search_directory
    raise ValueError(f"Provided path '{abspath}' does not exist")
ValueError: Provided path 'D:\Shrey\Projects\S-Bot\cogs' does not exist
turbid condor
#

Yeah load_extensions is there and it accepts a path

slate swan
#

for some reason its in S-Bot directory i think

turbid condor
#

The path to code cogs folder should be py D:\\Shrey\\Projects\\S-Bot\\code\\cogs\\

slate swan
#

yeah leme try that

naive briar
unkempt canyonBOT
#
NEGATORY.

No documentation found for the requested symbol.

naive briar
#

Right

twilit grotto
naive briar
#

I know, I just read the conversation before sending that

slate swan
#

Let me send the actual code in that cog.

#

basic.py file maybe something is wrong with it

#
import disnake
from disnake.ext import commands


class BasicCmds(commands.Cog):

    def __init__(self, bot):
        self.bot: commands.InteractionBot = bot


    @ commands.slash_command(name="test", description="Checks if the bot is functioning properly.")
    async def test(self, inter: disnake.AppCmdInter):
        await inter.send("I am working properly! :D")


def setup(bot):
    bot.add_cog(BasicCmds(bot))

Did I set it up correctly

naive briar
#

Filenames doesn't matter

slate swan
#

hmm

#
spec = importlib.util.find_spec(name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib.util>", line 94, in find_spec
ModuleNotFoundError: No module named 'code.cogs'; 'code' is not a package

this is smth i am getting in error and i dont understand it

#

add __init__.py file inside code folder

#

what do i add in it

#

nothing

#

nope, doesnt work

#

;-;

#

first time in my life i used git

#

and now it doesnt work

#

you know it has nothnig to do with git?

naive briar
#

When did git came into this?

#

I wonder pithink

slate swan
#

idk

#

this error is so weird

#

@slate swan this error doesn't occur if i open the code folder

#

and then run the file there by removing the extra code/

#

@turbid condor

turbid condor
slate swan
#

it just runs

turbid condor
#

So the issue?

slate swan
#

yes

turbid condor
#

I still don't get what you are trying to say

slate swan
#

bruh

#

so as you can see

#

currently i am in S-Bot directory

slate swan
#

so i use code/cogs

turbid condor
#

Hmm

slate swan
#

to access the folder

#

but if i switch the folder to code

#

and then edit the folder names from code/cogs to just cogs

#

the file runs

turbid condor
#

Tbh as far as i know black slash is used to specify a path instead of a forward slash

turbid condor
# slate swan the file runs

That is because your interpreter is set to the code folder by default where as previously it used to be S-bot

slate swan
#

hmm

#

and the function only supports 1 single folder name

#

no slahes or anything

turbid condor
#

Welp in the docs they told it was a path

slate swan
#

HOLY SHITIT

turbid condor
#

Instead of folder name

slate swan
#

bro you scared the hell out of me

#

i was on full volume with headphones

#

and i clicked your link 😭

#

onlyfans thing

turbid condor
#

XD

slate swan
slate swan
#

thank @turbid condor

harsh orbit
#
@bot.event
async def on_message(message):
  print("ss")

why the bot is not making any thing when I send a message?

#

it is have permissions

naive briar
#

What intents do it have?

harsh orbit
naive briar
#

What permissions do it have?

harsh orbit
#

administrator

naive briar
#

!paste show your entire code

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.

harsh orbit
#
import discord
from discord.ext import commands
from math import *

intents = discord.Intents()
bot = commands.Bot("a", intents=intents)
bot.remove_command("help")

tax_channel_id = 1158366596922888252


@bot.event
async def on_ready():
    print("online")

@bot.event
async def on_message(message):
  print("ss")


bot.run("")```
its just this
naive briar
#

It doesn't have all intents, it have none, in fact

harsh orbit
#

lol

slate swan
#

I don‘t know if the code that works at the timeout after the timeout even though the button worked before the timeout was pressed. How can I fix this issue?

bitter knoll
#

How can I host my bot in replit

cold oyster
#

How do I get the server name of a person who executed the cmd

meager rock
turbid condor
unkempt canyonBOT
#

property display_name```
Returns the user’s display name.

For regular users this is just their global name or their username, but if they have a guild specific nickname then that is returned instead.
cold oyster
turbid condor
bitter knoll
#

Btw can u suggest any free server

meager rock
bitter knoll
#

I don’t have sadly 🥲

wicked atlas
#

Nothing is free

#

Even if it says it’s free, the money to run it has to come from somewhere

bitter knoll
#

Hmm 🤔 ya

#

Like selling our data or something

wicked atlas
#

Yeah oracle did that iirc

bitter knoll
#

Dam ☠️ I used trusted oracal but now 📉

wicked atlas
#

Most website do that nowadays

#

Google definitely does

bitter knoll
#

Lol ya

#

Apple too 🤔?

wicked atlas
#

Honestly the “free-est” hosting you could get is just grabbing old computer or buying a cheap one off ebay and hosting it yourself

final iron
wicked atlas
#

You don’t get all the perks of a data enter but long-term it’s cheaper if its just a small or personal application

bitter knoll
#

Windows is too heavy ☠️

wicked atlas
#

Yeah windows is not for servers, unless windows server edition is somehow better

#

Never tried it but because windows is in the name i don’t want to

bitter knoll
#

Mint

late reef
#

I can't seem to get the embed hyperlink here to work. Always seems to just print the entire thing as a single string. Am I doing something wrong?
embed.add_field("[link](https...)")

wicked atlas
#

iirc markdown formatting does not work in embed fields

late reef
#

It doesn't? I thought that was the only place they DID work

#

Ooh, does it only work in the embed description?

wicked atlas
#

I believe it only works in the description

late reef
#

Man that's lame

wicked atlas
#

Maybe the title? Not sure on that one

#

It makes it easier to make embeds sometimes, because you can just put everything in one string

#

Actually, it could also be because you’re putting the link as the field name?

bitter knoll
#

What’s embed ?

wicked atlas
#

It might work in the body

#

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

wicked atlas
#

^ this is an embed

bitter knoll
#

Oh

#

I wish telegram also adapt this (I am Actually a telegram bot dev)

final iron
#

Damn that’s crazy bro

#

Good for you

bitter knoll
#

Who ?

slate swan
late reef
#

I now put it into a string for the description. Am I doing this right? It's still not working

slate swan
#

you need to actually use that varriable

#

Probably want f strings

wicked atlas
#

You’re missing the {} for your string formatting

slate swan
#

!fstring

unkempt canyonBOT
#
Format-strings

Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.

>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."

Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.

bitter knoll
#

Hi 👋

slate swan
burnt coral
bitter knoll
stoic tusk
#

Hey if someone is kind enough to dm to fix a python problem regarding my discord bot?

slate swan
#

there's a channel made for that, use it and send it here.

stoic tusk
slate swan
#

you'll get help here. so ask

#

if you don't want to then you won't get help

#

asking people to dm you out of nowhere is weird

stoic tusk
#

I have problems with my cryptography bot, for my friend it worked but for me it doesn't work for some reason.

The bot won't respond to any command and it doesn't show any error in the "terminal"

import discord
import asyncio
from discord.ext import commands
from cryptography.fernet import Fernet
import json

intents = discord.Intents.default()
intents.members = True
intents.messages = True  # Enable the message content intent


TOKEN = 'TOKEN'

key = Fernet.generate_key()
cipher_suite = Fernet(key)

PREFIX = ["?", ">", ".", "-"]

bot = commands.Bot(command_prefix=PREFIX, intents=intents, case_insensitive=True)
bot.remove_command('help')

try:
    with open("encrypted.json", "r") as file:
        encrypted_data_dict = json.load(file)
except FileNotFoundError:
    encrypted_data_dict = {}

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

@bot.command()
async def e(ctx, *, data_to_encrypt):
    encrypted_data = cipher_suite.encrypt(data_to_encrypt.encode()).decode()
    encrypted_data_dict[ctx.author.id] = encrypted_data
    with open("encrypted.json", "w") as file:
        json.dump(encrypted_data_dict, file, indent=4)
    await ctx.send(f'``{encrypted_data}``')

@bot.command()
async def d(ctx, *, encrypted_data):
    if ctx.author.id == 821755569248403487:
        try:
            decrypted_data = cipher_suite.decrypt(encrypted_data.encode()).decode()
            await ctx.send(f'Decrypted data: ```{decrypted_data}```')
        except Exception as e:
            await ctx.send(f'Error: {e}')
    else:
        await ctx.send("You don't have permission to use this command.")

bot.run(TOKEN)
#

there's a second JSON file as well

#

it worked for some time but now it doesn't

slate swan
#

Message content intent is message_content, not messages

slate swan
#

Yeah, reading is useful 👍

stoic tusk
#

@slate swan Thanks for the help, the bot got fixed.

oblique adder
#

Is it possible for a bot to receive image as an input from either a slash command or form ? But not from on message or normal command

final iron
gentle epoch
#

^Deff gonna need to have them pass a link for the image

#

Which they can just send the image in chat, then copy the discord link for that image

final iron
#

It would be cool for discord to add that though

slow fog
#

and the bot received it

#

it was years ago I don't even remember how

#

something was related to ctx.message.attachments

#

my old code shows this await ctx.message.attachments[0].save(file_name)

young shuttle
#

are discord bots difficult to code

slate swan
final iron
final iron
final iron
slow fog
#

yeah slash commands sucks

final iron
#

Why…

slow fog
#

and haven't touched a slash command

slow fog
slate swan
final iron
#

And discord takes that as an input?

slow fog
slate swan
#

?

slow fog
#

because the user can upload multiple attachments

final iron
slate swan
final iron
#

1.7.3 also uses old APIs

slow fog
final iron
#

2nd worst take I’ve seen in this channel tbh

slate swan
slow fog
slate swan
#

Yes. Slash command option where you upload an attachment

#

Something that's been existing for months if not years

slow fog
slate swan
final iron
#

Oh I wasn't aware discord took that as an input

#

Nice

slate swan
#

hi,
i'm having the

Ignoring exception in command watchlist:
Traceback (most recent call last):
  File "C:\Users\acatt\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\bot.py", line 1114, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Users\acatt\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 375, in invoke
    await injected(ctx)
  File "C:\Users\acatt\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 132, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction

error
does anyone know any fix to it?

final iron
slate swan
#

i ran a command and does nothing, saying the interaction didn't respond

final iron
#

You have to respond to an interaction within 3 seconds

slate swan
#

?

#

theres no time.sleep or anything

final iron
#

Okay?

#

time.sleep isn't the only thing that'll stall your code for more than 3 seconds

slate swan
#

im sending 2 requests and its inside a command idk how to implement it outside

final iron
#

what

slate swan
#

do i really have to send my code

final iron
#

or rewrite your sentences to be coherent

slate swan
#

wtf

final iron
#

?

slate swan
#

how do i phrase this

#

do i just send code and you'll know what i mean

final iron
#

If you want

slate swan
#

where do i send

#

hastebin or something?

final iron
#

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

ok

#

idk how to optimize it myself, i made it and it worked

#

but not sometimes

#

any idea

final iron
#

Also, requests is blocking

slate swan
slate swan
final iron
#

Neither does ApplicationContext

#

And by extension ApplicationContext.respond() doesn't either

#

So which fork are you using?

slate swan
#

but applicationcontext works

final iron
#

Yes, because you're using a fork

slate swan
final iron
#

not using a fork
py-cord i think

final iron
slate swan
#

i was unsure

final iron
#

You can also defer the interaction but pycords slash commands implementation fucking sucks so I wouldn't know how

slate swan
#

okay

final iron
#

Pycord really sucks though

#

Why are you using it?

slate swan
#

what do u recommend

slate swan
final iron
slate swan
#

not even nextcord or anything?

#

idk how to make slash commands in dpy thgo

final iron
#

Why would you use a fork

slate swan
#

idk, faster maybe

final iron
#

No?

slate swan
#

okay

#

oh well switching to aiohttp fixed my issue

lunar vine
#

whatever the 2nd place it was running from might still b runnin

late reef
#

Would anyone here be willing to give my first bot a test run, and tell me if there are any problems or errors? Or any change suggestions?

oblique adder
#

What python discord api wrapper should I use now ? Pycord ,discord.py , nextcord ,etc , anything new and better ? I have been away for quite a while

late reef
burnt coral
split nest
#

How can i fix the intents error
import discord

client = discord.Client()

@client.event
async def on_ready():
print("loggen on as {0.user}".format(client))

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

if message.content.startswith("/test"):
await message.channel.send("test")

late reef
fading marlin
#

!intents

unkempt canyonBOT
#
Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.

There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.

Afterwards in your code, you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True

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

For more info about using intents, see discord.py's related guide, and for general information about them, see the Discord developer documentation on intents.

split nest
#

but why doesnt my bot respond
import discord
from discord.flags import Intents

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

@client.event
async def on_ready():
print("logged on as {0.user}".format(client))

@client.event
async def on_message(message):

if message.content.startswith("/test"):
print("test1")
await message.channel.send("test")

fading marlin
#

You need message content intent for message commands

split nest
#

how do i do that

fading marlin
#

Look at the codeblock there

split nest
#

ok thx

turbid condor
#

Also that test is not a command

#

It's an on_message event

naive briar
#

They can make a command handler out of it

vale wing
#

Dpy bad me no like

#

!e print(len("await interaction.response.send_message()") / len("await inter.send()"))

unkempt canyonBOT
#

@vale wing :white_check_mark: Your 3.11 eval job has completed with return code 0.

2.2777777777777777
vale wing
#

And yeah dpy code is 230% longer!1!1!1

glad cradle
vale wing
#

It's one of countless

#

I wrote an article on that once

#

This for disnake advantages

loud junco
#

hi people long time no see
railway isnt free anymore
do you guys know where to host now (other than replit)

golden portal
#

gcp

loud junco
quick brook
quick brook
# loud junco foc?

Please make sure you read this fully

When you look for hosting your bot, you might be tempted to use free services or providers that claim to support hosting discord bots (eg PebbleHost and others). Do not use them. Why? Let me explain.

Free hosts and tiers always have drawbacks - The point of a free tier or a host is to get the user to use their product, and upgrade for all of the good features. Hosts such as replit use shared cpus, oftentimes will run into ratelimits, and have "gotchas" that make you tempted to upgrade to their paid tiers. They also literally remove all control out of how you run your bot. Think about it: Hosts need to make money somehow in order to either break even or gain profit. So naturally they will tempt you into upgrading in order to do that. This is basic economics and quite literally how businesses run.

If you are still looking for a host after reading this, then you have some options. And here are them:

  1. Pay up - Pay up and use a VPS provider. My pick is Heznter, but see ?tag vps for the full list (if you are on the Python discord server, then see !hosting for your options). More than likely if you are not an eligible HS or college student, this is your option.

  2. Self Host - If you are able to self host your own server, then go for it. This is really the only "free" way if you already pay for your electricity bill and have the equipment to do so. Raspberry Pis oftentimes are great for this.

  3. GitHub Student Developer Pack - IF you are a enrolled student in an HS or college (you will need to either provide an valid student ID or proof of education of your HS or college), then you may apply for this deal. More info about this can be found here. The deal offers $200 free credits on DigitalOcean for 1 year, so if you are a student and need to host your bot, go for it.

vale wing
#

I wonder if gh student allows music college students

quick brook
loud junco
vale wing
#

What's worse it's russian

quick brook
vale wing
#

I doubt they will even recognize the handwriting on my ID 💀

burnt coral
#

you are eligible for gh student pack if you're over 13 and can prove you're a student, no matter where afaik, i got mine by uploading a picture of my public transport card provided by my school

burnt coral
#

If you do not have a dated student ID to upload, you may upload a current transcript, letter on school letterhead, or any documentation that demonstrates your current enrollment.

vale wing
#

Lol imma try too

burnt coral
#

it's also worthwhile to note that the student pack is as much of a "gotcha" Noelle tried pointing free hosting tiers to be. you get free hosts from the pack, you grow somewhat familiar with the stack and you're tempted to stay after your student pack expires.

just buy a VPS.

quick brook
burnt coral
#

yeah there are 3-4 nice deals in the bundle, iirc there is one for AWS aswell if im not mistaken

glad cradle
#

you're still missing some things

#

smh 😔

vale wing
#

Ok snipee tell us more ☺️

glad cradle
#

you can send raw components

#

this is a big deal if someone wants something less ram eating than persistent views

#

and for other things like commands with which you can interact anytime even if they're old responses

golden portal
#

not a lot of people wants a low level interface such as raw components though, it's bad UX

#

auto syncing is also kinda effy, you get ratelimited unnecessarily if you reboot a lot

glad cradle
#

What does UX have to do here?

loud junco
#

im self hosting now
can i save my token in a file
secret.env

TOKEN = 'XXXXXX'

main.py

from secret import TOKEN
await bot.start(TOKEN)
glad cradle
#

you talk about ux in gui(s)

golden portal
#

no

vale wing
glad cradle
vale wing
#

Yeah I guessed correctly

glad cradle
#

ig before updating you fetch the commands in d.py

vale wing
#

!pypi python-dotenv

unkempt canyonBOT
golden portal
#

how would it 'know' when to sync

#

without automatically fetching first

vale wing
glad cradle
golden portal
#

unnecessary API calls tho no? you even rarely change slash commands

vale wing
#

It's a single call

glad cradle
golden portal
#

i don't? i only sync when i added/change any slash command signatures, after that im good

#

and i do that after like idk, once a few weeks if im actively developing

vale wing
#

Yeah same but manual and without that one api call

#

Does discord have individual ratelimits for endpoints somewhere

glad cradle
#

i mean, how do you know if you have added/removed a command from code if you don't fetch, are you sincying manually? otherwise what you're saying doesn't make sense

vale wing
golden portal
#

yea im syncing manually

vale wing
#

Disnake vs dpy drama ☺️

#

Let's make dramacord lib that will be epic

glad cradle
vale wing
#

Then that single request at startup doesn't matter at all

glad cradle
glad cradle
glad cradle
loud junco
#

bro used the idgaf card on me

golden portal
#

well i was just stating opinion tbh, people make it like a bad thing, it's barely there

vale wing
#

No rizz

loud junco
#

so how do i make it like me

vale wing
#

What were you trying to connect to

loud junco
vale wing
#

So discord?

loud junco
vale wing
#

Can you send full tb

loud junco
vale wing
#

Traceback

loud junco
vale wing
#

That's kinda sus but I remember it happens cause of something

glad cradle
#

make sure that the database server is running

loud junco
vale wing
#

And please show how you connect to database

vale wing
loud junco
vale wing
#

Asyncpg there both in error and in code

glad cradle
#

there's written asyncpg in the error

loud junco
glad cradle
#

lmaoooo

loud junco
#

i used to host this bot in railway.app but its premium now

vale wing
#

🧐

#

So where the database is

#

And what's connection config

loud junco
#

idk how to setup one ;-;

vale wing
#

You gotta get it then

loud junco
#

do u have any source for that?

glad cradle
vale wing
#

Then create a database and update your connection config

#

Or you could dockerize everything ☺️

loud junco
quick brook
loud junco
quick brook
quick brook
#

I dont need people who are closed minded and shill a fork and claim it's better when they are baseless claims and go "oh this fork is better than the other"

loud junco
quick brook
#

in fact, your error boils down to networking than anything else

vale wing
loud junco
#

and idk what to do next lemme read the docs again

quick brook
meager rock
#

don't you need to setup users and the core first? i remember doing it in Linux atleast

quick brook
#

yes also that

loud junco
#

which chapter should i go 😭

quick brook
glad cradle
quick brook
#

I'm still sticking with pg 15 until asyncpg supports 16

loud junco
#

then im using 15 then

quick brook
#

Np

loud junco
quick brook
# loud junco what do i do

You don't need stack builder. Either just continue if you want stack builder installed or just cancel it

loud junco
#

after i installed it idk where to continue
it mention something about setting environment var

loud junco
glad cradle
#

mh is psql added to the PATH? btw this is not the right channel for this

loud junco
glad cradle
#

when you installed postgresql the launcher most likely asked you to add psql to PATH, was that Option enabled?

#

you need that to run psql commands without issues

loud junco
#

doesnt work ig 💀

cold oyster
quick gust
quick gust
#

I'd recommend you don't continue using this channel for this

#

you didn't need to delete it but alright

naive briar
#

🫠

slate swan
loud junco
#

i forgot my password :D

vale wing
loud junco
#

wow thanks

loud junco
vale wing
#

Sure

harsh orbit
#

how to make change prefix command?

#

not per server prefix

#

the bot in 1 server but I want to change the prefix with a command

final iron
#

In the function you’ll query your DB for the servers specific prefix

#

You’ll also want to create a set prefix command, and also implement some logic in your on guild remove event to remove the guild from your DB when the bot leaves the server

sage otter
#

personally i wouldnt query the db everytime you want to check a servers prefix (its not very efficient/timely)

#

id load all the prefixes from database into memory on startup

vale wing
#

Makes sense only if db is on remote server

#

If it's on same ping is typically around 3ms so doesn't matter much

#

Especially taking rest latencies lately into account 💀

sage otter
vale wing
#

Sure

#

It's either ram or delay

sage otter
#

since the prefix function he speaks of will query the database every time a message is sent

vale wing
#

Now that you mentioned it imma write that down to the list of slash commands advantages

#

Latencies are defo smoking something when we're not looking

sage otter
#

generally though it will always be more efficient to query volatile memory like ram over disc (where your db will be) especially if you're going to making excessive amounts of queries which is what he would be doing with getting a servers custom prefix

worldly harbor
#
@tasks.loop(minutes=30)  
async def update_followers(yt_channel_id,ig_channel_id,tk_channel_id,member_count_id,guild_id,update_channel):
    print(id)
    
    ig_channel = bot.get_channel(ig_channel_id) 
    yt_channel = bot.get_channel(yt_channel_id)
    tk_channel = bot.get_channel(tk_channel_id)
    member_channel = bot.get_channel(member_count_id)

    ig_follower_count = get_ig_follower_count()
    yt_follower_count = get_yt_follower_count()
    tk_follower_count = get_tiktok_follower_count()
    get_member_count = guild_id.member_count

    u_channel = bot.get_channel(update_channel)
    
    if ig_channel and yt_channel and u_channel:
        await ig_channel.edit(name=f"Instagram : {ig_follower_count}")
        await yt_channel.edit(name=f"Youtube : {yt_follower_count}")
        await tk_channel.edit(name=f"Tiktok : {tk_follower_count}")
        await member_channel.edit(name=f"Server Members : {get_member_count}")
        await u_channel.send(f'Follower counters updated\nCurrent followers:\n Instagram : {str(ig_follower_count)} \n Youtube : {str(yt_follower_count)} \n Tiktok : {str(tk_follower_count)} \n Server Couunt : {str(get_member_count)}')
        print("Update Done")
    else:
        print("Channels or update channel not found")```

Traceback (most recent call last):
  File "C:\Users\ASUS\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\tasks\__init__.py", line 239, in _loop
    await self.coro(*args, **kwargs)
  File "c:\Users\ASUS\Desktop\dcBot\main.py", line 119, in update_followers
    get_member_count = guild.guild.member_count
                       ^^^^^^^^^^^
AttributeError: 'int' object has no attribute 'guild'



pretty new to bot developement, im trying to make a task that does what you can p much see above but im struggling with the server member counter part. any help?
slate swan
#

you need actual Guild object to get amount of members

#

thats like you would do 123.member_count

#

!e x = 123; x.member_count

unkempt canyonBOT
#

@slate swan :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 1, in <module>
003 |     x = 123; x.member_count
004 |              ^^^^^^^^^^^^^^
005 | AttributeError: 'int' object has no attribute 'member_count'
worldly harbor
slate swan
#

!d discord.ext.commands.Bot.get_guild

unkempt canyonBOT
slate swan
#

can someone help me with a prject

chrome tartan
#

is anyone here familiar with making discord music bots?

slate swan
#

music bots are against TOS

chrome tartan
#

huh? since when? i still havea bunch of servers which have their own music bots

slate swan
#

oh well they always have been, or atleast for a while now

chrome tartan
#

man

slate swan
naive briar
slate swan
#

oh

#

!ytdl for more info

#

well i heard there Against TOS so thats my mistake sorry abt that

chrome tartan
#

do u guys know how i can use local files instead?

slate swan
#

No Clue

#

but does anyone have experience with making Servers, Databases and User Authentiction / Accounts

chrome tartan
slate swan
final iron
final iron
#

How does pycord sync commands?

#

Don't they have autosync (ass)?