#discord-bots

1 messages · Page 1115 of 1

slate swan
#

and how do I go about doing that?

fading marlin
#

what's your code looking like?

slate swan
#

bloody confusing if you could send me the docs maybe i can understand it better, im so used to the orginal version

slate swan
slate swan
#

disnake?

#

!pypi disnake

unkempt canyonBOT
slate swan
#

you can just do

pip install disnake
#

you say that and your grammar makes you look like a dummy

#

💀

#

youre not a dummy

#

youre my dummy😉

#

😳

heady sluice
slate swan
#

lmao

slate swan
#

just ping sarthak hes a smart boy

#

⭐docs⭐

#

⭐src⭐

#

⭐seems like a you problem⭐

#

😡

pliant gulch
#

Okimii reads source at a 5th grade level

slate swan
#

4*

#

andy

#

play fall guys with me

#

or ryuga

pliant gulch
#

No

slate swan
#

no females

paper sluice
slate swan
#

you were typing

#

clients stop typing after like 10secs

paper sluice
#

oh

#

i was alt tabbing

slate swan
#

welp i saw that

paper sluice
#

mightve pressed a space or 2

slate swan
#

play fall guys with me

pliant gulch
#

Alt tab couldn’t be me

paper sluice
#

i dont have fall guys 😔

slate swan
pliant gulch
#

Super + Tab

#

😏 BSPWM

paper sluice
slate swan
#

its free to play

#

so lets play

paper sluice
#

wait what, last time i saw it was paid on steam

#

now i dont see it on steam

slate swan
#

and it has crossplay

paper sluice
#

i can't install epic games, it requires admin which i dont have 😔

slate swan
paper sluice
#

maybe 😳

slate swan
#

bro

pliant gulch
#

Bro probably on ChromeOS

slate swan
#

💀

slate swan
#

😭

#

channel = bot.get_channel(ID_OF_THE_CHANNEL_HERE)

if ctx.channel is not channel:
return await ctx.send("This command is not available in this channel")

Where do I put this code? I want to add it to my command

errant coral
#
async def on_voice_state_update(member, before, after):
    if after.channel.id == 984492572544213083:
        CAT = discord.utils.get(member.guild.channels, id = 984491906237075496)
        vc = await member.guild.create_voice_channel(f"{member.name}", category = CAT)
        await member.move_to(vc)
if not before.voice is None and after.voice is None:
  if len(before.voice.channel.members) == 0:
    def before.channel.delete()```
anyone know why it dosnt delete the voice channel after all people leave it?
junior vigil
#

how can i make a command that pings the person that sent it and sends an embed in the same message as opposed to it pinging them then sending the embed in a different message

sick birch
errant coral
#

i know how to fix embed but not the ping thing

junior vigil
errant coral
#

k

errant coral
sick birch
sick birch
errant coral
slate swan
#

@sick birch can u help me in dms

sick birch
#

I don't do DM help sorry, ask here instead

sick birch
slate swan
#

channel = bot.get_channel(ID_OF_THE_CHANNEL_HERE)

if ctx.channel is not channel:
return await ctx.send("This command is not available in this channel")

Where do I put this code? I want to add it to my command

#

well you would use logic no?

sick birch
#

Are you trying to restrict a command to a certain channel?

slate swan
#

Yes

sick birch
#

use a check instead then

slate swan
#

Idk how

slate swan
#

you can just check the id of the channel the command was invoked in

#
if ctx.channel.id != int:
    ...
#

But where do I paste the code

errant coral
sick birch
#

Remove your first member argument

errant coral
#

ok

slate swan
slate swan
errant coral
slate swan
sick birch
#

ah wait nevermind

slate swan
#

Bro wtf I get no help

sick birch
#

ignore what I said, I just checked the docs

#

It needs a member as well. My apologies

slate swan
sick birch
slate swan
#

I asked a simple fucking question

#

and it was answered.

sick birch
#

Yes, yes it was

slate swan
#

Nah

#

WHERE DO I PUT THE CODE IN WHAT LINE AFTER WHAT

errant coral
slate swan
#

I never got answer for this

#

use logic.

sick birch
#

That's bordering on the line of spoonfeeding

slate swan
#

Go fuck off

sick birch
#

Okay? No need to get heated over it

slate swan
#

thats not very nice is it?

#

we dont know how your code looks so how can we help😵‍💫

#

Its a simple command

errant coral
slate swan
#

depends what he wants

#

is it hard to make a DISCORD BOT AUTOSHOP

#

what

sick birch
#

That way I can figure out what's going on in the context of lines around it

errant coral
# sick birch I feel like it may be indented incorrectly, as mentioned before. Can you send th...
async def on_voice_state_update(member, before, after):
    if after.channel.id == 984492572544213083:
        CAT = discord.utils.get(member.guild.channels, id = 984491906237075496)
        vc = await member.guild.create_voice_channel(f"{member.name}", category = CAT)
        await member.move_to(vc)
if not before.voice is None and after.voice is None:
  if(len(after.voice.channel.members) == 0):
    def before.channel.delete()```
sick birch
#

Aha, culprit spotted

wary shadow
#

!warn 815897400211800105 This is no way to speak to other community members. Please read the #code-of-conduct and our #rules if you wish to remain a member here.

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied warning to @slate swan.

sick birch
#

It is indented incorrectly, it's outside the scope of the function hence the undefined name error

errant coral
dim tapir
#

how would one do some threading with dpy

sick birch
#

Yeah, basically those last 3 lines are outside the function

sick birch
#

Which is why it can't access before/after as that's defined inside the function

slate swan
#

robin is it hard to make discord bot autoshop

dim tapir
#

so wahts the best library for dpy? is it pycord?

sick birch
sick birch
dim tapir
#

whats something thats thread safe

sick birch
#

Why do you need threading?

slate swan
#

hmm I will get some more info and then I will reach out to you

errant coral
dim tapir
sick birch
sick birch
dim tapir
#

i am addicted to threads

errant coral
slate swan
#

tab

errant coral
#

im still trying to learn stuff

dim tapir
sick birch
#

Select those 3 lines, press the tab button on your keyboard

errant coral
#

ok

slate swan
#

robin are you a php dev toooo?

errant coral
#

oh that what you meant by outside lines

sick birch
dim tapir
#

do need toi

sick birch
errant coral
dim tapir
#

sadly i cant just smack numba onto PIL

slate swan
dim tapir
#

there fore making image processing SLOW

sick birch
#

Ah I see what you're doing

slate swan
#

like I am still learning python but I dont have any ideas in my mind to do

#

you have any

sick birch
#

You want to spawn a new thread when you have to do image processing?

dim tapir
#

yes

slate swan
sick birch
#

That's more reasonable

dim tapir
#

ofcourse i wouldnt want to do it for any command

sick birch
#

Other than being a "threading monster"

dim tapir
#

i am a threading monster

slate swan
slate swan
sick birch
#

I'm not fully sure if discord.py is threadsafe so there's that to keep in mind

slate swan
#

which isnt thread safe?

errant coral
dim tapir
#

are async functions even thread safe

sick birch
sick birch
#

But how you implement it is the problem (discord.py, for example)

dim tapir
#

ya i tried dat

slate swan
errant coral
# sick birch Code again please?
async def on_voice_state_update(member, before, after):
    if after.channel.id == 984492572544213083:
        CAT = discord.utils.get(member.guild.channels, id = 984491906237075496)
        vc = await member.guild.create_voice_channel(f"{member.name}", category = CAT)
        await member.move_to(vc)
    if not before.voice is None and after.voice is None:
    if(len(after.voice.channel.members) == 0):
        def before.channel.delete()```
dim tapir
#

dat shit was buggy

errant coral
#

ops

slate swan
#

can I ask what pingu is trying to do?

sick birch
#

Delete a voice channel once everyone has left

dim tapir
#

think he is doing one of those join to create voice channels

errant coral
# sick birch Delete a voice channel once everyone has left
async def on_voice_state_update(member, before, after):
    if after.channel.id == 984492572544213083:
        CAT = discord.utils.get(member.guild.channels, id = 984491906237075496)
        vc = await member.guild.create_voice_channel(f"{member.name}", category = CAT)
        await member.move_to(vc)
    if not before.voice is None and after.voice is None:
    if(len(after.voice.channel.members) == 0):
       ``` so?
sick birch
#

Let's not spoonfeed please

dim tapir
dim tapir
sick birch
#

!resources you may find these helpful

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.

sick birch
#

I don't mean to turn you away, but you'll only be doing yourself a favour by learning python before attempting discord.py

slate swan
#

i wonder why python doesnt have an up to date book and async book

errant coral
sick birch
#

As the issues you're having are quite trivial and should be solved pretty easily

dim tapir
#

anyways spoonfeed me some information

#

i aim quiet clueless as to how id do dis

#

wait let me show uy what i tried first

sick birch
#

The first thing that pops up into my head is to have an API that does all the image processing

dim tapir
#

ya i thought about that as well

sick birch
#

Use aiohttp which is already a dependency of discord.py, so it still shouldn't be blocking

dim tapir
#

hm

#
@commands.command()
async def foo(self, ctx):
  async def processimg(ctx):
    ...
  await self.client.loop.run(await processimg(ctx))
#

what did i do wrong here

slate swan
#

asyncio.AbstractEventLoop has no such attr

sick birch
#

What's the point here? Why not just await processimg(ctx)?

#

Also why nesting it?

dim tapir
#

idk i cant think of another alternative to threading a command

tacit token
#

anybody know, how can i mention a role with webhook?

#

AttributeError: 'Webhook' object has no attribute 'get_role'

cloud dawn
#

<@&831776746206265384>

#

To ping the mod role for example.

rancid grail
#

now interestingly enough

#

that does ping us

cloud dawn
#

Why pithink

rancid grail
#

i made that mistake like 2 days ago too so... :D

cloud dawn
#

Sorry it was meant as an example.

slate swan
#

you sure?

rancid grail
slate swan
#

it doesnt seem formatted for me😭

rancid grail
#

yeah it isnt formatted

rancid grail
#

still pings

sage otter
#

Yo that’s crazy bro 😭

#

Discord is actually insane.

slate swan
#

frrr😭

rancid grail
#

discord really outdoing 'emselves once again

slate swan
#

like always

cloud dawn
#

Does it also ping with a user id?

slate swan
#

ping me

rancid grail
cloud dawn
#

@slate swan

slate swan
#

yes it does

cloud dawn
#

😮

rancid grail
#

🎉

slate swan
#

😭

cloud dawn
#

Well the more you know I guess.

slate swan
#

yup

cloud dawn
#

It's not betterdc it's just a back-slash before a mention.

slate swan
#

            cursor.execute("UPDATE users SET (работа, должность) = (?,?) WHERE  id = ?", ('Шахта',  'Шахтер[1]', {interaction.user.id}))
            conn.commit()

Dear, tell me what is wrong?

heady sluice
slate swan
heady sluice
#

but it don't matter

#

we love u okimii

slate swan
#

i love you guys more!

cloud dawn
heady sluice
#

did you just monkey me

rancid grail
#

could be the build override

cloud dawn
cloud dawn
#

Too bad betterdc violates ToS, awesome stuff could be done.

slate swan
slate swan
heady sluice
#

not even a command exception wraps that error, I don't know how we even got to this channel with that error

slate swan
cloud dawn
heady sluice
#

except that it's because it's in a discord bot

slate swan
heady sluice
slate swan
#

Is there a way for the bot write emojis?

cloud dawn
slate swan
ionic turtle
quaint epoch
#

woah did you make this override urself?

round knoll
#

hello, my bot does not post to discord anymore, and im not sure why

quaint epoch
#

are u hosting it

round knoll
#

yeah, i can test !hello, and it answers Hello RenegadeZed.. i can also !ping and he says Pong!

#

it's a mess of a code, cause i was trying to create a list to check all the people streaming, and post who is streaming from the list.. but im the only one streaming in my discord atm.. and it just plain doesnt work

#

i think somehow it gets stuck at the if no channel: return live.. and just doesnt do the for loop

#

in this part.. cause i never see the print statement

# post in discord if streamer is live
@loop(seconds=90)
async def check_twitch_online_streamers():
    channel = bot.get_channel(966493808869138442)
    if not channel:
        return

    notifications = get_notifications()
    for notification in notifications:
        print("Sending discord notification")
        await channel.send(f"We are now live at https://www.twitch.tv/renegadezed\n{notification}")
round knoll
torn sail
#

You need to start the loop check_twitch_online_streamers.start()

#

!d discord.ext.tasks.Loop.start

unkempt canyonBOT
round knoll
#

yeah, thats in the pasted link, at the end

torn sail
#

Oh lol I can’t see it on mobile

round knoll
#
if __name__ == "__main__":
    check_twitch_online_streamers.start()
    bot.run(disctoken)
torn sail
#

Before you check if not channel can u print channel

round knoll
#

let me check.. also as a quick side question.. the @rigid granite(seconds=90) how short of a timer can i use there?

torn sail
#

Probably any time but I wouldn’t make it too short

round knoll
#

do i get a soft ban if i spam the API too much? like 30 seconds?

torn sail
#

I’m not sure

round knoll
#

hmm, it printed None

torn sail
#

Is this happening the first time it’s looping?

round knoll
#

ok now i got live-notifications.. which is the name of the channel

#

yeah on first time, None, second time, after 90 seconds, i got live-notifications

#

im getting live-notifications every 90 seconds

torn sail
#

!d discord.ext.tasks.Loop.before_loop

unkempt canyonBOT
#

@before_loop```
A decorator that registers a coroutine to be called before the loop starts running.

This is useful if you want to wait for some bot state before the loop starts, such as [`discord.Client.wait_until_ready()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.wait_until_ready "discord.Client.wait_until_ready").

The coroutine must take no arguments (except `self` in a class context).

Changed in version 2.0: Calling [`stop()`](https://discordpy.readthedocs.io/en/latest/ext/tasks/index.html#discord.ext.tasks.Loop.stop "discord.ext.tasks.Loop.stop") in this coroutine will stop the initial iteration from running.
torn sail
#

Here is an example if u need one

#

Except it doesn’t have to be in a class

round knoll
#

well, the None being printed at start isnt the problem i think.. cause i do get live-notifications after 90 seconds.. so it should post to discord no?

torn sail
#

Well if it’s returning then it won’t do anything

#

But after 90 seconds it’ll work good

tacit token
#

guys, i want to get message id and edit it in webhook, how?

#
msg = await channel.fetch_message(message_id)

I want to this but in webhook

#

ty i ge it

round knoll
#

alright so this one return

live-notifications
Check...
just before forloop

so its not entering the for loop? is it because get_notifications is broken?

# post in discord if streamer is live
@loop(seconds=30)
async def check_twitch_online_streamers():
    channel = bot.get_channel(966493808869138442)

    print(channel)

    if not channel:
        print("not channel")
        return

    print("Check...")

    notifications = get_notifications()
    print("just before forloop")
    for notification in notifications:
        print("Sending discord notification")
        await channel.send(f"We are now live at https://www.twitch.tv/renegadezed\n{notification}")
#
# add streamer to online_users
def get_notifications():
    users = get_users(config_data["watchlist"])
    streams = get_streams(users)

    notifications = []
    for user_name in config_data["watchlist"]:
        if user_name not in online_users:
            online_users[user_name] = datetime.utcnow()

        if user_name not in streams:
            online_users[user_name] = None
        else:
            started_at = datetime.strptime(
                streams[user_name]["started_at"], "%Y-%m-%dT%H:%M:%SZ"
            )
            if online_users[user_name] is None or started_at > online_users[user_name]:
                notifications.append(streams[user_name])
                online_users[user_name] = started_at

    return notifications


if __name__ == "__main__":
    check_twitch_online_streamers.start()
    bot.run(disctoken)
#

alright, i just check the access token... had a weird feeling

#

it was expired lol

still copper
#

does anyone know what the problem is when bot.get_channel(server_id) never resolves the promise?

fading marlin
#

wdym by 'never resolves the promise'?

cloud cairn
#

How do i make (str(client.guilds)) just show the name of the servers?

    print("Server online in:",(str(client.guilds)))
still copper
#

like I do await bot.get_channel(server_id) and the program is stuck on the line and never goes past it

#

I meant channel_id

fading marlin
#

get_channel isn't awaitable, it searches through cache. In the other hand, you've got fetch_channel which is awaitable

cloud cairn
#

and how do i do that. Pretty new to python :/

fading marlin
#

!listcomp

unkempt canyonBOT
#

Do you ever find yourself writing something like this?

>>> squares = []
>>> for n in range(5):
...    squares.append(n ** 2)
[0, 1, 4, 9, 16]

Using list comprehensions can make this both shorter and more readable. As a list comprehension, the same code would look like this:

>>> [n ** 2 for n in range(5)]
[0, 1, 4, 9, 16]

List comprehensions also get an if statement:

>>> [n ** 2 for n in range(5) if n % 2 == 0]
[0, 4, 16]

For more info, see this pythonforbeginners.com post.

slate swan
#

Can someon help me i have a giveaway bot and when giveaway ends it says @invalid user and I tried doing {winner.displayName} but when giveaway ends bot doesnt send anything

#

Pls help

#

Hello?

#

It only works with winner.mention

round knoll
#

where can i get help for a way to format the twitch API response to a proper discord notification?

#

theres a key in the json response that says thumbnail_url.. but when i click on it i get 404

warm tulip
#

hey guys why warn cmd is not working?

  @commands.has_any_role(989044819101896735,989043172007104552,)
  async def warn(self, ctx: commands.Context, target: discord.Member, *, reason):
    await target.send(f"{reason}")
    await ctx.send("Member warned :white_check_mark:")
fading marlin
#

traceback?

warm tulip
#

Traceback (most recent call last):
File "C:\Users\Copy Service\PycharmProjects\wibuos\venv\lib\site-packages\discord\ext\commands\bot.py", line 606, in _load_from_module_spec
spec.loader.exec_module(lib)
File "<frozen importlib._bootstrap_external>", line 879, in exec_module
File "<frozen importlib._bootstrap_external>", line 1017, in get_code
File "<frozen importlib._bootstrap_external>", line 947, in source_to_code
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "C:\Users\Copy Service\PycharmProjects\wibuos\venv\commands.py", line 76
@commands.command(name="warn")
^
IndentationError: unindent does not match any outer indentation level

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

Traceback (most recent call last):
File "C:\Users\Copy Service\PycharmProjects\wibuos\main.py", line 16, in <module>
bot.load_extension("commands")
File "C:\Users\Copy Service\PycharmProjects\wibuos\venv\lib\site-packages\discord\ext\commands\bot.py", line 678, in load_extension
self._load_from_module_spec(spec, name)
File "C:\Users\Copy Service\PycharmProjects\wibuos\venv\lib\site-packages\discord\ext\commands\bot.py", line 609, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'commands' raised an error: IndentationError: unindent does not match any outer indentation level (commands.py, line 76)

Process finished with exit code 1

slate swan
#

Can someon help me i have a giveaway bot and when giveaway ends it says @invalid user and I tried doing {winner.displayName} but when giveaway ends bot doesnt send anything
It only works with winner.mention

smoky cedar
slate swan
#

^^

smoky cedar
#

I know for roles you use <@&{role_id_here}>

slate swan
#

And what is winners.displayname

smoky cedar
#

not sure if its the same with user id

slate swan
#

Sounds like ur using a giveaway bot dashboard

#

how can u make a giveaway command but not know how to ping

warm tulip
#

helpppp

smoky cedar
slate swan
#

dude @slate swan ur so ........ thats what rhe bot says not me

#

....

warm tulip
#

my warn cmd its not working

smoky cedar
warm tulip
# smoky cedar With?
  @commands.has_any_role(989044819101896735,989043172007104552,)
  async def warn(self, ctx: commands.Context, target: discord.Member, *, reason):
    await target.send(f"{reason}")
    await ctx.send("Member warned :white_check_mark:")
slate swan
#

I need to change winner.mention but how cause I tried and then the giveaway bot doesnt send message when giveaway ends

smoky cedar
#

But why can't you use winner.mention?

slate swan
#

This is what happens if I use that

smoky cedar
#

Oh, I misunderstood the original message

#

But yeah: **Winner**: <@%{winners_user_id}>\n

#

@slate swan

slate swan
#

@smoky cedar

#

Hello?

smoky cedar
# slate swan Like this?

No, the braces and winner. are not needed. Also I was wrong, that is for roles, you just need <@id>

fading marlin
#

<@&> is for roles, <@!> is for users

smoky cedar
#

Say the user's id is 1234, you need @balmy crown to ping them

smoky cedar
cerulean folio
#

Guys I'm making a bot for tickets reporting, and it has to store image proofs of reports that he gathered from the reported via image links, and image uploads.
However when the report ends, the channel gets deleted and all these images links stored in database don't work anymore.

Anyone has an idea?

slate swan
#

@smoky cedar like this?

fading marlin
smoky cedar
# slate swan <@272989403486617602> like this?

No, replace id with the id, don't actually include the word id. And don't include those braces either, they were just to show where the id would go

And I don't mean to be a butthole, but for the love of god please just copy paste into a code block.

slate swan
#

With what id man?

smoky cedar
slate swan
#

This is a giveaway bot it has random pick

smoky cedar
#

That ur pinging

slate swan
#

Omfg

smoky cedar
#

Okay, you have the user object no?

#

How can you not grab their id lol

slate swan
#

THIS IS A RANDOM CHOICE

smoky cedar
slate swan
#

BOT PICKS WINNER FROM PARTICIPANTS

smoky cedar
#

winner.id man idk what model is being used here

slate swan
#

WHAT ID DO I NEED FOR THE LOVE OF GOD

smoky cedar
#

You're hilarious

#

Tell ya what

#

Copy paste into a code block, and I'll edit and send exactly how it should look

slate swan
#

Ok

smoky cedar
#

Triple backticks to start a codeblock, triple at the end

#
Like so
smoky cedar
# slate swan Ok

You can even use py after the three ticks to color

print('hello')
x = 5 
y = 3
print(x+y)
slate swan
smoky cedar
slate swan
# smoky cedar Did it?

Yes I did 2 giveaways 5 minutes the users showed now im gonna try a 1 hour one and we will see

daring olive
#

hey guys let's chill with the all caps please

smoky cedar
indigo pilot
#

Hey, could someone give mea a idea on how i could do a check to send a msg at a ceritn time?
ex sending a message at 9 pm exactly every day

smoky cedar
indigo pilot
#

ill give that a try ty

smoky cedar
indigo pilot
#

yeah

bright palm
smoky cedar
cerulean folio
#

Guys I'm making a bot for tickets reporting, and it has to store image proofs of reports that he gathered from the reported via image links, and image uploads.
However when the report ends, the channel gets deleted and all these images links stored in database don't work anymore.

Anyone has an idea?

smoky cedar
indigo pilot
#

^^ or if you make/have a log system you can just send the images in a log channel and then just save the new url, his way is better but yeah lmao

smoky cedar
#

It's an easy way to stay on discord too lmao

indigo pilot
#

xD

cerulean folio
#

hmmmm

#

so get_images() would take images of type list as argument that contains all the image links from a message text and attachements.

It would then use request or curl to store the image in a variable. Then upload it in a channel that won't be deleted. Then take all image links from attachements, then return a list of all new links?

#

sounds like a fair project indeed !

indigo pilot
#

lmao, yep

slate swan
#

its a better theme imo

radiant junco
#

i'mi trying to create a thread using discord's api,

headers = {"content-type": "application/json", "Authorization": os.environ['AUTH_TOKEN']}
json = {"name": name, "type": 11, "auto_archive_duration": 10080, 'location': 'Message'}
request = requests.post(f"https://discord.com/api/v9/channels/{channel_id}/threads", headers=headers, json=json)

but this code returns:

{'code': 50035, 'errors': {'channel_id': {'_errors': [{'code': 'NUMBER_TYPE_COERCE', 'message': 'Value "general" is not snowflake.'}]}}, 'message': 'Invalid Form Body'}

any ideas as to what the error could be? I've searched online and most of the scripts are similar or exactly the same as this one

rare saddle
#

How to make a bot a speaker in the stage channel through the code?

dusky pine
radiant junco
slate swan
dusky pine
#

wait no, channel_id isn't even an ID right, it says it's general

slate swan
#

its in an f string and im pretty sure thats self botting no?

#

yeah it needs to be an int

radiant junco
slate swan
dusky pine
#

can you show us what channel_id is?

#

it has to be the ID, not the channel name

slate swan
#

im pretty sure we shouldnt help him @dusky pine

dusky pine
#

yeah..

slate swan
#

looking at his auth header its a self bot

radiant junco
#

what i'm running it on repl

#

i have to hide my tokens in an env variable

dusky pine
#

the only reason why you wouldn't be using it is because dpy doesn't support selfbotting

radiant junco
slate swan
#

im pretty sure bots use {"Authorization": "Bot TOKEN"})

pliant gulch
#

No bearer is for oauth2

#

Bots use “Bot TOKEN”

slate swan
#

right

dusky pine
#

discord.py 2.0a has channel.threads, update to that @radiant junco

#

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

radiant junco
#

does that create a new thread or just view existing threads?

dusky pine
#

that property is just to view existing ones

radiant junco
rare saddle
#

How to make a bot a speaker in the stage channel through the code?

slate swan
#

@smoky cedar it didnt get fixed

#

@smoky cedar is there a code so it doesnt mention it only writes their name

smoky cedar
#

Go to Discord Models, on the left, open User

#

You can see all the attributes and methods for a user object

sick birch
slate swan
unkempt canyonBOT
#

property name```
Equivalent to [`User.name`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User.name "discord.User.name")
blazing lantern
#

Hello! I wrote a custom decorator that checks if a user has set an account name with the bot, so if it doesn't it raises a CheckFailure exception. I'm writing a cog-level exception handler and wondering, if I have several decorator checks on a command, how do I know which of those decorators raised the exception in the first place?

#

I was looking at using the exception string, but I realized it only tells me the name of the command that a decorator failed on. This isn't useful because I may have several decorators on multiple commands

jovial plover
junior vigil
#
if __name__ == '__main__':  
    for extension in extensions:
        bot.load_extension(extension)```
#

2 questions

#

is this necessary?

#

and why is it giving me this error

Traceback (most recent call last):
  File "main.py", line 30, in <module>
    bot.load_extension(extension)  # Loades every extension.
  File "/home/runner/discord-bot-moment-thing/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 674, in load_extension
    spec = importlib.util.find_spec(name)
  File "/nix/store/p21fdyxqb3yqflpim7g8s1mymgpnqiv7-python3-3.8.12/lib/python3.8/importlib/util.py", line 94, in find_spec
    parent = __import__(parent_name, fromlist=['__path__'])
  File "/home/runner/discord-bot-moment-thing/venv/lib/python3.8/site-packages/cogs/__init__.py", line 7, in <module>
    from .shell import Shell, ArgDsc, OptDsc, Failure
  File "/home/runner/discord-bot-moment-thing/venv/lib/python3.8/site-packages/cogs/shell.py", line 276
    except (Failure, IOError, KeyboardInterrupt), exc:
                                                ^
SyntaxError: invalid syntax```
junior vigil
#

so just ignore the error?

slate swan
#

you missed an as dude

junior vigil
#

where do i put the as

slate swan
#

after the error tuple

junior vigil
#

it doesnt exist

slate swan
#

...?

junior vigil
#

this is all i have

slate swan
#

replit

#

uwu
make a new repl

junior vigil
#

ok

#

still errored

slate swan
#

cool

junior vigil
#

i feel like it has something to do with not having this folder

#

how do i get it

slate swan
#

...?

junior vigil
#

cause i have another bot with that folder and it works

paper sluice
#

what is keep_alive, is it some replit thing?

junior vigil
#

so it doesnt die

#

pings the repl so that it doesnt auto turn off

#

workaround so you dont need to pay for it to be on 24/7

slate swan
#

which people use for hosting their repl by pinging it with uptimerobot

paper sluice
#

oh

junior vigil
paper sluice
junior vigil
#

yea

paper sluice
#

why?

#

its basically compiled python files

junior vigil
#

well i want everything in that screenshot i sent

paper sluice
#

wdym by want?

junior vigil
#

well i need

#

cause its depended on by something

paper sluice
#

explain what you want to do

junior vigil
#
if __name__ == '__main__':  
    for extension in extensions:
        bot.load_extension(extension)``` needs it
#

cause an extension i have is cogs

slate swan
#

pycache is not related to that.

paper sluice
#

(1) loading a .pyc which is the files inside __pycache__ will just throw errors cuz its not a python file
(2) just load the .py files, u should not mess with pycache

junior vigil
#

well its in the cogs folder

slate swan
#

it just get created whenever you'll run the program

junior vigil
#

clearly it didnt

slate swan
#

you didn't load the cogs then.

paper sluice
junior vigil
#

look all i know

#

is the only difference between 2 bots is 1 has the folder and works

#

1 doesnt have the folder and doesnt work

paper sluice
#

what?

junior vigil
slate swan
#

✨ doesn't work ✨ won't get you any help. you need to mention the traceback

paper sluice
#

pycache is not related to discord bots

junior vigil
paper sluice
slate swan
#

you don't even have a cogs folder idk what ur talking about

junior vigil
#

long story short

#

is there a command to load the cogs folder

slate swan
#

create the cog folder, create the cog_example file
run the code, and the pycache will get created itself.

paper sluice
slate swan
paper sluice
paper sluice
slate swan
junior vigil
#

i clicked the run button

dusky pine
paper sluice
#

its not, its a background image

slate swan
#

don't think its transparent but its a theme?

#

yeah

#

pycache is compiled byte code of your program so its faster its like caching ig

#

use vscode with GlassIt extension kannapogg looks pog

#

wait yall dont use notepad?

paper sluice
slate swan
#

not a windows user, I'd rather use gedit

#

dual boot note pad is the best ide

#

not a text editor, an ide

#

😳

#

gedit is better, use ur terminal as the editor

paper sluice
#

windows 11 notepad it better, it has dark mode, regex text search, etc

slate swan
paper sluice
slate swan
#

😳

paper sluice
#

all my homies hate cmd

junior vigil
#

after i click run this remains in the folder

slate swan
#

guys i have a problem

slate swan
#

why doesnt my command work?

paper sluice
#

powershell is better

slate swan
paper sluice
slate swan
#

sudo pacman -S sarth prettythumbsup

paper sluice
#

use wsl

#

ezz

dusky pine
#

choco install sarth

slate swan
#

brew install sarth

#

ok enough lol

paper sluice
#

rm -rf sarth 😳

slate swan
#

let me import you sarthak

#

😩

dusky pine
#

bro

slate swan
#

you can't import me, i have already imported you
circular import !!!!

dusky pine
#

refactor your code then

paper sluice
#

if typing.TYPE_CHECKING:

slate swan
dusky pine
#

oki why u keep flirting with everyone 😔

paper sluice
slate swan
slate swan
slate swan
#

😩 why, i spent 1 hr trying to figure that out lmao

#

💀

slate swan
paper sluice
#

was python annotations inspired from rust?

dusky pine
#

i think its the other way around

slate swan
#

im pretty sure annotations were always a concept in programming langauges idk

#

rust is younger than python annotations ig?

paper sluice
#

no i mean the syntax for it

paper sluice
jovial plover
#

How to install dpy 2.0

dusky pine
#

you need to install Git beforehand

slate swan
#

5*

paper sluice
#

im talking this sort of thing

def foo(a: int, b: int) -> int:

rust

fn foo(a: u32, b: u32) -> u32 {

they are exactly same

slate swan
#

2010-2016 = 5?

#

im pretty sure 3.5 was released in 2015

dusky pine
#

i32 or u32?

paper sluice
#

u - unsigned

dusky pine
#

ik what it is but like why would you want to use unsigned instead of signed

slate swan
#

!pep 526

unkempt canyonBOT
#
**PEP 526 - Syntax for Variable Annotations**
Status

Final

Python-Version

3.6

Created

09-Aug-2016

Type

Standards Track

paper sluice
slate swan
#

while basic type annotations goes back to 2014

#

!pep 484

unkempt canyonBOT
#
**PEP 484 - Type Hints**
Status

Final

Python-Version

3.5

Created

29-Sep-2014

Type

Standards Track

slate swan
#

peps are so annoyingly confusing smh

#

😒

pliant gulch
#

How

slate swan
paper sluice
#

bruh

slate swan
vocal snow
vocal snow
#

i did without google

slate swan
#

like i would believe you

paper sluice
slate swan
#

i have to google a word for every sentence smh

paper sluice
#

arent u used to googling?

slate swan
paper sluice
#

who said u read everything

#

i just look at code blocks and text around it

slate swan
#

the pep did😳

slate swan
paper sluice
#

thats good enough ig

slate swan
#

not for me!

paper sluice
#

then stop complaining ...

slate swan
#

how and why

paper sluice
#

just read it like its a story book from a very high class writer who only uses weird words

slate swan
paper sluice
slate swan
pliant gulch
slate swan
pliant gulch
#

I am

#

😳

slate swan
#

👍

pliant gulch
#

Just the wording or?

slate swan
#

the meaning of some words which im not quite familiar with

paper sluice
#

install a dictionary pulgin

slate swan
#

good idea

paper sluice
#

puts word meaning when u hover over it

slate swan
#

oh no

#

thats annoying

#

i want a keybind

paper sluice
#

ya anything

slate swan
#

ill check

pliant gulch
paper sluice
#

i didnt google it

pliant gulch
#

This would be the plan définition and not a one directed in a programming context

slate swan
#

mhm ill check that out

pliant gulch
#

Semantics in a programming way would be your regulated stuff

#

Eg PEP-8 is really the baseline semantics for python style

pliant gulch
#

Semantic Versioning eg MAJOR.MINOR.PATCH is the regulation for versioning, regulation with a grain of salt as it isn’t strictly enforced by simply the most used one

#

Hence semantics

paper sluice
#

andy smort

slate swan
#

no andy doesnt go outside hence why he plays league of legends

pliant gulch
#

I’ve never played league in a day of my life

#

Also it’s not hard to do research on the internet!

slate swan
paper sluice
slate swan
pliant gulch
#

But anyways peps are good! Better to have an organized thing than not

#

Typehinting is good too, but don’t even get me started on that type theory mathematics

slate swan
#

theres math behind type hints?🗿

tough lance
#

Wut

pliant gulch
slate swan
tough lance
#

I don't hate math

#

I don't even study maths

pliant gulch
slate swan
#

😒

pliant gulch
#

Ok

slate swan
#

you love ruining stuff for me smh

paper sluice
#

quantum type hints

slate swan
#

ryuga bro

#

😭

grand shell
#

hey guys, this worked perfectly before but it just started giving me errors even tho i didnt change anything lol.

from discord.ext import commands
import discord

from scripts.channelFinder import ChannelFinder
from scripts.fileHandler import JsonHandler
from scripts.botManager import BotManager
#

is there a more reliable way to import classes from other scripts in other folders? thanks for the help :))

slate swan
#

stop running cog files.

grand shell
#

wdym

left idol
#

how would i override a command cooldown on pycord for users in a list?

slate swan
slate swan
#

!d discord.ext.commands.dynamic_cooldown

unkempt canyonBOT
#

@discord.ext.commands.dynamic_cooldown(cooldown, type)```
A decorator that adds a dynamic cooldown to a [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")

This differs from [`cooldown()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.cooldown "discord.ext.commands.cooldown") in that it takes a function that accepts a single parameter of type [`discord.Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message") and must return a [`Cooldown`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.Cooldown "discord.app_commands.Cooldown") or `None`. If `None` is returned then that cooldown is effectively bypassed.

A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").

If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") and the local error handler.

A command can only have a single cooldown.

New in version 2.0.
slate swan
#

see if it exists in pycord

slate swan
#

does any1 have a good bot idea?

placid skiff
#

bruh why you don't use cogs my god.. or... my cog

#

the bot instance in that view is a string

slate swan
placid skiff
#

check where you pass the bot variable to it

#

duh in that file there isn't any cog

#

neither a command

#

only a lot of views builded in that same file

#

Why not creating a file for every views D_D

#

if there are more that means that they don't do the same thing

#

so have more files is more easy to handle

#

and you could create a utils file in that folder where you can create a base View subclass and then subclass it, with that you will not have to setup a new view every time you create a new one, with maybe some function that you keep using more times D_D

warm tulip
#

hellpppp

#
  async def warn(self, ctx: commands.Context, target: discord.Member, *, reason):
    await target.send(f"{reason}")
    await ctx.send("Member warned :white_check_mark:")``` this warn cmd is not workingg
placid skiff
#

It doesn't do really much D_D

warm tulip
# warm tulip ``` @commands.command(name="warn") async def warn(self, ctx: commands.Context...

eror :
"C:\Users\Copy Service\PycharmProjects\wibuos\venv\Scripts\python.exe" "C:/Users/Copy Service/PycharmProjects/wibuos/main.py"
Traceback (most recent call last):
File "C:\Users\Copy Service\PycharmProjects\wibuos\venv\lib\site-packages\discord\ext\commands\bot.py", line 606, in _load_from_module_spec
spec.loader.exec_module(lib)
File "<frozen importlib._bootstrap_external>", line 879, in exec_module
File "<frozen importlib._bootstrap_external>", line 1017, in get_code
File "<frozen importlib._bootstrap_external>", line 947, in source_to_code
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "C:\Users\Copy Service\PycharmProjects\wibuos\venv\commands.py", line 75
@commands.command(name="warn")
^
IndentationError: unindent does not match any outer indentation level

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

Traceback (most recent call last):
File "C:\Users\Copy Service\PycharmProjects\wibuos\main.py", line 16, in <module>
bot.load_extension("commands")
File "C:\Users\Copy Service\PycharmProjects\wibuos\venv\lib\site-packages\discord\ext\commands\bot.py", line 678, in load_extension
self._load_from_module_spec(spec, name)
File "C:\Users\Copy Service\PycharmProjects\wibuos\venv\lib\site-packages\discord\ext\commands\bot.py", line 609, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'commands' raised an error: IndentationError: unindent does not match any outer indentation level (commands.py, line 75)

Process finished with exit code 1

placid skiff
#

that is not even a discord error

#

check the line 75

warm tulip
#

😐

#

75@commands.command(name="warn")

placid skiff
#

in your code
the identation is wrong

#

it is clearly written

warm tulip
#

idk wym

placid skiff
#

then you should study more python, d.py isn't beginner friendly

warm tulip
#

uhhhhh

placid skiff
#

!e

def my_func():
  print("a")
my_func()
unkempt canyonBOT
#

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

a
placid skiff
#

!e

def my_func():
print("a")
my_func()
unkempt canyonBOT
#

@placid skiff :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 2
002 |     print("a")
003 |     ^
004 | IndentationError: expected an indented block after function definition on line 1
slate swan
#

!indents

unkempt canyonBOT
#

Indentation

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

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

Example

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

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

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

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

warm tulip
#

guys why its not working

@commands.has_permissions(ban_members=True)
async def ban(self, ctx, user: discord.Member, *, reason):
    await ctx.guild.ban(user, reason=reason)
    await user.send(f"You have been banned in {ctx.guild} for {reason}")
    await ctx.send(f"{user} has been successfully banned.")
slate swan
#

¯_(ツ)_/¯

#

what's the error?

#

and you cant send messages to the user after banning them

alpine cove
#

and make sure to try and except the send message part

paper sluice
#

value = self.__dict__.get(value, value) 😳

slate swan
errant coral
#

!d id

unkempt canyonBOT
#
id

id(object)```
Return the “identity” of an object. This is an integer which is guaranteed to be unique and constant for this object during its lifetime. Two objects with non-overlapping lifetimes may have the same [`id()`](https://docs.python.org/3/library/functions.html#id "id") value.

**CPython implementation detail:** This is the address of the object in memory.

Raises an [auditing event](https://docs.python.org/3/library/sys.html#auditing) `builtins.id` with argument `id`.
errant coral
#

no info ....

#

that i can use

slate swan
errant coral
#

object has no attribute 'id'

slate swan
#

because the docs command(!d) has 41 packages so you must be specific

errant coral
#

ok

slate swan
errant coral
#

ok

#

hmm what should i use then

slate swan
alpine cove
#

pycord is a bunch of stolen bullcrap and is coded poorly

#

never heard of disnake but wouldn’tbt recommnd it

meager chasm
alpine cove
#

all of their stuff

#

and renamed it

#

like just look at their source

#

and compare it to other forks

#

like i like pycord

#

pycord aint bad

meager chasm
alpine cove
alpine cove
pure crypt
#

how can i make that my bot add an reaction to the message he just send? In a command

meager chasm
alpine cove
pure crypt
#

ok

meager chasm
pure crypt
alpine cove
#

im not argue over some dpy fork

meager chasm
#

Well you said they stole code so I'm just trying to find out what exactly they stole lol

placid skiff
#

pycord is considered as a fork of d.py but actually it could be nearly considered as a completely different package

alpine cove
#

cya guys later

meager chasm
slate swan
placid skiff
#

it is*

slate swan
#

dpy

slate swan
#

¯\_(ツ)_/¯

#

yes it does

#

put you'll have to install dpy using the link of the master branch from ithub

#

for that
github*

pure crypt
#

my commands don't work after i out in an on_message event

#

ehat did i have to do?

fierce sonnet
pure crypt
#

ok

fierce sonnet
slate swan
#

||hikari||

vocal snow
#

snekcord 😡

slate swan
vocal snow
#

prolly not lol

#

sleep-cult keeps dying every few weeks

slate swan
#

f

#

looli ill use literally every wrapper atleast once

#

pycord is an exception

slate swan
slate swan
#

i love pycord thats why i wont use it

fierce sonnet
#

deep pain

slate swan
#

i'd rather just keep digging into the source code to point out mistakes

fierce sonnet
#

well that would be a good choice

slate swan
#

imo pycord should patent api wrappers for discord

#

so that people dont counterfeit its uwuness

#

😔

#

!pip pycord its not even related to discord

unkempt canyonBOT
fierce sonnet
slate swan
#

i bet ashley loves your idea

slate swan
fierce sonnet
slate swan
fierce sonnet
slate swan
#

smh

placid skiff
uncut jacinth
#

I got this in my cog listener

print("tewst" + self.client.user)

It wont print the bot name eventho the listener is working because the print above will print.

#

No error

placid skiff
uncut jacinth
#

Nvm fixed it by myself

placid skiff
#

You could learn how to properly setup a bot with that

uncut jacinth
#

Ok, I have my bot properly setuped

dusky pine
#

open source advertisement 😔

slate swan
#

💀

heavy folio
#

where 2 spacing before in-line comments

slate swan
#

smh

slate swan
jagged adder
#

in the example below, how can i reference the knife value to change my output, without changing (=) the value? ```py
KnifeTest = {cond: 'damaged', value: 25}
Inv = [KnifeTest]
money = 100
print(Inv)
print(money)

if KnifeTest['cond'] == 'used':
money += KnifeTest['value']
print(money)

elif Knife['cond'] == 'damaged':
money += KnifeTest['value'] * 0.5
print(money)```

slate swan
#

huh?

jagged adder
#

coz this aint workin; this is simply a test i want to implement further later on

#

when i change the knife cond dict entry, it prints correctly before i try to modify the end result. as soon as i try to * the value it doesnt work... i think i understand why, just not what the correct way to do it is

slate swan
#

ah

jagged adder
#

specifically this line

money += KnifeTest['value'] * 0.5
slate swan
jagged adder
#

correct

slate swan
#

lemme see

jagged adder
#

just prints 100; doesnt modify anything at all

slate swan
#

also shouldnt cond and value be keys inside quotes?

jagged adder
#

i have this

cond = "cond"
``` coz i prefer the look rather than everything being green
#

makes it easier to read

slate swan
#

works perfectly fine for me

jagged adder
#

yeah thats what it should be doing; im missing something on my end clearly

slate swan
#

!e

KnifeTest = {"cond": 'damaged', "value": 25}
money = 100

if KnifeTest['cond'] == 'used':
    money += KnifeTest['value']
    print(money)
elif KnifeTest['cond'] == 'damaged':
    money += KnifeTest['value'] * 0.5
    print(f"damaged -> {money}")
unkempt canyonBOT
#

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

damaged -> 112.5
slate swan
#

¯_(ツ)_/¯

#

Idts you would be missing anything

jagged adder
#

ok wth lol

#

if i copy paste it works; i cant see what is diff tho

#

oh my gawd

#

i figured it out x.x

#

i had a typo referencing somethin further up the doc smh

slate swan
#

did Knife[...]?

#

lmao

#

shit happens

#

glad it got fixed

jagged adder
#

was ```py
Knife['cond'] == 'damaged':

not ```py
KnifeTest['cond'] == 'damaged':
#

thanks for the help haha

slate swan
#

knew it

slate swan
#

Can someon help me add a reroll command to my giveaway bot cause I tried and failed

slate swan
shrewd apex
#

what do u have so far?

slate swan
slate swan
# shrewd apex what do u have so far?

@client.command()
@commands.has_permissions(kick_members=True)
async def reroll(ctx, channel : discord.TextChannel, id_ : int):
try:
new_msg = await channel.fetch_message(id_)
except:
embed = discord.Embed(title="Command Error ⛔ - GameBot", description=f"The Id Of A Channel Was Entered Incorrectly! 🎉", color=0x992d22)
await ctx.send(embed=embed)
return

    users = await new_msg.reactions[0].users().flatten()
    users.pop(users.index(client.user))

    winner = random.choice(users)

    embed = discord.Embed(title="Giveaways 🎉 - GameBot", description=f"**Giveaway Has Been Rerolled!** \n \n**Winner -** \n`{winner.mention}`", color=0xe74c3c)
    await ctx.send(embed=embed)
#

When I run the command nothing shows

supple thorn
shrewd apex
#
@client.command()
@commands.has_permissions(kickmembers=True)
async def reroll(ctx, channel : discord.TextChannel, id : int):
        try:
            new_msg = await channel.fetch_message(id)
        except:
            embed = discord.Embed(title="Command Error ⛔ - GameBot", description=f"The Id Of A Channel Was Entered Incorrectly! 🎉", color=0x992d22)
            await ctx.send(embed=embed)
            return

        users = await new_msg.reactions[0].users().flatten()
        users.pop(users.index(client.user))

        winner = random.choice(users)

        embed = discord.Embed(title="Giveaways 🎉 - GameBot", description=f"Giveaway Has Been Rerolled! \n \nWinner - \n{winner.mention}", color=0xe74c3c)
        await ctx.send(embed=embed)
slate swan
#

someone help me cretate a discord bot

slate swan
supple thorn
#

Helly

#

Yes

shrewd apex
#

no

#

thats for me to read

supple thorn
slate swan
#

Ok

paper sluice
#

!rule 9

unkempt canyonBOT
#

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

slate swan
#

o shit sry

#

@shrewd apex do u need my giveaway command

shrewd apex
#

btw 2.0?

slate swan
#

?

shrewd apex
#

is it dpy2.0?

#

or 1.7.3

slate swan
#

Python

paper sluice
#

they are talking about the version of discord.py,not software 🤦

shrewd apex
#

open the toml and lock file and see

slate swan
#

Before acting smart

slate swan
paper sluice
shrewd apex
slate swan
slate swan
shrewd apex
#

u missed a _ in fetch_message

slate swan
shrewd apex
#

side note if it is 2.0 u have to iterate async

slate swan
shrewd apex
supple thorn
#

I literally hate vcokltfre's name

#

I had to search the entire discord for that

slate swan
jagged adder
#

is it possible to get print(Inv) in the below to just print names without changing Inv = [x, y] to Inv = [x['name'], y['name']?

KnifeTest = {name: 'Knife', cond: 'used', value: 25}
SwordTest = {name: 'Sword', cond: 'used', value: 25}
Inv = [KnifeTest, SwordTest]
Selected = []
money = 100
print(Inv)
print(money)
vocal snow
jagged adder
#

its to do with my bot; its a simplified test of a feature :p

supple thorn
#

For you

slate swan
supple thorn
shrewd apex
slate swan
#

fr

shrewd apex
#
dic = {'name': 'a'}#
full = [v for k, v in dic.items() if k == 'name']
slate swan
#

I swear if I applied the same amount of brain as Asher does in this channel, I'd be long time gone

dusky pine
slate swan
#

@shrewd apex no work

#

Do u want my giveaway command too

shrewd apex
#

no

#

reroll require message id

#

i dont see message id in ur .reroll

slate swan
#

Ok ima try with message id then

shrewd apex
#

it should be .reroll 9xyz...

slate swan
#

@shrewd apex

shrewd apex
#

send ur giveaway command here

#

the reroll part

slate swan
#

Ok

shrewd apex
#
@client.command()
@commands.has_permissions(kickmembers=True)
async def reroll(ctx, channel : discord.TextChannel, id : int):
        try:
            new_msg = await channel.fetch_message(id)
        except:
            embed = discord.Embed(title="Command Error ⛔ - GameBot", description=f"The Id Of A Channel Was Entered Incorrectly! 🎉", color=0x992d22)
            await ctx.send(embed=embed)
            return

        users = await new_msg.reactions[0].users().flatten()
        print(users)
        users.pop(users.index(client.user))
        print(users)
        winner = random.choice(users)

        embed = discord.Embed(title="Giveaways 🎉 - GameBot", description=f"Giveaway Has Been Rerolled! \n \nWinner - \n{winner.mention}", color=0xe74c3c)
        await ctx.send(embed=embed)
slate swan
#

''@client.command()
@commands.has_permissions(manage_messages=True)
async def reroll(ctx, channel : discord.TextChannel, id_ : int):
try:
new_msg = await channel.fetch_message(id_)
except:
embed = discord.Embed(title="Command Error ⛔ - Giveaway", description=f"The Id Of A Channel Was Entered Incorrectly! 🎉", color=0x992d22)
await ctx.send(embed=embed)
return

    users = await new_msg.reactions[0].users().flatten()
    users.pop(users.index(client.user))

    winner = random.choice(users)

    embed = discord.Embed(title="Giveaways 🎉", description=f"**Giveaway Has Been Rerolled!** \n \n**Winner -** \n`{winner.name}`", color=0xe74c3c)
    await ctx.send(embed=embed)''
shrewd apex
#

run this and tell what it prints

slate swan
#

ok

jagged adder
shrewd apex
#

this is not so useful for single dicts since there can only be one key = name

#

so its better usage would be i a nested dict

#

k and v are variables unpacking the dictionary as it iterates through it

#

aka the key value pairs

jagged adder
#

ah

paper sluice
shrewd apex
#

indeed

jagged adder
#

yeah that helps me understand whats going on; i think im missing something tho... i gtg briefly but ill be back in a bit

slate swan
#

Yo @shrewd apex i get no response to the command still

#

???

#

Yo hello

errant coral
#

Anyone know what i can use instead of name?
object has no attribute 'name'

shrewd apex
errant coral
#

its a event

#

join to create voice channel

slate swan
errant coral
# shrewd apex command?
async def on_voice_state_update(member, before, after):
    if after.channel.name == "🎤|join to create":
        CAT = discord.utils.get(member.guild.channels, name="Voice")
        vc = await member.guild.create_voice_channel(f"{member.name}", category=CAT)
        await member.move_to(vc)
    else:
        if str(before.channel.name) == str(member.name) and after.channel == None:
            await before.channel.delete()```
This is the code
shrewd apex
slate swan
shrewd apex
#

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

shrewd apex
unkempt canyonBOT
#

The voice channel that the user is currently connected to. None if the user is not currently in a voice channel.

#

Hey @slate swan!

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

slate swan
#

bruh

#

@shrewd apex what should i do

shrewd apex
#

only voice channel has

unkempt canyonBOT
slate swan
#

👀

shrewd apex
#

👋

slate swan
#

In my code

slate swan
#

hello, how can i show the api latency?

#

like

#

!ping

unkempt canyonBOT
#

You are not allowed to use that command here. Please use the #bot-commands channel instead.

slate swan
unkempt canyonBOT
#

property latency```
Measures latency between a HEARTBEAT and a HEARTBEAT\_ACK in seconds.

This could be referred to as the Discord WebSocket protocol latency.
slate swan
#

format it using round(latency * 1000)

#

and it would be in milliseconds

#

Nvm I did it

#

so like py api_latency = discord.Client.latency(latency * 1000)?

#

no?

shrewd apex
#

bot.latency*1000

slate swan
#

imagine 'bot' is not defined

empty vine
#

im getting a weird exception guys

paper sluice
empty vine
#

AttributeError: 'Member' object has no attribute 'avatar_url'

paper sluice
#

which version of dpy do u use?

shrewd apex
#

avatar.url

paper sluice
#

its ^ in 2.0

shrewd apex
#

it's either that or this i don't think dpy has any other implementation 👀