#discord-bots

1 messages · Page 1099 of 1

slate swan
#

no

#

the answer remains same for all interactions

#

okay

slate swan
#

what about this??

#

i did wrong

#

?

#

maybe it will help me in future

#

that works, for normal messages

#

ctx.send gives you a discord.Message object
intereaction.response.any_send_method gives you None

#

ohkay

#

thanks 👍

#

also dont mind whats interaction.send lol its context i forgot to rename it

zealous dagger
#

@slate swan

#

How can I use

slate swan
zealous dagger
#

Select Menu

slate swan
#

!d discord.ui.Select

unkempt canyonBOT
#

class discord.ui.Select(*, custom_id=..., placeholder=None, min_values=1, max_values=1, options=..., disabled=False, row=None)```
Represents a UI select menu.

This is usually represented as a drop down menu.

In order to get the selected items that the user has chosen, use [`Select.values`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.Select.values "discord.ui.Select.values").

New in version 2.0.
zealous dagger
#

I am using them only

#
@client.group(invoke_without_command=True)
async def help(ctx):
  embed_hm = disnake.Embed(title="Categories",description="Please use the Select Menu below to explore the corresponding category")

  async def slct1_callback(interaction):
      await interaction.send("working")
  async def slct2_callback(interaction):
      await interaction.send("working2")
  
  slct = Select(placeholder="Select the command category you want to see",custom_id="20")
  sct_ct1 = SelectOption(label="Moderation",description="For Admins and Mods")
  sct_ct2 = SelectOption(label="Fun",description="Games and other fun commands")
  #sct_ct1.callback = slct1_callback
  #sct_ct2.callback = slct2_callback

  slct.append_option(sct_ct1)
  slct.append_option(sct_ct2)
 
  view = View()
  view.add_item(slct)

  
  
  await ctx.send("Testing selects for help command!",embed=embed_hm,view=view)

  slct.custom_id
#

@slate swan

#

@slate swan

#

how can I use them

slate swan
#

wdym by use them

west wigeon
#

i'm not sure how disnake works, but help commands are special. i imagine if you try to redefine help as an ordinary command group without reference to the built in help at all, it will either:
a) not work at all
OR
b) break horribly when the normal help routines are called

#

try it first with another name of the command other than help. async def myhelp(ctx): or so.

west wigeon
#

or that, yeah.

#

(i've done something similar to do custom help with Red)

#

not with interactions yet, though.

west wigeon
slate swan
#

possible to increase bot latency?

loud junco
placid skiff
#

Or travel to California near discord servers

loud junco
#

lower latency = lower ping :/

paper sluice
slate swan
maiden fable
#

@slate swan do u mean reduce bot latency?

loud junco
slate swan
maiden fable
#

Hahaha

slate swan
#

mb

loud junco
#

thats why im having visible confusion

maiden fable
#

Just shift to California @slate swan

loud junco
#

LOL

maiden fable
#

Ezzzz

slate swan
#

💀

maiden fable
#

Or get into a discord data center, plug in yr bot and run it. And if someone asks who's Hunter, u don't know me

maiden fable
placid skiff
#

Sorry now i have to get the location of a data center, cya

loud junco
#

but i live in south east asia
and my bot ping is always lower than 50ms

maiden fable
#

Same, the last time I checked

maiden fable
loud junco
#

💀

pure crypt
#

how can i make that only user’s with a specific permission can use the command? @bot.command() and @bot.command.has_permission(‘send_messages’)

loud junco
loud junco
pure crypt
#

i change the permission then bur for the example yes

#

i forgot it

#

ah i found it @bot.has_permissions(kick_user = True)

maiden fable
#

kick_member

#

Anyways

placid skiff
#

!d discord.Permissions.kick_members

unkempt canyonBOT
placid skiff
#

it's plural buddy

jagged adder
#

heya, atm im trying to improve my save system im using for my bot. i'm currently "saving" by converting a class instance to a json file.
My issue atm is that whenever i add a variable to that class, the save command wont add the new variable to the save overwrite.
This only occurs when someone loads a current out-of-date save. As far as i understand it, when i load an instance of the game from a save, its pulling the variables from the saved file, and not the updated class.
If anyone can make sense of the above statement, does anyone have a suggestion how i can get the load game to add the new variables (perhaps compare to the class?). Because atm anytime a 'loaded' game reaches a variable in my code that doesnt exist in the save, it crashes that instance, resulting in all progress since the game was loaded being lost

maiden fable
placid skiff
#

same goes to for reactions, files, threads, webhooks, emojis, stikers, links, events, messages and activities

#

The only exception are invites

#

the create_invite permission is singular lmao

maiden fable
slate swan
#

view_channel pithink

placid skiff
#

I think that they could add a method to set the permission by giving the raw value of that permission lmao

slate swan
#

in hikari you can just do hikari.Permissions(value) pithink

placid skiff
#

cool

slate swan
#

thats the only way

placid skiff
#

lol

#

less cool but

#

that's fair enough

unkempt canyonBOT
#

discord/permissions.py lines 399 to 402

@flag_value
def read_messages(self) -> int:
    """:class:`​bool`​: Returns `​`​True`​`​ if a user can read messages from all or specific text channels."""
    return 1 << 10```
slate swan
#

i would just READ_MESSAGES = 1 << 10 in the Permission class

glacial glacier
#

Help code

slate swan
#

my bot is working but

#

what is this?

tawdry perch
#

Seems like some sort of log from request

loud junco
slate swan
loud junco
leaden solar
#

@glacial glacier

#

could you show me your code

#

like everything you have rn

glacial glacier
glacial glacier
#

I did't have that code

leaden solar
glacial glacier
#

Custom help command can you give me?

leaden solar
#

i hope you use discord.ext commands tho

glacial glacier
leaden solar
#

yeah

slate swan
#

!customhelp

unkempt canyonBOT
#

Custom help commands in discord.py

To learn more about how to create custom help commands in discord.py by subclassing the help command, please see this tutorial by Stella#2000

glacial glacier
#

Yes i use it

leaden solar
#

but do you use discord.ext

#

okay nice

glacial glacier
#

Yes

leaden solar
#

ight so ill show you how you can do it

leaden solar
# glacial glacier Yes
@bot.remove_command('help')
@bot.command()
async def help(ctx):
    m = await ctx.reply('Sent `help` to your DMs!')
    await asyncio.sleep(2)
    await m.delete()
    await ctx.message.delete()
slate swan
#

!d discord.Guild.bans check if the user is in this iter

unkempt canyonBOT
#

async for ... in bans(*, limit=1000, before=..., after=...)```
Retrieves an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.10)") of the users that are banned from the guild as a [`BanEntry`](https://discordpy.readthedocs.io/en/latest/api.html#discord.BanEntry "discord.BanEntry").

You must have the [`ban_members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to get this information.

Changed in version 2.0: Due to a breaking change in Discord’s API, this now returns a paginated iterator instead of a list.

Examples

Usage...
leaden solar
#

this is from a discord bot i have made in the past

glacial glacier
leaden solar
#

to use help commands within discord.ext, you have to firstly remove the help command and then make a new one

leaden solar
glacial glacier
#

Because i did't understand that

leaden solar
#

could you show me how your code looks like btw

#

like how you wrote the lines with the commands functions

glacial glacier
#

Embed

glacial glacier
#

Like catogory 1

Catogory 2

leaden solar
#

on your commands

glacial glacier
#

Yes

leaden solar
#

okay

glacial glacier
#

But maybe that not work some times

leaden solar
#

so basically, make a new line and paste this code i made

glacial glacier
#

Give me a example pls

leaden solar
#

okay

crimson nova
#

How can i downgrade aiohttp to Version 3.7.1.post0 ?

slate swan
#

why do you want to do that?

#

"anything about it" click on the blue link?

leaden solar
# glacial glacier Give me a example pls

for example

Let's say this is your bot event to listen if your bot is online

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

(Here is a new line, which means you can put the help command code here so it looks like this)

@bot.remove_command('help')
@bot.command()
async def help(ctx):
    m = await ctx.reply('Sent `help` to your DMs!')
    await asyncio.sleep(2)
    await m.delete()
    await ctx.message.delete()
crimson nova
slate swan
#

stop using that library. its outdated and unmaintained, will stop working soon

slate swan
#

that gives you a list you can use user in list?, isnt that some basic python knowledge

crimson nova
slate swan
slate swan
#

!customhelp @glacial glacier

unkempt canyonBOT
#

Custom help commands in discord.py

To learn more about how to create custom help commands in discord.py by subclassing the help command, please see this tutorial by Stella#2000

leaden solar
#

oh

leaden solar
#

you looking for how to make an embed?

glacial glacier
leaden solar
#

right, i would like to check your code. So i can show you how to use it

glacial glacier
#

Not dm

crimson nova
leaden solar
#

because it's not so easy for me to describe how to use it

leaden solar
#

dont show the token of your bot tho

glacial glacier
leaden solar
#

of the code

glacial glacier
#

Can i send a image which like me need?

leaden solar
#

or no actually, send a hastebin

glacial glacier
leaden solar
glacial glacier
leaden solar
#

oh you dont even have a bot rn?

glacial glacier
#

Yes

#

My bot is already running

placid skiff
#

It's not like we have that code

#

Even if someone does i don't think that he will sent the whole project to you

#

https://pokeapi.co/ most probably that bot is using those API, start studying and you will be able to create a bot like that

leaden solar
#

then i have missunderstod this

leaden solar
#

the code that the bot you talked about is not easy to get

#

all code in public discord bots are not available for the public to get

shrewd apex
#

poketwo is public u can see that

shrewd apex
spring flax
#
class Reddit(commands.Cog):
    def __init__(self, bot):
        self.time_dict = {}

does theself.time_dict hold data persistently after bot restarts?

slate swan
slate swan
#

it's stored in the temp memory

spring flax
#

okay - so how would i make it persistent?

slate swan
shrewd apex
slate swan
#

make a bot in javascript, at least you won't need to learn python 😔 that's what I was thinking

shrewd apex
#

lmao 😂

shrewd apex
slate swan
#

meh

#

whatever

slate swan
#

but okay

#

how can i set a command to say if a command is not found?

pure crypt
#

does anyone know the “color code” for neon green for embeds? Normal green is 0x2ecc71 But i need neon or light green

lament depotBOT
#
Green

Color information for Hex #00FF00.

RGB

(0, 255, 0)

HSV

(120, 100, 100)

HSL

(120, 100, 50)

CMYK

(100, 0, 100, 0)

Hex

#00FF00

Name

Green

glacial glacier
velvet compass
#

I'm sorry, I don't have a good tutorial for how to make commands

pure crypt
glacial glacier
#

.color hex white

slate swan
#

@slate swan I pinged u by mistake

heady sluice
#

just type hex color picker in google

slate swan
#

Ye

heady sluice
#

copy it and replace the # to 0x

slate swan
#

..

velvet compass
slate swan
pure crypt
heady sluice
#

only with 0x

heady sluice
#

we shall make this with all the 16m colors

slate swan
#

Wow more than 100

slate swan
#

Dc laged

#

I replied 💀

shrewd apex
#

nice

#

that looks like a quite a bit of work

slate swan
#

Ye

slate swan
#

how can i create a pattern for my auth command, which takes 1d or 1y or 1m or 2m for example and i wanna get the time unit and the number standalone

pliant gulch
#

!e ```py
inputted = "10d"
print(inputted[:-1], inputted[-1:])

unkempt canyonBOT
#

@pliant gulch :white_check_mark: Your eval job has completed with return code 0.

10 d
placid skiff
#

!e

timestamps = {"s": 1, "m": 60, "h": 60*60, "d": 60*60*24}
time = "2h"
time_unit, time_stamp = time[:-1], time[-1]
print(time_unit, time_stamp)
print(f"there are {int(time_unit)*timestamps[time_stamp]} seconds in {time} hours")
unkempt canyonBOT
#

@placid skiff :white_check_mark: Your eval job has completed with return code 0.

001 | 2 h
002 | there are 7200 seconds in 2h hours
slate swan
#
    @commands.command(aliases = ["баланс"])
    async def ballans(self, ctx, member: discord.member):
        await ctx.send(
            f"""Твой баланс **{cursor.execute("SELECT cash FROM users WHERE id = {}".format(ctx.author.id)).fetchone()[0]}** рублей"""
        )

Dear please tell me what is wrong

#

discord.Member

#

!sql-fstrings also this

unkempt canyonBOT
#

SQL & f-strings
Don't use f-strings (f"") or other forms of "string interpolation" (%, +, .format) to inject data into a SQL query. It is an endless source of bugs and syntax errors. Additionally, in user-facing applications, it presents a major security risk via SQL injection.

Your database library should support "query parameters". A query parameter is a placeholder that you put in the SQL query. When the query is executed, you provide data to the database library, and the library inserts the data into the query for you, safely.

For example, the sqlite3 package supports using ? as a placeholder:

query = "SELECT * FROM stocks WHERE symbol = ?;"
params = ("RHAT",)
db.execute(query, params)

Note: Different database libraries support different placeholder styles, e.g. %s and $1. Consult your library's documentation for details.

See Also
Extended Example with SQLite (search for "Instead, use the DB-API's parameter substitution")
PEP-249 - A specification of how database libraries in Python should work

vale sierra
slate swan
#

its alright, you can blame your linter's autocomplete for that

#

member is actually the .py file which has the Member class, the full path is discord.member.Member CL_KokoSip

#

Oh it's hard😅

shrewd apex
crimson nova
#

Hi I hope someone knows a solution to this problem:
I use discord.py 1.7.3 and supplementary discord-py-slash-command. (I know, that there is a way to update discord.py to 2.0.0, but I don't want to do that) So I uninstalled discord-py-slash-command accidentally and then, when I wanted to install it again, it doesn't work, because of the "not compatibility" with the version of aiohttp. I need the version 3.7.1.post0, but it always installs 3.7.4.post0 or 3.8.1
And my bot doesn't work, because of this and I'm a bit desperate, because of trying everything, but it doesn't work 😅
Please let me know, if someone knows a way to figure it out

sick birch
crimson nova
shrewd apex
#

it will get deprecated sooner or later change now so u don't have to be in hurry later...

crimson nova
shrewd apex
#

ic

sick birch
#

I see what you mean by having the bot be online though

shrewd apex
#

pip install using strong equality operator

#

like pip install xyz==a.b.c

#

u could also manually install their releases as well

crimson nova
#

Ah thank you guys, I found a way to make it work again

#

I'm glad it works now ^^

shrewd apex
#

np

slate swan
#

guys dont name your file enum.py and use typing in it or else typing will raise a partially initialized module error😵‍💫

#

crazy how your own file name can break some stuff😭

quick gust
#

!ot

unkempt canyonBOT
slate swan
#

bro

pliant gulch
#

The same exact name

slate swan
#

hence the error being raised

pliant gulch
#

Yea, zero issues naming my file enum.py

slate swan
#

odd

pliant gulch
#

switching it up 😳

slate swan
pliant gulch
#

Because that's how I'm designing rin rewrite to work, it'll be based off multiple states each with a internal queue which contains the inbound data ```py
client = rin.GatewayClient(TOKEN, Intents.GUILD_MEMBERS | Intents.GUILDS)

@client.messages.on(rin.Events.MESSAGE_CREATE)
async def message(...) -> None:
...

async for event in client.messages.listen():
...

@client.shard.on(rin.Events.HEARTBEAT)
async def heartbeat(...) -> None:
...

#

You'll have things, such as ```py
client.messages(...)
await client.messages.create(...)
await client.channels.create(...)

slate swan
#

interesting design non the less

stone beacon
#

Reminds me of atom

#

But the theme monkai

pliant gulch
stone beacon
#

Beautiful ty

#

Last vim I used was spacevim

pliant gulch
#

Spacevim is nice, but I always recommend using your own configs

#

Home court advantage, you get you know every single thing about your editor

#

It makes it easier to code

unkempt canyonBOT
#

Hey @slate swan!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

steep drift
slate swan
#

it was invoked in a dm, hence why guild is None

modern fiber
#

Can someone PLEASE help? Bot was online like 3 minutes ago until I did git add ., git commit -m "update" and git push heroku master

#

its offline now

#

aint coming online

#

could anybody help?

minor totem
#

Hey hanks to those who had feedback last time. I've improved the sidebar and table of contents slightly since. Anyways I am asking again to cover different times.

Please take a look at the tutorial I made for interaction bots and let me know if you have any feedback:
https://wumpy.readthedocs.io/ does not work on mobile

maiden fable
#

thanks*

modern fiber
#

will anybody ever help

slate swan
# minor totem Hey hanks to those who had feedback last time. I've improved the sidebar and tab...

this was the first thing(the image below) i noticed tbh and i kinda feel like it shouldnt be taking much of my attention it kinda feels like those websites that ask for your permission that they use cookies for a better experience, maybe a simple arrow with the number of which page you are on? maybe you can add some custom images in the side of the page, it kinda feels blan, maybe custom images of clyde and wumpus playing together? thats a very friendly environment and it suits your slogan. i really shouldnt be talking much as my docs arent good, but thats all that bothers me really, everything looks good.

minor totem
paper sluice
#

is it weird when the docs for the command is bigger than the command itself pithink

slate swan
paper sluice
#

ya starting to notice that pattern quiet alot in my code xD

slate swan
#

yep

minor totem
slate swan
#

@minor totem maybe this in the bottom but make the numbers centered and clickable

#

whatever you want im just giving ideas!

minor totem
#

Yeah sure I've been considering icons, but then I need to get that setup and all 😅

karmic marsh
#

Hi. How can I make it not required?

#

I thought it was just

async def help(self, inter, *input):

instead of

async def help(self, inter, input):

but then it doesn't show up as a param at all

fading marlin
#

set a default to input or type hint Optional to it

karmic marsh
#

a default doesn't make it completely optional, does it?

#

type hint Optional to it
could you show what you mean by this?

fading marlin
#

it does

#
from typing import Optional
arg: Optional[str] = None

arg can optionally be a string or it can be None
as opposed to

arg: str = ""

where arg should be a string

karmic marsh
#

no need to import Optional

#

just do ```py
arg: str|None = ""

slate swan
karmic marsh
#

alright, now I need to know how to get a cog's command description

fading marlin
#

wdym by "a cog's command description"?

karmic marsh
#

the thing in triple quotes

#

that shows up in the command list

slate swan
#

!d disnake.ext.commands.slash_command

unkempt canyonBOT
#

@disnake.ext.commands.slash_command(*, name=None, description=None, dm_permission=None, default_member_permissions=None, options=None, guild_ids=None, connectors=None, auto_sync=None, extras=None, **kwargs)```
A decorator that builds a slash command.
karmic marsh
#

ah wait, I got it

#

self.bot.cogs[cog].__doc__

#

it wasn't working

slate swan
#

imagine using disnake

karmic marsh
#

I had the quotes in the wrong spot

slate swan
fading marlin
#

perhaps self.bot.get_cog is a better alternative?

slate swan
slate swan
karmic marsh
#

I did a moderate amount of research to decide on disnake

slate swan
#

I dont trust forks

#

idk why

#

hikari isnt a fork?

slate swan
karmic marsh
#

disnake sounded like the best option for someone like me who wants up-to-date features without too much hassle. Probably not the most powerful choice, but I'm happy enough with it

slate swan
#

and thankfully dpy added basic logging when using Client.run

slate swan
slate swan
#

like completely

#

i know? but how do you prefer dpy more?

#

because of originality, hikari is full different

slate swan
#

now it makes more sense, i would disagree tho

#

hm

#

i like disnakes implementation and helpers

#

i feel like dpy isnt as professional as disnake

#

both of them suck, that's why I use hikari with lightbulb meh

#

not really, the only thing that sucks in disnake is the old dpy codebase

slate swan
slate swan
#

save the hastle for another time

#

would be a pain to connect to the gateway and making request lmao

slate swan
#

just use a wrapper ez, nakano

slate swan
slate swan
#

and nakano? not in my worst senses

#

🗿

#

I'd want to try it though

#

but dont think itll be worth it

#

since there are a million others

#

i still need to make allot of library abstractions e.g cache and ratelimiter

#

yep, that's the issue, it's gonna be a nice amount of time and I've stopped with discord bots anyways

#

so whatever idc what I prefer

#

lmao

slate swan
slate swan
#

yor san kannapoggy

slate swan
#

morning, 😔 i just found out that theres a discord api wrapper for php too

slate swan
#

theres a list of wrappers for all langs in the unofficial official discord api server

slate swan
slate swan
slate swan
slate swan
slate swan
slate swan
slate swan
#

meh who even cares about assembly, most of people just use nodejs, python or rust for making bots

#

cpp like: shipit

#

||rust >cpp||

#

syntax wise yes

#

memory allocationCL_KokoSip

#

yes

#

speed too

sage otter
#

Literally anything besides python is an L language

#

Based opinion.

#

👌

slate swan
#

tyler, youre a simp to python

#

meaning c is an L language

slate swan
#

nothing wrong with that, i am too🕴️

sage otter
#

i don’t simp language. I simp women okimii. Smh.

slate swan
#

python is a women

#

😳

#

*woman

#

bro its the same creature

#

😔

#

women are creatures
woman is creature

#

chill

#

woman*

slate swan
#

rust's documentation makes me wanna learn it

#

just learn the documentation

slate swan
#

i want to try out js but its syntax is something else

#

python gets compiled to byte code too iirc kannapogg

slate swan
#

js is easier than python

slate swan
sage otter
#

That’s cap.

#

Loop logic looks really weird.

#

Like wtf is i++

slate swan
#

i = i+1

#

it isnt that crappy though

sage otter
#

Uh huh.

slate swan
#

but is is crappy i agree

slate swan
#

sad c++ noises

#

and i++ is not only used in js , but cpp and some other langs like java too iirc

sage otter
slate swan
unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

2
sage otter
#

i mean in a loop

slate swan
#

python would use this in a while loop.

#

!e ```py
a = 0
while a < 6:
print(a); a+= 1

unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

001 | 0
002 | 1
003 | 2
004 | 3
005 | 4
006 | 5
sage otter
#

oh. i see now. i was having a hard time understanding what you meant earlier for some reason

slate swan
#

the second input in a for loop for those langauge is more like a while statement

karmic marsh
#

question (because I have no clue what I'm doing):
when I type

self.bot.cogs[cog].__doc__

where does __doc__ come from? it doesn't pop up when I type the .
How do I find other members that don't autocomplete? Can I write something like

for member in self.bot.cogs[cog].(something):
print(member)

?

sage otter
#

Are you able to control how much it increments i by or does it only allow to increment by 1

slate swan
pliant citrus
#
  @commands.Cog.listener()
  async def on_message(self, message):
    if message.author.bot:
      return
    else:
      if "#Selfi" in message.content:
        if "private" in message.channel.type:
          await message.channel.send(f"{message.attachments[0].url}")

Error:

IndexError: list index out of range

If I output message.attachments I get: [<Attachment id=986051038941437962 filename='1519855918965.jpg' url='https://cdn.discordapp.com/attachments/98603435xxxxxxxxxx/98605103xxxxxxxxxx/xxxxxxxxxxxxx.jpg%27%3E]

slate swan
karmic marsh
#

I have this:

class Foo:
   """this is Foo."""

how does the computer know this is .__doc__?

slate swan
sage otter
#

I still don’t really like the implementation. I’m ngl.

slate swan
karmic marsh
#

okay lol

desert heart
karmic marsh
#

I see

pliant citrus
# slate swan read ths error, have fun

If I output message.attachments I get:
[<Attachment id=986051038941437962 filename='1519855918965.jpg' url='https://cdn.discordapp.com/attachments/98603435xxxxxxxxxx/98605103xxxxxxxxxx/xxxxxxxxxxxxx.jpg%27%3E]
I know what this error means

slate swan
#

this is an Attachment object

#

actually a list of Attachment objects

pliant citrus
slate swan
#

!d discord.Attachment.url

unkempt canyonBOT
#

The attachment URL. If the message this attachment was attached to is deleted, then this will 404.

pliant citrus
#

ok

indigo pilot
#

how do i remove a view from a message when i edit a message?

#

ex sending a message with a view then editing it, to remove the view

slate swan
indigo pilot
#

ohh okay ty

slate swan
#

It has been [0] days without a heroku-caused issue
For reasons, see ?tag noheroku or ?tag dannycalmlyexplainswhyherokuisbad or ?tag dannyexplainswhyherokuisbadbutitsnotdannyitsdevonssignificantlyandobjectivelybettertag
Skull the tags

#

omg💀

sick birch
#

This channel's been kind of dry today

#

Maybe that's a good thing, because people are getting better with these things and need less help

slate swan
#

😳

stray adder
#

Hey anyone help me

#

Iam trying to add a cmmd to ban members and admins

#

Members cmmd is working but admin command not working showing error when running

slate swan
#

hello👋

stray adder
#

''' Module 'discord' has no attribute admin '''

slate swan
#

can u show code

stray adder
slate swan
stray adder
stray adder
slate swan
stray adder
#

Ok

#

Ok i changed

stray adder
slate swan
stray adder
#

Bro do you know how to make a help cmmd

slate swan
#

!custom-help

unkempt canyonBOT
#

Custom help commands in discord.py

To learn more about how to create custom help commands in discord.py by subclassing the help command, please see this tutorial by Stella#2000

karmic marsh
#

bruh

#

why does this have to be in the one place where it won't work

#
@commands.slash_command()
    async def cog(self, inter, module: str = commands.Param(name="Cog", choices=[self.bot.cogs])):
#

the last self is invalid

#

what can I do?

glacial glacier
#

I need catogory command

slate swan
karmic marsh
#

I know lmao

slate swan
#

you cant access an argument in another argument

karmic marsh
#

that's the problem

slate swan
#

thi you can do that statically, or maybe use an autocomplete

stray adder
karmic marsh
#

what do you mean by that?

#

using an autocomplete, I mean

slate swan
#

either write the choices manually, or use autocomplete

karmic marsh
#

I just don't know what you mean by the autocomplete

slate swan
#

eh wait

regal pulsar
#

lol

unkempt canyonBOT
#

examples/slash_commands/autocomplete.py lines 30 to 38

@bot.slash_command()
async def languages(inter: disnake.CommandInteraction, language: str):
    ...


@languages.autocomplete("language")
async def language_autocomp(inter: disnake.CommandInteraction, string: str):
    string = string.lower()
    return [lang for lang in LANGUAGES if string in lang.lower()]```
karmic marsh
#
    @cog.autocomplete("module")
    async def module_autocomplete(self, inter, module):
        cogs = []
        for cog in self.bot.cogs:
            cogs.append(cog)
        return cogs
slate swan
karmic marsh
#

nah, throws some funky errors

#

File "C:\Users\carso\AppData\Local\Programs\Python\Python310\lib\json\encoder.py", line 179, in default
raise TypeError(f'Object of type {o.class.name} '
TypeError: Object of type Avatar is not JSON serializable

slate swan
#

notice the .items() 🤡

karmic marsh
#

literally word for word I put

return self.bot.cogs.items()
#

anyway this works:

return list(self.bot.cogs)
slate swan
glacial glacier
#

I need catogory command

karmic marsh
#

clarify your question

short silo
#

is there a way to restrict the users who can use the slash command, or that needs to be checked inside the function ?

slate swan
#

permission v2 allows that in your server settings

short silo
slate swan
#

for a particular command, yes

#

the server integrations' permission settings allow that

short silo
#

i see, thanks

pearl fjord
#

how do i check what permissions the bot has and make a new role with the same permissions?

heavy folio
#

!d discord.Guild.create_role

unkempt canyonBOT
#

await create_role(*, name=..., permissions=..., color=..., colour=..., hoist=..., display_icon=..., mentionable=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Creates a [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role") for the guild.

All fields are optional.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to do this.

Changed in version 1.6: Can now pass `int` to `colour` keyword-only parameter.

New in version 2.0: The `display_icon` keyword-only parameter was added...
heavy folio
#

!d discord.Member.guild_permissions

unkempt canyonBOT
#

property guild_permissions```
Returns the member’s guild permissions.

This only takes into consideration the guild permissions and not most of the implied permissions or any of the channel permission overwrites. For 100% accurate permission calculation, please use [`abc.GuildChannel.permissions_for()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.GuildChannel.permissions_for "discord.abc.GuildChannel.permissions_for").

This does take into consideration guild ownership, the administrator implication, and whether the member is timed out.

Changed in version 2.0: Member timeouts are taken into consideration.
heavy folio
#

so like ```py
await create_role(
name=...,
permissions=member.guild_permissions
)

heavy folio
#

ah right

unkempt canyonBOT
#

property me```
Similar to [`Client.user`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.user "discord.Client.user") except an instance of [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member"). This is essentially used to get the member version of yourself.
heavy folio
#

this is a Member instance of your bot

rain olive
heavy folio
#

i mean... guild.me

pearl fjord
#

so permissions=guild.me.guild_permissions?

heavy folio
#

yeah

pearl fjord
#

thanks

#

ill test it

rain olive
lyric apex
#

How to bypass if statement for guild owner?

pearl fjord
heavy folio
#

?

slate swan
#

Yes

heavy folio
#

what nuke

slate swan
#

Nvn

#

You know how to ban all

#

Script

#

For python

pearl fjord
#

its not hard to make a nuke

slate swan
#

Ye ye ye

pearl fjord
#

but yet, we dont

slate swan
#

I have nuke now

#

But ineed ban all

#

we will not have a discussion about nuking here so pls take it somewhere else.

#

Members

heavy folio
pearl fjord
#
guildd = await client.fetch_guild(int(gid))
            await guildd.create_role(name="a", permissions=guildd.me.guild_permissions())
heavy folio
#

why are you fetching guild, i dont think you get everything from a fetched guild

#

!d discord.Client.fetch_guild

unkempt canyonBOT
#

await fetch_guild(guild_id, /, *, with_counts=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Retrieves a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild") from an ID.

Note

Using this, you will **not** receive [`Guild.channels`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.channels "discord.Guild.channels"), [`Guild.members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.members "discord.Guild.members"), [`Member.activity`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member.activity "discord.Member.activity") and [`Member.voice`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member.voice "discord.Member.voice") per [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member").

Note

This method is an API call. For general usage, consider [`get_guild()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.get_guild "discord.Client.get_guild") instead...
pearl fjord
#

so get_guild(int(gid))?

#

Unresolved reference 'get_guild'

slate swan
#

bot.get_guild.

glacial glacier
#

!d help

unkempt canyonBOT
#

help([object])```
Invoke the built-in help system. (This function is intended for interactive use.) If no argument is given, the interactive help system starts on the interpreter console. If the argument is a string, then the string is looked up as the name of a module, function, class, method, keyword, or documentation topic, and a help page is printed on the console. If the argument is any other kind of object, a help page on the object is generated.

Note that if a slash(/) appears in the parameter list of a function when invoking [`help()`](https://docs.python.org/3/library/functions.html#help "help"), it means that the parameters prior to the slash are positional-only. For more info, see [the FAQ entry on positional-only parameters](https://docs.python.org/3/faq/programming.html#faq-positional-only-arguments).

This function is added to the built-in namespace by the [`site`](https://docs.python.org/3/library/site.html#module-site "site: Module responsible for site-specific configuration.") module.
glacial glacier
#

!d help discord Client.help

unkempt canyonBOT
#

help([object])```
Invoke the built-in help system. (This function is intended for interactive use.) If no argument is given, the interactive help system starts on the interpreter console. If the argument is a string, then the string is looked up as the name of a module, function, class, method, keyword, or documentation topic, and a help page is printed on the console. If the argument is any other kind of object, a help page on the object is generated.

Note that if a slash(/) appears in the parameter list of a function when invoking [`help()`](https://docs.python.org/3/library/functions.html#help "help"), it means that the parameters prior to the slash are positional-only. For more info, see [the FAQ entry on positional-only parameters](https://docs.python.org/3/faq/programming.html#faq-positional-only-arguments).

This function is added to the built-in namespace by the [`site`](https://docs.python.org/3/library/site.html#module-site "site: Module responsible for site-specific configuration.") module.
glacial glacier
#

!d help command

unkempt canyonBOT
#

help([object])```
Invoke the built-in help system. (This function is intended for interactive use.) If no argument is given, the interactive help system starts on the interpreter console. If the argument is a string, then the string is looked up as the name of a module, function, class, method, keyword, or documentation topic, and a help page is printed on the console. If the argument is any other kind of object, a help page on the object is generated.

Note that if a slash(/) appears in the parameter list of a function when invoking [`help()`](https://docs.python.org/3/library/functions.html#help "help"), it means that the parameters prior to the slash are positional-only. For more info, see [the FAQ entry on positional-only parameters](https://docs.python.org/3/faq/programming.html#faq-positional-only-arguments).

This function is added to the built-in namespace by the [`site`](https://docs.python.org/3/library/site.html#module-site "site: Module responsible for site-specific configuration.") module.
paper sluice
#

!customhelp

unkempt canyonBOT
#

Custom help commands in discord.py

To learn more about how to create custom help commands in discord.py by subclassing the help command, please see this tutorial by Stella#2000

heavy folio
#

@glacial glacier #bot-commands

glacial glacier
sonic flax
#

How would I make it so if a user did .ban for example, instead of using context, it would display a help command showing them what they need to put to make the command work

short silo
#

What might i be doing wrong, other than the 'description' lol.

Object of type SelectOption is not JSON Serializable.
placid skiff
placid skiff
#

You can do that only for a specific command or you can do that for every commands that your bot has, it depends on you

dim sentinel
#

how can i host my bot for free any other alternatives than heroku please

placid skiff
#

host it on your pc D_D

dim sentinel
#

but need it to be on a website

slate swan
short silo
dim sentinel
slate swan
placid skiff
#

There are no free host service which guarantee a good service

#

so buy a VPS

short silo
slate swan
#

if you have a credit card you can get free micros from aws or Google cloud free fkr a year

vale wing
#

I might be wrong, haven't ever seen the method you use

short silo
vale wing
#

!d disnake.OptionChoice

unkempt canyonBOT
short silo
#

i had tried that i think some days back, didnt work well for me

vale wing
#

Ok

#

I just typehint with enum 😉

#

Cause I don't need long texts as option choices

short silo
vale wing
vale wing
#

Might is usable for past tense right

short silo
vale wing
# short silo how would typehinting help <:lemon_glass:754441879935778867>
from enum import Enum

class SomeChoice(Enum):
    one = 1
    two = 2
    amo = 69

...
async def nice_cmd(inter, choice: SomeChoice):
    choice = SomeChoice(choice)  # iirc it won't give the enum itself but the value of an enum, so if you really need the enum you can get it from value. In the options the names of the enums will be displayed```
vale wing
short silo
vale wing
#

Np

rocky hornet
#

hey

#

are all members available at all times in all guilds?

paper sluice
#

huh?

desert cosmos
#

can i keep different prefixes for different cogs?

slate swan
#

yeah 😳, it's possible but not that simple.

slate swan
#

and your memory doesn't creates an issue

glacial glacier
#
@client.event
async def on_message(message):
  if message.content.startswith('p!help','P!help'):
     embedVar=discord.Embed(title="test", description="description", colour=0x00ff00)
embedVar.add_field(name="name1",value="value1", inline=False)
await message.channel.send(embed=embed)
#

Whats wrong in that command?

#

@slate swan pls

slate swan
#

!customhelp

unkempt canyonBOT
#

Custom help commands in discord.py

To learn more about how to create custom help commands in discord.py by subclassing the help command, please see this tutorial by Stella#2000

glacial glacier
#

@slate swan

paper sluice
#

!indent

unkempt canyonBOT
#

Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

paper sluice
#

by learning python before making a discord bot

glacial glacier
#

Ok

zealous dagger
#

I want to change the embed of discord message after I send it

#

How can I do so

placid skiff
#

!d discord.Message.edit

unkempt canyonBOT
#

await edit(*, content=..., embed=..., embeds=..., attachments=..., suppress=False, delete_after=None, allowed_mentions=..., view=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the message.

The content must be able to be transformed into a string via `str(content)`.

Changed in version 1.3: The `suppress` keyword-only parameter was added.

Changed in version 2.0: Edits are no longer in-place, the newly edited message is returned instead.

Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") instead of `InvalidArgument`.
placid skiff
#

you set again the embed here as the parameter after you've modified it

zealous dagger
#

ok

#

let me try and see it works or not

desert cosmos
glacial glacier
#

How to solve await?

slate swan
#

what

glacial glacier
#

How can i end that?

slate swan
#

return

glacial glacier
#
@client.event
async def on_message(message):
  if message.content.startswith('p!help','P!help'):
     embedVar=discord.Embed(title="test", description="description", colour=0x00ff00)
embedVar.add_field(name="name1",value="value1", inline=False)
await message.channel.send(embed=embed)
placid skiff
glacial glacier
slate swan
#

wdym

desert cosmos
glacial glacier
#

await message.channel.send(embed=embed)

#

Thats wrong telling

desert cosmos
#
@client.event
async def on_message(message):
  if message.content.startswith('p!help','P!help'):
     embedVar=discord.Embed(title="test",
                          description="description",           
                          colour=0x00ff00
                          )
     embedVar.add_field(name="name1",value="value1", inline=False)
     await message.channel.send(embed=embed)
glacial glacier
#

Thats telling outside funtion

desert cosmos
placid skiff
#

Bruh do you want an hint?
Learn python, you can't use d.py if you don't know python syntax and OOP concepts

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

desert cosmos
#

i can 't do it using that command prefix function right cuz it has nothing to do with command invocation

#

!d discord.ext.commands.Bot.command_prefix

unkempt canyonBOT
#

The command prefix is what the message content must contain initially to have a command invoked. This prefix could either be a string to indicate what the prefix should be, or a callable that takes in the bot as its first parameter and discord.Message as its second parameter and returns the prefix. This is to facilitate “dynamic” command prefixes. This callable can be either a regular function or a coroutine.

An empty string as the prefix always matches, enabling prefix-less command invocation. While this may be useful in DMs it should be avoided in servers, as it’s likely to cause performance issues and unintended command invocations.

zealous dagger
#

!d discord.Message.edit

unkempt canyonBOT
#

await edit(*, content=..., embed=..., embeds=..., attachments=..., suppress=False, delete_after=None, allowed_mentions=..., view=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the message.

The content must be able to be transformed into a string via `str(content)`.

Changed in version 1.3: The `suppress` keyword-only parameter was added.

Changed in version 2.0: Edits are no longer in-place, the newly edited message is returned instead.

Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") instead of `InvalidArgument`.
zealous dagger
#

How can I use this command

#

any example

#

I want to change the embed of discord message after I send it

desert cosmos
glacial glacier
glacial glacier
cerulean osprey
#

In this case embedVar.add_field(name="name1",value="value1", inline=False) is outside the if statement

desert cosmos
zealous dagger
#

ok

#

but I am

#

not storing my await ctx.send in a var

desert cosmos
#

you mean you want to edit in other command invocation ?

zealous dagger
#

yup

desert cosmos
#

for that you can have a workaround like saving the message as bot attribute but i don't think that is a good way to do

async def cmd1(self, ctx):
  self.todelete = await ctx.send("hello")
 
async def cmd2(self, ctx):
  if hasattr(self, "todelete"):
    await self.todelete.edit() 
#

you can also do it using fetch message

#

ughh

cerulean osprey
#

!d discord.ext.commands.Context.fetch_message

unkempt canyonBOT
#

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

Retrieves a single [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message") from the destination.
cerulean osprey
#

That one?

desert cosmos
#

yup

#

but it will only work in channel your command is called from

#

iirc

cerulean osprey
#

shrug Idk, I actually came here to ask a question tho, is there a way to check for a reply ping?

paper sluice
#

i would imagine something like a try-finally or a contextmanager for specific commands where u set prefix to something, and finally set it back to default

zealous dagger
#

Ok

#

my problem is solved

paper sluice
#

ns

zealous dagger
#

but I don't know why

#

this is showing

#

an error

#

in discord

#

I made a callback

paper sluice
zealous dagger
#

Sure

#
async def btn_callback(interaction):

    await send.edit(embed=embed_hm)
#

This is the callback for button

desert cosmos
paper sluice
zealous dagger
#

This is the callback for select menu

#
async def slct_callback(interaction):
    if select.values[0] == "Music":
      await send.edit(embed=embed_hm_music)
    elif select.values[0] == "Fun":
      await send.edit(embed=embed_hm_fun)
paper sluice
zealous dagger
#
btn_back.callback = btn_callback
  
select.callback = slct_callback
paper sluice
#

!paste if too long

zealous dagger
#

Ok

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 floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

desert cosmos
#

i don't think i am proficient enough to do that :/

zealous dagger
#

Is that ok @paper sluice

slate swan
desert cosmos
paper sluice
slate swan
slate swan
desert cosmos
#

alr

zealous dagger
# paper sluice ya? idc
@client.group(invoke_without_command=True)
async def help(ctx):
  embed_hm = disnake.Embed(title="Categories",description="Please use the Select Menu below to explore the corresponding category")

  embed_hm_music = disnake.Embed(title="Music", description="Commands for music")
  embed_hm_music.add_field(name="`k!play`", value="This command plays music", inline=True)
  embed_hm_music.add_field(name="`k!volume`", value="This command controls volume", inline=True)
  embed_hm_music.add_field(name="`k!pause`", value="This command pauses the music", inline=True)
  embed_hm_music.add_field(name="`k!resume`", value="This command resumes the music ", inline=True)
  embed_hm_music.add_field(name="`k!stop`", value="This command stops the music", inline=True)
  embed_hm_music.add_field(name="`k!queue`", value="This command adds music to queue", inline=True)
  embed_hm_music.add_field(name="`k!view`", value="This command shows the queue", inline=True)
  embed_hm_music.add_field(name="`k!remove`", value="This command removes music from queue", inline=True)

  embed_hm_fun = disnake.Embed()
  
  select = Select(options=[  
disnake.SelectOption(label="Fun",emoji=":person_bouncing_ball:",description="Games and other fun commands"),
disnake.SelectOption(label="Music",emoji=":musical_note:",description="Commands for music features"),
  ],placeholder="Select the command category you want to see")
 
  async def slct_callback(interaction):
    if select.values[0] == "Music":
      await send.edit(embed=embed_hm_music)
    elif select.values[0] == "Fun":
      await send.edit(embed=embed_hm_fun)

  async def btn_callback(interaction):
    await send.edit(embed=embed_hm)
    

  btn_back = Button(label="Back",style=disnake.ButtonStyle.gray)
  btn_back.callback = btn_callback
  
  select.callback = slct_callback
  view=View()
  view.add_item(select)
  view.add_item(btn_back)
  
  send = await ctx.send("Testing selects for help command!",embed=embed_hm,view=view)
desert cosmos
zealous dagger
#

all clear

#

all I see is this error in discord

#

@desert cosmos

desert cosmos
#

in terminal where your code is running

#

there must be some error

zealous dagger
paper sluice
#

!d disnake.InteractionResponse

unkempt canyonBOT
#

class disnake.InteractionResponse```
Represents a Discord interaction response.

This type can be accessed through [`Interaction.response`](https://docs.disnake.dev/en/latest/api.html#disnake.Interaction.response "disnake.Interaction.response").

New in version 2.0.
paper sluice
#

interaction.response calls InteractionResponse

#

and embed_hm_fun is an empty embed, so that might cause it to not send

paper sluice
slate swan
#

i noticed that this only works for command names and not aliases but you can modify it lol
and its disnake, but in case you use any other library, the way still remains same

sonic flax
slate swan
#

Dear tell me why it gives errors?

sonic flax
slate swan
slate swan
# slate swan Can u show the on_ready event code
    @commands.Cog.listener()
    async def on_ready(self):
        DiscordComponents(client)
        print("READY!")
        await self.client.change_presence( status= discord.Status.online, activity= discord.Game(".хелп"))
        
        cursor.execute("""CREATE TABLE IF NOT EXISTS users(
            name TEXT,
            id INT,
            cash BIGINT,
            rep INT,
            lvl INT
            )""")
        for guild in self.client.guilds:
            for member in guild.members:
                if cursor.execute(f"SELECT id FROM users WHERE id = {member.id}").fetchone() is None:
                    cursor.execute(f"INSERT INTO  users VALUES ('{member}', {member.id}, 0, 0, 1)")
                else:
                    pass
        conn.commit()
slate swan
slate swan
#

lmao

paper sluice
#

lol

slate swan
#

!rules 5 noone's helping with it

unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

slate swan
#

!sql-fstrings

unkempt canyonBOT
#

SQL & f-strings
Don't use f-strings (f"") or other forms of "string interpolation" (%, +, .format) to inject data into a SQL query. It is an endless source of bugs and syntax errors. Additionally, in user-facing applications, it presents a major security risk via SQL injection.

Your database library should support "query parameters". A query parameter is a placeholder that you put in the SQL query. When the query is executed, you provide data to the database library, and the library inserts the data into the query for you, safely.

For example, the sqlite3 package supports using ? as a placeholder:

query = "SELECT * FROM stocks WHERE symbol = ?;"
params = ("RHAT",)
db.execute(query, params)

Note: Different database libraries support different placeholder styles, e.g. %s and $1. Consult your library's documentation for details.

See Also
Extended Example with SQLite (search for "Instead, use the DB-API's parameter substitution")
PEP-249 - A specification of how database libraries in Python should work

slate swan
#

read this

slate swan
loud junco
#

Im using holy water to wash my eyes

slate swan
loud junco
#

@untold anchor

untold anchor
#

Im here

loud junco
#

Ask here

untold anchor
#

Ask what exactly

loud junco
#

Ask what u want to ask

#

:/

slate swan
# slate swan read this
    @commands.Cog.listener()
    async def on_ready(self):
        DiscordComponents(client)
        print("READY!")
        await self.client.change_presence( status= discord.Status.online, activity= discord.Game(".хелп"))
        
        cursor.execute("""CREATE TABLE IF NOT EXISTS users(
            name TEXT,
            id INT,
            cash BIGINT,
            rep INT,
            lvl INT
            )""")
        for guild in self.client.guilds:
            for member in guild.members:
                query = "SELECT id FROM users WHERE id = {member.id}"
                params = ("RHAT",)
                if cursor.execute(query, params) is None:
                    cursor.execute(f"INSERT INTO  users VALUES ('{member}', {member.id}, 0, 0, 1)")
                else:
                    pass
        conn.commit()

I didn't quite understand how

slate swan
#

How do I slove it

#

@slate swan

#

What should I put there

slate swan
maiden fable
# slate swan

Set the language to Python and iirc, u gotta set the configuration to python main.py

slate swan
#
    @commands.command(aliases = ["123"])
    async def asd(self, ctx):
        await ctx.send(
            "123",
            components = [
                Button(style = ButtonStyle.green, label = 'Да'),
                Button(style = ButtonStyle.red, label = 'Нет'),
                Button(style = ButtonStyle.blue, label = 'А')
            ]
        )
        responce = await client.wait_for('button_click', check = lambda message: message.author == ctx.author)
        if responce.components.label == 'Да':
            await responce.respond(content = 'Деньги успешно переведены!')
        elif responce.components.label == 'Нет':
            await responce.respond(content = 'Вы отменили перевод.')
        else:
            await responce.respond(content = 'Б')

Dear, why when I click on the button, an error pops up?

loud junco
loud junco
#

Typo?

heavy folio
slate swan
slate swan
loud junco
#

Who

slate swan
loud junco
#

Its in the error

slate swan
# loud junco

Can you please tell me what I need to do to avoid the error?

#

I did not understand

loud junco
unkempt canyonBOT
#

Source code: Lib/http/client.py

This module defines classes which implement the client side of the HTTP and HTTPS protocols. It is normally not used directly — the module urllib.request uses it to handle URLs that use HTTP and HTTPS.

slate swan
#

@slate swan use self.client or ctx.bot instead of client

#

AAA, exactly. I keep forgetting about self

#

why is it not interacting?🥺

#
    @commands.command(aliases = ["123"])
    async def asd(self, ctx):
        await ctx.send(
            "123",
            components = [
                Button(style = ButtonStyle.green, label = 'Да'),
                Button(style = ButtonStyle.red, label = 'Нет'),
                Button(style = ButtonStyle.blue, label = 'А')
            ]
        )
        responce = await self.client.wait_for('button_click')
        if responce.components.label == 'Да':
            await responce.respond(content = 'Деньги успешно переведены!')
        elif responce.components.label == 'Нет':
            await responce.respond(content = 'Вы отменили перевод.')
        else:
            await responce.respond(content = 'Б')
loud junco
slate swan
#

well, you see, third party libraries.

frigid apex
#

someone has experience with twitchIO?

slate swan
#

which one to remove?

heavy folio
#

uninstall discord-components

dull terrace
#

The bug on my bots verification is finally fixed by discord but it took 3 weeks so now it's off all of the new pages and it never grew enough to reach the top pages 7739monkathink

#

gonna have to drop money on ads to stand any chance now

slate swan
dull terrace
heavy folio
#

pip install -U git+https://github.com/Rapptz/discord.py

dull terrace
#

pip install disnake

slate swan
#

Issued at startup

heavy folio
shrewd apex
#

🤣

heavy folio
shrewd apex
#

intents

#

u don't have the intents enabled in ur dev page which u enabled in ur code

slate swan
heavy folio
#

oh yeah andyou need message_content intents for 2.0

slate swan
#

||HIKARI exists||

heavy folio
#

fr, either dpy or hikari 🗿

shrewd apex
slate swan
#

im interested in nextcord v3 too, but I won't be using it anyways

dull terrace
shrewd apex
#

🍴

dull terrace
#

disnake is pretty good froggy_chill

heady sluice
#

forks aren't as bad as 3rd party libs...

dull terrace
#

i needed a bunch of stuff discord.py didn't have yet

sonic flax
#

token = os.getenv(DC_TOKEN)
NameError: name ‘DC_TOKEN’ is not defined

#

i have a folder called .env with my discord token called DC_TOKEN thi

shrewd apex
#

load the env folder first

heady sluice
#

use strings

shrewd apex
#

pip install python-dotenv then from dotenv import load_dotenv

sonic flax
shrewd apex
#

they should have some environment variables

glacial glacier
#

I have maked a pokemon botpy_strong

shrewd apex
#

put ur token there

glacial glacier
heady sluice
#

use strings...

dull terrace
#

gratz but also why

shrewd apex
sonic flax
heady sluice
#

that's like the only problem

dull terrace
shrewd apex
sonic flax
dull terrace
#

sorry froggy_chill

shrewd apex
#

he worked all morning

heady sluice
#

token = os.getenv("DC_TOKEN")

sonic flax
heady sluice
#

you store a wrong token in the env or it returned None

slate swan
# heavy folio full code
    @commands.command(aliases = ["123"])
    async def asd(self, ctx):
        await ctx.send(
            "123",
            components = [
                Button(style = ButtonStyle.green, label = 'Да'),
                Button(style = ButtonStyle.red, label = 'Нет'),
                Button(style = ButtonStyle.blue, label = 'А')
            ]
        )
        responce = await self.client.wait_for('button_click')
        if responce.components.label == 'Да':
            await responce.respond(content = 'Деньги успешно переведены!')
        elif responce.components.label == 'Нет':
            await responce.respond(content = 'Вы отменили перевод.')
        else:
            await responce.respond(content = 'Б')
sonic flax
#

but instead of the spam it was my tolen

#

do i need to make it a string too

slate swan
heady sluice
#

if you did that in code, yes

#

it has to be a string

heady sluice
sonic flax
#

and it still doesn’t work

heady sluice
#

try printing token

#

see what it is

heady sluice
#

what you request

slate swan
#

oop i pinged asher too ig, sorry for da ping

merry cliff
#

and make sure you also request it in the code

shrewd apex
#

ah np

merry cliff
#
intents = discord.Intents.default()
intents.members = True
#

if you wanted to add the members intent for example

shrewd apex
#

just do .all() saves some trouble for beginners

glacial glacier
#

I need help how to add a image in the end of command?

merry cliff
#

also a way

shrewd apex
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.

For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") for you.

Changed in version 2.0: `Embed.Empty` has been removed in favour of `None`.
slate swan
#

Dear, I did not quite understand what I need to do?

sonic flax
shrewd apex
sonic flax
#

and token = none

shrewd apex
#

then in code do

intents=discord.Intents.all()
heady sluice
#

print(token)

shrewd apex
heady sluice
#

what

heady sluice
#

he saved it to token in code

merry cliff
#

oh

slate swan
shrewd apex
#

then he didn't load the env file

sonic flax
#

In replit my environmental variables worked

sonic flax
shrewd apex
#

but when u host ur bot they create their own venv generally heroku does atleast

#

so they would have a place for storing env variables for heroku it's in settings -> config var

sonic flax
shrewd apex
#

idk pebble host never used

shrewd apex
#
async def setup(bot):
     await bot.add_cog(cog)
merry cliff
#

I use vultr to host bots

#

bc u can pipeline

sonic flax
shrewd apex
#

like i said b4

merry cliff
#
load_dotenv()
TOKEN = os.getenv("TOKEN")```
sonic flax
#

ok

merry cliff
#

or whatever your name is in the .env file

shrewd apex
#

in load dotenv ur file path goes

merry cliff
#

make sure to import os

shrewd apex
#

to env file

slate swan
shrewd apex
#

that too

sonic flax
#

do i just type python-dotenv there

shrewd apex
#

...

merry cliff
#

lol

shrewd apex
#

pip install python-dotenv

#

then do pip freeze

#

se which version was installed

#

then copy paste that part in the txt

sonic flax
shrewd apex
#

💀

merry cliff
#

noooo

#

install it first

#

then cop paste the list

shrewd apex
#

i bet 5 bucks he gonna ask where next

slate swan
sonic flax
#

python-dotenv==0.20.0

shrewd apex
#

👍

#

put that instead of pip install

merry cliff
#

yay

slate swan
#

most petrodactyl hosts trigger requirements.txt automatically on runtime, so you don't need to run the pip command yourself

shrewd apex
#

💸

slate swan
shrewd apex
#

can u show ur cogs code

#

the part where u are loading ur cogs

sonic flax
#

NameError: load_dotenv is not dfined

merry cliff
#

wait why do they have discord and dpy

shrewd apex
#

did u import in the code

sonic flax
#

No

shrewd apex
#

...

sonic flax
#

do i import load_dotenv

#

Or is it called something else

slate swan
#
class mod(commands.Cog):
    def __init__(self, client: discord.Client):
        self.client = client
#commands


async def setup(bot):
    await bot.add_cog(mod(bot))
cogs = [        
    "mod"
]

# Class Main 
class Main(commands.Bot):                   
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
slate swan
sonic flax
#

No module named load_dotenv

shrewd apex
#
from dotenv import load_dotenv
sonic flax
#

Ok

slate swan
shrewd apex
#
await client.load_extension('mod')
slate swan
#

remove that dotenv part, asher was answering to dew

shrewd apex
#

i though china was demonstrating to dew this was like 3 different levels of thinking going on here

sonic flax
#

Improper token has been passed

#

Does that just mean my tokens wrong

shrewd apex
#

either ur tokens wrong or the way u stored ur token is wrong

#

in .env

token=abcd1234
#

this is how u are supposed to store

slate swan
shrewd apex
#

don't put the token in string in the env file

shrewd apex
glacial glacier
#

image=https://media.discordapp.net/attachments/986212628810580018/986223675726528602/749aa4e23c7b2a6f72d1f9a63cb8c890530e74fd23d19fa930e5bf8dd909cce9.0.JPG

shrewd apex
glacial glacier
#

embed.set_image(url='https://media.discordapp.net/attachments/986212628810580018/986223675726528602/749aa4e23c7b2a6f72d1f9a63cb8c890530e74fd23d19fa930e5bf8dd909cce9.0.JPG') 

shrewd apex
#

yeah

#

but do consider learning python first and checking discord.py docs before jumping into discord bots

merry cliff
#

highly reccomended

sonic flax
#

I keep getting unproper token bas been passed when I literally pasted a new one in and it isnt a string

shrewd apex
#

ur tokens wrong then