#discord-bots

1 messages · Page 1050 of 1

maiden fable
#

Not everytime

waxen python
#

i can share resources through passing in functions, the only issue is self is not something im aware i can pass

pliant gulch
#

You can

waxen python
#

(im not)

pliant gulch
#

!d discord.ext.commands.Bot.get_cog

unkempt canyonBOT
#

get_cog(name, /)```
Gets the cog instance requested.

If the cog is not found, `None` is returned instead.

Changed in version 2.0: `name` parameter is now positional-only.
pliant gulch
#

Pass this as self to the method

vale wing
#

And what I am trying to tell you

# utils.py
async def your_func(bot, *args):
    ...

# your_cog.py
await your_func(self.bot, ...)

# api.py
class APICog(commands.Cog):
    def __init__(...):
        # you can construct your API anyhow
        await your_func(self.client, ...)```
waxen python
pliant gulch
vale wing
#

Wrap your whole API into a cog and you will have no issues with those between-app communications

slate swan
#

how to make like command

pliant gulch
vale wing
waxen python
#

from?

vale wing
#

Cog object

waxen python
#

i dont have cogs in the webserver file or access to discord.py

slate swan
#

async def carry(ctx, member)
await ctx.send(f"ctx.author carrying {member}")

#

how to do that cmd?

vale wing
#

And you will have access to everything

waxen python
#

im not sure how that would work, how can you have decorators in decorators?

vale wing
#

Decorator basically takes a function and returns something instead of it

#

Or adds that function to somewhere

waxen python
#

would i start the webserver on on ready then?

slate swan
#

hello people!
does anyone know how to make a discord bot respond to webhooks / other bots.

vale wing
#

Better to do it in the overwritten setup_hook method of your bot subclass

waxen python
vale wing
waxen python
#

yup they are, just been doing that

#

im not sure if putting my whole webserver in a cog is a good idea

slate swan
#

TypeError: event() missing 1 required positional argument: 'coro'

waxen python
#

what did you do?

slate swan
#
@bot.event()
async def on_message(ctx, user: discord.User, *, message=None):
    message = message or "This Message is sent via DM"
    await user.send(message)```
waxen python
#

what.

#

are you trying to DM a webhook?

slate swan
#

im just trying to make my webhook do this
@sterile spindle message

#

and then the bot send the message

waxen python
#
@bot.event()
async def on_message(message):
    await message.author.send("This Message is sent via DM")
```?
slate swan
#

ty

#

wait

#

nope, im trying to make it send a message to the user tagged

waxen python
#

tagged in the on_message?

slate swan
#

yes

waxen python
#

right okay

#
@bot.event()
async def on_message(message):
    if message.mentions:
    user = message.mentions[0]
        await user.send("This Message is sent via DM")

#

can you try that?

slate swan
#

sure.

waxen python
#

wait

#

fixed typo

slate swan
#

also missed an indent

waxen python
#

yup

slate swan
#

Traceback (most recent call last):
File "record.py", line 6, in <module>
@bot.event()
TypeError: event() missing 1 required positional argument: 'coro'

waxen python
#
@bot.event
async def on_message(message):
    if message.mentions:
        user = message.mentions[0]
        await user.send("This Message is sent via DM")
waxen python
#

is this in the main file of your bot? or a cog?

slate swan
#

nvm

#

that works

#

now i need the message to be arrangeable

#

so it sends what the webhook says

waxen python
#

well the message content you can get with message.content, so replace the string in user.send() with it

slate swan
#

kk

#

wtf

#

it did it like 10 times

waxen python
#

because the bot is seeing its own message

slate swan
#

how do i whitelist to user id

#

so only the webhook works with it

waxen python
#

use the user id one for that, then

slate swan
#

where bouts would i put that xd

#

sorry im not used to discord bots

#

how to make to my bot send when u ask .Help to bot send u in dm private message

#

can it go of by name

#

message.author == Recording.Mp3

waxen python
#

replace 00000000 with the webhook id

slate swan
#

thought so

slate swan
waxen python
#

they do

slate swan
#

It's just doing some weird loading thing for me

waxen python
#

what do you mean?

slate swan
#

I'll show u in a min

slate swan
#

why wont this send?

                 join_msg = await bot.get_channel(975083898365157376).send(content="<@&925444830480453644>", embed=req_embed)
                  await join_msg.send()```
waxen python
#

mobile issue maybe

austere herald
#

Make sure to run it inside a thread

slate swan
#

I'll fix when on pc legit just downstairs rn

austere herald
waxen python
waxen python
#
join_msg = await bot.get_channel(975083898365157376)
await join_msg.send("<@&925444830480453644>", embed=req_embed)
#

would be the way of doing it
not sure if your get_channel will work tho case you arent passing any info or guild id

slate swan
reef dock
#

since someone might know the answer is anything required for slash commands in terms of the guilded side of things because all my bots slash commands do work in dm's but never seem to show in my guild even when syncing them specifically i have no clue what happened over the course of 2 years for them to break and only show in dm's 🤔

waxen python
slate swan
#

like

#

@waxen python worked ty sm

waxen python
#

nice, np

slate swan
#

@bot.command()

waxen python
#

@bot.command(name="help") yeah

slate swan
#

yeah and i add under that

waxen python
#

well the name bit isnt needed per-say but i like to have it for clarity

slate swan
#

on_message
user = message.author
await user.send("TEST")?

waxen python
#

thats the idea

slate swan
#

@waxen python how would i make it instead of mentioning the user it does the user id

#

ik the part for the webhook

#

can u give me full code?

waxen python
slate swan
waxen python
waxen python
#

a ping in DM doesnt really do anything though, really, right?

slate swan
#

yeah but i just only don't know to use on_message

#

and i want to put it in a embed

waxen python
#

would a user id 611976655619227648 look nicer 🤔

slate swan
#

nah

#

no user mention at all

#

just text

slate swan
#

just say how

#

@bot.command(name="help")
Then what here?

waxen python
# slate swan just text

you could take the string and remove the [#00000000000](/guild/267624335836053506/channel/00000000000/) from it

slate swan
waxen python
#

the bot could do that

slate swan
#

could make it split it

waxen python
#

like split this out
f"<#{user.id}>"

slate swan
#

it indeed works

#

mentioned, text = message.content.split(">")

#

how would i do user.send(embed)

waxen python
waxen python
slate swan
#

ahh

#

i build embeds in json for webhooks so idfk how to use that

waxen python
#

might help :P

slate swan
#

ty

round mirage
#

pls beg

austere vale
#
  @commands.command(aliases=["disconnect", "leave"])
  async def stop(self, ctx):
    await ctx.author.voice.channel.disconnect()

whats the command to make the bot disconnect?

knotty agate
austere vale
spring swallow
hollow edge
#

whenever my bot sends a message in response to slash commands it sends it as a reply

#

is there a way I can send it as a normal message?

slate swan
slate swan
unkempt canyonBOT
slate swan
#

!d discord.PartialMessageable.send

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...
hollow edge
#

thanks :)

hollow edge
#

will this bypass the 3 second timeout

#

or do I have to run it outside the slash command block

slate swan
#

you can defer the reponse

#

await interaction.response.defer()

hollow edge
#

alright thanks

hollow edge
#

tried using discord.interaction too, both didn't work

#

am I doing something wrong?

slate swan
#

what library are you using?

hollow edge
slate swan
#

no idea, that's extremely outdated and doesnt have docs either

slate swan
#

discord_slash

hollow edge
#

oh yeah I get that, but it shouldn't be an issue for this

#

at least to my knowledge

slate swan
#

you need to defer the interaction, that would be the solution

but idk how to do that in discord_slash, thats the point

hollow edge
austere vale
hasty chasm
#
import discord
from discord.ext.commands import Bot
from discord.ext import commands
import asyncio
import time
import datetime
import emoji
import os
import random
client = discord.Client()
bot = commands.Bot(command_prefix = "!")
bot.remove_command("help")
@bot.event
async def on_ready():
    print("Im online")
    Bot.wait_until_ready
    client.wait_until_ready
    game = discord.Game("with your feelings")
    guild = bot.get_guild(811624953740263476)
    await bot.change_presence(status=discord.Status.online, activity=game)
extenstions = []
if __name__ == '__main__':
    for extension in extenstions:
        try:
            bot.load_extension(extension)
            print(extension)
        except Exception as error:
            print(error)
bot.run(os.environ[(TOKEN)])

the 'TOKEN' is actually the token in my code
its saying the token isnt defined on vs code is there another way to get the token to connect to the bot

potent spear
#

commands.Bot is just the subclassed discord.Client with commands and tasks built on top

#

also, don't do shit in on_ready
also, you can set the presence of the bot straight in the constructor

hasty chasm
#

it had worked on github/heroku so i assumed it would work on vs code

potent spear
hasty chasm
#

what would i look up to find it

#

d.py .env file example?

potent spear
#

reading out variables from a .env file has nothing to do with dpy

hasty chasm
#

from what i see do i call it
dotenv.env
with the like token =

#

ive called it in using

import os
from dotenv import load_dotenv
load_dotenv()
#

i got it now

#

thx for the help

dull terrace
potent spear
#

I'm not a lawyer, can't say

sick birch
dull terrace
#

it has been something i've thought about a bit before. i imagine legally it doesn't offer much protection but better than nothing

sharp imp
#

I'm trying to make a command that just simply says the guild name but i cant get my head around it

heavy shard
#

Aloo: almost right, you want ctx.guild.name

#

also, closing apostrophe and right curly brace seems to be swapped

sharp imp
#

oh wait i havent defined the ctx yet

#

this is my first time using it 💀

potent spear
#

you should check out the docs on how ot correctly make a command

sharp imp
#

mb, i recently started learning

#

is there a link to the docs

potent spear
#

excuse me?

#

you're using a library and you've never seen the docs of it? 💀

sharp imp
#

no, im sorry i probably sound like an idiot

#

i literally just started python

potent spear
#

then how have you even been learning?

sharp imp
#

yt vids...

potent spear
#

please don't tell me through YT

sharp imp
#

...

#

😭

potent spear
#

don't learn frequently changing libraries through YT vids, they quickly get outdated and irrelevant

#

you can learn python fine with YT, just not any libraries that change often

sharp imp
#

i see

potent spear
#

so, start with reading documentation I'd say, basic examples etc etc
mostly, YT tutorials are TOO focused on one subject or even have a bad implementation

sharp imp
#

thank you

flint isle
#

    @commands.command(name='logoff')
    async def logoff(self, ctx):
        await ctx.send('`Bot Is Logging Off`')
        await self.bot.close()
        print('Bot Logged off')

RuntimeError: Event loop is closed

Process finished with exit code 0
dull terrace
stone beacon
#

Might work better for ya

flint isle
#

just stop()?

stone beacon
#

nvm 💀

#

stop is just my implementation totally forgot that's not a function in the library

flint isle
#

lol

slate swan
#

just not a method of the Bot class

#

!d discord.ui.View.stop

unkempt canyonBOT
#

stop()```
Stops listening to interaction events from this view.

This operation cannot be undone.
stone beacon
#

well yea that stop

#

I mean't a Bot class stop

modest plover
#
    @commands.Cog.listener()
    async def on_message(self, message: disnake.Message):
        channelID = 976266566972887090
        appEmbed = disnake.Embed(
            title = "Apply!",
            description = "Press the button to apply for that game.",
            colour = disnake.Colour.random())
        if message.channel.id == channelID and message.author.id != self.bot.user.id:
            await message.channel.send(embed = appEmbed)
        async for x in message.channel.history(limit = 10):
            if x.embeds[0].title == "Apply!":
                await message.delete()

Written in Disnake

sick birch
#

"Sticky message type thing"?

#

No

modest plover
stoic scarab
#

Sup guys

modest plover
#

It's for a uhh application thing, you press a button, it makes a thread, but it moves the embed up, so a solution to that is to delete the previous message and send it again, no?

stoic scarab
#

Never made a discord bot before and just learnt python anyone wanna help me lol

modest plover
#

Like is it discord.py, nextcord, disnake, hikari, etc

stoic scarab
#

😅

modest plover
#

Uhh right well my personal recommendation is to use the library Disnake, but each to their own.
Main reason for that is that it's updated frequently and has a pretty decent guide

modest plover
stoic scarab
#

Haven’t rlly commuted lol I didn’t even know there was more than 1

modest plover
#

They're about the same difficulty wise, but Disnake has some features over discord.py I think(?)

stoic scarab
#

Oki

#

Let’s do that then lol

modest plover
#

Ok

#

To get it, it's just pip install disnake

stoic scarab
#

First time using a modual outside default ones lol

#

Oki wait lemme pull replit up

modest plover
#

oh boy

stoic scarab
#

Huh?

modest plover
#

Also another thing, don't use replit as a permanent host, it can cause your bot to get rate limited very easily

stoic scarab
#

What happened lol

modest plover
#

So like it's fine for developing it

sick birch
stoic scarab
#

Huh

sick birch
#

Build up good habits from the start

stoic scarab
#

😅

modest plover
#

But not for hosting it

stoic scarab
#

I only have replit lol

sick birch
#

Save yourself some trouble, and download an IDE like Pycharm or an editor like VSCode

stoic scarab
#

U have to host a bot :0

#

????????????

modest plover
#

A rate limit is basically how many requests you can send to discord per second or minute I think(?)

sick birch
#

You do, it needs a machine to be online 24/7 to be able to run

modest plover
stoic scarab
#

Wow

modest plover
#

You're able to get stuff like uhh Railway or Heroku that can host it tho

#

Cloud services

stoic scarab
#

Ig I’ll be using replit for development lol

sick birch
#

Also if you don't have an intermediate understanding of Python, I'd recommend you go do that first before attempting discord bots

modest plover
#

Like robin said tho, break bad habits and try and use something other than replit

stoic scarab
sick birch
#

You're only going to hinder yourself with basic python knowledge

modest plover
#

What platform are you on?

#

Like you on windows, Chromebook, android, etc

stoic scarab
modest plover
#

oh boy

stoic scarab
#

😅

sick birch
modest plover
#

you got a laptop or anything?

stoic scarab
modest plover
#

an ios is arguably the worst thing to code on

sick birch
#

Make sure you understand concepts such as asynchronous programming, coroutines, the event loop, etc

stoic scarab
modest plover
#

this is coming from the same person using a phone to code

oblique laurel
stoic scarab
#

Lol

stoic scarab
modest plover
#

I'm using an android which is a bit better

oblique laurel
#

XD

stoic scarab
#

Lol

modest plover
stoic scarab
#

Anonymous explain

sick birch
#

Bottom line is a laptop or desktop is preferable

stoic scarab
sick birch
#

Mobile is fine but it's going to be a terrible developer experience

stoic scarab
oblique laurel
#

You can make a discord bot on mobile, but its 1000x easier on desktop lol

sick birch
#

It's going to be an absolute pain

#

But if you insist

modest plover
#

I agree, it's a pain in the arse

stoic scarab
#

Guysssss this is for learning

#

Not to make a actual working bot

zenith basin
#

help pls

stoic scarab
#

When I wanna do that I’ll do it on pc

sick birch
#

We know, but it's difficult to learn when you're being held back by your platform

#

Which is not something that should hinder one's learning experience

sick birch
#

If you say so

stoic scarab
#

Uhh oki

oblique laurel
#

Does replit even support disnake?

stoic scarab
#

Good question

#

Hmm where did everyone go lol

#

Uhh guys

#

Guyssssdd

#

@oblique laurel not working out : (

oblique laurel
#

Just wait a bit ig for other ppl to be online

stoic scarab
#

Uhh ok

oblique laurel
#

You dont need to learn everything by tmrw ;)

stoic scarab
oblique laurel
#

Try running the example code from github and see what it does with your bot

#

Also rule no. one, never share your token

stoic scarab
#

Ok

#

Orrrrre I can try joining other servers :p

#

Imma do that

oblique laurel
#

Yeah dpy has a server

stoic scarab
#

Also if anyone wants to help a professional idiot dm me :p

gaunt mortar
#

Good evening, I got an issue :
I'm currently displaying a message which contains a ui.Select menu, when I select an option I want to edit the current message with another one - I'm using a subclass of Select and the callback method but I'm facing a "discord.errors.NotFound: 404 Not Found (error code: 10015): Unknown Webhook" when selecting an option..

Here is the code of my callback method :

    async def callback(self,interaction : Interaction):
        embed = discord.Embed(color=0x152dff)
        embed.add_field(name="Pari selectionné", value="Placeholder text", inline=False)
        view = View()
        view.add_item(Choice1())
        view.add_item(Choice2())

        await interaction.edit_original_message(embed=embed, view=view)
modest plover
#

It supports pip packages iirc

modest plover
#

Try looking there..?

gaunt mortar
#

Import the variable or make a function that returns the value of it and call the get function from where you need it

zenith basin
gaunt mortar
#

!d discord.ui.Button

unkempt canyonBOT
#

class discord.ui.Button(*, style=<ButtonStyle.secondary: 2>, label=None, disabled=False, custom_id=None, url=None, emoji=None, row=None)```
Represents a UI button.

New in version 2.0.
gaunt mortar
#

If I'm not mistaken, yes

sick birch
gaunt mortar
#

Then ; in your main.py =>

client.myVariable = "placeholder"

in your cog =>

    def __init__(self,client):
        self.client = client
        print(client.myVariable)
gaunt mortar
slate swan
austere vale
#

what does this mean?

fast musk
#

that address/port is already bound

#

another running instance maybe

austere vale
#

thats weird my bot isnt on

heavy shard
#

means others variable was used, but it wasn't initialized (set) before, likely because condition if teamsinuser[i].name in teams: was never met

slate swan
#

you should know about variable scopes before you really start any project, thats a must

heavy shard
#

why do you need it? while True: is an infinte loop which prevents bot from doing any logic related to reactions on events

sick birch
#

It depends on what you're doing inside it

#

If it's async you may be able to get away with it

heavy shard
#

before the loop, set others to anything, like None

slate swan
#

you cant....., an infinite loop is blocking, you might want to use asyncio and run it in an event loop maybe correct me if im wrong

heavy shard
#

the for i in range ... loop

sick birch
#

Again, depends on what you're doing inside the while True loop

#

discord.py internally has a few while True loops (e.g for polling websocket events, heartbeating, etc) that don't block

heavy shard
#

while True: loop means you're checking something or counting maybe, it can be rewritten using different logic probably

slate swan
#

you could count without a loop too

#

and without range

#

and again, check stuff without a loop

slate swan
#

making a task wont block the bots heartbeats

#

pykawaii lmao

slate swan
heavy shard
#

also, second for i in range(0, len(roles)): should be for i in range(0, len(teamsinuser)): following your logic

#

i think you could get away with an infinte loop with asyncio.sleep(0.1) for example

slate swan
slate swan
heavy shard
#

yes, but you want to loop through teamsinuser roles, which you take len(roles) as a size of it... len(roles) may (and will be) different than len(teamsinuser)

slate swan
# slate swan what

the wrapper, I wantef those stuff for my bot, but I was just too lazy to do api stuff lmao

slate swan
slate swan
slate swan
#

😔

#

thanks

#

i have an exam tomorrow as well but i need to fix pykawaii first

slate swan
abstract kindle
#

hey guys, just curious about how some of you would implement an inventory system in a database

#

Like if I'm storing my discord users ID's in a database and I wanted them to have inventories for items, how would you guys go about doing that?

slate swan
#

wait, werent you doing the same thing a few days ago...

meager chasm
meager chasm
#

it's just a normal many to many relation

slate swan
#

wait, no

meager chasm
#

what?

slate swan
#

I'm crazy

#

we dont talk about that

meager chasm
#

👍

slate swan
#

I can’t view messages from my laptop-

#

Can I send code as an image?

slate swan
#

@slate swan bro your banner 🤣

#

Got an error NameError: name ‘fetch’ is not defined code: py @guild.command() async def emojis(ctx): emojis = await fetch.emojis() try: emojiEmbed = discord.Embed(title=f”Emojis for {ctx.guild.name}”, description=emojis) await ctx.send(embed=emojiEmbed)

#

!d discord.Guild.fetch_emojis

unkempt canyonBOT
#

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

Retrieves all custom [`Emoji`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Emoji "discord.Emoji")s from the guild...
slate swan
#

it's underscore not a period

#

and its a method of the guild class lol

#

undefined name ‘fetch_emojis’

#

so it would be await ctx.guild.fetch_emojis()since Context has a guild attr which returns a Guild object

#

was gonna say this ^

#

Mhm. Let me use it

#

if you want to get all emojis the bot is in just add the bot/client object instead of ctx

#

@slate swan are you good with async requests?

#

ig

#

Nothing

#

?

#

I meant to send this before

#

But it is sent now

#

@slate swan

async def web_scrape(text):
    async with aiohttp.ClientSession() as session:
        async with session.get(text) as r:
            status = r.status
            if status == 200:
                text = await r.text()
                return text

@client.command()
async def wyr(ctx):
    text = await web_scrape("https://either.io/")
    soup = BeautifulSoup(text, 'lxml')
    l = []
    for choice in soup.find_all("span",{"class":"option-text"}):
        l.append(choice.text)
    embed = discord.Embed(color=discord.Color.blue())
    embed.set_author(name = "Would you rather..", url="https://either.io/", icon_url=ctx.author.avatar_url)
    embed.add_field(name = "EITHER..", value=f"🇦 {l[0]}", inline=False)
    embed.add_field(name = "OR..", value=f"🇧 {l[1]}", inline=False)
    msg = await ctx.send(embed=embed)
    await msg.add_reaction("🇦")
    await msg.add_reaction("🇧")

takes like 2-3 seconds to actually send the embed, any way to speed it up?

#

I’m getting this

#
@guild.command()
async def members(ctx):
  mem = ctx.guild.fetch_members(limit=100000)
  await ctx.send(mem)

code ^

slate swan
slate swan
maiden fable
#

U can't have it in a cog?

slate swan
# slate swan its probably because of the for loop and your function can be done better
# old
async def web_scrape(text):
    async with aiohttp.ClientSession() as session:
        async with session.get(text) as r:
            status = r.status
            if status == 200:
                text = await r.text()
                return text
# new
async def request(method: str, endpoint: str, /) -> dict["Any", "Any"]:
    async with aiohttp.request(method, endpoint) as payload:
        return await payload.json()

is what i do

supple thorn
#

A subclassed of HelpCommand?

supple thorn
slate swan
slate swan
supple thorn
slate swan
slate swan
#

how much faster would it actually be

#

which the for loop or the function?

#

the entire command as a whole

#

your site waifu.pics is sick asf btw

#

😳

slate swan
#

Oh and
Whenever I use a subcommand the parent command is also invoked

slate swan
#

Like this:
Aliases is parent command

#

!d discord.ext.commands.group

unkempt canyonBOT
#

@discord.ext.commands.group(name=..., cls=..., **attrs)```
A decorator that transforms a function into a [`Group`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Group "discord.ext.commands.Group").

This is similar to the [`command()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.command "discord.ext.commands.command") decorator but the `cls`
parameter is set to [`Group`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Group "discord.ext.commands.Group") by default.

Changed in version 1.1: The `cls` parameter can now be passed.
slate swan
#

with my old code it was about 3 seconds

slate swan
#

Or subcommand

#

yes sir, inside the group decorator

slate swan
# slate swan with my old code it was about 3 seconds

remember python is an interpreter language so most times it would read from top to bottom and if you execute a coro before a blocking for loop it would be faster yes as the coro before wont get invoked until the for loops is done with its iteration

slate swan
#

the thing that sucks more is typehinting them

#

😭

slate swan
#

what

#

this is definitely not what i asked you to do

#

@slate swan TypeError: request() missing 1 required positional argument: 'endpoint'
?

slate swan
#

wdym?

#

the site im requesting is already in text =

slate swan
slate swan
#

the first one is for the http request method and the other one is the url

slate swan
#

!d asyncio.iscoroutine

unkempt canyonBOT
#

asyncio.iscoroutine(obj)```
Return `True` if *obj* is a [coroutine object](https://docs.python.org/3/library/asyncio-task.html#coroutine).

This method is different from [`inspect.iscoroutine()`](https://docs.python.org/3/library/inspect.html#inspect.iscoroutine "inspect.iscoroutine") because it returns `True` for generator-based coroutines.
slate swan
slate swan
#

since it seems like in your old code all the http request methods are get i suppose

#

and why is this request not with a session?

#

how to i make when u send .Help to bot send u in dm a help message

hollow zealot
#

I'm new to python. and I wanna how u can combine a string with a number and then combined it again with a string
For example 'Hi im' + 20 + 'Years old'

slate swan
slate swan
unkempt canyonBOT
slate swan
#

!d discord.Member.send

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

I got, ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8'

do I disable content_type?

#

xcirno knows everything😳

slate swan
#

?*

slate swan
#

i thought the api returns json as most do😅

slate swan
slate swan
#

yes

#

yeah i figured as i rechecked and the function name is web_scrape

#

yeah

#

so what do I do instead?

#

how to my bot keep be alive?

slate swan
slate swan
#

yeah but i don't gonna have my cmds

slate swan
slate swan
slate swan
slate swan
slate swan
# slate swan the unparsed payload
async def request(method: str, endpoint: str, /) -> "Any":
    async with aiohttp.request(method, endpoint) as data:
        return data

this is what i ment

#

and my actual command code would remain the same?

#

or just with the get

#

the coroutine aiohttp provides await ClientResponse.json() just parses the payload and makes it into a dict

slate swan
#

what do I have to await?
coroutine 'ClientResponse.read' was never awaited

#

well the line where an instance of ClientResponse is getting used to invoke ClientReponse.read

#

I dont see one?

#

show traceback

#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'coroutine' object has no attribute 'startswith' C:\Users\AppData\Local\Programs\Python\Python310\lib\asyncio\events.py:80: RuntimeWarning: coroutine 'ClientResponse.read' was never awaited self._context.run(self._callback, *self._args)

#

can you show your code

#
async def web_scrape(method: str, endpoint: str, /) -> "Any":
    async with aiohttp.request(method, endpoint) as data:
        return data

@client.command()
async def wyr(ctx):
    text = await web_scrape("GET", "https://either.io/")
    soup = BeautifulSoup(text, 'lxml')
    l = []
    for choice in soup.find_all("span",{"class":"option-text"}):
        l.append(choice.text)
    embed = discord.Embed(color=discord.Color.blue())
    embed.set_author(name = "Would you rather..", url="https://either.io/", icon_url=ctx.author.avatar_url)
    embed.add_field(name = "EITHER..", value=f":regional_indicator_a: {l[0]}", inline=False)
    embed.add_field(name = "OR..", value=f":regional_indicator_b: {l[1]}", inline=False)
    msg = await ctx.send(embed=embed)
    await msg.add_reaction("🇦")
    await msg.add_reaction("🇧")
#

well i dont really see anything related to the traceback itself

#

my code is probably incorrect

hollow zealot
#

nvm i figured it out

slate swan
slate swan
slate swan
unkempt canyonBOT
slate swan
heavy shard
hollow zealot
#

but i figured it out already

slate swan
#

yeah rud0lf is right you forgot to parse the data as text

hollow zealot
slate swan
slate swan
#

!d discord.Message.author

unkempt canyonBOT
slate swan
slate swan
hollow zealot
slate swan
unkempt canyonBOT
#

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

Deletes the message.

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

let me try

slate swan
#

since youre iterating through the elements its O(n) the more elements their is the more time it will take since its not linear

#

and im guessing you cant speed that part up?

hollow zealot
#

the message that triggered it?

#

or the bots message?

slate swan
slate swan
slate swan
slate swan
#

does someone know how to my bot keep alive but to i don't host somewhere

slate swan
#
def for_loop():
    for num in range(101):
        print(num)
bot_instance.loop.create_task(for_loop())

since youre creating a task with the loop attr the Bot class has which returns a AbstractEventLoop it wont block anything in your code but in your case you should leave your for loop to execute first as it depends on the results of it

slate swan
slate swan
slate swan
#

what did you code your api in?

#

my api wrapper?

#

the actual site

stone beacon
#

Crython

slate swan
slate swan
slate swan
hollow zealot
slate swan
slate swan
#

when i host

slate swan
#

my bot gonna have of that site commands

#

not mine what i maked

slate swan
#

!d discord.ext.commands.Context.message

unkempt canyonBOT
#

The message that triggered the command being executed.

Note

In the case of an interaction based context, this message is “synthetic”
and does not actually exist. Therefore, the ID on it is invalid similar
to ephemeral messages.

slate swan
#

I don't understand what you tryna say sorry @slate swan

slate swan
#

how do I make an api

keen talon
#

Web api ?

slate swan
slate swan
hollow zealot
slate swan
slate swan
slate swan
spice adder
#

Is it possible to loop a try: expression x times, and if there are any exceptions in those x attempts, for it to go to the except?

slate swan
stone beacon
keen talon
slate swan
hollow zealot
keen talon
oak bridge
unkempt canyonBOT
#

discord/client.py line 212

self._listeners: Dict[str, List[Tuple[asyncio.Future, Callable[..., bool]]]] = {}```
slate swan
slate swan
oak bridge
hollow zealot
slate swan
hollow zealot
stone beacon
#

👀

slate swan
hollow zealot
stone beacon
slate swan
#

a function is an object yes

slate swan
hollow zealot
slate swan
#

!e

def a():
    ...
print(type(a))
unkempt canyonBOT
#

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

<class 'function'>
slate swan
#

since it hasnt been called no return type has been given so its not literal to anything

#

just to a function obj

heavy shard
#

you can use elipsis instead of pass?

slate swan
#

yea

#

yes

#

its just bitwise pass

oak bridge
hollow zealot
slate swan
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.

This works similarly to [`send()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for non-interaction contexts.

For interaction based contexts this does one of the following...
slate swan
#

use the kwarg

slate swan
hollow zealot
slate swan
#

error:

slate swan
#
@client.command()
async def gstart(ctx, prize, donor, host, *, msg):
  now = datetime.now()
  embed = discord.Embed(title = f"{prize}", description = f"Hosted By: {host}\n Donor: {donor}\n \n Message: {msg}", color = discord.Colour.random())

  embed.set_footer(text = f"1 Winner | Started At {now}")

  my_msg = await ctx.send(embed = embed)

  await my_msg.add_reaction("🎉")

  await asyncio.sleep(15)

  new_msg = await ctx.fetch_message(my_msg.id)

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

  winner = random.choice(users)

  await ctx.send(f"Congratulations! {winner.mention} won the prize: {prize}!")
``` code ^
#

!d discord.TextChannel.send

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

it would be await message.channel.send(embed=embed)

hollow zealot
slate swan
slate swan
hollow zealot
#

can i do this? ```JSON
message.channel.send({
"content": "aaaa",
"embeds": [
{
"title": "wahhp",
"description": "em cool",
"color": null
}
],
"attachments": []
})

oak bridge
slate swan
#

no. we are not doing discord.js

but if you still want to do something like that , this exists:

#

!d discord.Embed.from_dict

unkempt canyonBOT
#

classmethod from_dict(data)```
Converts a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.10)") to a [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") provided it is in the
format that Discord expects it to be in.

You can find out about this format in the [official Discord documentation](https://discord.com/developers/docs/resources/channel#embed-object).
slate swan
#

!kwargs-args

unkempt canyonBOT
#

*args and **kwargs

These special parameters allow functions to take arbitrary amounts of positional and keyword arguments. The names args and kwargs are purely convention, and could be named any other valid variable name. The special functionality comes from the single and double asterisks (*). If both are used in a function signature, *args must appear before **kwargs.

Single asterisk
*args will ingest an arbitrary amount of positional arguments, and store it in a tuple. If there are parameters after *args in the parameter list with no default value, they will become required keyword arguments by default.

Double asterisk
**kwargs will ingest an arbitrary amount of keyword arguments, and store it in a dictionary. There can be no additional parameters after **kwargs in the parameter list.

Use cases
Decorators (see !tags decorators)
Inheritance (overriding methods)
Future proofing (in the case of the first two bullet points, if the parameters change, your code won't break)
Flexibility (writing functions that behave like dict() or print())

See !tags positional-keyword for information about positional and keyword arguments

slate swan
#

anyways im going to sleep, good night guys!

hollow zealot
unkempt canyonBOT
#

discord/client.py line 395

def dispatch(self, event: str, /, *args: Any, **kwargs: Any) -> None:```
slate swan
hollow zealot
#
async def on_message(message):
  if message.content == "!embed":
Then what now .-.```
hollow zealot
slate swan
# slate swan why would they?

those are not really something which needs to be hidden from users, if they really are, just use private methods and variables......

oak bridge
#

But ws._dispatch = client.dispatch are not looping over anything too

slate swan
oak bridge
#

and then dispatch has this component listeners = self._listeners.get(event)

slate swan
oak bridge
#

so the focus shift from dispatch to _listener (dict)

slate swan
slate swan
hollow zealot
slate swan
#

i think you ment enlighten?

oak bridge
slate swan
unkempt canyonBOT
#

add_listener(func, /, name=...)```
The non decorator alternative to [`listen()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.listen "discord.ext.commands.Bot.listen").

Changed in version 2.0: `func` parameter is now positional-only.
slate swan
#

the @event decorator for client and bot both

slate swan
austere herald
#

Use an async for list comprehension

slate swan
heavy shard
slate swan
#

well you dont even really need to see the documentation of a lib to learn about it

#

quite ironic

#

i just read its source when i wanna know deeply about it but documentation is just a shortcut

oak bridge
slate swan
#

and some libs docs offer source code location

slate swan
slate swan
#

!d discord.ext.commands.Bot

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, intents, **options)```
Represents a discord bot.

This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") and as a result
anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") you can do with
this bot.

This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality
to manage commands...
slate swan
#

you are looking in the opposite way.

oak bridge
#

but it's running client, not running bot

slate swan
#

then, your events work with setattr

unkempt canyonBOT
#

discord/ext/commands/bot.py line 1377

class Bot(BotBase, discord.Client):```
unkempt canyonBOT
#

discord/client.py line 1133

setattr(self, coro.__name__, coro)```
slate swan
#

they just set those methods using @client.event

oak bridge
#

wait, running client would trigger any bot command? as you said bot is the child

slate swan
#

if you are using Client, Bot things wont bother you

oak bridge
#

? it should be some line to link them otherwise your viewpoint is not valid

slate swan
#

not at all

#

!e ```py
class A:
name = "parent class"

class B(A):
name2 = "child class"

a = A()
print(getattr(a, "name2", None))
``` the B class which is a subclass of A has name2 variable in it, but that doesn't affect the parent class A

unkempt canyonBOT
#

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

None
slate swan
#

but if you did B().name, it would get the "name" from its parent class A, thats how inheritance works.

oak bridge
slate swan
#

you mean if i did the same for B, it will still return None?

oak bridge
#

this return None as well

slate swan
#

thats not the point

#

or actually that is, i said the Bot class wont bother Client , even if it stays or not

#

you just proved what i said....

oak bridge
#

what do you mean?

oak bridge
#

my viewpoint is parent class won't link to any child class command.

slate swan
#

what else did i say?

slate swan
oak bridge
slate swan
#

read the messages below that? xd

slate swan
oak bridge
#

the branch of mentioning bot script is totally irrelevant

#

and you mention bot

slate swan
#

you were taking about listeners, and client doesn't have listeners, bot does.

#

doesnt exist

#

!d discord.ext.commands.Bot.listen does

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

difference between listeners and event is
you can have only one event
but unlimited listeners.

oak bridge
#

yeah so the question would be how client calls bot's method

slate swan
#

why not just use Bot

oak bridge
#

hey client.run(TOKEN) could load @events

#

that's not a problem of choice, it's actually working like this

slate swan
#

client does not depend on bot any ways

#

and that _listeners dictionary is only being utilised while using wait_for

oak bridge
#

yeah so that confirms bot script is irrelevent

slate swan
#

what do you actually want to do kin?

oak bridge
#

see how client loads event

slate swan
#

the bot class isnt really useless if it were then the client class is useless as well just handle the gateway events yourself am i right

maiden fable
#

oki calm down

slate swan
#

i need sleep

#
@client.event
async def event_name(*args):
   ... 

client.event_name = event_name # where event_name is a function
``` are the exposed methods of adding events to a client
fierce kite
#

discord webhooks can't load nsfw?

slate swan
#

this has nothing to do with listeners, its utilised in wait_for and the Bot subclass

oak bridge
slate swan
#

mention the lines you are talking about

oak bridge
#

this whole thing only override the client instance attribute (event attribute)

slate swan
#

thats how "events" work

oak bridge
#

class ABC:
method1
method2
method3

@client.event modifies it that's all

#

But it is not mounting them or changing the dictionary of _listener

oak bridge
#

so why you mention them?

quartz phoenix
#

Traceback (most recent call last):
File "main.py", line 5, in <module>
from mails import GetDiscordEmail, GetEmail
ModuleNotFoundError: No module named 'mails'
How do I fix it?

placid skiff
jade jolt
#

install that module

quartz phoenix
#

how i can install?

fierce kite
#

can discord webhooks load nsfw?

slate swan
# oak bridge so why you mention them?

i just mentioned the dispatch method, you bringed up the listeners discussion, while the solution of your question is in the last 3 lines of that method

placid skiff
#

Bruh i dunno what you wanna do but discord.py has no module related to emails

jade jolt
#

probably a different module he wants

#

this isnt the channel for that anyway

slate swan
#

if you mean display by "load"

fierce kite
slate swan
#

doesn't reddit let only registered users access nsfw content?

oak bridge
quartz phoenix
slate swan
#

getattr is not dependent over it

#

!d getattr

unkempt canyonBOT
#

getattr(object, name[, default])```
Return the value of the named attribute of *object*. *name* must be a string. If the string is the name of one of the object’s attributes, the result is the value of that attribute. For example, `getattr(x, 'foobar')` is equivalent to `x.foobar`. If the named attribute does not exist, *default* is returned if provided, otherwise [`AttributeError`](https://docs.python.org/3/library/exceptions.html#AttributeError "AttributeError") is raised.

Note

Since [private name mangling](https://docs.python.org/3/reference/expressions.html#private-name-mangling) happens at compilation time, one must manually mangle a private attribute’s (attributes with two leading underscores) name in order to retrieve it with [`getattr()`](https://docs.python.org/3/library/functions.html#getattr "getattr").
slate swan
#

its a python fucntion which just needs an object and name of the method to get it, nothing else

oak bridge
#

The path should be like this:

  1. client.run(TOKEN)
  2. await self start()
  3. await self.connect()
  4. coro = DiscordWebSocket.from_client(self, **ws_params)

gateway.py

  1. LINE366 ws._dispatch = client.dispatch
#

ok I found it.
entry = EventListener(event=event, predicate=predicate, result=result, future=future)

fierce kite
slate swan
#

i don't see any mention of _listeners here

#

why don't you try one thing

#

make a client object, add some event to it and then print(client._listeners) after running it

#

if that returns a dictionary with those items then it should matter else thats not related

oak bridge
#

dispatch method still need to intake event strings in it

slate swan
#

Why am I getting an error ModuleNotFoundError: no module named ‘discord-interactions’
I had this import for over 2 days without anything like this

oak bridge
oak bridge
hasty bison
#
@client.event
@commands.has_permissions(ban_members=True)
async def ban(ctx, member: discord.Member, *, reason=None):
    await member.ban(reason=reason)
    await message.channel.send('Member `banned` successfully')
#

this won't work

unkempt canyonBOT
#

discord/state.py line 594

self.dispatch('message', message)```
slate swan
#

message is not defined, wrong decorator

minor oriole
#

can someone help me with nextcord's cogs?

#

i made a setup function which takes client as a parameter

#

but then i dont know what to put in it

#

the load_extension and the add_cog are 2 options given to me by nextcord helper staff

slate swan
minor oriole
#

the thing is Ping here is not in the same file so

#

i mean it shows that its not defined

paper sluice
#

import Ping then...

paper sluice
#

while loading the cog, it tries to look for the setup function

hasty bison
placid skiff
#

you have nothing called message in that function
you have the context (ctx) since it is a command

#

the context has a send method

#

!d discord.ext.commands.Context.send

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.

This works similarly to [`send()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for non-interaction contexts.

For interaction based contexts this does one of the following...
minor oriole
#

Does it take a lot of time to register the slash command of Ping?

#

i put my guild id inside tho

placid skiff
#

and the deco for command is not @client.event it is @client.command in your case

placid skiff
regal pulsar
#

and its await ctx.guild.ban(member, reason = reason)

#

and its await ctx.channel.send

hasty bison
regal pulsar
#

send the code now

hasty bison
#
@client.command
@commands.has_permissions(ban_members=True)
async def ban(ctx, member: discord.Member, *, reason=None):
    await ctx.guild.ban(member, reason = reason)
    await ctx.channel.send('Member `banned` successfully')
regal pulsar
#

its @client.command()

#

with brackets

hasty bison
#

doesn't work

regal pulsar
#

whats the error

hasty bison
#

no error

regal pulsar
#

does the bot have permission to ban

hasty bison
#

yes

regal pulsar
#

and do you have permission to ban

hasty bison
#

it has administrator

hasty bison
regal pulsar
#

you cant ban anyone higher in heirarchy than the bot

hasty bison
#

i know

#

im tryna ban my alt which has no permissions

regal pulsar
#

!d discord.Guild.ban

unkempt canyonBOT
#

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

Bans a user from the guild.

The user must meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.

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

@waxen python

crimson compass
#

how can i make the bot "ask" for a number and then print it

cloud dawn
unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

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

what does this mean?

#

ive never seen this error before

#

and ive tried fixing the code but nothing works

scarlet sorrel
#

can i get my bot to add me as a friend?

cloud dawn
scarlet sorrel
#

not any way?

latent anchor
scarlet sorrel
latent anchor
#

it already be able to?

vocal plover
#

That used to be a feature long ago, but bots can no longer be in group dms

placid verge
placid verge
latent anchor
#

cuz this thing happened since last year and i ignored this code until now and still doesnt work

placid verge
vocal plover
#

429 is definitely a ratelimit, given it's got HTML I'd assume it's a cloudflare level ratelimit, rather than API level, which generally means you managed to spam a massive number of bad requests at the api within 10 minutes

latent anchor
vocal plover
#

are you running any other bots on the same machine which could be increasing the overall number of requests you're making?

latent anchor
#

no?

#

i only running that bot

latent anchor
dense swallow
#

i have a question about d.py's interactions... if interaction.user is the person who sent the interaction then who is the one clicking the interaction

#

ex: if the user types the help cmd and the bot sends a select menu, the user who invoked that select menu is interaction.user.. so if i want to add a check, so that it only works for the person who invoked it, how do i do it

scarlet sorrel
crimson compass
#

can a bot send a spoiler image

#

?

placid skiff
dense swallow
#

its used with prefixed commands

placid skiff
#

then when the command is invoked you will have a Context object

dense swallow
#

basically how can i add a check for that.. the menu should be only used by tthe person who invoked it.. i think is possible with async def interaction_check

#

but idk how to make the if/else funcs

placid skiff
#

it depends on how your menu works

placid verge
hasty bison
#

not text

placid verge
#

well actually there is a way to send spoiler images with bots .
Just add SPOILER_ to files name and then send that image

placid verge
dense swallow
# placid skiff it depends on how your menu works
    async def interaction_check(self, interaction: discord.Interaction) -> bool:
        if interaction.user and interaction.user.id != # random person clicking the menu:
            await interaction.response.send_message(content="This menu is not for you!", ephemeral=True)
        else:
            return True
#

i need to know what i should use in the place of that comment

placid skiff
#

bruh i told ya it depends on how your menu is constructed

dense swallow
#

in my opinion its pretty basic, want the full code?

placid skiff
#

you subclassed the View class?

dense swallow
#

yes

placid skiff
#

then you can do it like this
You will add a new parameter in the constructor called user (which will be passed whenever the help command is casted) which will be equal to the user which has used the help command, then you will need, inside your view subclass, to override a method of the view class called interaction_check (you will just need to add an async def interaction_check(self, interaction: discord.Interaction) in your subclass). This callback method will be called every time a button of that view is pressed. inside of that you will have an if statement:
if self.user (or wathever you will call the user parameter in your view) != interaction.user and inside the if you will do your stuff

slate swan
#

how to do on_message

dense swallow
unkempt canyonBOT
#

discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message") is created and sent.

This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled...
slate swan
#

thx

outer blaze
maiden fable
slate swan
#

for that what he need

maiden fable
#

Nvm misread it as Visual Studio Code

#

I was like: VSC doesn't provide that functionality wtf

hasty bison
#

guys

#

how do i make a hyperlink

regal pulsar
#

what

#

oh that

paper sluice
hasty bison
#

thanks

regal pulsar
#

!d discord.Embed.title

unkempt canyonBOT
#

The title of the embed.
This can be set during initialisation.
Can only be up to 256 characters.

regal pulsar
#

the url kwarg

maiden fable
unkempt canyonBOT
regal pulsar
#

oops

hasty bison
#

??

paper sluice
#

ya

hasty bison
#

ok

regal pulsar
hasty bison
flint isle
#

imusing

self.bot.get_command('ping')
```to call the command. how do i run the command that it gets?
cloud dawn
#

!d discord.ext.commands.Context.invoke

unkempt canyonBOT
#

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

Calls a command with the arguments given.

This is useful if you want to just call the callback that a
[`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") holds internally...
maiden fable
#

Smh the new discord update for Android sucks

cloud dawn
maiden fable
# cloud dawn why?

See the new channels UI. The spacing has been decreased and the app has become highly unoptimized

cloud dawn
#

Unless you got some kinda of beta

placid skiff
#

yeah mine too are pretty the same

maiden fable
#

Prolly that's the issue

#

Also, context commands are available on phone at last!

placid skiff
#

wdym?

maiden fable
placid skiff
#

Oh nice

#

but wait message commands weren't already available?

maiden fable
#

Not on mobile, no

placid skiff
#

weird, i remember that i used them D_D

maiden fable
#

Idk, I wasn't ever able to use them on mobile

cloud dawn
#

Oh the new menu thingy no those were not.

maiden fable
#

New menu seems good tho

#

The UI is the same as that of iOS

placid skiff
#

uhm well i don't have the new update yet, just realized it Phx_PepoLMAO

maiden fable
#

Lol

placid skiff
#

i've v126.12

maiden fable
#

128.8

placid skiff
#

now i'm sad

maiden fable
maiden fable
placid skiff
#

yeah but i don't have any update in the store too D_D

maiden fable
#

Yoo Discord now supports using Regex for filtering logs

placid skiff
#

I pay the nitro but i can't get the newest feature

#

really sad

maiden fable
#

Lmaoo

#

Imagine if they lock App Commands usage behind a paywall. "Pay for nitro and use those"

placid skiff
#

death for the mobile app for the whole dev community

#

bruh i updated my website locally like 1 month ago i can't believe that i'm that lazy even for updating a file

hexed pagoda
#

henlo can somone help me find a really good explanation where to use intents and how? im a beginner to python and discord bots ,thanks 🙂

hollow zealot
#

how do I add bot activity? i tried a lot of things but nothing seems to work .-.

neat field
#

Which ipc can i use for my discord bot?

hollow zealot
neat field
#

like is there packages i can use?'

#

or should i creare my own

hollow zealot
neat field
#

no lmoa nvm

placid skiff
hollow zealot
placid skiff
#

!d discord.Guild.fetch_members

unkempt canyonBOT
#

async for ... in fetch_members(*, limit=1000, after=...)```
Retrieves an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.10)") that enables receiving the guild’s members. In order to use this,
[`Intents.members()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.members "discord.Intents.members") must be enabled.

Note

This method is an API call. For general usage, consider [`members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.members "discord.Guild.members") instead...
neat field
#
                type=discord.ActivityType.watching,
                name=f"{len(self.guilds)} servers!"
            )```
placid skiff
#

for example this, you can see that in order to use it you require member intents

hollow zealot
#

like await bot.change_presence(status=discord.Status.idle, activity=activity)

hexed pagoda
#

im failing at first step cus i watched an older video, i fail at the beginning by client

#

it saiys type error but i dont se no type errors :DD

hollow zealot
placid skiff
#

well d.py and related forks are constantly updated so it is hard to find video up to date, but the docs is constantly updated so everytime you use a method it is hardly recommended to read the docs

neat field
#

wat is it

hollow zealot
neat field
#

whats ur client variable?

hollow zealot
#

cant copy paste it

neat field
#

is this in ur main file or a cog?

hollow zealot
neat field
#

yes

hollow zealot
neat field
#

so instead of bot use client

hollow zealot
#

oh ok

#

thank your a life saver

#

i've been searching an hour

neat field
#

glad i helped

hollow zealot
#

i cant find an answer

neat field
hexed pagoda
#

mine says: client = discord.Client()
TypeError: Client.init() missing 1 required keyword-only argument: 'intents'

hollow zealot
#

thats where i search

hexed pagoda
#

and i foun out i should put intents.deafault or smt

neat field
#

something like that

hollow zealot
neat field
#

enables defualt intents for th bot