#discord-bots

1 messages ยท Page 73 of 1

primal token
#

@sick birch hey robin @unkempt canyon isnt written in a custom wrapper because of the community and contributors right?

lone lichen
#

Good luck ๐Ÿคž๐Ÿป

lone lichen
primal token
lone lichen
primal token
lone lichen
primal token
#

and python brings happiness isnt that enough๐Ÿ˜ฟ

lone lichen
#

It is but not enough to make custom wrapper ig ๐Ÿ˜‚

primal token
#

but making a custom wrapper brings people happiness ๐Ÿค”

lone lichen
#

Ppl wouldnt even realise Itโ€™ s not made in custom wrapper it wasnt open source

#

So ig ppl can still be happy

unkempt canyonBOT
#
Bad argument

Unable to convert '?' to valid command, tag, or Cog.

primal token
#

!src

unkempt canyonBOT
primal token
#

it is open source?

lone lichen
#

Idk I never looked

#

But since robin is contributing

#

I figured

#

It may be

wicked atlas
primal token
#

yep

#

iirc it went from discord.py -> disnake -> discord.py

lone lichen
primal token
#

that is correct

lone lichen
#

That was worse that corona

primal token
#

๐Ÿ˜ญ

#

we should actually stop joking around before we get banned lmao

lone lichen
#

I had to put up with pycord

#

And then I found disnake

primal token
lone lichen
#

As long as u havent tried discord.js either

primal token
#

ive tried discord.rb

lone lichen
#

Ruby?

primal token
#

yep

lone lichen
#

Haha how was it

primal token
#

its not that bad its actually a bit similar to discord.py

lone lichen
#

Rn Iโ€™ m working on some integration between discord whatsapp and telegram

#

And Itโ€™ s using discord.js

primal token
lone lichen
#

And js is just deciding to make my life hell

wicked atlas
#

js is a nightmare sometimes

lone lichen
#

Yes, but the funny part is just beginning

#

I gotta store so e data

wicked atlas
#

"I want to make a simple multipage websit-" gets crushed by 3 GB node_module folder and like 50 choices in web frameworks and libraries

lone lichen
#

And from what I heard js and databases dont != healthy developer

wicked atlas
#

yeah, needless to say I just used jekyll for that project

lone lichen
#

Whats that, a cms?

grizzled reef
#
async def h(ctx, channel: discord.TextChannel):
    channel = bot.get_channel(101312783609103568)
    async for command in channel.slash_commands(query="no", limit=None):
        if command.name == "hello":
            await command[0]()```

TextChannel has no attribute slash_commands
pliant gulch
#

Static site generators are great

#

Love them for documentations cause it's just so easy

wicked atlas
# lone lichen Whats that, a cms?

It's static site framework writen in ruby. You can put markdown through it and it'll spit out html based on templates you give it.

grizzled reef
#

โ€˜TextChannelโ€™ object has no attribute โ€˜slash_commandsโ€™

lone lichen
wicked atlas
#

text channels don't have slash commands ยฏ_(ใƒ„)_/ยฏ

wicked atlas
lone lichen
#

Not usefull for web applications

wicked atlas
#

yeah for web applications, I just don't use js

lone lichen
#

In school next year they are gonna teach us html and word press and php

lone lichen
pliant gulch
#

At least it's not java

lone lichen
#

Frontendโ€ฆ I dont do ๐Ÿ˜‚

lone lichen
silk fulcrum
pliant gulch
#

You can't be serious

wicked atlas
#

You set the value of channel to the value of channel.id, overwriting the channel object

#

Use some different variable names

lone lichen
#

And Itโ€™ s not random nonsense

#

But I like kotlin more

wicked atlas
#

Yeah, I can see why Java is a good learning language, maybe not the first language I would want to encounter learning programming, but still it's easier than languages like C for static typing and OOP imo

pliant gulch
#

It's multi-paradigm

primal token
pliant gulch
#

Java is just too much boilerplate

#

Also don't overlook the fact that Java is memory-hungry

#

Even for small applications

lone lichen
pliant gulch
#

And java has the worst semantics I've seen. Reading source of java applications is literally horrible they have 5 empty directories all nested and the final one has actual code

#

I don't like Javascript, but java is def worse imo

wicked atlas
#

What are you trying to get about the channel?

lone lichen
#

U can do (โ€œbโ€ + โ€œaโ€ + + โ€œaโ€) and u will get banana ๐Ÿ˜‚

wicked atlas
#

If you want type, it's just channel.type

lone lichen
lone lichen
pliant gulch
#

And why the long names as well in java?

lone lichen
pliant gulch
#

I literally sometimes cannot fit the whole line in my neovim buffer because it's so long

lone lichen
#

๐Ÿ˜‚

#

I have no clue, only thing I use java for is backend

wicked atlas
#

I never use java unless I'm required to for something

pliant gulch
wicked atlas
pliant gulch
#

I can't understand how you'd get used too that

wicked atlas
#

idek what spring boot is ngl

lone lichen
pliant gulch
lone lichen
#

I dont think Itโ€™ s possible

pliant gulch
#

But I swear you look at any java project in trending and it'll have soo many folders like that

lone lichen
wicked atlas
lone lichen
#

But there is a better one for java called quarkus

pliant gulch
lone lichen
slate swan
#

how to react to message discord py?

wicked atlas
#

You know, maybe we should not talk about java in the #discord-bots channel

wicked atlas
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 "discord.Emoji").

You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission to use this. If nobody else has reacted to the message using this emoji, the [`add_reactions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission 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 "(in Python v3.10)") instead of `InvalidArgument`.
lone lichen
slate swan
wicked atlas
#

how so?

slate swan
lone lichen
wicked atlas
#

Can you show your code?

slate swan
# wicked atlas Can you show your code?
                        await interaction.response.send_message("embed has been sent", ephemeral=True)
                        reaction1 = "๐Ÿ“ˆ"
                        await msg.add_reaction(emoji=reaction1)
                        reaction2 = "๐Ÿ“‰"
                        await msg.add_reaction(emoji=reaction2)```
wicked atlas
#

What is msg defined as?>

slate swan
#

msg = await channell.send(embed=evm)

lone lichen
#

!d discord.Emoji

unkempt canyonBOT
#

class discord.Emoji```
Represents a custom emoji.

Depending on the way this object was created, some of the attributes can have a value of `None`...
wicked atlas
#

The emoji can be a string, that's not the issue

lone lichen
#

Try using that

wicked atlas
#

especially unicode emojis

scarlet aurora
pliant gulch
#

Pass it as a positional argument otherwise it'll error

#

The function is guarded to be pos-only

slate swan
pliant gulch
#

!e ```py
def foo(bar: str, /) -> None:
print(bar)

foo("Hello World!")
foo(bar="Hello World!")

unkempt canyonBOT
#

@pliant gulch :x: Your 3.11 eval job has completed with return code 1.

001 | Hello World!
002 | Traceback (most recent call last):
003 |   File "<string>", line 5, in <module>
004 | TypeError: foo() got some positional-only arguments passed as keyword arguments: 'bar'
pliant gulch
scarlet aurora
#

Can someone help?

wicked atlas
lone lichen
scarlet aurora
lone lichen
#

!resources for loop

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.

lone lichen
#

!d for loop

unkempt canyonBOT
#
for

8.3. The for statement

The for statement is used to iterate over the elements of a sequence (such as a string, tuple or list) or other iterable object:


for_stmt ::=  "for" target_list "in" expression_list ":" suite
              ["else" ":" suite]
pliant gulch
#

BNF ๐Ÿ

scarlet aurora
#

where did I do that wrong @lone lichen

#

what line

lone lichen
wicked atlas
scarlet aurora
#

well the general idea is

#

someone types a rank they want in #role-request

#

a message from the bot gets sent to #admin and then we have to react to the bot with 'confirm' to give that person said rank

#

all ranks work apart from the company ranks, i.e, (1st, 2nd, 3rd company)

#

and I have no idea why

lone lichen
#

Set some breakpoints

#

Go line by line

wicked atlas
scarlet aurora
#

no and the message to reply to doesn't send either

wicked atlas
#

Try printing out the values you use in these if statements then, and seeing what values are in them

        if message.channel == channel:
            if message.content in list:
                if mention == 'None':
#

You might be getting some values that you might not be expecting

#

Should note, you don't have to use a string 'None', you could just use the actual None value

#

Then check if mention:

queen reef
#
  • ๐Ÿ‘‹ has Discord recently changed thread archiving to 7 days of inactivity, ignoring the auto_archive_duration parameter of TextChannel.create_thread(), which now seems more of an auto_hide_duration? Is there a new way to auto-archive a thread?
heady citrus
#

TypeError: Dropdown.callback() missing 1 required positional argument: 'select'

any help?

ionic edge
#
Traceback (most recent call last):
  File "", line 409, in _run_event
    await coro(*args, **kwargs)
  File "d:\shr!ke.exe\Marvis\marvis.py", line 158, in on_command_error
    raise error
discord.ext.commands.errors.HybridCommandError: Hybrid command raised an error: Command 'list' raised an exception: OperationalError: no such column: reason```
#
CREATE TABLE IF NOT EXISTS `blacklist` (
  `user_id` varchar(20) NOT NULL,
  `moderator_id` varchar(20) NOT NULL,
  `reason` varchar(255) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
);```
slate swan
#

why is it `reason` ?

#

you should be using the same thing in all your queries then

slate swan
hollow plank
#

!e
Print("Hello World!")

unkempt canyonBOT
#

@hollow plank :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | NameError: name 'Print' is not defined. Did you mean: 'print'?
primal token
#

#bot-commands

vale wing
shrewd apex
#

i think it's just included in the column name

#

so its prolly not sql syntax

vale wing
#

Yeah probably

slate swan
shrewd apex
#

sup ashley ducky_beer

slate swan
shrewd apex
#

nothing just having fun lately vacation ends this sunday

silk fulcrum
#

w-w-w-wait, Pyweek starts tmrw

shrewd apex
#

yesh

silk fulcrum
#

oof

slate tundra
#

Since the news/update my bot only responds to dms now.

shrewd apex
#

rip

silk fulcrum
#

F

shrewd apex
#

if u enable message content it should work but ur bot can't join new servers

slate tundra
#

is this the one in the intents?

shrewd apex
#

yes

slate tundra
#

I only use it for my personal server so no problem there

shrewd apex
#

hmm if its not a verfied bot there should be no problem

slate tundra
#

Ok i'll try that. thanks

shrewd apex
torn sail
#

@primal token yo is ur pfp kurzegesat

primal token
primal token
#

asher can you send a ss?

shrewd apex
#

yes

primal token
#

thanks

shrewd apex
#

actually u can just try many big bots still responding to prefix commands

#

lemme open my applications page meanwhile

primal token
shrewd apex
primal token
#

bro clean your screen

shrewd apex
#

its in the changelog yesterday it was on applications page they removed it today so took some time to find

shrewd apex
primal token
#

the heck you doing to have your screen that dirty

shrewd apex
#

bit of it is the window reflection due to sun

#

but mostly finger prints

#

and all

primal token
# shrewd apex

either way your statement isnt quite true as you never explicitly said that your statement is only directed at verified apps that have asked for the intent and not enabled

Asher โ€” Today at 12:01 AM
if u enable message content

primal token
#

is the monitor touch screen or something to be touching it so much

shrewd apex
#

bruh unverified apps have message content intent anyway

shrewd apex
primal token
shrewd apex
#

yes yes my fault sir ๐Ÿ’€

primal token
shrewd apex
#

kewl how u know altho i wouldn't have punched that way no more coding for me ๐Ÿ’€

primal token
#

kek i wouldve punched my left monitor(dual monitors)

shrewd apex
#

rich ppl pithink me only have a potato laptop ๐Ÿฅฒ

primal token
#

i saved for my desktop for like 5years and now i cant even buy a kitkat, im at the verge of being homeless

shrewd apex
#

hmm u live alone?

primal token
silk fulcrum
primal token
#

you wouldnt fit in them

shrewd apex
primal token
#

theyre pretty thin walls what can i say

shrewd apex
#

if i started saving a week after saving i would go to pizza hut or something and spend it all

#

๐Ÿ™

primal token
#

now im saving each penny i find in the streets for food

#

inflammation๐Ÿ˜ฟ

slate swan
primal token
#

I legally cant work, whats your point?

slate swan
#

hm that's sad

primal token
#

its not sad, its nice not thinking about a job/work, the only thing i'm thinking about is formulas i need to learn for physics๐Ÿ˜”

slate swan
#

have fun

primal token
#

i need to learn like 20 formulas im having the time of my life right now

slate swan
#

only 20

primal token
#

for now

slate swan
#

which ones

primal token
#

i dont even know one currently

#

i need to check my notebook kek

slate swan
#

hellish

#

no comments

slate swan
#

Why does this look so cursed ๐Ÿ’€

vocal snow
#

Looks fine

primal token
#

Looks good to me over binding app commands to a tree๐ŸŒด

slate swan
#

and a @describe decorator

primal token
#

๐Ÿ‘

sly fog
#

how do you make buttons in discordpy

#

i heard u can do so in 2.0

vocal snow
vocal snow
sly fog
#

thx

rain olive
vocal snow
#

You create a discord.ui.View, add ui components/items to it and pass it to view kwarg of .send

sly fog
#

can u make mutiple?

rain olive
#

yes

vocal snow
#

Yes

#

5 per row for 5 rows

sly fog
#

ok

#

im still getting used to 2.0 lol

rain olive
#

hikari is neat

primal token
rain olive
sly fog
#

ok

silk fulcrum
primal token
#

what

slate swan
slate swan
rain olive
#

agreed

slate swan
#

lightbulb ๐Ÿ˜ณ

primal token
slate swan
#

I hate nitro-less days

primal token
#

ew

slate swan
#

ok

primal token
#

ok

rain olive
#

๐Ÿ’€

slate swan
rain olive
#

@slate swan miru good too

vocal snow
#

I mean, you can create an instance of discord.ui.View, add items with its add_item method and pass the view obj to the view kwarg of Messageable.send

primal token
#

yes

silk fulcrum
rain olive
#

hikari component handler.

maiden fable
silk fulcrum
maiden fable
#

All those decorators ๐Ÿฅบ

slate swan
vocal snow
#

You can subclass if you want, in the end you have to instantiate it

primal token
# slate swan I hate nitro-less days

Why tho? nitros only good feature is using emojis everywhere and i wouldnt doubt it would be removed from nitro classic, its quite funny seeing how discord has 2 nitros, but either way my point doesnt matter because i have no nitro kek

rain olive
slate swan
primal token
#

because i want discord to go bankrupt

#

everyone go back to skype

#

please๐Ÿฅบ๐Ÿ˜”

maiden fable
#

I mean

#

What a comparison

slate swan
maiden fable
#

Discord and Skype

primal token
slate swan
primal token
#

my grandma destroyed cancer twice pithink

#

talk about a menace

maiden fable
#

!ot

unkempt canyonBOT
rain olive
#

@slate swan do you have instagram

primal token
#

bro

maiden fable
#

And yea, I mean ot2, not #ot3-discord-bots

primal token
#

ok

slate swan
#

oof

primal token
#

the only account ive viewed this week on insta was a cat account mina shared with me kek

buoyant quartz
#

I have 100 voice channels in my discord and i want my bot to join each one for about 5 seconds before joining another one.

unkempt canyonBOT
#

property voice_channels```
A list of voice channels that belongs to this guild.

This is sorted by the position and are in UI order from top to bottom.
primal token
#

you can iterate through each channel in a command or a task depending on what you want

slate swan
#

and make sure to play a rickroll each time the bot joins a channel

primal token
buoyant quartz
#

i want it to be like join vc 100, wait like 1 sec then join vc 99

primal token
#

yes

#

iteration

slate swan
#

with a try/except block cuz you might not have the perms to join some vc

primal token
slate swan
#

cmon its not even that annoying

lone lichen
primal token
#

L

#

i like Kiss - I Was Made For Lovin' You better

lone lichen
#

Same same

primal token
#

not as old but i love it

lone lichen
#

Or eric clapton layla

slate swan
#

laufs in metal

primal token
lone lichen
#

That too

lone lichen
slate swan
lone lichen
primal token
#

wait let me give the original link

slate swan
# lone lichen Megadeth?

i heard some songs from them but didn't engage too much
lets move to an ot channel before ee get yeeted

buoyant quartz
grim oar
#

Big MacDonalds

glossy ruin
#

how to know if an error is Mission Permission or Unknown Ban
when printed type both are discord.errors.ApplicationCommandInvokeError
in pycord

#

\python

#

is this the way ^ ?

slate swan
#

you can accept an argument with a discord.Emoji typehint and use the id attr to it

async def mycmd(ctx, emoji: discord.Emoji):
  em_id = emoji.id

but note that this is only applicable for custom static/animated emojis and not default emojis

#

or you can always get/fetch the emoji

#

welcome

gentle crescent
#

So, links arent considered attachments. What would be a good way to seeing the type of attachment, and if the message has a link

gentle crescent
#

wat

silk fulcrum
#

!d discord.Embed

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...
gentle crescent
#

ah

#

That should work then?

silk fulcrum
#

what do you want from an embed?

gentle crescent
#

Embed.video.url

silk fulcrum
#

it can't even handle a video

#

only images/gifs

gentle crescent
#

?

silk fulcrum
#

w-w-wh-hat?

silk fulcrum
#

it actually exisys

#

๐Ÿ˜ณ surprising

gentle crescent
#

!d discord.Embed.video

unkempt canyonBOT
#

property video```
Returns an `EmbedProxy` denoting the video contents.

Possible attributes include:

โ€ข `url` for the video URL.

โ€ข `height` for the video height.

โ€ข `width` for the video width...
gentle crescent
#

Will that work for videos with urls?

#

if message.Embed.video.url != None:

silk fulcrum
#

!d discord.Message.embeds

unkempt canyonBOT
silk fulcrum
#

yeop

gentle crescent
#

So wait just replace message.Embed with message.embeds?

slate swan
gentle crescent
#

Great

slow fog
vale wing
#
  1. Try printing wel[0]
  2. Try using fetch_channel instead
#
ch = await interaction.guild.fetch_channel(...)```
#

I don't see any code of modal neither you gave me the error

#

Do you respond to modal interaction

unkempt canyonBOT
fierce karma
#

Does someone how to make a auto kill 1 if the bot stops working in py ?

slate swan
#

yes, depends how and where do you want it

#

and what guild would it be? is there any reference to it? like the name or something

brazen raft
#

Search the guild in bot.guilds or bot.fetch_guilds using some filter of your choice

slate swan
#

there's a on_guild_join event which gets triggered when the bot is added to a server

brazen raft
#

Ye

#

If it happens when the bot joins a guild, you might as well use the event and only run code in it if there is something special about the guild

#

In an if statement or something

gentle crescent
#

Why? Why not just use the on_guild_join? Will the bot only be in one guild?

#

If it's only in one guild then just do it manually

white citrus
#

How can I check in an autocomplete whether the entry is, for example, 1s 2s 3s or 1m or 1h?

slate swan
#

the answer varies with the library you're using

white citrus
slate swan
white citrus
slate swan
fierce karma
#

oh

white citrus
glossy ruin
slate swan
glossy ruin
#

you have 2 opening ( and 3 closing )

brazen raft
#

You flipped one parenthesis

slate swan
#

aaaa

brazen raft
#

In the range

slate swan
#

yea i was typing on phone and it went wrong

unkempt canyonBOT
#

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

001 |   File "<string>", line 1
002 |     print ([*(f"{n}h", f"{n}s", f"{n}m") for n in range(10)])
003 |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
004 | SyntaxError: iterable unpacking cannot be used in comprehension
brazen raft
#

Use list() over the generator expression

slate swan
#

so they don't allow that in comps

brazen raft
#

Or itertools.chain.from_iterable

#

What do you mean to do

slate swan
#

unpack the result tuple inside the comp

#

which doesn't seem possible here

slate swan
rugged shadow
brazen raft
#

!e

from itertools import chain

print(list(chain.from_iterable((f"{n}h", f"{n}s", f"{n}m") for n in range(10))))
unkempt canyonBOT
#

@brazen raft :white_check_mark: Your 3.11 eval job has completed with return code 0.

['0h', '0s', '0m', '1h', '1s', '1m', '2h', '2s', '2m', '3h', '3s', '3m', '4h', '4s', '4m', '5h', '5s', '5m', '6h', '6s', '6m', '7h', '7s', '7m', '8h', '8s', '8m', '9h', '9s', '9m']
rugged shadow
#

are you getting ratelimited because of spamming, or?

brazen raft
#

Like this?

slate swan
rugged shadow
#

oh i forgor abou that

slate swan
#

kill 1 in general would shut down your computer lmao

fierce karma
rugged shadow
slate swan
#

understood

slate swan
#

regex is cute

#

because youre making it do that? the part of code was triggered multiple times

#

How do i add a Slash command to a cog in discord.py

#

check pins, 2nd message

#

sarth

#

ash

ashen perch
#

im having issues with this import (background its for a bot i built a few months ago and im trying to go back to it)

from discord_components import DiscordComponents

it throwing this error

Traceback (most recent call last):
  File "c:\Users\maLev\Desktop\Optimized Arcade Bot\Arcade\src\main.py", line 5, in <module>
    from discord_components import DiscordComponents
  File "C:\Users\maLev\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord_components\__init__.py", line 1, in <module>
    from .client import *
  File "C:\Users\maLev\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord_components\client.py", line 12, in <module>
    from .component import Component
  File "C:\Users\maLev\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord_components\component.py", line 3, in <module>
    from discord import PartialEmoji, Emoji, InvalidArgument
ImportError: cannot import name 'InvalidArgument' from 'discord' (C:\Users\maLev\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\__init__.py)

any help would be appreciated

slate swan
#

you should not use this library

ashen perch
#

why?

slate swan
slate swan
ashen perch
#

ah ok

slate swan
ashen perch
#

so discord.py now has all of the features already integrated if I understood you or do I need a newer library?

slate swan
ashen perch
#

k thanks!

slate swan
slate swan
#

show

slate swan
#

why update then

#

I just had a stroke

slate swan
#

that lib is using the class, dont use the lib = don't need to class

#

?

vocal snow
#

ashley being a sussy

slate swan
# slate swan show

would me doing external cogs be an issue? i have a folder named: "cogs"

vocal snow
#

show the error pls

slate swan
#

or show the error

#

no need

#

..

#

i cant do this

from discord import app_commands

#

why...?

#

did you update dpy?

vocal snow
#

please stop making half-assed statements man

slate swan
#

you guys help, I'll be off

slate swan
slate swan
slate swan
#

Now i get this

bot.py:24: RuntimeWarning: coroutine 'BotBase.add_cog' was never awaited
bot.add_cog(moderation(bot))
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Traceback (most recent call last):
File "/Users/c/Desktop/Bot With Cogs <3/bot.py", line 26, in <module>
bot.loop.create_task(ch_pr())
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/client.py", line 108, in getattr
raise AttributeError(msg)
AttributeError: loop attribute cannot be accessed in non-async contexts. Consider using either an asynchronous main function and passing it to asyncio.run or using asynchronous initialisation hooks such as Client.setup_hook

white citrus
slate swan
slate swan
#

๐Ÿ‘จโ€โค๏ธโ€๐Ÿ’‹โ€๐Ÿ‘จ everyone loves regex

#

,

white citrus
#

How can i do a regex for the results 1s - 3000s

brazen raft
ashen perch
#

is there documentation for the slash commands?

#

nvm found it

shrewd apex
ashen perch
brazen raft
#

Only discord.py is needed

slate swan
ashen perch
#

k

slate swan
#

just run pip uninstall discord discord-components discord-py-interaction discord-py-slash-command
uwu

ionic edge
#
  File "", line 409, in _run_event
    await coro(*args, **kwargs)
  File "d:\shr!ke.exe\Marvis\marvis.py", line 158, in on_command_error
    raise error
discord.ext.commands.errors.HybridCommandError: Hybrid command raised an error: Command 'list' raised an exception: OperationalError: no such column: reason```
#
CREATE TABLE IF NOT EXISTS `blacklist` (
  `user_id` varchar(20) NOT NULL,
  `moderator_id` varchar(20) NOT NULL,
  `reason` varchar(255) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
);```
grim oar
#

Ashley

brazen raft
#

What are those back ticks for

ashen perch
#

thanks

slate swan
ashen perch
shrewd apex
#

remove that discord as well

#

pip uninstall discord

radiant wave
ashen perch
#

im so confused how do you make a slash command with discord.py 2.0.1
can anyone give me an example

#

after taking a break for 5 months of making bots i dont remember a thing, this is sad

ashen perch
#

you are literally a life saver tysm

paper sluice
#

thank ashley, lol

white citrus
shrewd apex
#

!pypi durations-nlp

unkempt canyonBOT
slate swan
#

imagine making a custom timeout command over the builtin one

white citrus
#

He should still check in the slash command whether the input is 52s, for example, or 91m or 5d

#

@shrewd apex

shrewd apex
slate swan
#

specifically 1.7.3

wicked atlas
#

pip install discord==1.7.3

white citrus
slate swan
wicked atlas
#

Either one works

brazen raft
#

It shouldn't

wicked atlas
#

Why not?

#

Itโ€™s a mirror package, and itโ€™s got that version on pypi.

slate swan
#

@bot.slash_command(description="Sends the bots current ping")
AttributeError: 'Bot' object has no attribute 'slash_command'. Did you mean: 'add_command'?

#

uhm

#

How fix

wicked atlas
slate swan
#

but thats what i have been using...

#

ive been using that for months

wicked atlas
#

Well, it doesnโ€™t have them. They were only added in 2.0.

#

Maybe you were using another package which monkey-patched your install

slate swan
#

but even then, my friends are also using slash commands with that

wicked atlas
#

Iโ€™d suggest just using 2.0

slate swan
#

even with 2.0

#

its still giving the error...

brazen raft
#

This is because this is not the way you define slash commands in discord.py

slate swan
#

read that

#

see what i dont understand

#

or

class MyBot(commands.Bot):
  def slash_command(self, name: str=None, description: str=None, nsfw: bool=False, guild: int=None, guilds: list[int]=None, auto_locale_strings: bool=True, extras: dict=None) -> ...:
        return self.tree.command(name=name, description=description, nsfw=nsfw, guild=guild, guilds=guilds, auto_locale_strings=auto_locale_strings, extras=extras)

๐Ÿ’€

slate swan
#

my slash command setup worked perfectly fine on 1.17.3.

But once i install discord.py 2.0 and downgrade back

All of the sudden they dont work...

#

1.7.3 never had slashes

brazen raft
#

The libraries with which you created slash commands aren't discord.py, so downgrading from the version of discord.py which has them means you lose them

slate swan
#

then how in tf was i able to use it...

brazen raft
#

discord.py introduces slash commands in version 2 and it is most definitely handled in a different way than the libraries you used

wicked atlas
brazen raft
slate swan
wicked atlas
#

There are probably a bunch that do it the way you show

tidal hawk
#

maybe connection just expires?

tidal hawk
#

Does anyone have a clue why Oauth2 guilds.join returns a "401 unauthorized" response, though the token is valid, bot has permissions and scope is selected xd

#
export async function joinGuild(tokenType, accessToken, guildID, userID) {
  const res = await fetch(`https://discord.com/api/guilds/${guildID}/members/${userID}`, {
    method: "put",
    headers: {authorization: `${accessToken}`}
  })
}```
slate swan
#

are you using a connection or a connection pool

slate swan
slate swan
tidal hawk
#

same logic goes for request lol

slate swan
#

huh?

#

request isn't limited to a language

tidal hawk
#

python returns the same error, asked about discord api

slate swan
tidal hawk
#

Tried it bearer aswell but no difference, and docs state "All parameters to this endpoint except for access_token are optional."

#

but bearer goes with it ig then

#

ohhh

#

wait lemme try

slate swan
#

because for the rest api we use the headers lile this ```py
{
"Authorization": "Bot <bot token here>"
}

#

shouldn't be, try using a Pool instead

#

and use aiomysql, not mysql

#

well then learn how to, cause mysql would be blocking the processes most of the time

tidal hawk
slate swan
#

its not rocket science, just some changes in awaits

tidal hawk
#

checkout tutorials

slate swan
tidal hawk
#

just watch tutorial how to handle aiomysql and then figure out how to link it with discord bot

slate swan
#

there are examples and docs on the Library's docs page

#

stop referring to how to use "x" with discord bots, but how to use "x"

#

noone is going to spoonfeed if you watch an year old outdated yt tutorial either

tidal hawk
mossy warren
#

is there a way to get a user object with just the ID?

slate swan
tidal hawk
#

xD

slate swan
mossy warren
night crater
white citrus
#
days: int = SlashOption(name="days", description="How many days to mute the Member for", required=False, max_value=28) = 0,```

I got here a error
slate swan
mossy warren
#

ah ok thanks I'll try that

slate swan
grim oar
#

I dont think fetch_user caches anyways

slate swan
#

!d nextcord.SlashOption

unkempt canyonBOT
#
class nextcord.SlashOption(name=None, description=None, required=None, *, name_localizations=None, description_localizations=None, choices=None, choice_localizations=None, ...)```
Provides Discord with information about an option in a command.

When this class is set as the default argument of a parameter in an Application Command, additional information about the parameter is sent to Discord for the user to see.
slate swan
#

there's not, sad

white citrus
#

There is

slate swan
#

well then just use that :p

wicked atlas
#

it was hidden at the bottom pithink

slate swan
#

yeah the codeblock didn't show all the args

white citrus
#
Traceback (most recent call last):
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\client.py", line 499, in _run_event
    await coro(*args, **kwargs)
  File "c:\Discord\Maja Projekt\MajaSystem\bot.py", line 220, in on_application_command_error
    raise error
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\application_command.py", line 848, in invoke_callback_with_hooks
    await self(interaction, *args, **kwargs)
  File "c:\Discord\Maja Projekt\MajaSystem\modules\mod\cog.py", line 195, in timeout
    time = datetime(day=now.day + days, hour=now.hour + hours, minute=now.minute + minutes, second=now.second + seconds)
TypeError: 'module' object is not callable```
#

Mhh

wicked atlas
#

Yeah, the datetime module do be like that

from datetime import datetime
white citrus
#
Traceback (most recent call last):
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\client.py", line 499, in _run_event
    await coro(*args, **kwargs)
  File "c:\Discord\Maja Projekt\MajaSystem\bot.py", line 220, in on_application_command_error
    raise error
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\application_command.py", line 848, in invoke_callback_with_hooks
    await self(interaction, *args, **kwargs)
  File "c:\Discord\Maja Projekt\MajaSystem\modules\mod\cog.py", line 211, in timeout
    future = now + datetime.timedelta(time)
AttributeError: type object 'datetime.datetime' has no attribute 'timedelta'```
wicked atlas
tidal hawk
#

maybe interaction.channel.id works?

white citrus
# wicked atlas In this case you're no longer using the module. So you can either import it, or ...

Mhh

Ignoring exception in on_application_command_error
Traceback (most recent call last):
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\client.py", line 499, in _run_event
    await coro(*args, **kwargs)
  File "c:\Discord\Maja Projekt\MajaSystem\bot.py", line 220, in on_application_command_error
    raise error
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\application_command.py", line 848, in invoke_callback_with_hooks
    await self(interaction, *args, **kwargs)
  File "c:\Discord\Maja Projekt\MajaSystem\modules\mod\cog.py", line 211, in timeout
    future = now + timedelta(time)
TypeError: unsupported type for timedelta days component: datetime.datetime```
white citrus
# brazen raft What's `time`?
        time = datetime(year=now.year, month=now.month, day=now.day + days, hour=now.hour + hours, minute=now.minute + minutes, second=now.second + seconds)
brazen raft
#

What are you trying to do

floral stratus
#
Traceback (most recent call last):
  File "D:\python\lib\site-packages\discord\client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "D:\python\lib\site-packages\discord\bot.py", line 1147, in on_connect
    await self.sync_commands()
  File "D:\python\lib\site-packages\discord\bot.py", line 643, in sync_commands
    registered_guild_commands[guild_id] = await self.register_commands(
  File "D:\python\lib\site-packages\discord\bot.py", line 473, in register_commands
    prefetched_commands = await self.http.get_guild_commands(self.user.id, guild_id)
  File "D:\python\lib\site-packages\discord\http.py", line 353, in request
    raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access```
tidal hawk
#

into the same channel, where the id is taken from?

#

You have to make the welcome channel object and just send it there

#

maybe there's error on line 356 which results the event from stopping further

#

creizy now replicate it

#

Srry I can't

#

make an alt account

white citrus
#

d! datetime.now

primal token
unkempt canyonBOT
#

classmethod datetime.now(tz=None)```
Return the current local date and time.

If optional argument *tz* is `None` or not specified, this is like [`today()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.today "datetime.datetime.today"), but, if possible, supplies more precision than can be gotten from going through a [`time.time()`](https://docs.python.org/3/library/time.html#time.time "time.time") timestamp (for example, this may be possible on platforms supplying the C `gettimeofday()` function).

If *tz* is not `None`, it must be an instance of a [`tzinfo`](https://docs.python.org/3/library/datetime.html#datetime.tzinfo "datetime.tzinfo") subclass, and the current date and time are converted to *tz*โ€™s time zone.

This function is preferred over [`today()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.today "datetime.datetime.today") and [`utcnow()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow "datetime.datetime.utcnow").
light jungle
#

Hello everyone, who can tell me how to make this window (probably with the help of what attribute) if this is a window receiving discord hypesquad

#

if it is necessary briefly, then I need to make a window with such questions.

#

most likely on discord modals only if you enter text there, then there are ready-made answers

glad cradle
#

afaik you can't create such a modal rn

light jungle
wicked atlas
#

Multiple choice prompts are currently not part of discord modals or message components, there's no way to make them right now

#

They might add them in the future, but we don't know right now

light jungle
#

sadly(

#

will wait

wispy spade
#

can you check whether or not the else statement is running?

#

can you check whether channel and message are a thing

#

we need to make sure things are running

#

you can put a print statement inside the else and the if to get an idea of what's running

#

yes

wispy spade
# wispy spade yes

!sql-fstrings -- also, this is not related to your error but would extremely advise against

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

wispy spade
#

where did you put those?

#

oh ok so since we confirmed that it printed, you can now check the else part

#

maybe take a look into those excepts? they might be hiding an error from you

light jungle
#

The question is can I give a person a role in voice chat if he does not make sounds for 5-10 minutes (the check will be in a green circle around the avatar) and if the person is simply tortured

tidal hawk
#

I don't think so

wispy spade
#

also, can you add the channel and message prints to the else part as well?

wispy spade
#

inside the else statement

#

then test to see if it prints it

kind trellis
#

How can I edit this embed to add another line of text?

slate swan
#

and then send the embed again

#
@uwu.command()
async def uwuwu(ctx: commands.Context, message_id: int) -> None:
  message = await ctx.channel.fetch_message(message_id)
  embed = message.embeds[0].add_field(...)
  await message.edit(embed=embed)
kind trellis
#

Alright, thanks

wild spoke
#

how to make bot stop responding to one command until it's finished

stone hornet
#

I'm trying to write a function to send a user a DM if their id isn't in a JSON, the problem is that when I try to put 'await send()' inside the function, and then calling it inside the on_message coroutine, it raises an error

wild spoke
#

basically you can't run the same command two times

#

you need to wait before it finishes

terse hawk
#

how do i make a welcome bot

wild spoke
stone hornet
slate swan
#

nice

wild spoke
#

so, help pls

torn sail
unkempt canyonBOT
#

@discord.ext.commands.max_concurrency(number, per=discord.ext.commands.BucketType.default, *, wait=False)```
A decorator that adds a maximum concurrency to a [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") or its subclasses.

This enables you to only allow a certain number of command invocations at the same time, for example if a command takes too long or if only one user can use it at a time. This differs from a cooldown in that there is no set waiting period or token bucket โ€“ only a set number of people can run the command.

New in version 1.3.
slate swan
#
2022-09-03 17:29:11 INFO     discord.client logging in using static token
2022-09-03 17:29:11 INFO     discord.gateway Shard ID None has connected to Gateway (Session ID: ef0fd2a1e4bf391bf703208b9897a1fa).
floral stratus
#
Traceback (most recent call last):
  File "D:\python\lib\site-packages\discord\client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "D:\python\lib\site-packages\discord\bot.py", line 1147, in on_connect
    await self.sync_commands()
  File "D:\python\lib\site-packages\discord\bot.py", line 643, in sync_commands
    registered_guild_commands[guild_id] = await self.register_commands(
  File "D:\python\lib\site-packages\discord\bot.py", line 473, in register_commands
    prefetched_commands = await self.http.get_guild_commands(self.user.id, guild_id)
  File "D:\python\lib\site-packages\discord\http.py", line 353, in request
    raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
wild spoke
torn sail
wild spoke
#

how

torn sail
wild spoke
#

no

#

and idk how to set it up

torn sail
#
@bot.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.MaxConcurrencyReached):
        ...
    else:
        raise error
wild spoke
#

in main file?

torn sail
#

whichever file contains the bot instance

wild spoke
#

commands is not found

torn sail
#

from discord.ext import commands

kind trellis
#

^

wild spoke
#

ight

#

and reaction?

#

message.react("id")?

#

with await

torn sail
#

!d discord.Message.add_reaction

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 "discord.Emoji").

You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission to use this. If nobody else has reacted to the message using this emoji, the [`add_reactions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission 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 "(in Python v3.10)") instead of `InvalidArgument`.
wild spoke
#

ty

torn sail
#

await ctx.message.add_reaction(...)

wild spoke
#

tysm

#

and last question

#

how to see all server names where bot is invited?

#

preferably in embed

kind trellis
#

I don't think you can do that, as per Discored rules

torn sail
#

you can get all the bots servers with bot.guilds then use the .name attribute on each guild in that

#

but yeah you shouldnt show all the bots guilds publicly

kind trellis
#

That was the stipulation

wild spoke
#

and if it got invited?

#

nvm

#

ok bot reacts but still send the error message

torn sail
wild spoke
#

hmm

#

Does not seem like this

#

I checked all files for isintstance

slate swan
#

can someone help me with this it says i dont have the ctx argument but i do clearly do?

primal token
#

so when internally called it would raise an error

#

!d discord.ext.commands.Bot.setup_hook

unkempt canyonBOT
#

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

A coroutine to be called to setup the bot, by default this is blank.

To perform asynchronous setup after the bot is logged in but before it has connected to the Websocket, overwrite this coroutine.

This is only called once, in [`login()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.login "discord.ext.commands.Bot.login"), and will be called before any events are dispatched, making it a better solution than doing such setup in the [`on_ready()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_ready "discord.on_ready") event.

Warning

Since this is called *before* the websocket connection is made therefore anything that waits for the websocket will deadlock, this includes things like [`wait_for()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.wait_for "discord.ext.commands.Bot.wait_for") and [`wait_until_ready()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.wait_until_ready "discord.ext.commands.Bot.wait_until_ready")...
slate swan
#

oh ok mb

#

thanks

primal token
#

math is a SlashCommandGroup

slate swan
#

noid how can i add spacing in my app commands name

#

i want it to be points add

#

but it says it cant have spaces

primal token
#

yeah im pretty sure slash commands cant have spaces in their names only slash command groups

slate swan
#

ah ok

heady citrus
#

how would i disable buttons after a certain period of time?

steel void
#

how would I get all member ids in a role on pycord? Do I need to have an intent for this

dull moon
#

how to make the bot wait for the user to send code

paper sluice
#

!d discord.ext.commands.Bot.wait_for

unkempt canyonBOT
#

wait_for(event, /, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.10)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.10)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.10)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/latest/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
primal token
unkempt canyonBOT
#

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

A callback that is called when a viewโ€™s timeout elapses without being explicitly stopped.
slate swan
#

so my command works but it says "sending command" then it says application did not respond how can i fix this?

    @nextcord.slash_command(guild_ids=[TESTING_GUILD_ID], description="Test Greet")
    async def test_greet(self, interaction: nextcord.Interaction):

        async with self.bot.db.cursor() as cursor:
            await cursor.execute(f"SELECT channel_id FROM Welcome WHERE guild_id = {interaction.guild.id}")

            channel_id = await cursor.fetchone()
            welcome_channel = self.bot.get_channel(channel_id[0])


        welcomeEmbed = nextcord.Embed(title = "test", description= f"test", color=nextcord.Color.orange())
        await welcome_channel.send(f"{interaction.user.mention}", embed = welcomeEmbed)
feral frost
#

Hello there

#

i need some help with my discord bot

#

so the problem is that i just changed to visual studio because pycharm didnt show error things in the code so i moved to vs code but now there it asks for Intents and i put it in but now my bot doesnt work

#

there is no output when i input a command

slate swan
#

Is it really possible to make a message under which there will be buttons ? Not as a team. And write a message and use event to make buttons under this message

sick birch
unkempt canyonBOT
#

@sick birch :white_check_mark: Your 3.11 eval job has completed with return code 0.

VVV do you mean like the buttons under this message? VVV
paper sluice
#

Satisfactory ๐Ÿ‘€

feral frost
#

i lov that game

sick birch
feral frost
#

but uh anyone knows why intents are broken ?

paper sluice
sick birch
paper sluice
sick birch
#

Without those we can only take vague guesses as to what's wrong

heady citrus
#

  @commands.command(aliases=["firstmessage"])
  @commands.cooldown(1, 5, commands.BucketType.user)
  async def firstmsg(self, ctx, channel: discord.TextChannel = None):
      if channel is None:
          channel = ctx.channel
      first_message = (await channel.history(limit=1, oldest_first=True))
      embed = discord.Embed(color=col)
      embed.description=f"{blue} [Jump To The First Message In This Guild]({first_message.jump_url})"
      await ctx.send(embed=embed)
``` any help?
#

No error at all

sick birch
#

What happens when you call the command?

feral frost
# sick birch Can we see any errors, or any code?

no error messages but like i moved to vs code and when i started the bot up it gave an error about intents so i looked it up and i added it and now the bot runs but i dont get an output on commands

sick birch
#

What's the error, and what's your code?

feral frost
#

and there was no code

#

just my whole bot

#

without intents

paper sluice
feral frost
#

so i added this intents = discord.Intents.default()

#

and this bot = commands.Bot(command_prefix=BOT_PREFIX, intents=intents)

#

the intents=intents

#

but now there is no output on commands

slate swan
#

well, so that you just write a message, send it to the chat and just use the ID of the message itself

feral frost
sick birch
unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default discord.py has all intents enabled except for Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot 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

intents = Intents.default()
intents.members = True

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

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

feral frost
#

what does it mean ?

#

the 2.0

#

or up

sick birch
feral frost
#

how do i see it

dull moon
sick birch
#

supporting slash commands, buttons, selects, context menus, modals, and all the new stuff

sick birch
feral frost
#

ok

sick birch
#

you need intents.message_content = True in order to get message content dispatched to you via the gateway

feral frost
#

do i have to import smth ?

sick birch
#

You also need to enable it in the developer portal

feral frost
#

how and where ?

sick birch
feral frost
#

in what tab

sick birch
#

Sorry?

feral frost
#

bot ?

sick birch
#

I'm not understanding

feral frost
#

in this tab ?

sick birch
#

Ah, yeah that tab

feral frost
#

and under what thing in that tab ?

sick birch
#

Make sure this is enabled

feral frost
#

k

#

i am blind

#

i cant find it

#

k found it

#

and what was the code again ?

sick birch
#

intents.message_content = True

feral frost
#

k

#

thanks ill see if it works

#

YES thanku man ๐Ÿ˜„

cloud pike
slate swan
#

read this.

slate swan
#

interesting lambda

#

how can you accept image input

#

when i try this it doesn't accept the image as a paramater

cloud pike
slate swan
unkempt canyonBOT
slate swan
gusty shard
#

why am i getting that error?

feral frost
#

hello i need some help again, this is my code

#

from discord.ui import Button, View

@bot.command()
async def button(ctx):
button1 = Button(label="Click me!", style=discord.ButtonStyle.green, emoji="๐Ÿ‘‹")

async def button_callback(interaction):
    await interaction.response.send_message("Hi!")

button.callback = button_callback

view = View()
view.add_item(item=button1)
await ctx.send("This message has buttons!", view=view)
gusty shard
#

i did pip install discord and pip install discord.py but its still giving the error

feral frost
#

the thing that isnt working is the (await interaction.response.send_message("hi"))

#

anyone knows why ?

knotty agate
#

how can i get a members avatar url?

an update must have changed its name/location because Member.avatar_url dosent work for me anymore

feral frost
#

@bot.command()
async def avatar(ctx, member: discord.Member = None):
if member == None:
member = ctx.author

userAvatar = member.display_avatar

avaEmbed = discord.Embed(title=f"{member.name}'s Avatar", color=color)
avaEmbed.set_image(url=userAvatar.url)
avaEmbed.set_footer(text=footer)

await ctx.send(embed=avaEmbed)
knotty agate
slate swan
#

what code did you use

sage otter
feral frost
#

i used something else too and it didnt work

feral frost
knotty agate
#

naw.

#

it works though

feral frost
#

userAvatar = member.display_avatar

use that and this if you want to put it in an embed

avaEmbed.set_image(url=userAvatar.url)

#

dont forget .url

slate swan
#

I think he knows how

knotty agate
#

im aware, tylerr just answers

feral frost
#

๐Ÿ˜

knotty agate
#

i only asked where they put the url in Member object

#

thx though

feral frost
#

ok

torn sail
#

In Formulaire_Modal.__init__ you need to call super().__init__()

warm grail
#

does anyone know how to print whenever a message is sent in a discord channel without using a bot?

torn sail
warm grail
#

yes

#

like using this account to detect when a message has been sent

torn sail
warm grail
torn sail
#

Yeah

torn sail
#

!rule 5

unkempt canyonBOT
#

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

warm grail
#

why does it break tos?

torn sail
#

Because self bots are not allowed according to the tos

warm grail
#

๐Ÿ˜ฆ

torn sail
#

Can u show ur code

#

For Suite_Formulaire_Button

#

Well it doesnโ€™t take a channel arguement

#

Well now ur not passing channel in

dull moon
#

cant i use wait_for() in slash command ?

ornate sail
#
@client.slash_command(guild_ids=[1012830605421068359])
@commands.has_permissions(manage_messages=True)
async def purge(interaction: nextcord.Interaction, arg: int):
    channel = interaction.channel
    deleted = await channel.purge(limit=arg)
    await interaction.response.send_message(f"Deleted `{arg}` number of messages!")
#

for some reason ppl w out manage messages can use the command

#

any reason why?

#

never mind i found the fix

#

it has already been pinned

kind trellis
#

Ah

worldly solstice
#

Hey guys, if one of you geniuses could check out #help-avocado and maybe let me know where i fuck up, that would be awesome ๐Ÿ™๐Ÿผ

slate swan
kind trellis
kind trellis
dull terrace
#

how tf do you handle a ton of attributes for a class

dull moon
dull terrace
#

got a player class and it's storing all the game info for each person and it's getting way too big, gotta be a better way 7739monkathink

dull moon
#

storing them into dicts i think

dull terrace
#

some of them are already dicts

dull moon
#

database ?

slate swan
#

so i don't have to set those attributes manually

dull terrace
#

just getting too big

slate swan
#

seems just fine, whats the issue with it lol?

dull terrace
#

i guess, it's just painful to my eyes and im about to add a bunch more

#

here's a better question

dull moon
#

what is the alt for wait_for in slash command

slate swan
dull terrace
#

say you have a skill tree like this that you need to unpack into a db, what's the best way to store it in the class 7739monkathink

#

i could do a dictionary to keep track but then it's a pain to unpack, or i could make a single attribute for each one but then my class is bloated

#

i guess i could do a list and then just store what each index corresponds to elsewhere

sick birch
# dull terrace

You could probably abstract certain related attributes into their own dataclasses

#

I do believe dataclasses can link to other dataclasses?

dull terrace
#

that probably would have been a lot neater than some of the mess i've made with these dictionaries

kind trellis
dull terrace
#

only thing i can think is you're doing message.content.to_dict() which would give you that error?

kind trellis
#

No, message.embeds[0].description

dull terrace
#

okay so that's the description? which is a string

#

what's your code

sick birch
#

You need to re-send the message, with the same content and your new embed

kind trellis
# dull terrace what's your code
ย    ย ย ย @commands.command(name='edit') 
 ย ย ย ย @commands.is_owner() 
 ย ย ย ย asyncย defย _edit(self,ย ctx,ย id): 
 ย ย ย ย ย ย ย ย messageย =ย awaitย ctx.channel.fetch_message(id) 
 ย ย ย ย ย ย ย ย embedย =ย message.embeds[0].descriptionย =ย ''' 
 :video_camera:ย toย getย theย <@&731397963259052133>ย role 
 :microphone:ย toย getย theย <@&732118149285150800>ย role 
 :tada:ย toย getย theย <@&732868630710190140>ย role 
 :video_game:ย toย getย theย <@&786174523405107200>ย role 
 :movie_camera:ย toย getย theย <@&802013687333781534>ย role 
 :grey_question:ย toย getย theย <@&809068173868400720>ย role 
 :question:ย toย getย theย <@&948495979940823070>ย role 
 :robot:ย toย getย theย <@&1015680899511242832>ย role 
 ย ย ย ย ย ย ย ย ย ย ย ย ''' 
 ย ย ย ย ย ย ย ย awaitย message.edit(embed=embed) 
 ย ย ย ย ย ย ย ย pass
dull terrace
#

do embed = message.embeds[0] first i think

sick birch
#

On second thought you might be able to edit it that way

kind trellis
#

Ignore the indent error on the first line, unrelated (Can't fix it)

dull terrace
#

then change the description like that

#

right now you're making the embed object the description string rather than the entire embed

kind trellis
#

So how do I call it then?

slate swan
#

how do i respond to an interaction

dull terrace
#
embed = message.embeds[0]
embed.description = "your new description"```
kind trellis
#

K

dull terrace
slate swan
#

ah it changed

dull terrace
#

.send_message, .edit_message
use print(dir(interaction.response)) to get a full list of possible attributes

slate swan
#

thought it was interaction.response.send_message

dull terrace
#

yeah that's one possible response

slate swan
#

?

dull terrace
#

interaction.response not InteractionResponse

slate swan
#

oh

slate swan
#

whats gone wrong here

candid cliff
#

hi, i have a question so is it possible to do an app command like async def verify_app_command(self, interaction: discord.Interaction, member: discord.Member) -> None: ... and when moderators use the app command it only shows the members that have "unverified" role?

candid cliff
# slate swan

the function isnt a variable of the VerifyMe class xd

candid cliff
candid cliff
slate swan
#

omfg

#

sorry im stupid

candid cliff
#

np xd

slate swan
#

been staring at this for too long

candid cliff
#

i quitted python for long time too rip me..

candid cliff
hard summit
#

I just made a bot cog that runs DOOM

#

(playable)

#

The people in the server are currently collectively trying to beat hangar

wicked atlas
#

how many fps

#

@hard summit

hard summit
wicked atlas
#

on discord

hard summit
#

okay so uh

#

when you run a command

#

it's !<action> <time> where action is the action you want to do, and time is the time in seconds you want to do it for

wicked atlas
#

oh so it takes a snapshot of it after every command?

hard summit
#

after an action is executed, the viewport updates

wicked atlas
#

guess that's one way to do it

hard summit
#

under the hood the game still runs at 35 FPS

#

although it pauses the game between commands

hard summit
#

I am very proud of myself right now

wicked atlas
#

yeah that's pretty cool

hard summit
#

people are even asking me to put the cog into a separate bot they can invite to their own servers

#

I should do that once I run it on a dedicated machine

#

(because it pops up a console window shortly before it becomes headless)

wicked atlas
#

At that point you might need to start worrying about concurrency, unless you want to have multiple servers running the same instance of doom

#

but not sure how you've got it setup under the hood so

hard summit
#

the game can have multiple instances with not too much work

#

it's fine

wicked atlas
#

damn yeah what am I thinking It's doom, you can run it on a toaster

hard summit
#

yeah lol

#

Also yes this did in fact happen because someone asked me 'but can it run doom"

wicked atlas
#

lmao

hard summit
#

since someone suggested it I'm also going to add a minimap

wicked atlas
#

If you make it interaction-based, you could make buttons to control the game

#

And from my experience with interactions, the edit message endpoint is ratelimited per-interaction ๐Ÿ˜ˆ

#

discovered that when I made a tetris bot

hard summit
#

sometimes you need to turn for an exact amount

#

or move for an exact amount

#

and yes, my bot already has interactions, and I did consider it

dapper harbor
#

Hey all, I am wanting to have an external config file used for my bot. Coming from JS so I would use JSON for this file. I see that I can parse JSON with python but is there a better option for that file type?

gentle eagle
dapper harbor
gentle eagle
#

most people also just parse yaml or toml and make it a dataclass so its an object that contains attrs etc over having a dict with JSON

dapper harbor
#

I like that idea quite a bit, thank you

primal token
gentle eagle
gentle eagle
cerulean shale
#

Yo

primal token
gentle eagle
cerulean shale
#

๐Ÿ‘‹

#

Sup

gentle eagle
#

nothing much, wbu????

cerulean shale
#

Meh, just the usual