#discord-bots

1 messages · Page 78 of 1

jagged adder
#

do emoji/reactions count as a message?

paper sluice
#

no, its a reaction object, you can get the message using reaction.message

jagged adder
#

so in my check id want

if msg.author == bot.user

and how do i check for the emoji author

#

to make sure its not the bot

paper sluice
#

you can check reaction.author

#

and to make sure its not a bot, you can do reaction.author.bot, it returns True if it is, else False

jagged adder
#

how come it says reaction isnt a valid term

#

unresolved reference

paper sluice
#

code?

jagged adder
#
def del_check():
        if reaction.author == bot.user
#

im prob overlooking somethin so simple

paper sluice
#

you didn't take reaction and use in the function parameter

jagged adder
#

oh mb

#

so reaction is a valid term in itself?

#

if i parse it as a parameter

paper sluice
#

what do you mean by valid term?
its just a normal variable

jagged adder
#

well currently its deleting the msg when the bot reacts

#

i wonder if im oversimplifying a step

#

ok i got this

    async def del_check(reaction):
        if not reaction.author == bot.user:
            await msg.delete()

    await bot.wait_for('on_reaction_add', check=del_check)
#

what am i overlooking

paper sluice
jagged adder
gilded gust
#

Hey, I'm working on a bot in py-cord and have some code in the following format:

class MyView(View):
  def __init__(self, user):
    self.user = user

  @MySelect(a)
  async def callback(self, select, interaction):
    ...

class MySelect(Select):
  def __init__(self, page_count):
    super().__init__(options=[...])

The issue is on line 5, @MySelect(a). a is a variable which I can get from the user attribute that I assigned earlier, but I need self for that and can't get self outside a function.
How can get the data from user and use it in the decorator?

TL;DR: Need to access an instance attribute in a decorator inside the same class.

jagged adder
naive briar
gilded gust
naive briar
#

you can try something simple like

def check(reaction, user):
    return not user.bot

reaction, user await bot.wait_for("reaction_add", check=check)
await msg.delete()
paper sluice
paper sluice
jagged adder
paper sluice
#

so its not going to work...

jagged adder
#

what

paper sluice
#

why are you deleting the message when the bot reacts

jagged adder
#

im not, im tryin to delete it when anyone else reacts

#

just somehow i managed to make it so the bot deleted it b4

#

isnt anymore

paper sluice
#

well, you are not, you are doing reaction.author == bot.user

#

== checks if left and right are the same

shrewd apex
#

u can just do != then delete

jagged adder
#

i got

    def del_check(reaction):
        if reaction.author is not bot.user and reaction == '⚔️':
            msg.delete()


    await bot.wait_for('on_reaction_add', check=del_check)
paper sluice
#

don't use is not

shrewd apex
#

it think it was reaction_add

paper sluice
#

on works as well

paper sluice
shrewd apex
#

it looks for the dispatched event i think

#

so on should also work ig

jagged adder
jagged adder
shrewd apex
#

wait_for looks for bot dispatched event for reaction its reaction_add

#

on_reaction_add should work also

jagged adder
#

hang on i got somethin mixed up there

shrewd apex
#

its fine u can run it no change needed

jagged adder
#

ok so where is this wrong

    async def del_check(reaction):
        if not reaction.author == bot.user and reaction == '⚔️':
            await msg.delete()


    await bot.wait_for('on_reaction_add', check=del_check)
paper sluice
#

thats the same as doing not (reaction.author == bot.user and reaction == ':crossed_swords:')
just use != and remove the not

naive briar
#

Use len to count the guild members

@bot.event
async def on_guild_join(guild):
    if len(guild.members) < 20:
      await guild.leave()
paper sluice
naive briar
jagged adder
# paper sluice rip

if i put a print under the check, shouldnt it print something if its called?

#

coz its not

#

i wonder if the issue is in the wait_for part of it

paper sluice
#

at this point, you are just asking us to write it for you

jagged adder
#

im doing plenty of my own fiddling

brazen raft
#

You can compare IDs if that does anything

vocal snow
#

And event is "reaction_add" not on_reaction_add

jagged adder
#

at least it’s something smh

jagged adder
vocal snow
#

You can use asyncio.create_task or have wait_for in a loop and break on a favorable condition

#

Where are you using this wait_for, in a command?

jagged adder
#

ive sent a msg, added an emoji, now i want to delete said message when someone reacts to it with that same emoji

vocal snow
#

Specific reaction on a specific message or any message?

vocal snow
#

That isn't checking on a specific message so i was curious

#

If it's not for a specific message you could just use an event

jagged adder
#

i also want a timeout feature that clears x msg after say 5 mins if someone doesn’t close it before that

#

sec

#
msg = await ctx.send(f"...")
    await msg.add_reaction('⚔️')

    async def del_check(reaction):
        if reaction.author != bot.user and reaction == '⚔️':
            await msg.delete()
#

thats what i got rn

vocal snow
#

You'll also need to check if the message being reacted to is the same as the one you reacted to

#

But yeah checks can't be async, easy solution would be to use asyncio.create_task

jagged adder
#

idek how that one works

vocal snow
#

You pass a coro and it schedules it to run

#

!d asyncio.create_task

unkempt canyonBOT
#

asyncio.create_task(coro, *, name=None)```
Wrap the *coro* [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine) into a [`Task`](https://docs.python.org/3/library/asyncio-task.html#asyncio.Task "asyncio.Task") and schedule its execution. Return the Task object.

If *name* is not `None`, it is set as the name of the task using [`Task.set_name()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.Task.set_name "asyncio.Task.set_name").

The task is executed in the loop returned by [`get_running_loop()`](https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_running_loop "asyncio.get_running_loop"), [`RuntimeError`](https://docs.python.org/3/library/exceptions.html#RuntimeError "RuntimeError") is raised if there is no running loop in current thread.
jagged adder
#

so where would this fit into what i got rn..?

vocal snow
#

Or if this is too alien, you could just call wait_for in a loop and break when you get the condition you want

vocal snow
jagged adder
#

im not sure why its printing this in the callback

#

TypeError: del_check() takes 1 positional argument but 2 were given

vocal snow
#

what arguments does on_reaction_add give

jagged adder
#

its just 'reaction_add' atm

#

im not quite sure

vocal snow
#

Check the docs

#

Whatever arguments it gives is what you need in your check

jagged adder
#

dam

vocal snow
#

!d discord

unkempt canyonBOT
#

In order to work with the library and the Discord API in general, we must first create a Discord Bot account.

Creating a Bot account is a pretty straightforward process.

vocal snow
#

There's a search bar on the site

jagged adder
#

reaction and user

vocal snow
#

I see, so your check needs to have both those parameters

jagged adder
#

well now my traceback is

AttributeError: 'Reaction' object has no attribute 'author'
vocal snow
#

!d discord.Reaction.message

unkempt canyonBOT
vocal snow
#

You'll want to use this, and then .author

#

Or if you want the person who reacted

#

Then you use the user argument

jagged adder
vocal snow
#

Wdym

jagged adder
#

AttributeError: 'member_descriptor' object has no attribute 'author'

vocal snow
#

I'm guessing you literally did discord.Reaction.message.author

#

Anyways, you can learn oop later

#

You need to check that user.bot is False, str(reaction.emoji) == "..." and reaction.message.id == msg.id

jagged adder
#

user.bot means any bot ?

vocal snow
#

Yes

dark pine
#

good morning

#

i still need help with my bot

jagged adder
#

3 hrs of troubleshooting, googling and conversing, came down to 3 lines

dark pine
jagged adder
#

i know that feeling...

dark pine
#

yesterday i have read my code for like 16 times and im still on it, someone helped me to change my main from over 230 line to like 24 lines, and the bot isnt working

dark pine
#

the issue too that im not that good coding discord bot, it was my literal 27 hrs lol

#

i just started of a youtube tutorial

#

but like, i had a python class last Sem

#

where was the link i can copy the code to?

dull knot
#

Sheesh, help. Can't quite make this to work:

@bot.listen
async def on_ready():
    Message = await bot.fetch_guild(943462265317912576).get_channel(960392445135290408)
    Shuma = await bot.get_or_fetch_user(user_id="786978127816818698")
    await Shuma.send("Bot Online!")
    await Message.send("Bot Online!")

I'm trying to make the bot send a DM to me or Send a MSG to a channel after it becomes Online but it just doesn't work. No errors in the terminal though. All my cmds also work fine.

naive briar
dull knot
#

It's listening for the bot to become online?

naive briar
#

Use bot.event instead

dull knot
#

Don't they work the same?

naive briar
#

!d discord.ext.commands.Bot.listen

unkempt canyonBOT
#

@listen(name=None)```
A decorator that registers another function as an external event listener. Basically this allows you to listen to multiple events from different places e.g. such as [`on_ready()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_ready "discord.on_ready")

The functions being listened to must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.10)").

Example...
dull knot
#

I mean, the problem I'm facing here is that the bot won't send me a DM, nor does it send the Msg in the guild's specified channel

dull knot
#

Nope.

#

Does't send it in my DMs

vocal snow
#

Also you're awaiting get_channel not fetch _guild

#

And why does your get or fetch take a str ducky_beer

naive briar
dull knot
dull knot
#

Nah, still doesn't work.

vocal snow
#

How is get_or_fetch_user defined

naive briar
dull knot
vocal snow
#

Do you have an on_error event

#

Why is your error handling so broken

dull knot
#

local error handlers yes.

naive briar
#

Uhhhh

vocal snow
#

Need to edit the message with the new view

vocal snow
dark pine
naive briar
#

Uhhhhhhhh

naive briar
dull knot
#

I was working on getting the bot to DM first before the channel

dull knot
#

What cmd should I start with if I want to get started with learning databases and storing data? Or is it not recommended if I don't fully understand around 40% of Python Basics yet?

#

Gotchu, so I guess, for now, OOP & Async + familiarizing basics. Alright, will probably read about them later. Thanks for the feedback! ✔️

maiden fable
#

Do u think Danny uploaded a mirror package, named discord so that none can upload a malicious with that name?

heady citrus
#
    async def interaction_check(self, interaction) -> bool:
        if interaction.user.id != interaction.author.id:
            await intraction.response.send_message("You cant use dis kid", ephemeral=True)
            return
        else:
            return
#

any help? I dont want my buttons working for anyone other than the one who started the command

#

@naive briar

maiden fable
#

Nice

heady citrus
#

anyone @slate swan

#

Lol

maiden fable
#

Dude, stop pinging randoms

heady citrus
#

@maiden fable

maiden fable
#

Just add something in the else block

heady citrus
#

I need the author@of the embed

maiden fable
#

What embed

#

Tbh, @vocal snow is more experienced and will be more than happy to help you (:

vocal snow
slate swan
heady citrus
slate swan
#

exactly the point, why would you compare the user who invoked the interaction with its author, its literally the same thing

slate swan
#

yes sure. imagine not understanding the diffence between command author and an interaction'a author.

heady citrus
#

basically i want to get the id of the person who clicked on the button.. Then the one who started the command & compare them

#

if they not the same return

naive briar
#

You have to store the ID of the user in the view

heady citrus
#

since u can’t understand Lol

slate swan
#

why do you think the command author's data will be stored in the interaction?

vocal snow
slate swan
#

you need to set that up yourself

shrewd apex
#

pass the interaction or ctx depending on the command to the view which u subclassed

vocal snow
#

I think u shld use pychord

fading sleet
#

I wanted to add a giveaway command for my bot

#

but I've got an error

#

AttributeError: 'async_generator' object has no attribute 'flatten'

#

I searched this error on API reference, but I couldn't fix this error

fading sleet
#

users = await new_msg.reactions[0].users().flatten() this is the error section

vocal snow
#

!d discord.Reaction.users

unkempt canyonBOT
#

async for ... in users(*, limit=None, after=None)```
Returns an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.10)") representing the users that have reacted to the message.

The `after` parameter must represent a member and meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.

Changed in version 2.0: `limit` and `after` parameters are now keyword-only.

Examples

Usage...
vocal snow
#

There are examples there

shrewd apex
#

its now an async iterator object

#

u have ti iterate using async for

primal token
# shrewd apex its now an async iterator object

I wouldnt really call it an "async iterator object" as it may cause confusion as an "async iterator object" doesnt exactly exist, over something like a genexpr that would return an object named generator, but async iterator is a bit more clearer, i would say, as you would be referring to an object that implements __aiter__() and __anext__() that would return an awaitable object. I'm not saying you're wrong but you're not exactly correct either.

shrewd apex
#

bro did u type all that just to say my explanation wasn't complicated enough 💀

maiden fable
#

Lmao

vocal snow
#

okimi moment

shrewd apex
#

its clearer and more understandable to explain it as async iterator

ivory cave
#

is there a way for me to make a thread with discord.py ?

#

or i must use the threading lib

vocal snow
#

i mean, what do you need to thread

ivory cave
#

well long explanation but, im trying to get the bot to createchannels while simultaneously sending things in the channels

vocal snow
#

that's why asyncio is there, for concurrency

#

although if you're attempting to make a spam bot, it isn't going to work

ivory cave
#

if im making a spam bot i assume there is threading needed?

#

with the threading lib

#

the problem here is i cant make it make channels and simultaneously spam things in those channels while making them with one command

vocal snow
#

we don't help with spam bots here

ivory cave
#

ah, no im not making the bot so i can harm discord servers or anything like that

#

me and my friends use the bot for shits and giggles in our server although i understand your reason so

#

👍

vocal snow
#

"asynchronous iterator... An object"

primal token
#

Its more of a term as shown in the link, "async iterator" would be a term used for any object that implements the given methods in the documentation

vocal snow
#

exactly

#

async iterator object 👍

primal token
#

ok

vocal snow
errant night
#

bruh is there way to extract a specific pokemon sprite from this png using python?

rugged shadow
errant night
#

nope

rugged shadow
#

like, you just want to extract them into their own separate files

errant night
#

yep

rugged shadow
#

you could use something like Pillow

errant night
#

o

rugged shadow
#

then slice the image up into some size

errant night
#

ic

rugged shadow
#

idk if they are 32x32

#

or whatever

errant night
#

alr i will do it rn thank you

rugged shadow
#

np

shrewd apex
#

!pypi image-slicer

unkempt canyonBOT
errant night
shrewd apex
#

was?

errant night
shrewd apex
#

oh ok

errant night
#

still i will make a pokemon-based bot 💀 anyways have a good day

shrewd apex
#

gl have fun u never know u might make something new innovate 😉

errant night
#

😳 ty

boreal ravine
#

Anyone know why it isn't printing 2?

shrewd apex
boreal ravine
#

Yes

shrewd apex
#

u can just leave lenght none as default for that

boreal ravine
#

to_list?

shrewd apex
shrewd apex
#

u are using motor right?

boreal ravine
shrewd apex
#

yeah so u can do await bot.db.find({}).to_list(length=None)

spiral fern
#

guys i'm new at dpy2.0 so idk if much has changed but whenever I try using bot.user.avatar.url, it outputs as "NoneType object has no attribute 'url'"

#

what am I doing wrong?

sick thorn
#

hey guys , i want to make a discord bot. i have list of quotes. i want the bot to send it every morning 8:30 am on one of the server channel. how can i do this? im complete noob in making discord bot but i know python

vocal snow
spiral fern
#

no I'm pretty sure it's a default avatar

#

the one discord gives you if you don't have any

vocal snow
#

then you should use the display_avatar attribute instead of avatar

#

!d discord.User.display_avatar

unkempt canyonBOT
#

property display_avatar```
Returns the user’s display avatar.

For regular users this is just their default avatar or uploaded avatar.

New in version 2.0.
vocal snow
#

the bot died?

spiral fern
#

thanks, I'm new to dpy2 so I don't know if something has changed

#

I think I've heard something changed in the way you use bot.run or bot.login

vocal snow
spiral fern
#

something that has to do with async maybe

#

but I can't seem to find it anymore so idk

shrewd apex
#

dpy has them listed

spiral fern
#

what if I use run like a normal person?

#

instead of trying to async everything?

shrewd apex
#

i think he needs to change cog loading

spiral fern
#

i'm not using cogs rn

shrewd apex
#

use run

spiral fern
#

but yeah it did mess up my cogs with other projects

#

and it's something I haven't fixed yet

shrewd apex
#

if u use start u will have to setup ur own logger

shrewd apex
#

not necessary tho

unkempt canyonBOT
#

discord.utils.setup_logging(*, handler=..., formatter=..., level=..., root=True)```
A helper function to setup logging.

This is superficially similar to [`logging.basicConfig()`](https://docs.python.org/3/library/logging.html#logging.basicConfig "(in Python v3.10)") but uses different defaults and a colour formatter if the stream can display colour.

This is used by the [`Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") to set up logging if `log_handler` is not `None`.

New in version 2.0.
shrewd apex
#

there is a more detailed example in dpy github examples 🗿

slate swan
#

why a context manager to just run the bot?

pulsar thistle
#

guys i dunno whats wrong here it used to work, but maybe you could help?

'dict' object has no attribute 'Cog'
slate swan
#

await instance.start() directly is totally usable

primal token
#

You should only use it when running other processes in the same file so it closes which most people just kill the process

slate swan
#

still not needed

primal token
#

I still dont like the context managers usage with bots tbh

rugged shadow
#

what does a ctx manager even do to a bot

#

no, like what does those functions do in the commands.Bot impl

boreal ravine
primal token
# rugged shadow no, like what does those functions do in the commands.Bot impl

If were talking about what happens when __aenter__ and __aexit__ get called, well, When the context manager opens it opens a websocket connection with the gateway and when closing the lib checks if the bot is in a voice channel it disconnects the bot from the voice channel and then it disconnects from the gateway

rugged shadow
#

oh nice

#

ty

#

also why is there a slowmode here now 😔

primal token
#

Iirc it's dynamic and gets set by @unkempt canyon by the activity or amount of users in the channel or past history with discussions in a certain time frame

dark pine
#

How to you guys setup your json file to be updated?

#

I have a bot with virtual points, and i want to make sure every member starts with 0 points.
I dont want to make it manually by adding a new command

#

Is it possible?

ionic edge
#

how can i get options in hybrid commands

boreal ravine
#

Anyone know why?

slate swan
#

How do I make the bot change only one permission in a text channel and not affect the others permissions?

naive briar
#

!d discord.TextChannel.set_permissions

unkempt canyonBOT
#

await set_permissions(target, *, overwrite=see - below, reason=None, **permissions)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sets the channel specific permission overwrites for a target in the channel.

The `target` parameter should either be a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role") that belongs to guild.

The `overwrite` parameter, if given, must either be `None` or [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/latest/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite"). For convenience, you can pass in keyword arguments denoting [`Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions") attributes. If this is done, then you cannot mix the keyword arguments with the `overwrite` parameter.

If the `overwrite` parameter is `None`, then the permission overwrites are deleted.

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

how to send in specific channel after button pressed?

#

getting this error

#
AttributeError: 'NoneType' object has no attribute 'send'```
naive briar
#

How do you define channel2?

radiant parrot
#

channel2 = client.get_channel(channel_sent_in)

naive briar
radiant parrot
#

Im confused why it wldnt work

naive briar
#

Can you show the code of the command?

radiant parrot
#

Ofc 🙂

#
        await interaction.response.send_message(f'Approved and sent to #{channel_sent_in}!')
        embed_approve = discord.Embed(title=f"{channel_sent_in} ping!", color=discord.Color.purple())
        embed_approve.add_field(name='Message: ', value=f"{message.content}")
        embed_approve.add_field(name='Sent in by: ', value=f"{message.author}")
        embed_approve.set_footer(text=f'Provided by Donks#1048 • {current_time}')
        channel2 = client.get_channel(channel_sent_in)
        await channel2.send(embed=embed_approve)```
#

shld i change to fetch then?

#

Let me try that now 🙂

#
In channel_id: Value "staff-spam" is not snowflake.```
#

Got this error now

slate swan
#

you have to pass in an integer and staff-spam isnt an int

radiant parrot
slate swan
#

depends if channel_sent_in can be converted to an integer

radiant parrot
#

channel_sent_in = message.channel

naive briar
slate swan
radiant parrot
#

let me send my whole code

#

as might have to change bits around

#
async def on_message(message):
    button1 = Button(label="Approve!",style=discord.ButtonStyle.green)
    button2 = Button(label="Disapprove!",style=discord.ButtonStyle.red)
    view = View()
    view.add_item(button1)
    view.add_item(button2)
    message_channel = message.channel.id
    user_id = message.author.id
    channel_sent_in = message.channel
    # Check if message has content

    if message.content is not None and message_channel == 640107609801752577 or message_channel == 1011257952142888970:
        # Add message content to list
        msg_list.append(message.content)
        print(msg_list)
        channel = client.get_channel(1017118446284177419)
        embed = discord.Embed(title=f'Message detected in #{channel_sent_in}', color=10181046)
        embed.add_field(name='Message: ', value=f'{message.content}')
        embed.add_field(name='User: ', value=f'{message.author}')
        embed.set_footer(text=f'Provided by Donks#1048 • {current_time}')
        await channel.send(embed=embed, view=view)
    async def button_callback(interaction):
        await interaction.response.send_message(f'Approved and sent to #{channel_sent_in}!')
        embed_approve = discord.Embed(title=f"{channel_sent_in} ping!", color=discord.Color.purple())
        embed_approve.add_field(name='Message: ', value=f"{message.content}")
        embed_approve.add_field(name='Sent in by: ', value=f"{message.author}")
        embed_approve.set_footer(text=f'Provided by Donks#1048 • {current_time}')
        channel2 = client.get_channel(channel_sent_in) or await client.fetch_channel(int(channel_sent_in))
        await channel2.send(embed=embed_approve)
    async def button_callback_2(interaction):
        await interaction.response.send_message(f'Disapproved and warned user')
        await interaction.followup.send(f"-warn {message.author.mention}")

    button1.callback = button_callback
    button2.callback = button_callback_2```
naive briar
radiant parrot
naive briar
radiant parrot
#

Yea so message_channel to monitor two channels and see if message sent in it

naive briar
#

message_channel is just the ID of channel_sent_in

radiant parrot
#

then channel_sent_in to say which out of the two was sent in

#

yea

drifting arrow
#

I want to put my bot in 2 discords and if an event happens, say "!ping" i want to my bot to send "pong" to both discords.
how would I achieve this?

rugged shadow
drifting arrow
rugged shadow
#

you could iterate through bot.guilds, filter out other discords, send message to other channel

radiant parrot
drifting arrow
#

would "bot.guild.get_channel(123)" work even if bot is in 2 different guilds?

drifting arrow
#

would I first have to get the guild?

naive briar
rugged shadow
#

yes

naive briar
# naive briar Ah, well

Just replace

channel2 = client.get_channel(channel_sent_in) or await client.fetch_channel(int(channel_sent_in))
await channel2.send(embed=embed_approve)

with

await channel_sent_in.send(embed=embed_approve)
#

And I think you're fine

slate swan
#

i just want to change one permission and it changes all

#

by "changes all" I mean like this:

#

I wanted to keep the permissions that the member had already set and just change the permission of send_messages, for example

naive briar
naive briar
radiant parrot
#

one more question, how would i go about warning the player if i press the disapprove button?

#

got this so far but dnt work

#
async def warn(ctx, member: discord.Member, *, reason="Not Specified"):
    channel = client.get_channel(1013425592898703470)
    if member == ctx.author:
        await ctx.send("You cannot warn urself!")
    else:
        em = discord.Embed(title="**WARNED**", description=f"{member} was warned because: {reason}", color=discord.Color.red())
        em2 = discord.Embed(title="**WARNED**", description=f"You have been warned because: {reason}", color=discord.Color.red())
        await member.send(embed=em2)
        await ctx.send(embed=em)```
#
        await interaction.response.send_message(f'Disapproved and warned user')
        await interaction.followup.send(f"-warn {message.author.mention}")```
errant coral
#

Anyone know whats wrong

from nextcord import commands

class Bot(commands.Bot):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.persistent_views_added = False

    async def on_ready(self):

        print('Logged in as ' + bot.user.name)
        print('-----------------------------------------------')


bot = Bot(command_prefix="-", intents=nextcord.Intents.all())

@bot.slash_command(description="Test!", guild_ids=[989497807595507752])
@commands.has_permissions(administrator=True)
async def apply(ctx):
    await ctx.guild.create_text_channel(f"{ctx.user.name}-apply")
    embed = nextcord.Embed(
        title="Your Application has been created!",
        description="Go to the channel that has been created for your application <#>"
    )
    await ctx.channel.send(embed=embed)

bot.run("token")```
Error:

C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\health_check.py:23: DistributionWarning: discord.py is installed which is incompatible with nextcord. Please remove this library by using pip3 uninstall discord.py
warn(message, DistributionWarning, stacklevel=0)
Traceback (most recent call last):
File "c:\discordBot.py\main.py", line 2, in <module>
from nextcord import commands
ImportError: cannot import name 'commands' from 'nextcord' (C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord_init_.py)

tidal hawk
#

Read the error message :D

#

"Please remove this library by using pip3 uninstall discord.py"

shrewd apex
#

lmao no two or 3 timing between discord api libs 🤣

rare echo
livid jacinth
#

Hey, does somebody know how to create slash commands?

slate swan
livid jacinth
#

I dont know what lib i have to use

#

And whats the best lib for that

silk fulcrum
#

any actually

slate swan
silk fulcrum
#

except pycord

slate swan
#

💀

silk fulcrum
#

dont use pycord

slate swan
#

py-cord 🫂

slate swan
livid jacinth
#

Discord.ext

#

And Discord

silk fulcrum
#

lol

slate swan
#

see the second message in the channel's pins

livid jacinth
#

Ah okay

slate swan
silk fulcrum
#

it just even sounds bad for me

livid jacinth
#

Im currently not at home

slate swan
#

nice

slate swan
livid jacinth
#

I have to read it later

silk fulcrum
slate swan
slate swan
#

not like the best as in universally the best 💀

#

autocorrect

silk fulcrum
#

lol

errant coral
#

cant find the problem

from nextcord.ext import commands

class Bot(commands.Bot):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.persistent_views_added = False

    async def on_ready(self):

        print('Logged in as ' + bot.user.name)
        print('-----------------------------------------------')


bot = Bot(command_prefix="-", intents=nextcord.Intents.all())

@bot.slash_command(description="Test!", guild_ids=[989497807595507752])
@commands.has_permissions(administrator=True)
async def apply(ctx):
    await ctx.guild.create_text_channel(f"{ctx.user.name}")
    embed = nextcord.Embed(
        title="Your Application has been created!",
        description="Go to the channel that has been created for your application <#>"
    )
    await ctx.channel.send(embed=embed)

bot.run("Token")```
error:

Ignoring exception in command None:
nextcord.ext.commands.errors.CommandNotFound: Command "apply" is not found```

silk fulcrum
errant coral
#

i tryed both

silk fulcrum
errant coral
#

nothing just wait 2 sec need to try something

#

@bot.slash_command(description="Test!", guild_ids=[989497807595507752])

#

that was the problem

#

im blind

radiant parrot
#

why is this not warning a user when dissaprove button pressed?

#
async def warn(ctx, member: discord.Member, *, reason="Not Specified"):
    channel = client.get_channel(1013425592898703470)
    if member == ctx.author:
        await ctx.send("You cannot warn urself!")
    else:
        em = discord.Embed(title="**WARNED**", description=f"{member} was warned because: {reason}", color=discord.Color.red())
        em2 = discord.Embed(title="**WARNED**", description=f"You have been warned because: {reason}", color=discord.Color.red())
        await member.send(embed=em2)
        await ctx.send(embed=em)
    async def button_callback_2(interaction):
        await interaction.response.send_message(f'Disapproved and warned user')
        await interaction.followup.send(f"-warn {message.author.mention}")```
silk fulcrum
#

first of all it's @client.command()

#

with brackets

#

and second i dont even see any buttons here, only callback

radiant parrot
#

there is

#

let me send code for them

#
async def on_message(message):
    button1 = Button(label="Approve!",style=discord.ButtonStyle.green)
    button2 = Button(label="Disapprove!",style=discord.ButtonStyle.red)
    view = View()
    view.add_item(button1)
    view.add_item(button2)
    message_channel = message.channel.id
    user_id = message.author.id
    channel_sent_in = message.channel
    # Check if message has content

    if message.content is not None and message_channel == 640107609801752577 or message_channel == 1011257952142888970:
        # Add message content to list
        msg_list.append(message.content)
        print(msg_list)
        channel = client.get_channel(1017118446284177419)
        embed = discord.Embed(title=f'Message detected in #{channel_sent_in}', color=10181046)
        embed.add_field(name='Message: ', value=f'{message.content}')
        embed.add_field(name='User: ', value=f'{message.author}')
        embed.set_footer(text=f'Provided by Donks#1048 • {current_time}')
        await channel.send(embed=embed, view=view)
    async def button_callback(interaction):
        await interaction.response.send_message(f'Approved and sent to #{channel_sent_in}!')
        embed_approve = discord.Embed(title=f"{channel_sent_in} ping!", color=discord.Color.purple())
        embed_approve.add_field(name='Message: ', value=f"{message.content}")
        embed_approve.add_field(name='Sent in by: ', value=f"{message.author}")
        embed_approve.set_footer(text=f'Provided by Donks#1048 • {current_time}')
        await channel_sent_in.send(embed=embed_approve)
silk fulcrum
radiant parrot
#
    button2.callback = button_callback_2```
silk fulcrum
#

where is that

#

and also please make highlights

#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

radiant parrot
#

let me send whole code

#
@client.command()
async def warn(ctx, member: discord.Member, *, reason="Not Specified"):
    channel = client.get_channel(1013425592898703470)
    if member == ctx.author:
        await ctx.send("You cannot warn urself!")
    else:
        em = discord.Embed(title="**WARNED**", description=f"{member} was warned because: {reason}", color=discord.Color.red())
        em2 = discord.Embed(title="**WARNED**", description=f"You have been warned because: {reason}", color=discord.Color.red())
        await member.send(embed=em2)
        await ctx.send(embed=em)
#

@client.event
async def on_message(message):
    button1 = Button(label="Approve!",style=discord.ButtonStyle.green)
    button2 = Button(label="Disapprove!",style=discord.ButtonStyle.red)
    view = View()
    view.add_item(button1)
    view.add_item(button2)
    message_channel = message.channel.id
    user_id = message.author.id
    channel_sent_in = message.channel
    # Check if message has content

    if message.content is not None and message_channel == 640107609801752577 or message_channel == 1011257952142888970:
        # Add message content to list
        msg_list.append(message.content)
        print(msg_list)
        channel = client.get_channel(1017118446284177419)
        embed = discord.Embed(title=f'Message detected in #{channel_sent_in}', color=10181046)
        embed.add_field(name='Message: ', value=f'{message.content}')
        embed.add_field(name='User: ', value=f'{message.author}')
        embed.set_footer(text=f'Provided by Donks#1048 • {current_time}')
        await channel.send(embed=embed, view=view)
    async def button_callback(interaction):
        await interaction.response.send_message(f'Approved and sent to #{channel_sent_in}!')
        embed_approve = discord.Embed(title=f"{channel_sent_in} ping!", color=discord.Color.purple())
        embed_approve.add_field(name='Message: ', value=f"{message.content}")
        embed_approve.add_field(name='Sent in by: ', value=f"{message.author}")
        embed_approve.set_footer(text=f'Provided by Donks#1048 • {current_time}')
        await channel_sent_in.send(embed=embed_approve)
    async def button_callback_2(interaction):
        await interaction.response.send_message(f'Disapproved and warned user')
        await interaction.followup.send(f"-warn {message.author.mention}")

    button1.callback = button_callback
    button2.callback = button_callback_2
silk fulcrum
#

buttons callbacks should be set before adding the buttons to the view, and you are doing that after everything is done and the message is sent

#

and don't forget that if you are moving the button.callback = ... up, then you should move your callback functions up too, so they won't be referenced before assigement

radiant parrot
#

yes i have done this 🙂

#

how would i now make it so when disapprove button clicked, it will execute the warn command

silk fulcrum
radiant parrot
silk fulcrum
#

and also i dont remember but some smart people said that

broken nexus
#

so ive got this discord.py bot on github, and i put it on heroku. it was written in 1.7.3 discord.py and i want to update it to 2.0, can i just update the requirements.txt file and change the code directly on github? will the changes be applied automatically on heroku?

silk fulcrum
#

i would exec the command somewhere myself tbh

slate swan
#

though I don't prefer doing that myself

#

how to add nsfw cmds in bot??

honest shoal
slate swan
#

Hello guys i got question i wanna make my bot add user in ticket when i send his id or user automatique since im New in discord.py can u help me guys please

honest shoal
#

you just have to change channel's permissions

slate swan
honest shoal
primal token
#

Its a quite subjective general question which depends on abstractions

silk fulcrum
# slate swan how to add nsfw cmds in bot??

depends on what you mean by "nsfw", because discord doesn't have any "nsfw commands" implemented, so if you want to check the age or warn the user you have to do it yourself

#

also you can make a command so it could only be executed in nsfw channel

slate swan
#

you probably mean the resources required by "how to make nsfw command"?
if yes, you're looking for some NSFW api, can google and find plenty of them

silk fulcrum
slate swan
honest shoal
primal token
#

?

slate swan
slate swan
honest shoal
#

it reminds me of an update by dank memer

slate swan
honest shoal
#

wait a min lemme find it

rare echo
slate swan
#

we do

slate swan
#

I just realized I wasn't supposed to post that too

honest shoal
slate swan
#

I dont know how do i make bot do it

#

$add command

silk fulcrum
#

you are importing from bot.py, you should just use import constants

#

same dir import

slate swan
#

When i send user the bot add him in ticket

#

Roblox 😭

#

Bro is definitely scamming some little kids

slate swan
#

I dont even play roblox

#

I got paid for it

slate swan
silk fulcrum
#

idk how that works

slate swan
#

Hi master

silk fulcrum
#

hi

slate swan
#

I think you wanna help him right @silk fulcrum

rare echo
slate swan
#

a discord bot for trading 💀

slate swan
#

ew

rare echo
slate swan
#

Hunter is typing

slate swan
#

just completing

#

Oh

maiden fable
# honest shoal

I'm thinking... Why tf Dank Memer even needs too much money to run. Dude just buy a VPS for like 10-15 USD a month and you're all set. Imagine telling people you need hundreds of dollars a month to run a bot

primal token
#

You only need like 20USD a month which you can always buy offers or bundles, which include more time or performance

slate swan
#

I’m hosting on aws for free

primal token
#

ok

slate swan
#

😊

maiden fable
slate swan
#

😭

primal token
#

You know what i fucking mean

rare echo
#

no, severe e-rash

primal token
#

😔😒

slate swan
#

😔

silk fulcrum
#

😔

primal token
#

First time i get correct for using an incorrect word

maiden fable
primal token
#

Hunter dont delete the message bro

primal token
maiden fable
#

Did it so u don't feel bad just cz I corrected u

maiden fable
rare echo
silk fulcrum
rare echo
#

both are correct spelling

#

ok i’m done lmfao

primal token
#

ok

rare echo
maiden fable
primal token
#

!ot

unkempt canyonBOT
primal token
#

Seriously lets stop fooling around

silk fulcrum
#

to!

maiden fable
#

Anyways, I'm happy being a bot dev. At least I don't get caught into these traps lol

silk fulcrum
maiden fable
#

He's andy v2

silk fulcrum
#

oh ok

primal token
dull knot
#

Question:
How can I turn an Emoji into a link? Somewhat like this (Image)
So far, I have this code:

    @commands.slash_command(name="e-magnify", description="Makes an emoji larger.")
    async def magnify_emoji(self, ctx, emoji:disnake.Emoji):
        EmojiEmbed = disnake.Embed(title="...",
                                   description="...",
                                   colour=disnake.Colour(0x2f3136))
        await ctx.send(embed=EmojiEmbed)
#

Or rather turning it into a link... How can I get the bot to get the link of the emoji?

#

If I can't reply today, I'll ask again tomorrow lol. Gotta do some assignments

unkempt canyonBOT
dull knot
gusty shard
#

how can i ping roles

silk fulcrum
unkempt canyonBOT
primal token
silk fulcrum
#

or <@your_role_id>

primal token
#

🐧

slate swan
#

lmao

silk fulcrum
dull knot
gusty shard
silk fulcrum
unkempt canyonBOT
primal token
#

ok

slate swan
#

hi okimii

honest shoal
primal token
dull knot
honest shoal
slate swan
paper sluice
#

:sus:

primal token
paper sluice
#

vote em

slate swan
primal token
#

Indirect points smh

silk fulcrum
primal token
#

Real mature on your part

rare echo
slate swan
primal token
#

!ot

unkempt canyonBOT
paper sluice
#

lol

primal token
#

.topic

lament depotBOT
#
**What feature would you be the most interested in making?**

Suggest more topics here!

slate swan
primal token
#

ok

slate swan
#

yes

maiden fable
#

Nice quarrel

silk fulcrum
quaint epoch
#

Hey what happened to okimii

maiden fable
#

Idk

silk fulcrum
maiden fable
#

He deleted his account and github

#

or did he

quaint epoch
honest shoal
paper sluice
#

no

quaint epoch
quaint epoch
#

Or just doesn't like social media

slate swan
#

so cringe

primal token
#

cringw

paper sluice
#

reqwst

slate swan
#

yes

#

ashlwy

paper sluice
#

.uwu does this work here?

primal token
#

It just doesnt know the type?

maiden fable
ionic moss
#

How do I get a Slash Command ID? I've tried bot.get_command(<String name>).id but HybridCommand has no attribute named id

maiden fable
ionic moss
#
from bot import Bot
from discord.ext.commands import Bot as _Bot # `Bot` is probably an instance of `commands.Bot`
Bot: _Bot
print(Bot)
primal token
#

Youre not using the Class thats not an error just a warning

paper sluice
#

I think you can set the root directory in a config file for your project, like pyproject.toml or something related to your env

ionic moss
paper sluice
#

It should

primal token
ionic moss
#

hm

#

¯_(ツ)_/¯

slate swan
primal token
#

If names collide you use a suffix with a _ and not a prefix of _

brazen raft
brazen raft
#

I remember it raising an exception consistently on my machine

brazen raft
#

I imagine it should

primal token
brazen raft
#

I know

primal token
#

ok

brazen raft
#

Wait it should only work if ext is a subpackage in discord

#

If it's a simple folder, it explains why it doesn't work

#

And why from discord.ext import commands does

primal token
#

Yes

vocal snow
#

you have a comma after channel_id

paper sluice
ruby anchor
#

Anyone know how to make a bot edit a message the bot sent

sick birch
unkempt canyonBOT
#
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/latest/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`File`](https://discordpy.readthedocs.io/en/latest/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
sick birch
#

You’ll notice this returns the sent message

ruby anchor
#

is it possible to do with a message.reply

sick birch
#

I believe that returns the sent message as well

#

A lot of discords CREATE endpoints will return the created resource

radiant parrot
#
async def send_warning(user, reason, channel):
    em = discord.Embed(title="**WARNED**", description=f"{user} was warned because: {reason}",
                       color=discord.Color.red())
    em2 = discord.Embed(title="**WARNED**", description=f"You have been warned because: {reason}",
                        color=discord.Color.red())
    await channel.send(embed=em)
    await user.send(embed=em2)

@client.command()
async def warn(ctx, user: discord.Member):
    await send_warning(user, 'my fancy reason')```
#

how to send first warning to channel?

#

as error is py await send_warning(message.author, f'Suggesting non-needed post for {channel_sent_in}') TypeError: send_warning() missing 1 required positional argument: 'channel'

slate swan
#
class User:
  name: str
  _id: int

async def send_warning(user: User, reason: str, channel):
  ...

#calling it using
await send_warning(user, "fancy reason", channel_where)
ruby anchor
slate swan
radiant parrot
slate swan
#

uhh guys how to fix

#

"decouple.UndefinedValueError: SECRET_KEY not found. Declare it as envvar or define a default value"

#

how to fix this issue??

violet wigeon
#

Guys I want to give a role when something happened (not member joined). Which event should I use? I tried on_ready and on_connect but it did not work.

slate swan
#

heres whats in users.json

{"755155481458114630": {"experience": 36, "level": 2}}

honest shoal
primal token
violet wigeon
#

Or like rank system. When you text 100+ messages I want to give a role to you

honest shoal
honest shoal
violet wigeon
honest shoal
#

Oh, I got it

#

Then you need to pass your event using dispatch

violet wigeon
#

Is this an event?

#

Oh

#

Sorry

violet wigeon
weary flume
#
if key in keylist and key not in redeemed:
#

is there something wrong with this?

radiant parrot
honest shoal
#

I don't really know much about it nor it's documented

void flax
violet wigeon
#

Okay

weary flume
#

ill just send the full thing bc my brain died

maiden fable
#

Nice

weary flume
#
@client.command()
async def redeem(ctx, key):
    tokens = open(r"C:\Users\ewill\OneDrive\Desktop\DevScripts\PYFILES\tokens\keys.txt", "r")
    used = open(r"C:\Users\ewill\OneDrive\Desktop\DevScripts\PYFILES\tokens\usedkey.txt", "r")
    keylist = tokens.read()
    redeemed = used.read()
    if key in keylist and key not in redeemed:
        await used.write(key)
        await ctx.reply(f"`{key}`-is now redeemed.")
        user = ctx.message.author
        role = discord.utils.get(user.guild.roles, name="Buyer")
        await user.add_roles(role, atomic=True)
        ticket = await ctx.guild.create_text_channel(f"{ctx.author.name}#{ctx.author.discriminator}") 
        await ctx.reply(f"Ticket created #{ticket}")
        await ticket.send(f"{ctx.author.mention} // `.send [YOUR MESSAGE]` // `This will delete in 60 seconds`")
        await asyncio.sleep(60)
        await ticket.delete()
    elif key in keylist and redeemed:
        await ctx.reply('`Token Already Redeemed`')
    else:
        await ctx.reply('`Token not found`')
violet wigeon
void flax
#

elif key in keylist and redeemed

#

this is probably a gotcha

#

you mean
elif key in keylist and key in redeemed

weary flume
#

let me check

#

bot still wont say anything

#
@client.command()
async def redeem(ctx, key):
    tokens = open(r"C:\Users\ewill\OneDrive\Desktop\DevScripts\PYFILES\tokens\keys.txt", "r")
    used = open(r"C:\Users\ewill\OneDrive\Desktop\DevScripts\PYFILES\tokens\usedkey.txt", "r")
    keylist = tokens.read()
    redeemed = used.read()
    if key in keylist and key not in redeemed:
        await used.write(key)
        await ctx.reply(f"`{key}`-is now redeemed.")
        user = ctx.message.author
        role = discord.utils.get(user.guild.roles, name="Buyer")
        await user.add_roles(role, atomic=True)
        ticket = await ctx.guild.create_text_channel(f"{ctx.author.name}#{ctx.author.discriminator}") 
        await ctx.reply(f"Ticket created #{ticket}")
        await ticket.send(f"{ctx.author.mention} // `.send [YOUR MESSAGE]` // `This will delete in 60 seconds`")
        await asyncio.sleep(60)
        await ticket.delete()
    elif key in keylist and key in redeemed:
        await ctx.reply('`Token Already Redeemed`')
    else:
        await ctx.reply('`Token not found`')
void flax
#

well. Put some logging messages or print statements and make sure it's running at all

weary flume
#

ok

#

yeah its not

#

before it even gets to the first part

#

im gonna kms

void flax
#

is this a slash command?

weary flume
#

no

#

it does .redeem

void flax
#

do you have other commands that are working?

weary flume
#

yeah i tried another command and it works

#

it started acting up

#
if key in keylist and key not in redeemed:
#

when i added this part

weary flume
#

no

shrewd apex
#

ppl who use full path 😔

weary flume
#

im selling pings in my discord server

silk fulcrum
weary flume
#

i just want it to work CRY

maiden fable
slate swan
#

people who use one drive 🗿

shrewd apex
slate swan
#

slow af + resource consuming

maiden fable
#

And paid ;-;

vale wing
#

People who never close files opened with open are sus

slate swan
#

thats y use context managers for open ops

maiden fable
#

Or they have probably forgot that and then rewrite their whole program just cz there is a massive resource usage

primal token
#

!ot

unkempt canyonBOT
vale wing
#

!to

unkempt canyonBOT
#
Did you mean ...

» microsoft-build-tools
» tools
» off-topic-names

void flax
#

None of this has anything to do with why his program isn't working. Yes, closing the file is a good idea, but don't they close at the end of the function anyway?

shrewd apex
slate swan
#

nope they still remain open

vale wing
#

Btw looking at the path I have some bad suspects

slate swan
#

whats the issue with your command tho?

fallen vector
#

how to make bot with oython

vale wing
#

tokens

maiden fable
vale wing
#

What tokens

weary flume
#

its like serial numbers

#

they get after buying

#

RrSnyx9aXU
oDM62ZQXsF
7Nkpp9IIpn
PtBVrRBVWv
TIUiPjep4t

#

looks like that

fallen vector
#

how to make bot with oython

shrewd apex
#

sussy sus

vale wing
#

That's not some 3rd party thing right?

shrewd apex
primal token
shrewd apex
slate swan
shrewd apex
#

noid just wants to refute whatever i speak 🥲

vale wing
#

You take your python, feed it and then it goes(?) to learning courses. After it learns, it needs a brain implant so it can code, after that it will create a bot for you if it studied hard

primal token
shrewd apex
#

🗿

primal token
#

Maybe study up on literature or even better the whole language of English!

shrewd apex
#

...

primal token
shrewd apex
#

that way we will code a discord bot in english

slate swan
#

don't think one onedrive provides anything particularly that google drive doesn't

shrewd apex
#

idk i don't use one drive either

#

i use nothing

slate swan
primal token
#

English the programming language is terrible

shrewd apex
#

i am just gonna go take a break 🥲🚶

slate swan
#

shore

primal token
cold sonnet
#

Noid am I doing good?

primal token
slate swan
#

lolcode is better

shrewd apex
#

queen elizabeth died pithink

primal token
#

Names start with capital letters and so do sentences.

shrewd apex
#

⚰️

sick birch
cold sonnet
#

The Pal Street Boys say writing a name in lowercase is taking the pride of it away.

void flax
sick birch
#

But discuss in OT please

cold sonnet
#

Imagine doing Queen Elizabeth like that.

void flax
#

also

primal token
void flax
#

I don't think it's async, so you can't use await on it

#

but maybe I'm wrong about that

shrewd apex
#

noid go check google

#

its II

primal token
#

I dont live in England so i dont need to

#

We have an old man that falls off a bike😔

shrewd apex
primal token
#

How is that arguing though?

shrewd apex
#

nvm pithink

#

bad choice of words

primal token
silk fulcrum
cold sonnet
#

that's a lot of seconds

void flax
# slate swan nope they still remain open

when a variable is garbage collected, it calls the __del__ method of the file. This will close the file. If there are no references to a variable, its __del__ will eventually get called

shrewd apex
primal token
#

Shes probably chilling in her room knowing she has retired

void flax
#

Obviously it is better to just close it explicitly though

shrewd apex
vale wing
shrewd apex
#

consuming memory

void flax
primal token
vale wing
#

Help my screen is blue for some reason 😢

cold sonnet
#

turn it off and never turn it on again

#

or put it in rice

vale wing
#

Is it okay if I put it into sushi

cold sonnet
#

no

vale wing
#

But it has rice

cold sonnet
#

fish have a bad effect on monitors

vale wing
#

Oh okay

primal token
#

Fish makes a monitor act a bit fishy

slate swan
cold sonnet
#

you know what else is fishy

#

Ashley, do you have anything to say about it

primal token
#

!ot

unkempt canyonBOT
primal token
#

Use ot channels for discussions that arent on topic!

cold sonnet
#

ratio

shrewd apex
#

i mean its not ancient times so atbest they gonna get a holiday at worst nothing happens pithink

slate swan
cold sonnet
#

completely missed it

slate swan
#

such a long token

#

that code....jeez

woeful yoke
#

hey

#

please help me guys

#

nextcord.ext.commands.errors.MissingRequiredArgument: ctx is a required argument that is missing.
I'm getting this error
there is a self parameter i have. When i delete it the bot's work but i need that self parameter
what can i do?

#

why does the code not see the ctx parameter

cold sonnet
#

could you show the rest of the code that is above this?

#

why are you using add_command?

vocal snow
#

you're supposed to load commands in cogs with bot.add_cog

woeful yoke
woeful yoke
#

I already have

cold sonnet
#

did you use load_extension?

vocal snow
woeful yoke
#

where should I use it

woeful yoke
cold sonnet
#

or with async if you're on 2.0

ionic edge
#
@client.command()
async def load(ctx, extension):
    client.load_extension(f"cogs.{extension}")
    await ctx.send(f"Loaded {extension}.")
    print(f"Loaded {extension}.")```
#
  client.load_extension(f"cogs.{extension}")
RuntimeWarning: Enable tracemalloc to get the object allocation traceback```
woeful yoke
primal token
vocal snow
#

why

ionic edge
vocal snow
#

what do you understand from this line

RuntimeWarning: coroutine 'BotBase.load_extension' was never awaited

#

hint: it's asking you to await something

ionic edge
#

wait should i use await client.load??

primal token
#

?

spice carbon
#

is there any listener to the audit logs of a guild?

violet wigeon
#

Omg I am gonna lose my mind

vocal snow
#

kk

violet wigeon
#

guys how can i add a role automatically when something happened (not member joined)

unkempt canyonBOT
#

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

Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")s.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
vocal snow
#

just call this when you want to

#

you can get the member with guild.get_member if you have an id

violet wigeon
vocal snow
#

what is the point

violet wigeon
#

there is no event which does meet my request

vocal snow
#

you haven't told us what the request is

violet wigeon
vocal snow
#

you've only told us what it's not which doesn't narrow it down

violet wigeon
#

at 1000 point i wanna give a role

#

not me the bot

vocal snow
#

what is 1000 point

violet wigeon
vocal snow
#

ok, so you're storing that data yourself right

violet wigeon
primal token
violet wigeon
primal token
violet wigeon
vocal snow
#

ignore okimi

primal token
#

Hes not even here

vocal snow
#

mhm

primal token
#

How can you ignore someone that isnt participating in a conversation?

violet wigeon
#

guys can we get to the point?

open narwhal
#

not related to discord.py itself but I wanted to use it for a bot.

Is there a dictionary like data structure that would let me access an entry using 2 different keys like for example:

datastructure = {
"key1", "100" --- maps to ----> {entry 1}
"key2", "105" --- maps to ----> {entry 2}
}

so when I do 
datastructure.get['key1'] or datastructure.get['100'] I would receive {entry 1}
datastructure.get['key2'] or datastructure.get['105'] = {entry 2}

and it can be assumed that there will never be conflicts with the keys

violet wigeon
#

i couldn't find anything about this

vocal snow
violet wigeon
vocal snow
#

ok but you're storing the member id right

violet wigeon
primal token
vocal snow
violet wigeon
open narwhal
vocal snow
# violet wigeon

so you're storing user_id but no information of the guild, how will you get the Member then

unkempt canyonBOT
#

@dataclasses.dataclass(*, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False)```
This function is a [decorator](https://docs.python.org/3/glossary.html#term-decorator) that is used to add generated [special method](https://docs.python.org/3/glossary.html#term-special-method)s to classes, as described below.

The [`dataclass()`](https://docs.python.org/3/library/dataclasses.html#dataclasses.dataclass "dataclasses.dataclass") decorator examines the class to find `field`s. A `field` is defined as a class variable that has a [type annotation](https://docs.python.org/3/glossary.html#term-variable-annotation). With two exceptions described below, nothing in [`dataclass()`](https://docs.python.org/3/library/dataclasses.html#dataclasses.dataclass "dataclasses.dataclass") examines the type specified in the variable annotation.

The order of the fields in all of the generated methods is the order in which they appear in the class definition.
open narwhal
#

ah

vocal snow
#

what

primal token
open narwhal
#

it's alright, thank you for all the help ❤️

violet wigeon
vocal snow
#

no, it gives user information

violet wigeon
#

every member has a userid

vocal snow
#

users can be in many guilds

#

member is only for 1 guild

violet wigeon
#

oh

#

okay

#

how can i store member then 🙂

vocal snow
vocal snow
violet wigeon
#

what will this do for me

vocal snow
#

so u can get the guild

#

and then get the member

violet wigeon
#

okay

#

then what?

vocal snow
#

then add roles to the member

vocal snow
violet wigeon
#

which event or command does this thing

vocal snow
#

wtf are you talking about

#

you store user_id and guild_id

#

when user points >= 1000

#

bot.get_guild to get guild

#

bot.get_member to get member

#

member.add_roles to add roles

open narwhal
# vocal snow sounds like you want a multidict

It behaves mostly like a regular dict but it may have several values for the same key and preserves insertion ordering.
Is this the one you are referring to?

I wanted the opposite thing, different keys pointing to the same value/row.

#

posting links arent against the rules right

vocal snow
#

i wasn't referring to a particular module, just the concept

vocal snow
violet wigeon
#

okay

open narwhal
#

aah okay

violet wigeon
#

but we doing things under @bot.command or @bot.event

primal token
violet wigeon
#

which one should i use

vocal snow
open narwhal
vale wing
vocal snow
#

💀

vale wing
#

I was just testing out link regex 😩

open narwhal
#

he do be kinda sussy tho

slate swan
#

guys how do i make my bots every 7 hours send annoucement ?

primal token
#

!d discord.ext.tasks.loop

unkempt canyonBOT
#

@discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/latest/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
primal token
slate swan
#

in which lines

void flax
vale wing
#

Create some class with overridden __del__ and see if it gets invoked?

slate swan
heady citrus
#

@slate swan

slate swan
#

is there a way to make that User 1 button be same width as User 2 .. more text button?

#

cause discord removes spaces

sick birch
#

Unless you want to add a lot of 0 width chars

#

Which looks weird on different devices

slate swan
#

i think making reference in message above buttons and then using numbers is better way

sick birch
#

E

#

Just had to make sure my internet was working

#

This chat too quiet

primal token
sick birch
#

This chat does that to you

#

Constantly on edge for the next “intents is a required argument” question

primal token
sick birch
#

“My commands don’t work no errors”

dark pine
#

how can i put the command to work for only some roles

#

like not for all

primal token
#

!d discord.ext.commands.has_role

unkempt canyonBOT
#

@discord.ext.commands.has_role(item)```
A [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member invoking the command has the role specified via the name or ID specified.

If a string is specified, you must give the exact name of the role, including caps and spelling.

If an integer is specified, you must give the exact snowflake ID of the role.

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

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

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

ty

simple kettle
#
async def notifier_channel(ctx, channel : discord.TextChannel):

I want this to have a error handling function incase they dont provide a text channel. How do I do that?

dark pine
#

the check() returns with errors

wintry panther
#

how do i add choice slash commands to my bot? like an option to choose from like: berry,fruit,egg,bananana that sort of thing

slate swan
primal token
slate swan
primal token
#

?

naive briar
primal token
#

You can always lower the string you will use to check in an expression

bright wedge
#

how i can add 2 button in 1 message in discord.py v2.0?

slate swan
naive briar
slate swan
wintry panther
primal token
#

over a type

slate swan
unkempt canyonBOT
#

typing.Literal```
A type that can be used to indicate to type checkers that the corresponding variable or function parameter has a value equivalent to the provided literal (or one of several literals). For example:

```py
def validate_simple(data: Any) -> Literal[True]:  # always returns True
    ...

MODE = Literal['r', 'rb', 'w', 'wb']
def open_helper(file: str, mode: MODE) -> str:
    ...

open_helper('/some/path', 'r')  # Passes type check
open_helper('/other/path', 'typo')  # Error in type checker
```...
primal token
#

why not just do

if message.content.lower() in words:
```?
wintry panther