#discord-bots

1 messages · Page 649 of 1

manic wing
#

do you want to delete the message or the actual webhook

#

!d discord.Message.delete

unkempt canyonBOT
#

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

Deletes the message.

Your own messages could be deleted without any proper permissions. However to delete other people’s messages, you need the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission.

Changed in version 1.1: Added the new `delay` keyword-only parameter.
novel bolt
#

in this i wanted to delete themessage 'testing'

manic wing
#

msg = await webhook.send(…) await msg.delete()

slate swan
#

alright

novel bolt
#

i tried it but it gave an error

#

'NoneType' object has no attribute 'delete'

#

i will try it again

dusk dust
#

how can I check if the user response has any special characters?

novel bolt
#

this is the code

slate swan
#

i'd help you

#

but my eyes are crying at that light mode

novel bolt
#

🥲

slate swan
#

😭

slate swan
#

it doesn't return the message you sent, therefore you cannot delete it either

novel bolt
#

oh

#

thank u for helping

slate swan
#

np

quaint epoch
#

What is the keyword for sending images, because i want to take away perms that let users send embeds or images

upbeat otter
velvet tinsel
#

hello 🙂

upbeat otter
#

Bye

velvet tinsel
#

bye

#

empty chat ;-;

quaint epoch
#

haha i love abusing my new-found power

manic wing
#

wow … life changing

velvet tinsel
#

wow...amazing

#

never knew that before

#

oh, hello Caeden

velvet tinsel
slate swan
#

?

velvet tinsel
#

did you release documentation of your dating bot

#

I'm just curious
not going to steal your code or anything

#

now that I said that, he'll think I will

slate swan
#

No

#

I don't plan on making the repo public anytime soon

velvet tinsel
#

Ok

#

wait

#

how would you find something like "h" if you did something like !mute @Bob 12h?

#

or anything after the number given?

slate swan
#

Get the end of the string

#

Use regex

#

How else do you think

velvet tinsel
#

regex ;-; ok

velvet tinsel
# slate swan How else do you think

I was thinking of breaking the argument down into a list, iterate through the list until you find something like m or h or s and then you use an if statement to check if it is h or m or s or d and then you mute them for like hours or minutes or days and then also check if the values are numbers, and then make it an int, and upon detecting any non-numbers stop the check and check if it is h or...yeah, you get the idea

quaint epoch
slate swan
#

You don't necessarily have to use regex

velvet tinsel
#

I may be bored, but I'm not *that* bored

slate swan
#

Just have the command take a single time argument

velvet tinsel
#

if you have the logic ig you have the answer

slate swan
#

Then index the latest character in the string

manic wing
#

fuck regex

quaint epoch
velvet tinsel
#

oh
I was just reading the documentation ;-;

slate swan
#

Then have a slice from the beginning to the near-end and turn it into an int

quaint epoch
slate swan
#

Then with the unit, multiply the time they gave accordingly

#

Very easy, but with regex it's a lot better imo

quaint epoch
#

They're talking about bedmas, pfttt, learned that in grade 4

velvet tinsel
#

I swear the maths teacher hates me

#

I know too much

quaint epoch
#

because i don't wanna get on their bad side

#

no one likes braggers

velvet tinsel
#

at least they have extra sessions where they take me and other people to a room and then task us with harder questions from Olympiads and stuff

#

That's fun

quaint epoch
#

they don't do that here

velvet tinsel
#

speaking of that, I haven't even done that homework. Oh well, I still have a week...

#

I think I just threw my homework in the bin
I need to find it

quaint epoch
#

lmao

velvet tinsel
quaint epoch
velvet tinsel
#

I'm doing easy maths rn
twice the number is equal to 6 more of a number
some small questions

#

the answer is obviously 6

quaint epoch
#

its for a project, apparently it should be difficult, that's why they only expect us to do 2 this year

velvet tinsel
#

6*2 = 12, 6+6 = 12

#

took me a second after reading it

#

they shouldn't have put 6 tbh

quaint epoch
#

im finishing my 3rd while they are expecting us to brainstorm the 2nd

velvet tinsel
#

7 maybe
but the answer is 7

velvet tinsel
velvet tinsel
#

bruh, I'm 9 parallel universes ahead of you

slate swan
#

!ot

unkempt canyonBOT
quaint epoch
#

oh

slate swan
#

Guys keep it on topic

velvet tinsel
quaint epoch
velvet tinsel
slate swan
velvet tinsel
#

go there @quaint epoch

wooden thorn
#

How do I make my bot play an audio file in a vc? I've got a command to make it join and one to make it leave but that's it.

velvet tinsel
#

use ffmpeg, the second answer is probably what you want

velvet tinsel
# wooden thorn

do you have ffmpeg installed? Sounds like a stupid question because I have never used ffmpeg

wooden thorn
#

it's a library right?

#

cuz no i dont i've never used it either xd

velvet tinsel
#

let me check

#

!pypi ffmpeg

unkempt canyonBOT
wooden thorn
#

ah ok so i do need to import it

velvet tinsel
#

idk

#

try it though

wooden thorn
velvet tinsel
#

errr

#

I made a mistake

wooden thorn
#

breh

velvet tinsel
#

can you just send the error in here as a text?

#

not bothered to type it in

manic wing
#

what os

velvet tinsel
#

ah, someone joins who never makes a mistake

#

that looks like replit
why are you coding on replit, just wondering

quaint epoch
#

how do i disable a users vc perms? Like, muting/unmuting or deafing/undeafing?

wooden thorn
#

`Ignoring exception in command scream:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 32, in scream
player = channel.create_ffmpeg_player('vuvuzela.mp3')
AttributeError: 'VoiceChannel' object has no attribute 'create_ffmpeg_player'

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

Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'VoiceChannel' object has no attribute 'create_ffmpeg_player'`

manic wing
#

its not an issue of ffmpeg not being installed i dont thjnk

velvet tinsel
wooden thorn
quaint epoch
#

how do i disable a users vc perms? Like, muting/unmuting or deafening/undeafening?

manic wing
quaint epoch
#

what attribute would i have to include in overwrite?

velvet tinsel
#

"*In the rewrite version, version 1.0, VoiceState.voice_channel was changed to VoiceState.channel.

If you are using the rewrite version, the below should be sufficient to play a file:

from discord import FFmpegPCMAudio
from discord.utils import get

@bot.command()
async def bb(ctx):
    channel = ctx.message.author.voice.channel
    if not channel:
        await ctx.send("You are not connected to a voice channel")
        return
    voice = get(bot.voice_clients, guild=ctx.guild)
    if voice and voice.is_connected():
        await voice.move_to(channel)
    else:
        voice = await channel.connect()
    source = FFmpegPCMAudio('1.m4a')
    player = voice.play(source)```*"
muted lynx
wooden thorn
wild comet
#

hello i have a small problem, im trying to make a command to give a christmas role if they dont have it and if they have it it just says you already have it, but im not getting any error or response and cant seem to figure out the issue

@client.command()
async def christmas(ctx, user: discord.Member):
    role = discord.utils.find(ctx.message.guild.roles, name="🎅• Christmas 2021")
    if role in user.roles:
      ctx.reply("You already have the Christmas 2021 role!")
    else:
      ctx.reply("Here's the role...in a moment.")
      await user.add_roles(role)```
velvet tinsel
#

maybe that's the answer? your error doesn't seem to be popular

wooden thorn
#

bruh

velvet tinsel
wild comet
#

yep

velvet tinsel
#

maybe adding it by the ID is simpler

wild comet
#

okay

muted lynx
velvet tinsel
#

what does it send?

velvet tinsel
quaint epoch
#

no, what attribute would i set to false to change deafening/muting in my bot? py overwrite.attr = False overwrite.attr2 = False?

velvet tinsel
#

or something
I think he just copied it straight off there?

muted lynx
#

Trial and error the best way to test anything

quaint epoch
# velvet tinsel idk try both ;-;

No, am i supposed to do py overwrite.VoiceChannel = false or overwrite.voice = false or overwrite.Voice = false because i can't find it on the docs

velvet tinsel
#

*False

quaint epoch
#

but what attribute?

velvet tinsel
#

just being annoying

muted lynx
#

Just try each till it works

quaint epoch
velvet tinsel
quaint epoch
#

kk

wild comet
#
@client.command()
async def christmas(ctx, user: discord.Member):
    role_id = 914221637132496926
    role = discord.utils.find(ctx.message.guild.roles, id=role_id)
    if role in user.roles:
      ctx.reply("You already have the Christmas 2021 role!")
    else:
      ctx.reply("Here's the role...in a moment.")
      await user.add_roles(role)``` this doesnt seem to work either not sure where i went wrong
velvet tinsel
#

what does it send?

wild comet
#

literally nothing

muted lynx
#

Any errors

wild comet
#

nop

velvet tinsel
#

and it's supposed to be ctx.guild.roles

wild comet
#

which is why im so confused

velvet tinsel
#

I think

wild comet
#

oh fr

velvet tinsel
#

maybe

wild comet
#

i'll try it

velvet tinsel
#

alright

muted lynx
#

You never defined messsge

#

So he's right

wild comet
#

ok that doesnt work either

velvet tinsel
#

oh

wild comet
#

im totally confused

velvet tinsel
#

well f

#

Tylerr thank you

sage otter
#

Honestly

#

I hate when people just post code and says it doesn’t work. That doesn’t help anyone. You should tell us what your intentions are, if there’s any errors post it with the code you're using whatnot.

velvet tinsel
#

there was no error

muted lynx
#

There were no errors

velvet tinsel
#

are you mad at me ;-;

wild comet
#

i filled it with prints to test

velvet tinsel
#

are you using PyCharm?

#

there is a way to add breakpoints and stuff

sage otter
#

and honestly you have a role id

wild comet
#

ok the prints didnt work

sage otter
#

You don’t need utils.find

velvet tinsel
muted lynx
#

Are you using client

velvet tinsel
#

;-; am I wrong

sage otter
#

just use Guild.get_role

wild comet
#

whats client

velvet tinsel
muted lynx
#

As commands.Bot

wild comet
#

im gonna be honest im pretty sure the whole command just isnt being called

#

oh ye sorry im using client

velvet tinsel
#

use bot

slate swan
muted lynx
#

Bad advice

velvet tinsel
wild comet
velvet tinsel
#

ctx.guild

slate swan
#

and is there any errors ?

velvet tinsel
#

nope

wild comet
#

no

sage otter
wild comet
#
@client.command()
async def christmas(ctx, user: discord.Member):
    print("getting christmas role")
    role_id = 914221637132496926
    role = discord.utils.find(ctx.guild.roles, id=role_id)
    print("got christmas role")
    if role in user.roles:
        print("already has role")
        ctx.reply("You already have the Christmas 2021 role!")
    else:
        print("giving role")
        ctx.reply("Here's the role...in a moment.")
        await user.add_roles(role)``` i have this rn
slate swan
muted lynx
#

He/she sorry

velvet tinsel
#

they can name it hello and it will still work

wild comet
#

even that first print is printing though so im confused

velvet tinsel
#

maybe I should use robot

wild comet
wild comet
#

okay

muted lynx
#

His entire command isn't working

sage otter
#

You don’t need to iterate over anything.

muted lynx
#

Is that a thing didn't see it in the docs

sage otter
#

!d discord.Guild.get_role

unkempt canyonBOT
muted lynx
#

Hmm

#

It is

sage otter
#

Really you only need to use utils.get or utils.find if you don’t have an ID

#

If you have a name that’s a different story.

slate swan
#

i think something is surprising it

velvet tinsel
#

I hate it when that happens

#

there was an example of a welcome command

slate swan
velvet tinsel
#

like 6 lines

#

me and winrar took ages trying to figure it out

wild comet
velvet tinsel
#

we went through line by line

slate swan
#

well show me what it looks like

velvet tinsel
#

never found out the reason

#

what does it print?

#

@wild comet ?

wild comet
#

oh sorry gimme a mo

#

im testing it on pycharm

velvet tinsel
#

oh

#

pycharm, I see

wild comet
#

thought it might be the thing i was using

velvet tinsel
#

there is a way to debug it

#

using PyCharm

wild comet
#

oh how

velvet tinsel
#

it's really complicated I'm kinda rusty

#

so just add a breakpoint to your code

#

at the start of your command

#

and then do run and debug? I think?

wild comet
#

ok apparently

#

user is a required argument that is missing.

#

ok sweet

#

im making progress

velvet tinsel
#

...

#

ok

#

you missed user

#

in your command

quaint epoch
#

guys how do i get all of the members in my guild?

slate swan
unkempt canyonBOT
#

property members: List[discord.member.Member]```
A list of members that belong to this guild.
quaint epoch
#

thnks

wild comet
#

thanks

quaint epoch
#

wait

slate swan
slate swan
quaint epoch
slate swan
#

if it's in a command then it's ctx.guild

quaint epoch
slate swan
#

which returns an instance of discord.Guild

hollow agate
#
("Account Made", target.created_at.strftime("%m/%d/%Y %H:%M:%S"), True),``` How would I change this datetime object into a timestamp?
slate swan
#

.created_at.timestamp()

#

!d datetime.datetime.timestamp

unkempt canyonBOT
#

datetime.timestamp()```
Return POSIX timestamp corresponding to the [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") instance. The return value is a [`float`](https://docs.python.org/3/library/functions.html#float "float") similar to that returned by [`time.time()`](https://docs.python.org/3/library/time.html#time.time "time.time").

Naive [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") instances are assumed to represent local time and this method relies on the platform C `mktime()` function to perform the conversion. Since [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") supports wider range of values than `mktime()` on many platforms, this method may raise [`OverflowError`](https://docs.python.org/3/library/exceptions.html#OverflowError "OverflowError") for times far in the past or far in the future.

For aware [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") instances, the return value is computed as:

```py
(dt - datetime(1970, 1, 1, tzinfo=timezone.utc)).total_seconds()
```   New in version 3.3.

Changed in version 3.6: The [`timestamp()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.timestamp "datetime.datetime.timestamp") method uses the [`fold`](https://docs.python.org/3/library/datetime.html#datetime.datetime.fold "datetime.datetime.fold") attribute to disambiguate the times during a repeated interval.
wild comet
#

HOLY GOD @slate swan I LOVE YOU

slate swan
#

no homo but lyt ❤️

quaint epoch
#

how do i mute entire channels?

#

for everyone except admins?

#

like set perms for a channel

slate swan
#

use .overwrites_for on a TextChannel object, which returns a PermissionOverwrite object, and then do .send_messages = False, then on your TextChannel object do .edit(overwrites=...)

#

!d discord.TextChannel.overwrites_for

unkempt canyonBOT
slate swan
#

!d discord.PermissionOverwrite

unkempt canyonBOT
#

class discord.PermissionOverwrite(**kwargs)```
A type that is used to represent a channel specific permission.

Unlike a regular [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions"), the default value of a permission is equivalent to `None` and not `False`. Setting a value to `False` is **explicitly** denying that permission, while setting a value to `True` is **explicitly** allowing that permission.

The values supported by this are the same as [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions") with the added possibility of it being set to `None`.

x == y Checks if two overwrites are equal.

x != y Checks if two overwrites are not equal.

iter(x) Returns an iterator of `(perm, value)` pairs. This allows it to be, for example, constructed as a dict or a list of pairs. Note that aliases are not shown.
slate swan
#

!d discord.TextChannel.edit

unkempt canyonBOT
#

await edit(*, reason=None, **options)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the channel.

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

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

Changed in version 1.4: The `type` keyword-only parameter was added.

Changed in version 2.0: Edits are no longer in-place, the newly edited channel is returned instead.
slate swan
#

those are the docs for everything i specified ^^

quaint epoch
slate swan
#

lmao

#

reply to it with the command .bm to bookmark it

#

👍

slate swan
#

Hi, how to delete slash commands from one / all servers?

#

I switched from 1 file to cogs now I got every command twice

#

pretty sure that's a client thing

#

the client caches the slash commands

#

and you moving them from a file to the other deleted the old one and added a new one which is actually the same one

#

Yes

#

So that means...

#

I gotta kick it from all and reinvite?

#

Or like at least try ... lol?

velvet tinsel
#

Kraots hi

slate swan
#

or you can just ignore it

#

Nah

#

it'll go away on its own

#

or so it should

velvet tinsel
slate swan
#

Ohh

slate swan
#

It will?

#

probably

#

Maybe if I delete the old main.py? I see

#

no that'll do even worse

#

Oh .. ;-;

#

Too late hah just kidding

#

How would that do it worse?

#

Like uh I cant just ignore it lol

velvet tinsel
#

whats going on here?

#

OH GOD

#

I JUST TURNED ON LIGHT MODE

#

AHHHHHHHHH HELP

#

oh thank god

slate swan
#

¯_(ツ)_/¯

slate swan
slate swan
#

But thanks anyway

#

oh that's possible?!

#

tell me the trick 🙇‍♂️

velvet tinsel
slate swan
#

tf is pipwin

velvet tinsel
#

git clone https://github.com/Rapptz/discord.py

slate swan
velvet tinsel
#

no

#

pip install pipwin

#

and then you use pipwin

slate swan
slate swan
velvet tinsel
#

f
stop it ;-;

velvet tinsel
manic wing
#

!pypi pipwin

unkempt canyonBOT
#

pipwin installs compiled python binaries on windows provided by Christoph Gohlke

slate swan
#

basically useless for me

#

¯_(ツ)_/¯

velvet tinsel
#

yes

#

unless you're installing pyaudio

#

but it still doesn't work

#

so git clone

#

works

quaint epoch
#

does anyone know how to mute channels?

#

and unmute them?

#

(only admins can text then)

#

Or does anyone know how to find all of the members in the guild, because i tried to do discord.Guild.members but it just returns a property value message

cloud dawn
#

Or if you don't care that bots get counted just do guild.members

cloud dawn
upper finch
#

Hello. How Can I display number instead of nan ?

sage otter
cloud dawn
#

Me and some other people had this discussion months back lol

sage otter
#

thats not true tho

#

If you work with many many data, list comp will always be faster

#

40% according to this arrival

sage otter
#

AMshrug idk then. Literally if you look it up online almost every article says it’s faster

cloud dawn
#

Not by much though but it would make sense that filter is faster otherwise the whole function would be pretty pointless. unless you got a large condition

sage otter
#

Idk then. I’ve just read a lot more into it. I’ve read like 6 different websites/blogs and they all say list comprehension is faster than filter by atleast 50-100%. Apparently according to one of the admins here, it says on the python docs that when offered the opportunity you should use list comp over functions like map, filter, reduce, etc.

cloud dawn
wanton veldt
#

hi i am trying to make a discord bot and i get this error

slate swan
#

how to edit permission of everyone role?

sage otter
manic wing
unkempt canyonBOT
#

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

Edits the role.

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

All fields are optional.

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

Changed in version 2.0: Edits are no longer in-place, the newly edited role is returned instead.
manic wing
#

where role is default_role

slate swan
#

\👍

kindred drum
#

hello

#

is there anyway that this could work? @bot.event async def on_reaction_remove(reaction, user): if reaction.emoji == "💸": roleid = 915961885738819604 roleobj = user.guild.get_role(roleid) await user.remove_roles(roleobj) for i in range(0,len(Json_Items)): #It doesn't exist for x in Json_Items[i]: if int(x) == int(user.id): Json_Items[i][x]['Payment Method'].remove("Paypal") json.dump(Json_Items, open("./all_user_rep.json", "w"), indent=1) await reaction.channel.message_delete()

#

AttributeError: 'Reaction' object has no attribute 'channel'

  • outputs the following error
visual island
slate swan
visual island
wicked atlas
kindred drum
#

not the the message it says after it

visual island
#

it deletes the message

kindred drum
#

I need to delete the message it says after this event @bot.event async def on_reaction_add(reaction, user): if reaction.emoji == "💸": if user == bot.user: return roleID = 915961885738819604 roleObj = user.guild.get_role(roleID) await user.add_roles(roleObj) for i in range(0,len(Json_Items)): #It doesn't exist for x in Json_Items[i]: if int(x) == int(user.id): Json_Items[i][x]['Payment Method'].append("Paypal") json.dump(Json_Items, open("./all_user_rep.json", "w"), indent=1) await reaction.message.channel.send(temp_list_4[0]) if they remove the reaction

velvet tinsel
#

linux or windows

#

for coding 🤔

slate swan
#

xbox

velvet tinsel
#

ok

slate swan
#

also u have to use morse code

velvet tinsel
#

ok

slate swan
#

and a json database

velvet tinsel
#

alright

#

thank you

slate swan
#

from the arcades store

velvet tinsel
#

thanks

slate swan
#

you're welcome

velvet tinsel
slate swan
#

()

velvet tinsel
#

{}

#

await reaction.message.delete()

#

how to breathe

#

@slate swan

#

wow windows 11 shakes whenever I send it when there's slowmode

slate swan
#

hard thing to do

velvet tinsel
#

teach me the way

velvet tinsel
#

I upgrade

slate swan
#

where you got that from

#

also

velvet tinsel
slate swan
#

!ot

unkempt canyonBOT
velvet tinsel
final iron
#

Windows shouldn't be shaking

kindred drum
#

but it deletes the wrong message

slate swan
#

how could i detect if a user sends a embed ?

#

a user can't send an embed

#

maybe a url that gets embedded by discord

velvet tinsel
velvet tinsel
velvet tinsel
#

very cool

velvet tinsel
kindred drum
#

😭

velvet tinsel
#

ok

#

errr w

#

which message do you want to delete?

rare saddle
#

How to make the buttons work until the bot is restarted?
I use dislash
in cogs

kindred drum
#

which is sent when the user reacts

velvet tinsel
#

hmmm
well
I gtg sleep

slate swan
rigid narwhal
#

can i get role using its ID?

#

because discord.utils.get(ctx.guild.roles, id=role_id) not working, gives none

manic wing
#

!d discord.Guild.get_role || but if you're passing a valid role_id, then it wont work for get_role either

unkempt canyonBOT
rigid narwhal
manic wing
#

do you have member intents?

#

or role intents

#

i get them mixed up

rigid narwhal
#

wdym

manic wing
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member 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.

rigid narwhal
rigid narwhal
#

thanks

torpid trout
#

new to programming, and im trying to code a bot for discord. I am trying to send local files to a sever based on some associated key words. I want these files (.png) to send repeatedly everytime the key words trigger the logic . Although - I came across some warning that tells me that the file method is a one time call, and cannot repeatedly send the .png everytime the logic is triggered.
is there anyway to bypass his?
I can send code, or join a vc or anything
pls ping me if youre willing to help, i may not see it, thank ya!<3

rigid narwhal
final iron
rigid narwhal
#

yeah

#

and added the args in the code

#

found a way around it, thanks everyone

wanton veldt
#

hi i have a question i have this script that gives a role to new members and dosent work(no error in logs) ```py
import discord
from discord.ext import commands, tasks
import random
import config
import asyncio
import aiofiles
import os
from typing import Optional, Set
intents = discord.Intents.default()
intents.members = True
from discord.utils import get

client = commands.Bot(command_prefix='.')

@client.event
async def on_member_join(member):
role = discord.utils.get(member.server.roles, id="<768876826092240929>")
await client.add_roles(member, role)```

summer flume
#

I dont understand the events too..

wanton veldt
#

you want a ss?

reef walrus
#

Code:
@command.commands()
async def resume(self,ctx,url):
wait.ctx.voice_client.pause()
await ctx.send("Music resumed▶️")
Error:
async def resume(self,ctx,url):
IndentationError: unexpected unindent

#

can some 1 help pls?

unkempt canyonBOT
#

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
manic wing
wanton veldt
reef walrus
#

why

#

ther is

#

youtube_Dl

manic wing
slate swan
#

There is, but his question wasn't related to ytdl, the rule says to not help with ytdl-related stuff, he has a problem with the on_member_join event

manic wing
reef walrus
#

K

wanton veldt
#

i am kinda dumb at this hours

peak loom
#

Hey I have Cogs in my bot, but I want to make a custom help command can someone help me do this?

manic wing
peak loom
#

But I don't know how to add the stuff.

#

on it.

manic wing
#

you need to indent the commands.Cog.listener and the async def into the class

#

(and all the code in the function)

manic wing
#

do you have your def setup?

peak loom
manic wing
#

!d discord.ext.commands.Bot.cogs

unkempt canyonBOT
peak loom
cloud dawn
manic wing
peak loom
cloud dawn
reef walrus
#

i ment

#

no installed modules

manic wing
#

oh idle edited the youtube_dl out of the imports

reef walrus
#

my error rn: ModuleNotFoundError: No module named 'youtube_dl'

cloud dawn
cloud dawn
peak loom
#

Yeah I'm lost @manic wing

cloud dawn
#

That's wrong but don't help him, we've made it clear it breaks ToS

reef walrus
#

wait

#

I broke TOS

peak loom
reef walrus
#

BRUV

cloud dawn
#

!ytdl

unkempt canyonBOT
#

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
reef walrus
#

ok

#

well i didint even used the bot

#

so im fine

#

il use sound cloud or spotify

peak loom
cloud dawn
#

Don't try to find loopholes.

reef walrus
#

!ytdl

unkempt canyonBOT
#

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
glacial sail
#

yeah, as pandabwear says, we can provide help about other stuff, but not things that break the TOS of other sites.

peak loom
cloud dawn
#

Rythm and groovy got a C & D letter couple of months back.

glacial sail
#

There are of course bots that break other site's ToS, but that's irrelevant to our policies.

cloud dawn
#

Just because they are breaking ToS doesn't mean you should.

glacial sail
#

we won't allow discussing or helping with such things here.

peak loom
cloud dawn
peak loom
cloud dawn
#

I don't know but rythm and groovy were the 2 biggest ones.

peak loom
peak loom
cloud dawn
peak loom
#

Heres what have as moderation cog.,.

cloud dawn
#

custom help commands are tough

peak loom
#

Can you at least help????

cloud dawn
#

stella made a walkthrough might be worth it to get started.

rare saddle
#

How to do the correct check? The fact is that I have indicated that if at least one guild does not have a channel specified, then - return, and I need to make sure that the message is sent to the guild that indicated the channel, and the one that did not indicate it is not sent

polar ice
#

Is anyone familiar with Discord-components?

#
    embed.set_footer(text="NOTICE: Please be patient, our staff will assist as soon as they are available.")
    embed.set_thumbnail(url=logo_url)
    msg = await ctx.send(embed=embed,components=[Button(label="Open Ticket", custom_id="ticket", style=ButtonStyle.green)])

sorry for the newb question. im just looking into buttons for the first time. Ive created a button but how do i then detect when its been clicked?

@bot.command()
async def button(ctx):
    await ctx.send("Buttons!", components=[Button(label="Button", custom_id="button1")])


@bot.event
async def on_button_click(interaction):
    await interaction.respond(content="Button Clicked")```

Ive just tried using the example on Git but it doesnt work for me
civic merlin
#

is it possible to use VS code to program a discord bot or will I have to use another program?

pliant gulch
#

You can use any IDE you want

polar ice
#

@civic merlinVS Code works 👍

civic merlin
#

ok i haven't really messed around with it so i wasn't sure

#

thanks

peak loom
civic merlin
peak loom
#

What’s up?

peak loom
#

What am I looking at I don’t see anything wrong…

simple gulch
#

I have a bot and it uses a particular website (the cookie from it) with selenium. I want to have a part of my script to just visit random pages using selenium so it won't get logged out (keep the cookie active). How would be the best way to do that?

rare saddle
#

How to do the correct check? The fact is that I have indicated that if at least one guild does not have a channel specified, then - return, and I need to make sure that the message is sent to the guild that indicated the channel, and the one that did not indicate it is not sent

peak loom
#

You can’t test your bot in the terminal it works better in discord it’s self. And type pyhello.

#

Yes.

polar ice
peak loom
#

I don’t do execution bots my bots run strictly by themselves.

sick birch
#

your client.run() is indentented incorrectly

#

Right now your bot will only start if someone sends a message, and your bot has to be online in the first place for it to detect that. So it's kind of an infinite loop and it will never start

#

just unindent that last line and you'll be good to go

sick birch
simple gulch
#

wdym?

sick birch
#

You can either have selenium run, and not have your bot work, or have your bot work and not have selenium. You cannot have both.

simple gulch
sick birch
#

I don't see why it would work as selenium would block the event loop from running

#

Unless you're threading or multiprocessing?

simple gulch
#

It connects through selenium, but the cookie expires if it isn't used for 20 minutes, that is why I wanted to build a script that would keep the cookie alive.

sick birch
#

The problem is that selenium itself blocks the event loop

#

If you do open a selenium instance then your bot will stop functioning

#

Try it, open a selenium instance while your bot is running and try to run, say, the help command. It won't respond.

simple gulch
#

I don't understand. I am using selenium now for the bot to connect to the website and pull the information?

sick birch
#

Selenium is not asynchronous, it stop the event loop from running which is absolutely crucial for your bot to function

#

The issue is not with selenium opening or working, it's with the bot not working at the same time as your selenium

#

Selenium will open and do what you tell it to just fine, except the fact that your bot would completely stop working, not do a heatbeat to the Discord gateway, and bring itself offline

simple gulch
sick birch
#

No everything within your selenium would work just fine

simple gulch
#

not that the command to grab it wouldn't? Could you have a script that activated selenium say every 15 minutes to do that and then have it turn off (so the bot wouldn't respond during that time but would right after)?

sick birch
#

The command to grab wouldn't work, yes

sick birch
#

Even if you miss one by a few seconds, give or take a few, it's going to completely bring your bot offline

simple gulch
#

What does heartbeating the gateway servers mean?

sick birch
#

Keeps the websocket connection alive to the gateway server knows your bot is still alive and listening

#

It sends a ping to the servers every 40-45 seconds, letting it know that it's still there

#

discord.py handles all of this behind the scenes so you don't have to worry about it, but in this case you do

simple gulch
#

like I could lock the channel while it is pinging so I don't have to worry about people sending requests while it is working.

rare saddle
#

Please tell me what's wrong?

slate swan
#

In your bot.add_cog you typed Button but your class name is Buttons

slate swan
#

Yw

rare saddle
# slate swan Yw

Sorry, can you tell me how to import files in the same directory correctly?

slate swan
#

from .buttons import

rare saddle
slate swan
#

Yw

boreal ravine
slate swan
#

what should i do to error handle that

#

is it the NotFound ?

#

nvm

late wigeon
#

how do I setup a thread that handles discord interactions in someone's dms when they click a static message with a "signup" button

#

I'm trying to have the bot handle multiple at once

simple gulch
#

I have a script I want to have run at the same time my main bot runs. (similar to the keep_alive scripts I've seen). However, when I try to add it in the same way, it just runs my secondary script and never does my bot?

boreal ravine
simple gulch
#

I did pinger.ping()

boreal ravine
simple gulch
boreal ravine
boreal ravine
simple gulch
boreal ravine
boreal ravine
simple gulch
boreal ravine
slate swan
#

How would I add pages to this (A page per every show.)

import discord
from bs4 import BeautifulSoup as bs
from discord.ext import commands
from discord.ext.commands.core import command
import requests as r

class watchlist(commands.Cog):
    def __init__(self,client):
        self.client = client

    @commands.command()
    async def watchlist(self, ctx):
        url = r.get("https://sites.google.com/view/cartoon-raws-series/home")
        soup = bs(url.content, "html.parser")

        for x in soup.find_all('a', class_="XqQF9c", href = True):
            Href = x['href']
            for t in x.findChildren('em'):
                lists = t.text
                embed=discord.Embed(title=f"Here Are The Shows!", color=0x00ff80)
                embed.add_field(name="Link: ", value=lists, inline = True)
                await ctx.send(embed=embed)

def setup(client):
    client.add_cog(watchlist(client))```
simple gulch
boreal ravine
boreal ravine
slate swan
#

ill go find an example rq

slate swan
#

like this

#

and say you react to the ◀️ , it takes you to the page you were on previously, and if you react to the ▶️ , it takes you to the next page

boreal ravine
upbeat otter
#

Or DiscordUtils library too

boreal ravine
upbeat otter
#

Idk, I use buttons smh

boreal ravine
upbeat otter
#

Maybe your own is better

boreal ravine
upbeat otter
late wigeon
#

causing a memory leak and the bot inevitably crashes

boreal ravine
# slate swan like this

So like, imagine you have a list ([1, 2, 3]) and theres reactions on your embed. You can check for a reaction using wait_for function and if the reaction gets clicked, you can index the list by one each time it gets clicked

boreal ravine
heavy folio
#

how do i read the statuses of all members in a guild
e.g. if someone has "this" in their status, the bot will add a role to them, else it'll remove it

boreal ravine
upbeat otter
#

Smh, this person

heavy folio
#

oh

bold surge
#

so im trying to make a dynamic cooldowns command using dpy 2.0 and when the user specified runs the command twice there is no cooldown (this part works fine)... although when another user that is not mentioned in the if statement runs the command twice there also is no cooldown (there should be a cooldown)

Code: https://mystb.in/ViennaGroupsObviously.python

Error: None, code just doesnt work

maiden fable
bold surge
#

its a decorator that sets the cooldown... im not sure if your able to add a print statement to that

verbal cairn
#

how can u make a command take *args as input

#
async def bazaar(inter, item: str):
#

like I have that rn, but it only takes first letter of input

#

slash command*

bold surge
#

hmm have you tried adding * before it

verbal cairn
#

yes

bold surge
#

that didnt work?

maiden fable
verbal cairn
#

ill try again but I think there was an error

bold surge
maiden fable
bold surge
#

ah

vocal plover
verbal cairn
#

disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: input_filter() takes 2 positional arguments but 8 were given

#

thinks each character is an argument

vocal plover
verbal cairn
#

fuck idk where to find that

#

ill look

bold surge
slate swan
#

embeds can be ephemeral right?

maiden fable
slate swan
bold surge
#

still nothing

maiden fable
#

Show code

bold surge
#
def ownerBypass(message):
    print("this works...")
    if message.author.id == 786789607147962388:
        return None
    return commands.cooldown(1, 30, commands.cooldowns.BucketType.user)
maiden fable
#

So it doesn't even print that thing?

bold surge
#

nope

maiden fable
#

Did u restart the bot and then ran the command?

bold surge
#

yep

#

dw abt the warnings

maiden fable
#

Weirddddd

boreal ravine
unkempt canyonBOT
#

class discord.ext.commands.Greedy```
A special converter that greedily consumes arguments until it can’t. As a consequence of this behaviour, most input errors are silently discarded, since it is used as an indicator of when to stop parsing.

When a parser error is met the greedy converter stops converting, undoes the internal string parsing routine, and continues parsing regularly.

For example, in the following code:

```py
@commands.command()
async def test(ctx, numbers: Greedy[int], reason: str):
    await ctx.send("numbers: {}, reason: {}".format(numbers, reason))
```  An invocation of `[p]test 1 2 3 4 5 6 hello` would pass `numbers` with `[1, 2, 3, 4, 5, 6]` and `reason` with `hello`...
maiden fable
#

Do u have an error handler

bold surge
#

not on this bot

pliant gulch
#

I doubt greedy would work with a slash command either way, the argument system is different

bold surge
#

its only for testing

maiden fable
#

Oh ok

boreal ravine
maiden fable
#

Weird tbh

verbal cairn
maiden fable
#

It should have printed at least

bold surge
#

yea...

#

i tried the docs but they told me nothing

pliant gulch
verbal cairn
#
import requests
import logging
import disnake
from fuzzywuzzy import fuzz
from datetime import datetime
from disnake.ext import commands
#

these are my imports

bold surge
#

might cause some errors later on

verbal cairn
#

idk how else to pull json data

pliant gulch
#

You could use aiohttp or httpx

maiden fable
#

!d aiohttp also exists

unkempt canyonBOT
#

Common data structures used by aiohttp internally...

verbal cairn
#

I think I gotta figure out how to make greedy work before!

bold surge
#

lol

verbal cairn
#

idk

pliant gulch
#

Are you even sure if Greedy works with slash commands

verbal cairn
#

yeah thats what idk

pliant gulch
#

Afaik last time I checked there was no argument type for slash commands taking X amount of args,

verbal cairn
#
@bot.slash_command(description='Pulls a list of up to 30 or more current orders in bazaar!')
async def bazaar(inter, item: Greedy[str]):
#

except greedy string doesnt work

vocal plover
#

Oh slash commands? Yeah that wont work

#

You'd need to just manually split it because slash commands arent advanced enough to support that

verbal cairn
#

wdym manually split

pliant gulch
#

You could make item a string argument type, then use .split(...)

vocal plover
#

^

pliant gulch
#

!e ```py
a = "1, 2, 3"
print(a.split(","))

unkempt canyonBOT
#

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

['1', ' 2', ' 3']
verbal cairn
#

no ik how to split

#

I thought it wasnt only taking

#

the first character

pliant gulch
#

The item argument only takes the first character?

verbal cairn
#

uh kinda?

#

well it takes the full input

pliant gulch
#

Do you mean like the first word of a sentence

verbal cairn
#

but its only sending the first character of the input to my input_filter function

pliant gulch
#

Tbh, I'm pretty sure that's just a slash command limitation

#

Maybe try async def bazaar(inter, *, item: str):

#

Although I doubt that would work

verbal cairn
#

no

#

bc then no option would show up when using /

pliant gulch
#

Yea, then it's a slash command limitation ig

verbal cairn
#

perfect jade <- THIS IS INPUT ITEM
ok so it does take full input

#

it just only sends the first character

pliant gulch
#

First character or the first word

verbal cairn
#
perf j <- THIS IS INPUT ITEM
perf j <- THIS IS INPUT ARG
['p', 'e', 'r', 'f', ' ', 'j'] <- THIS IS ARG LIST
#
    for stg in range(len(input_arg)):
        new_val = input_arg[stg].strip('0123456789!@#$%^&*()_+=`~|][;:"\'/?.-,<>')
        arg_list.append(new_val.lower())
pliant gulch
#

Yea, your iterating input_arg which is a string, thus new_val would be a single char

verbal cairn
#

hmm

pliant gulch
#

Since arg_list is a list of the cleaned characters you can just use .join

#

!e ```py
print(["h","i"].join())

unkempt canyonBOT
#

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

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | AttributeError: 'list' object has no attribute 'join'
pliant gulch
#

Brain fart

sullen shoal
#

lol

pliant gulch
#

!e ```py
print("".join(["h","i"]))

unkempt canyonBOT
#

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

hi
verbal cairn
#

!e

print("".join(['p', 'e', 'r', 'f', ' ', 'j']))
unkempt canyonBOT
#

@verbal cairn :white_check_mark: Your eval job has completed with return code 0.

perf j
verbal cairn
#

ty

upbeat otter
#

why isnt wait_for working?

slate swan
#

Are you able to edit a embed's title and description after post?

upbeat otter
#

it stops on client.wait_for

slate swan
tough lance
#

Message.edit

upbeat otter
tough lance
unkempt canyonBOT
#

await edit(content=..., embed=..., embeds=..., attachments=..., suppress=..., 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.
upbeat otter
#

full code ,-,

slate swan
# tough lance !d discord.Message.edit

The issue with this is, this is how you add a new embed to begin with.

I know how to extract the embed object, I can change certain fields using set_field_at yet I cant find an equivalent for the Title and Description values of an embed

tough lance
upbeat otter
tough lance
slate swan
pliant gulch
#

You shouldn't have to reconstruct an embed to edit an embed inside of a message. Just get the embed from message.embeds or any other way, E.g Embed.copy() and change the fields, etc. Then just call Message.edit with a embed kwarg set to the embed you editted

verbal cairn
#

is creating an on_message function a good way to log out of ur bot

maiden fable
#

Use a command instead

verbal cairn
#

like a complicated command or

maiden fable
#

And be sure to make it owner only or.... rip

verbal cairn
#

how do u do that

maiden fable
#

!d discord.Client.close

unkempt canyonBOT
#

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

Closes the connection to Discord.
verbal cairn
#

no the owner command

maiden fable
unkempt canyonBOT
#
Fat chance.

No documentation found for the requested symbol.

tough lance
unkempt canyonBOT
#

@discord.ext.commands.is_owner()```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that checks if the person invoking this command is the owner of the bot.

This is powered by [`Bot.is_owner()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.is_owner "discord.ext.commands.Bot.is_owner").

This check raises a special exception, [`NotOwner`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NotOwner "discord.ext.commands.NotOwner") that is derived from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
maiden fable
#

O my discord is lagging now ;-;

tough lance
#

Rip

tiny ibex
#

How to get the server pfp of a member

slate swan
maiden fable
unkempt canyonBOT
#

property avatar: Optional[discord.asset.Asset]```
Returns an [`Asset`](https://discordpy.readthedocs.io/en/master/api.html#discord.Asset "discord.Asset") for the avatar the user has.

If the user does not have a traditional avatar, `None` is returned. If you want the avatar that a user has displayed, consider [`display_avatar`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.display_avatar "discord.User.display_avatar").
maiden fable
#

!d discord.Member.display_avatar

unkempt canyonBOT
#

property display_avatar: discord.asset.Asset```
Returns the member’s display avatar.

For regular members this is just their avatar, but if they have a guild specific avatar then that is returned instead.

New in version 2.0.
tiny ibex
#

Not the server avatar

maiden fable
#

Damn discord do be lagging

maiden fable
unkempt canyonBOT
#

property display_avatar: discord.asset.Asset```
Returns the member’s display avatar.

For regular members this is just their avatar, but if they have a guild specific avatar then that is returned instead.

New in version 2.0.
tiny ibex
maiden fable
#

Yea...

boreal ravine
boreal ravine
maiden fable
#

As per the description at least

#

🤷‍♂️

boreal ravine
#

hm

maiden fable
#

Lemme test

tiny ibex
#

Can someone tell how to get server specific pfp

boreal ravine
#

try display_avatar ig

verbal cairn
#

how do u check who uses the command again

#

ctx.user isnt it I cant remmeber

maiden fable
tiny ibex
maiden fable
boreal ravine
tiny ibex
verbal cairn
#

oh

maiden fable
#

Damn discord do be lagging too much today

worthy wagon
# unkempt canyon

@verbal cairn, You don't need all of this, just check for your user ID.

verbal cairn
#

so

@bot.command()
async def logout(ctx):
  if ctx.author == bot.owner:
    await bot.close()
slate swan
#

bot.owner is not a thing?

verbal cairn
#

it is!

tiny ibex
#

Tf is bot.owner

slate swan
#

no

verbal cairn
#

wdym its not

#

it works tho

slate swan
#

bruh

verbal cairn
#

its prob not as safe as checking for ID's but idk

slate swan
#

you can either use is_owner() decorator , or compare a user/member object , but bot.owner does not exist

worthy wagon
boreal ravine
worthy wagon
boreal ravine
#

!d discord.ext.commands.Bot.close

unkempt canyonBOT
#

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

Closes the connection to Discord.
verbal cairn
#

but .owner is a thing

slate swan
boreal ravine
#

yes

verbal cairn
#

how is it not

slate swan
#

but the way they say that , dont think so

worthy wagon
#

np

slate swan
verbal cairn
slate swan
#

did you define it manually somewhere?

verbal cairn
#

no

slate swan
#

also "works for my code" is not a valid statement

heady night
#

How can i make my own discord client/edit it?

slate swan
#

you can use bot.user.edit

verbal cairn
slate swan
verbal cairn
#

yes

#

bot.owner = Taco#3025

#
async def is_owner(ctx):
    return ctx.author.id == 316026178463072268

@bot.command(name='eval')
@commands.check(is_owner)
async def _eval(ctx, *, code):
    """A bad example of an eval command"""
    await ctx.send(eval(code))
#

thats is_owner ig

slate swan
#

or you could use the default is_owner() check

verbal cairn
#
@bot.command(aliases=['log'])
async def logout(ctx):
    if ctx.author == bot.owner:
        await bot.close()

or

@bot.command(aliases=['log'])
async def logout(ctx):
    if ctx.author.id == 596428514895593472:
        await bot.close()

or

@bot.command(aliases=['log'])
@commands.is_owner
async def logout(ctx):
  if ctx.author.id == bot.owner.id:
        await bot.close()
#

idk which is best really

#

they all do the same thing

slate swan
#

for the 1st or 3rd to work
the bot.owner has to be a discord.Member object

#

not your name and discrim

verbal cairn
#

wait so .owner is showing guild owner or what

tough lance
slate swan
#

theres no bot.owner
you have to manually set it if you want

verbal cairn
slate swan
verbal cairn
#

yeah

slate swan
#

Which is better

verbal cairn
#

I just dont know why ppl keep saying .owner isnt a thing

slate swan
#

And no need for the if statement

verbal cairn
#

wait so does command.is_owner

#

im confused now

slate swan
verbal cairn
#
def is_owner():
    async def predicate(ctx):
        return ctx.author.id == 316026178463072268
    return commands.check(predicate)

@bot.command(name='eval')
@is_owner()
async def _eval(ctx, *, code):
    """A bad example of an eval command""
slate swan
#

Yeah the commands.is_owner i think is the decorator dpy has and @is_owner is a custom one

tiny ibex
#
  bot.lavalink = lavalink.Client(bot.user.id)```
#

Totally new to lavalink

#

And I can't understand wtf is this line

hasty loom
#

im new to virtual envs, youre supposed to gitignore these right?

#

using virtualenv module btw

civic fractal
#

well

#

you don't have to gitignore them

#

but yeah it would certainly be a little annoying to have a ton of generic binary files on your repo...

#

you should pip freeze > requirements.txt and add that to the repo

#

so that you can clone this repository and re-install all of the requirements

slate nymph
#

does anybody know why only admins in my server can run slash commands

#

for any bot?

maiden fable
#

Cz there are permissions set for those commands

slate nymph
#

but for all the bots

maiden fable
#

U can't see the slash commands or u can't use them?

maiden fable
#

Yeah to?

slate nymph
#

?

maiden fable
#

I asked two different things haha

tiny ibex
#
2021-12-04T05:38:38.121789+00:00 app[worker.1]: disnake.ext.commands.errors.ExtensionFailed: Extension 'cogs.music' raised an error: ImportError: cannot import name 'menus' from 'disnake.ext' (unknown location)```
Can someone tell me whyyyy
slate nymph
#

i cant see slash commands nor use them lol

tiny ibex
slate nymph
#

how can i use them when i cant see them-

maiden fable
#

Ah

#

Well caching issues. It takes time for the slash commands to sync with all the guilds

#

Discord issue, u can't really do anything

slate nymph
#

its been 12 hours-

maiden fable
#

Weird

slate nymph
#

ikr

#

one hour i could believe

tiny ibex
maiden fable
#

Did u try restarting your discord client and reinviting the bot with application.commands scope?

maiden fable
#

Ah nvm

tiny ibex
maiden fable
#

Just saw your messages in the disnake server

slate nymph
#

i ll wait a lil more

tiny ibex
#

What should I do @maiden fable

maiden fable
#

Yea ext.menus is a different package, not with disnake or dpy

maiden fable
maiden fable
#

Just click on the invite link with the application.commands scope and select your guild. This way, u will add the application.commands scope without kicking the bot (:

maiden fable
tiny ibex
#
2021-12-04T05:49:00.471728+00:00 app[worker.1]: 
2021-12-04T05:49:00.471738+00:00 app[worker.1]: Traceback (most recent call last):
2021-12-04T05:49:00.471740+00:00 app[worker.1]:   File "/app/main.py", line 1607, in <module>
2021-12-04T05:49:00.472369+00:00 app[worker.1]:     bot.load_extension("cogs.music")
2021-12-04T05:49:00.472370+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/disnake/ext/commands/common_bot_base.py", line 487, in load_extension
2021-12-04T05:49:00.472507+00:00 app[worker.1]:     self._load_from_module_spec(spec, name)
2021-12-04T05:49:00.472509+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/disnake/ext/commands/common_bot_base.py", line 432, in _load_from_module_spec
2021-12-04T05:49:00.472656+00:00 app[worker.1]:     raise errors.ExtensionFailed(key, e) from e
2021-12-04T05:49:00.472681+00:00 app[worker.1]: disnake.ext.commands.errors.ExtensionFailed: Extension 'cogs.music' raised an error: TypeError: wavelink.Client expected type <commands.Bot or commands.AutoShardedBot> not <class 'disnake.ext.commands.bot.Bot'>```
#

How to fix it

maiden fable
#

U need an instance of commands.AutoShardedBot, not commands.Bot

boreal ravine
#

wait bot is the file name right

tiny ibex
#

No IG

maiden fable
boreal ravine
#

🤔

maiden fable
#

Ah nvm

#

Didn't see that. My bad

tiny ibex
#

So what to do

#

Overall

tough lance
#

I think you would need a monkey patch to work with disnake

boreal ravine
#

ah

maiden fable
#

Yea

boreal ravine
tough lance
#

I have made it

maiden fable
#

It works only with discord.ext.commands.Bot

boreal ravine
#

lavalink is finding the dpy version of commands.Bot not disnake's one

tiny ibex
#

Oof

#

Fck wavelink

boreal ravine
tiny ibex
boreal ravine
#

not their fault

boreal ravine
tiny ibex
tough lance
boreal ravine
#

clearly said mine

tough lance
#

Sorry wrong link

#

Fck

tiny ibex
tough lance
tiny ibex
#

Oh it's not the official one

tough lance
#

I modified it

tiny ibex
#

Let's see if it works

#
        nodes = {'MAIN': {'host': 'http://lava.link/',
                          'port': 80,
                          'rest_uri': 'lava.link',
                          'password': 'anything as password',
                          'identifier': 'MAIN',
                          'region': 'us_central'
                          }}```
#

Is that right?

#

I am sorry but I am totally new to wavelink

boreal ravine
#

try it and see

tiny ibex
# boreal ravine try it and see
2021-12-04T05:57:16.487697+00:00 app[worker.1]: Traceback (most recent call last):
2021-12-04T05:57:16.487718+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/wavelink/websocket.py", line 76, in _connect
2021-12-04T05:57:16.487719+00:00 app[worker.1]:     self._websocket = await self._node.session.ws_connect(uri, headers=self.headers, heartbeat=self._node.heartbeat)
2021-12-04T05:57:16.487727+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/aiohttp/client.py", line 754, in _ws_connect
2021-12-04T05:57:16.487728+00:00 app[worker.1]:     resp = await self.request(
2021-12-04T05:57:16.487735+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/aiohttp/client.py", line 520, in _request
2021-12-04T05:57:16.487736+00:00 app[worker.1]:     conn = await self._connector.connect(
2021-12-04T05:57:16.487743+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/aiohttp/connector.py", line 535, in connect
2021-12-04T05:57:16.487744+00:00 app[worker.1]:     proto = await self._create_connection(req, traces, timeout)
2021-12-04T05:57:16.487751+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/aiohttp/connector.py", line 892, in _create_connection
2021-12-04T05:57:16.487752+00:00 app[worker.1]:     _, proto = await self._create_direct_connection(req, traces, timeout)
2021-12-04T05:57:16.487759+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/aiohttp/connector.py", line 1011, in _create_direct_connection
2021-12-04T05:57:16.487760+00:00 app[worker.1]:     raise ClientConnectorError(req.connection_key, exc) from exc
2021-12-04T05:57:16.487771+00:00 app[worker.1]: aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host http:80 ssl:default [Name or service not known]```
boreal ravine
#

no idea

tiny ibex
#

oof

maiden fable
#

@tiny ibex no help with that ngl

#

Wave Link is well... against ToS