#discord-bots

1 messages · Page 16 of 1

slate swan
#

!d discord.Embed

unkempt canyonBOT
#

class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.

len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.

bool(b) Returns whether the embed has any data set.

New in version 2.0.

x == y Checks if two embeds are equal.

New in version 2.0...
slate swan
#

the type kwarg

#

typehints dont clutter 2124_MikeSullyFaceSwap

#

yes they do

#

weirdo UniSips

tired notch
#

how do i make it so that a user can only run one command at a time

tired notch
#

no like

#

if one command is already active, then dont let the user use another command

silk fulcrum
#

😳

final geyser
#

does anyone here know anything about a voice recording via bot, it seems to be the hardest thing ever to get working, I've been reading github threads and stackoverflow and official api forever and I can't seem to find a solid answer

#

please

slate swan
final geyser
sick birch
#

Kind of like our bot @last ermine

slate swan
#

djs pepeShy

final geyser
#

damn I was afraid I'd have to use js

silk fulcrum
final geyser
#

😢

cloud dawn
final geyser
#

is there a way to use python and djs on one bot C_Deno

cloud dawn
#

Not without using a bridge.

final geyser
final geyser
slate swan
cloud dawn
silk fulcrum
#
async def command(ctx){
    await ctx.send('yes');
    console.log(f'{ctx.author} launched command')
}
``` i want this lang :lemao:
tired notch
#

what is on command i cant find in docs

cloud dawn
#

Yes ash

slate swan
#

no-

silk fulcrum
unkempt canyonBOT
#
I don't think so.

No documentation found for the requested symbol.

silk fulcrum
#

why(

final geyser
#

lol

slate swan
#

even I did, we're not weirdos

tired notch
#

ok thank

slate swan
silk fulcrum
#

!d discord.discord.ext.commands.on_command

unkempt canyonBOT
#

discord.ext.commands.on_command(ctx)```
An event that is called when a command is found and is about to be invoked.

This event is called regardless of whether the command itself succeeds via error or completes.
silk fulcrum
#

ahahahah

slate swan
#

just what I thought

final geyser
#

thats just my online alias I came up with, one that I've had for years I don't give a fuck if it means something inappropriate in moroccan arabic jesus

vocal snow
#

Ashley is basically a swear word in my local language so it's fine

final geyser
#

lol

slate swan
#

...

tired notch
#

what does this mean discord.errors.HTTPException: 400 Bad Request (error code: 40060): Interaction has already been acknowledged.

#

nvm

#

once a button has been clicked how can the command that sent the button receive information from the button?

silk fulcrum
primal token
#

result returned None

mortal thorn
#

It's just a normal message object

primal token
#

!d discord.Guild

unkempt canyonBOT
#

class discord.Guild```
Represents a Discord guild.

This is referred to as a “server” in the official Discord UI.

x == y Checks if two guilds are equal.

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

hash(x) Returns the guild’s hash.

str(x) Returns the guild’s name.
primal token
#

in discords documentation, a server is referred as a guild

mortal thorn
#

ok now no error but it just doesnt find me for some reason

primal token
#

do you have intents? and get_member can return None as well, as its a cache look up

mortal thorn
#

im not a bot dev i just assembled some really trashy code for something

primal token
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

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

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

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

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

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

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

mortal thorn
#

how is it related?

#

@primal token

primal token
#

Well, its needed so your bot can actually see the Member, better described in the links and description above in the embed

mortal thorn
#

I only have the basic of the basic

clientrd.Client()

and client.run

#

maybe

#

comammnds.client?

primal token
mortal thorn
#

tho I don't have commands lol

#

oh ok

brazen raft
mortal thorn
#

nothing

#

but ill connect it to google sheets

brazen raft
#

That doesn't help me help you

mortal thorn
#

@primal token not working

#

just given an error

brazen raft
#

Technically you could construct a Client like this, but commands.Bot has nice things like proper commands and errors handling

primal token
mortal thorn
primal token
#

the embed was sent by the bot to be specific and can you provide the error?

mortal thorn
#

File "D:\Devlopment\Disacord BOt\TGE\main.py", line 69, in <module>
client.run(Token)
File "D:\Devlopment\Disacord BOt\TGE\venv\lib\site-packages\discord\client.py", line 723, in run
return future.result()
File "D:\Devlopment\Disacord BOt\TGE\venv\lib\site-packages\discord\client.py", line 702, in runner
await self.start(*args, **kwargs)
File "D:\Devlopment\Disacord BOt\TGE\venv\lib\site-packages\discord\client.py", line 666, in start
await self.connect(reconnect=reconnect)
File "D:\Devlopment\Disacord BOt\TGE\venv\lib\site-packages\discord\client.py", line 601, in connect
raise PrivilegedIntentsRequired(exc.shard_id) from None
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.
Exception ignored in: <function _ProactorBasePipeTransport.del at 0x00000298B4DD8310>
Traceback (most recent call last):
File "C:\Program Files\Python39\lib\asyncio\proactor_events.py", line 116, in del
self.close()
File "C:\Program Files\Python39\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Program Files\Python39\lib\asyncio\base_events.py", line 751, in call_soon
self._check_closed()
File "C:\Program Files\Python39\lib\asyncio\base_events.py", line 515, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

Discord Developer Portal

Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.

brazen raft
#

I don't know what asynchronous database library you are using, but aiosqlite's fetchone method returns either a single item tuple or None (when the column value doesn't exist in the entire table)

primal token
mortal thorn
#

I did,
intents.members = True

primal token
#

In the developer portal as shown in the error.

brazen raft
#

Instead of (%s) try writing $1 or ? whichever you prefer

#

I'm assuming the channelID column type is INTEGER or something like that

#

Also the second argument to execute needs to be an iterable. (channel.guild.id) reads as channel.guild.id which is of type int (not an iterable)

#

If you meant to write a single item tuple, add a trailing comma inside the parentheses

vale wing
brazen raft
#

It supports $1

vale wing
#

Will know

#

? are cringe imo

brazen raft
#

sqlite3 (a standard library module it aims to write an asynchronous version of) also supports $N

primal token
mortal thorn
#

oh I get it

vale wing
primal token
# mortal thorn wdym

Read the error, its quite descriptive and redirects you to the developer portal

vale wing
#

And for god's sake

#

Don't start an argument about this

primal token
primal token
brazen raft
vale wing
primal token
#

It all depends on its context lmao

mortal thorn
vale wing
primal token
brazen raft
#

I miss asyncpg for the fact it doesn't give me an iterable for fetchone with a single column select

#

Or, at least, I think that's what it did

#

If I remember correctly

vale wing
#

I like that thing tho

mortal thorn
#

wait me I need a new token

brazen raft
mortal thorn
#

as it says I didnt enable it

scarlet pond
#

I am trying to create a new text channel on bot join, but its missing intents. what intents do I need?

#

the line of code: await guild.create_text_channel("contribute-to-the-code")

brazen raft
#

I don't think any intent is required to create a text channel. I think your bot simply needs permissions to do so

#

I think manage_channels

mortal thorn
#

okay I just needed a new token

brazen raft
vale wing
scarlet pond
vale wing
#

That's not intents issue

#

As @brazen raft said it's bot permissions issue

#

Make sure your bot has the permission to create channels

scarlet pond
#

ah

primal token
#

Which if you dont have permissions the endpoint would return a 403 HTTP code, which means ofc forbidden

scarlet pond
#

oops

#

oh yeah I forgot to tick it

#

thanks

brazen raft
#

@scarlet pond
You can check whether you have the guild permission to create text channels with

if guild.me.guild_permissions.manage_channels:
    ...

or use the commands.has_permissions decorator

@bot.command()
@commands.bot_has_permissions(manage_channels=True)
async def command_function(...):
    ...
scarlet pond
#

Yeah it works now

slate swan
#

How can I repeat a command on error? Instead of them manually retrying the command.

brazen raft
#

Perhaps reinvoke it with the same context in the command.error handler function

limber bison
#

can i host bot on aws 750 ec2 free service ?

#

this one ?

sick birch
limber bison
sick birch
limber bison
austere vale
#
  @commands.Cog.listener()
  async def on_message_delete(self, message):
    if not message.author.bot:
      embed=nextcord.Embed(title="Message delete", description= f"Deleted by {message.author.mention} in {message.channel.mention}",color=0xfd9fa1, timestamp=datetime.datetime.utcnow())
      fields=[("Content",message.content,False)]
      for name, value, inline in fields:
        embed.add_field(name=name,value=value,inline=inline)
        if value is None:
          embed.add_field(value="_ _")
      try:
        await self.bot.get_channel(933978399280599080).send( embed=embed)
```can someone help me with this? im trying to make it so that my code will change the value to \_ _ if the deleted message doesnt have any text in it, but im getting the error
sick birch
brazen raft
#

Probably

austere vale
brazen raft
#

Unless you want to use "\\_ \\_"

austere vale
# brazen raft Unless you want to use `"\\_ \\_"`
  @commands.Cog.listener()
  async def on_message_delete(self, message):
    if not message.author.bot:
      embed=nextcord.Embed(title="Message delete", description= f"Deleted by {message.author.mention} in {message.channel.mention}",color=0xfd9fa1, timestamp=datetime.datetime.utcnow())
      fields=[("Content",message.content,False)]
      for name, value, inline in fields:
        embed.add_field(name=name,value=value,inline=inline)
        if value is None:
          embed.add_field(value="\\_ \\_")
      try:
        await self.bot.get_channel(933978399280599080).send( embed=embed)
```i got the same error
brazen raft
#

The way you are checking whether the value is None and if so use another add_field is wrong

#

You are still adding the field with the invalid value

#

And you are not calling the add_field method correctly inside the if

#

I also see no reason for this to be inside a loop and for having to check the content of the message

austere vale
slate swan
#

what does TypeError: Client.event() missing 1 required positional argument: 'coro' mean?

crystal glen
#

Why my program isn't working?

brazen raft
#

Message content is never unfit for an embed field, I believe, so no checking has to be done, too

crystal glen
brazen raft
crystal glen
#

idc, And it's not all of it

brazen raft
#

The only reason you get this error that I can think of is that you used asyncio.run - or some similar function - already

slate swan
brazen raft
#

Also rename client to bot so it depicts its variable correctly

#

You are using commands.Bot, after all, not discord.Client

austere vale
#

i got it, thank you so much Roie

silver reef
#

how to get the column name in sqlite3?

here is my table :
id | sword |shield
12| 2 | 1
i want to send the user an embed containing :
sword : 2
shield : 1
i know already how to get the numbers of each item but i don't know how to get the column names (sword/shield) any help?

iam using aiosqlite python library btw

slate swan
crystal glen
#

Why does it only prints it's self?

slate swan
crystal glen
slate swan
#

yes

crystal glen
#

this error

slate swan
#

it could potentially be a bug with the library. i have no clue why that happens

crystal glen
#

How would this happen

slate swan
#

yes

crystal glen
#

Why does it not happen to you

slate swan
#

no idea

crystal glen
#

we're using the same library...

slate swan
crystal glen
slate swan
#

cool

crystal glen
#

I have another error

slate swan
#

show it fully

crystal glen
slate swan
#

well are you trying to do tasks with the EventLoop?

crystal glen
#

My code is 19 lines of code...

#

This is 18 of em

slate swan
crystal glen
#

I don't have event loops, No.

#

As I'm aware of...

slate swan
cold sonnet
#

time.sleep...

crystal glen
crystal glen
slate swan
#
print("\n".join([*map(str, ctx.guild.members)]))
crystal glen
#

Bruh

slate swan
#

reset your token and you need to enable all of the intents youre asking for, aka all the privileged intents

crystal glen
#

I reset the token

#

I don't know what im doing wrong here

slate swan
#

you forgot one

crystal glen
#

NOOOOW it works

#

Thanks <3 a lot

slate swan
#

👍

crystal glen
#

The bot has administrator and above all the roles...

#

@slate swan

#
@client.command()
async def everyoneisharyad(ctx, member = discord.Member):
    n = 1
    for member in ctx.guild.members:
        await member.edit(nick=f"Haryad V{n}")
        n += 1
        time.sleep(0.5)

slate swan
#

you really shouldnt use time.sleep, and why is the member argument for? and you can use enumarate

crystal glen
#

What do I do now

slate swan
#

skip it in the for loop

cold sonnet
#

the owner is also a person it can't edit

crystal glen
#
@client.command()
async def everyoneisharyad(ctx, member = discord.Member):
    n = 1
    for member in ctx.guild.members:
        try:

            await member.edit(nick=f"Haryad V{n}")
            n += 1
            time.sleep(0.5)
        except:
            pass
slate swan
#

it’ll work

#

bare excepts😭

crystal glen
#

Yay it works

#

Thanks

cold sonnet
slate swan
cold sonnet
#

yes else the code stops

#

acceptable in a loop

slate swan
#

just pass the exception smh

cold sonnet
#

what do you mean

slate swan
#

he used a bare except, which he could just pass the exception which is CommandInvokeError

#

!d discord.ext.commands.CommandInvokeError

unkempt canyonBOT
#

exception discord.ext.commands.CommandInvokeError(e)```
Exception raised when the command being invoked raised an exception.

This inherits from [`CommandError`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError")
limber bison
#

message.author.roles == 1002972472913707080

#

not working

#

not this to

#

i want has_role check on message listner

royal meteor
#

Why does this code:

async def main():
    [await bot.load_extension(f"cogs.{file[:-3]}") for file in os.listdir("main\cogs") if file.endswith(".py")]
    await bot.start(token)

asyncio.run(main())```
Give this error:
```discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.inventory' raised an error: RuntimeError: asyncio.run() cannot be called from a running event loop
sys:1: RuntimeWarning: coroutine 'main' was never awaited```
slate swan
#

Add await.

royal meteor
#

Okay thanks

visual island
#

the error means that you're trying to do asyncio.run() where there's a running loop already

novel prairie
#

i have a code that tells server roles and it works fine heres the code: py @bot.command() async def allroles(ctx): embed = discord.Embed(title=f"""{ctx.guild.name} Server Roles: """) output2 = "" server = ctx.message.guild role_id = server.roles[0] for role in server.roles: if role.name == "@everyone": print("it´s everyone role") else: output2 +=f"{role.name} \n" await ctx.send(embed=embed) await ctx.send(output2)

#

and the command works like this:

novel prairie
#

how can i make that?

wicked atlas
#

Put your output in the description or a field of the embed

@bot.command()
async def allroles(ctx):
  embed = discord.Embed(title=f"""{ctx.guild.name} Server Roles:
""")
  output2 = ""
  server = ctx.message.guild
  role_id = server.roles[0]
  for role in server.roles:
    if role.name == "@everyone":
      print("it´s everyone role")
    else:
      output2 +=f"{role.name} \n"
  
  embed.description = output2

  await ctx.send(embed=embed)
#

@novel prairie

novel prairie
#

hm

#

im new to dev

#
@bot.command()
async def allroles(ctx):
    embed = discord.Embed(title=f"""{ctx.guild.name} Server Roles:
""", description=f""
    output2 = ""
    server = ctx.message.guild
    role_id = server.roles[0]
    for role in server.roles:
        if role.name == "@everyone":
            print("it´s everyone role")
        else:
            output2 += f"{role.name} \n" "")

    embed.description = output2


    await ctx.send(embed=embed)
    await ctx.send(output2)``` like that?
#

sorry if i did something wrong im new to dev

novel prairie
wicked atlas
#

You're missing a ), and you're sending it twice, once in the embed, then again after sending the embed

#

The code that I sent should be working

novel prairie
#

oh

#

ok leme try

novel prairie
limber bison
#

Hii , i want my bot presence , watching something and also in profile a link with the image 😳

#

I can i do that ?

white aurora
#

check pinned messages

slate swan
#

Read that

#

who made that gist?😳

#

Okimii !!

#

🙀

#

anytime!🫂

#

yw bro

limber bison
slate swan
#

pretty sure you can't add images on bots presence'

#

sadly bots cant have rich presences😔

#

yeah

white aurora
#

this works for me

#

lol

limber bison
#

🥲 uff , links ? 🤔

sick birch
white aurora
#

oh

slate swan
white aurora
#

👀

#

i'll rewrite it later

limber bison
#

Create a command 😳

white aurora
#

what?

smoky cedar
#

How to role lock a slash command with discord py?

#

As admin only

limber bison
#

How much a on_message function put pressure on bot ?

#

If 300-400 users there !

#

Will t2.micro able to manage it ?

sick birch
#

Might be cutting it close but should be fine, depends on the activity of those 300-400 members of course

pliant gulch
# sick birch Not a good idea

For the longest time now, I've always also thought that changing presence in on_ready was an issue. But looking at many other libraries (mostly in different languages) such as DJS have all be setting presence in READY event with no issue at all

#

Is this just a python issue?

sick birch
#

I don't think so.. maybe it's just a one-off sort of deal where you have a chance to get disconnected from the websocket?

#

And maybe the other libraries you mention think it's not that big of a deal

pliant gulch
#

Premature disconnection is a pretty big deal isn't it?

sick birch
#

The question I've always had is, changing presence happens over the REST API, and on_ready happens after you establish contact with the gateway, which is a websocket, so I'm not sure why those 2 interfere

pliant gulch
#

And there is no warnings in the other libraries

pliant gulch
#

It's a gateway command

sick birch
#

Do you mean where you pass it into your IDENTIFY i believe it is?

pliant gulch
#

Yes

#

But you ALSO have a standalone

slate swan
#

its not related to python, its just a waste of dispatching an event thats identical to one thats already been dispatched which the real main issue is since on ready can get dispatched many times you send useless events to the gateway and iirc it can get you disconnected from the gateway or something like that which bluenix told me about

sick birch
#

The one passed into IDENTIFY is the one you pass into your client constructor, right?

pliant gulch
#

Yes but you also have a separate gateway command to change presence

pliant gulch
#

Correct

#

That's what the change_presence uses to set presence

#

It's not over rest, but infact a gateway command

pliant gulch
#

I doubt your bot sends READY more than that amount?

sick birch
#

That might make more sense as to getting disconnected.. maybe Discord doesn't like receiving gateway commands so soon after identification, though I wish Discord themselves had a little blob on it on their API page. If they do, I probably missed it

pliant gulch
#

?

#

I send HEARTBEAT as soon as I identify

#

No issue at all, why does discord not like receiving gateway commands after identification quickly?

#

Is this stated anywhere officially?

sick birch
limber bison
#

How can I use 1h or 1hr as input

pliant gulch
#

So what are your basis

limber bison
#

😳

sick birch
#

I'm only speculating as like you mentioned, discord.py seems to be the only one doing it, and there's no official information on it

slate swan
sick birch
#

Generally seems like there's not too much reason to do it

pliant gulch
#

Exceeding the GATEWAY ratelimits instantly disconnects you from the gateway

#

Unlike the REST ratelimits

slate swan
sick birch
pliant gulch
#

"nor did i mention ratelimits as i know that it wont affect anything"

#

Your whole argument is that, READY is dispatched more than once during conventional life-time of a bot

#

I'm refuting you because READY doesn't get called enough IN REGULAR USE cases that exceed the 120/2s 60/1s gateway command ratelimit

#

Which if it did would result in an instant disconnection from the gateway

#

Does your bot dispatch READY 80 times in 1 second?

slate swan
#

i never said it was due to ratelimits, either way i cant really recall the reason lol

pliant gulch
#

"real main issue is since on ready can get dispatched many times you send useless events to the gateway and iirc it can get you disconnected from the gateway or something like that which bluenix told me about" is basically saying, exceeding ratelimit (which I didn't know) disconnects

slate swan
#

so your point is saying that i dont have a valid reason because i cant recall a certain event?

pliant gulch
#

??????

slate swan
#

im not saying im right nor did i say i was, i just said it was something along the lines as i cant recall what bluenix told me

#

¯_(ツ)_/¯

pliant gulch
#

I'm refuting your argument because answer me this, does your bot dispatch READY 60+ times per second?

#

Just because you cannot recall a certain event does not mean it doesn't exist

slate swan
#

?

pliant gulch
slate swan
#

i never said ratelimits dont exist and i never said the reason was due to ratelimits lol

pliant gulch
#

And I'm telling you your argument is using ratelimits as the basis

slate swan
#

ok, great

pliant gulch
#

"real main issue is since on ready can get dispatched many times you send useless events to the gateway and iirc it can get you disconnected from the gateway or something like that which bluenix told me about"

slate swan
#

its just the dispatching of useless event but it still wouldnt be enough to get you ratelimit if it was on each call of on_ready

#

i think i was just mixing one of my memories about changing your presence in a certain time frame

#

how can I when I write a command that it is deleted immediately afterwards?

slate swan
#

!d discord.Message.delete

unkempt canyonBOT
#

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

Deletes the message.

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

Changed in version 1.1: Added the new `delay` keyword-only parameter.
slate swan
loud shard
#

hey guys im working on a discord bot to send the same message across different servers, but i cant figure out how to send the image or file attached to the command message, can som1 help me pls?

slate swan
golden tapir
#

is it possible to use client.event and bot.command in the same bot

loud shard
slate swan
#

@slate swan

sick birch
loud shard
slate swan
sick birch
golden tapir
#

well i want to have commands like joined but i also want a on_member_join

sick birch
golden tapir
#

how

#

when i use bot.commands it works but all the client.events dont work

sick birch
smoky cedar
#

I recently migrated my bot's slash commands to discord py 2.0. My commands are all working, however, the details haven't updated in the slash menu for my guilds. For example, here I have a command that I changed the description for, and I haven't been able to figure out how to add a mandatory parameter with discord py. But the command still works, it shows the old description and parameter in the slash menu.

@app_commands.command(
    name=FOLLOW_COMMAND,
    description="Follow a spotify artist",
)
async def follow_artist(self, interaction: discord.Interaction, artist_link: str):
golden tapir
sick birch
slate swan
golden tapir
sick birch
slate swan
#

^^

smoky cedar
sick birch
# golden tapir how?
bot = commands.Bot(...)

@bot.listen()
async def on_member_join(member: discord.Member) -> None:
  ...

@bot.command()
async def my_command(context: commands.Context, ...) -> None:
  ...
smoky cedar
slate swan
#

!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...
loud shard
#

pls how do i access a command message's attachment?

sick birch
unkempt canyonBOT
#

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

Syncs the application commands to Discord.

This must be called for the application commands to show up.
sick birch
#

You can sync in your setup_hook

slate swan
#

Robin knows everything

smoky cedar
sick birch
smoky cedar
slate swan
unkempt canyonBOT
sick birch
slate swan
slate swan
#
attachment = ctx.message.attachments[0]
print(attachment.url)

iirc...

#

you know whats cuter, robins examples😳pithink

slate swan
#

im joking robins examples arent that bad 🏃‍♂️

loud shard
sick birch
sick birch
slate swan
#

@slate swan Did you even finish your code jam?

sick birch
#

When new features come out, I'm the first to make an example haha

loud shard
#

thanks for the help guys i do appreciate it, ill try rn

slate swan
sick birch
#

no i just have all the notifications and whatnot turned on

slate swan
sick birch
#

Not to mention news spreads fast in this community

slate swan
#

lol

sick birch
#

Think d.py being shut down, that spread like wildfire

slate swan
#

i was one of the first ones spreading the gist when it revived lmao good times

#

iirc i was the first one who posted it in this channel

#

everyone couldnt believe it until they checked the dpy server lol

#

@loud shard you might get list index out of range, just means the command didn't have a file attached

slate swan
#

try sending the command without an attachment

loud shard
slate swan
#

means there was no attachment

left raptor
#

I'm trying to write a script to play mp3 files in discord without any user commands, and I was told discord.py can only do that through commands, so I downloaded voicemeter

loud shard
left raptor
#

but I can't get it to play sound through my mic. does anyone know of a way to do this?

#

or has anyone used voicemeter by any chance

sick birch
#

"Play sound through mic" how? Microphones are input devices

slate swan
#

LOL

sick birch
#

I'm just trying to understand here

slate swan
#

@slate swan 😭

#

dont ping me, you already have a cute helper nearby 🏃‍♂️

robust fulcrum
#

How we can make our bot send custom emojis?

slate swan
loud shard
spice kindle
#

how do you add the list of users to show up with a slash command

#

like this

quaint epoch
#

that would be a slash command

#

and it would be treason on my part to help with slash commands

left raptor
#

but I don't know how to use it and the tutorials are not helpful

#

and I was wondering if there was another way to play mp3 files in a discord voice server with a python script that doesn't require user commands in a text channel

dusky pine
left raptor
#

you've used it?

dusky pine
#

one time

#

then i deleted it since earraping wasn't allowed in the server i was in

left raptor
#

so it's possible I could use it to have python play an mp3 file in my voice channel?

dusky pine
#

you want to make a soundboard? or a discord bot that plays mp3 file?

left raptor
#

no my actual end goal is akin to a personal assistant. I've got a script with speech to text that can listen to my mic and call functions when I give certain commands

smoky cedar
#

How to respond to a discord interaction / slash command with a message that only the issuer can see? (DPY 2.0)

smoky cedar
#

For example in this case, I have a slash command limited to admin permission. If anyone else tries to use it I want the bot to tell them they can't but not send an actual message for everyone

golden tapir
#

is it possible to have a list of for example bad words and check if the message a user sent is in one of the bad words

#

list

smoky cedar
left raptor
#

and I recently discovered resemble.ai, which has really realistic text to speech

dusky pine
white aurora
#

interaction.response.send_message()

smoky cedar
left raptor
#

so I'd like to make a script that when I ask it questions, it uses the resemble.ai api to answer them

#

either with prerecorded answers or hooked up to a chatbot api like gpt3

dusky pine
dusky pine
#

mkay so I think you need to make a virtual input device, pipe the API response to that, and set up Discord so it accepts the virtual input device

#

i don't know how to do that though

left raptor
#

my voicemeter panel looks like this

#

but I've tried switching all of the sound settings so they use the virtual input

#

and trying to get it to pipe any output sound into input sound has been unsuccessful

dusky pine
#

you're supposed to change Input Device to that vb audio thing

left raptor
#

yeah when I do that, it picks up no sound from my 2-plantronics headset

dusky pine
#

so the API response is there, but no sound from the actual headset?

left raptor
#

I haven't coded the api code

#

I've been trying to test this first by getting something like a youtube video or system sound to play through my mic

#

so the end goal is to have both the api response audio and my voice coming out of the virtual input

#

but right now neither does

spice kindle
#

i want a list of users to show while typing in /hello, how can i add that option or whatever it's called to my code?

slate swan
#

Seems like something @sick birch would know

sick birch
#

If it was discord.py, I would, but it's not unfortunately.. my knowledge is quite limited in scope 😔

#

But, as a library-agnostic solution to point you in the right direction, I'm guessing you would have to pass in your libraries discord.Member equivalent to the first parameter of Option (which is currently str

slate swan
spice kindle
#

thanks

#

i found a couple other resources i'm taking a look at all of them

slate swan
#

well make sure they are for pycord because all libraries have their own implementations
you can always refer to the examples folder of the library on github for clear examples with explanations

spice kindle
#

yep

final pumice
#

how do i delete a message

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.

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

thanks

slate swan
#

np

spice kindle
#

is it possible to get the user's ID from this?

silk fulcrum
unkempt canyonBOT
#

property id```
Equivalent to [`User.id`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User.id "discord.User.id")
royal bone
#

how to record audio from
voice channel ?

royal bone
silk fulcrum
#

i guess it's easier to use only js

#

but you can try using both langs

royal bone
scarlet pond
#

can someone help me? I don't know the syntax for the lines with comments

@client.event
async def on_guild_join(guild):
    if "channel-name-blah" not in guild.text_channels:
        await guild.create_text_channel("channel-name-blah")
        # send message in "channel-name-blah"
    else:
        # send message in "channel-name-blah"
slate swan
#

error:
raise RuntimeError('Task is already launched and is not completed.')
RuntimeError: Task is already launched and is not completed.

Code:

async def on_message(message):
    if message.author == bot.user:
        return
    if message.author.bot: return

    if "hello" in message.content.lower():
        await message.channel.send("Hello")```
scarlet pond
#

how does message.channel.send work if its not in the function

slate swan
scarlet pond
#

oh ok

slate swan
#

it is this line

#

it will keeps spamming Hello in chat

scarlet pond
#

thats like 9 lines of code

#

oh

slate swan
#

because im using if "hello" in message.content.lower():
instead of if message.content.lower() == "hello":

scarlet pond
#

try using if else

#

thats usually a fix

slate swan
#

?

#

it keeps spamming hello in channels

scarlet pond
#

yeah

slate swan
#

idk why

scarlet pond
#

you should try using if/else statements

slate swan
#

wdym bro

#

show code example

scarlet pond
#
if (boolean):
  # do something
else:
  #do something
slate swan
#

and how does that fixes it?

scarlet pond
#

wait have you done programming before or just started

slate swan
#

i have bro

#

there is already an else command

scarlet pond
#

no that is a bunch of if statements

slate swan
#
        with open("/Users/bai/Documents/Personal Things/PythonDiscord/log.txt", 'a') as f:
            f.write(message.content + '\n')```
#

i have this as my else command

scarlet pond
#

else if?

slate swan
#

@slate swan have u fixed ur error?

scarlet pond
#

not yet

slate swan
#

it keeps sending it because u haven't processed it

slate swan
#

await bot.process_commands(message)

#

it should be like this

#

you should use listen

slate swan
#
@bot.event
async def on_message(message):
    if message.author == bot.user:
        return
    if message.author.bot: return

    if "hello" in message.content.lower():
        await message.channel.send("Hello")
    
    await bot.process_commands(message)```
#

I already have that added though

vocal snow
slate swan
#

and it doesn't stop the spam

scarlet pond
vocal snow
#

Yes

#

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

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**.
scarlet pond
#

ah ty

slate swan
#

no?

scarlet pond
scarlet pond
#

also parenthesis aren't needed

slate swan
slate swan
#

!e

mes = "zeffoisuwu"
if "zeffo" in mes: 
    print("uwu")
unkempt canyonBOT
#

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

uwu
vocal snow
scarlet pond
#

wait you can do that

slate swan
#

yeah

slate swan
slate swan
#

💀

vocal snow
#

It is syntactically correct

slate swan
unkempt hawk
#

What's the proper way of getting the message.author's connected_accounts? I see the Profile stuff is deprecated

scarlet pond
slate swan
silk fulcrum
#

i see

slate swan
unkempt hawk
slate swan
#

1 sec

#

fiddler is loading

#

/users/ID

unkempt hawk
loud shard
vocal snow
unkempt hawk
vocal snow
#

That's the endpoint

#

Not sure what it is in dpy

silk fulcrum
unkempt hawk
vocal snow
#

The latter i think

unkempt hawk
#

Unless I'm doing something wrong

silk fulcrum
#

only for bot

unkempt hawk
#

How do I get an user's connections then? I.e. if I wanted to create a /twitter bot command which returns their Twitter account

slate swan
unkempt hawk
slate swan
#

Though you can only get yours, which kind of makes sense

#

Well then it doesn't need the version, yet again Discord consistency I guess

unkempt hawk
slate swan
#

Well it's very simple: you can't

silk fulcrum
#

wow

unkempt hawk
slate swan
#

Where/what version

slate swan
#

Deprecated since version 1.7.

#

So most endpoints are dead and/or deprecated as of right now, hence why it's no longer in newer updates

#

The 404 on Discord's API clearly indicates the endpoint got removed, otherwise you'd get an error 401 or 403; I believe that's the error code for the other endpoints.

vocal snow
#

its listed in the documentation though

slate swan
#

In which documentation?

vocal snow
#

the discord api documentation

slate swan
#

For the logged in user, yes.

#

@me/connections

#

Not {user.id}/connections

vocal snow
#

yes, but there should be some way for an application to access that

#

why would it be listed there otherwise 🤔

slate swan
#

OAuth

#

Not bot applications

#

connections is an oauth scope

#

allows /users/@me/connections to return linked third-party accounts

unkempt hawk
#

discord.errors.Forbidden: 403 Forbidden (error code: 20001): Bots cannot use this endpoint

#

Is there a workaround for that?

#

I've looked it up and seen some "user bot" solutions but don't really know how to make that happen

slate swan
#

No there is none

#

User bots are against ToS, so don't do that :)

unkempt hawk
#

Couldn't care less tbh

slate swan
#

!rule 2

unkempt canyonBOT
slate swan
#

but you agreed on them uppon making an accountyert

#

We do, and won't help you breach it

silk fulcrum
#

okimiii 👋 👋

vocal snow
unkempt hawk
#

Maybe they should fix their shit API then

slate swan
#

Not if you don't make a bot login page on a website and then link it together

slate swan
#

hello zeffo and master✌️

#

and i see you krypton👋

#

Well gotta go, trains are cancelled and/or late for my second day at new work NotLikeThis

scarlet pond
#

how to edit past message 💀

vocal snow
silk fulcrum
unkempt canyonBOT
#

await edit(*, content=..., embed=..., embeds=..., attachments=..., suppress=False, delete_after=None, allowed_mentions=..., view=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the message.

The content must be able to be transformed into a string via `str(content)`.

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

Changed in version 2.0: Edits are no longer in-place, the newly edited message is returned instead.

Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") instead of `InvalidArgument`.
slate swan
scarlet pond
#

thanks

silk fulcrum
slate swan
#

im only 15yert

silk fulcrum
#

isnt 15 >= 20? :lemao:

slate swan
#

🗿

paper sluice
#

oki's age is dynamic

silk fulcrum
#

probably because his dad is Danny

paper sluice
#

now that i look at it, age is dynamic all the time

slate swan
slate swan
silk fulcrum
#

ok

slate swan
#

ok

paper sluice
unkempt canyonBOT
#

@paper sluice :white_check_mark: Your 3.11 eval job has completed with return code 0.

okimii
slate swan
#

@paper sluice youre so evil you probably pour the milk before the cereal🤬

silk fulcrum
#

whytf i did not commit anything

#

how am i going to commit 11 files, that's baad

slate swan
#

🥴

slate swan
#

Youre going straight to java's place aka hell

paper sluice
#

java is my fav lang 😳

silk fulcrum
slate swan
#

im not sure if theres a place worse than hell😔

#

Ryuga youre going to a place where python is replaced by Swift

#

😳

#

never

#

oh and @silk fulcrum i saw that mrpithink

silk fulcrum
#

:shh:

paper sluice
# slate swan Ryuga youre going to a place where python is replaced by Swift

!e

from ctypes import c_char
from fishhook import hook

@hook(str)
def greplace(to_be_replaced: str, replacement: str):
    replacement = f'{replacement:<{len(to_be_replaced)}}'
    l = len(replacement) + 1
    cbase = (c_char*l).from_address(id(to_be_replaced)+48)
    cbase.value = bytes(replacement, 'utf-8') + b'\0'
    
'python'.greplace('swift')
print('python')

already there 😎

slate swan
#

bozo

unkempt canyonBOT
#

@paper sluice :white_check_mark: Your 3.10 eval job has completed with return code 0.

swift 
slate swan
#

smh using ctypespBlush

paper sluice
slate swan
#

mhm

slate swan
grim oar
#

anyways ot.

slate swan
#

How to make bot send prefix when mentioned?

silk fulcrum
#

on_message: check if message contains bot mention (via message.mentions), get prefix, send it

slate swan
#

alr

vale wing
unkempt canyonBOT
#

discord.ext.commands.when_mentioned(bot, msg, /)```
A callable that implements a command prefix equivalent to being mentioned.

These are meant to be passed into the [`Bot.command_prefix`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.command_prefix "discord.ext.commands.Bot.command_prefix") attribute.

>   Changed in version 2.0: `bot` and `msg` parameters are now positional-only.
> 
>
silk fulcrum
#

he wants to send prefix if bot is mentioned, not launch commands

#

i guess

vale wing
#

Ah that

slate swan
#

and how to make my bot delete an embed message after 10 seconds?

#

await ctx.send(embed=embed, delete_after=10)

#

ok thanks bro

#

how to set a embed image/gif?

#

and how to put python variable in embed?

shrewd apex
#

!d discord.Embed.set_image

unkempt canyonBOT
#

set_image(*, url)```
Sets the image for the embed content.

This function returns the class instance to allow for fluent-style chaining.
slate swan
#

how?

#

rannum = ['1',
'2']
em = discord.Embed(title=f"You got {rannum}!")

#

!e @bot.command() async def ping(ctx): await ctx.send('Pong!')

slate swan
#

!e ```import discord
from discord.ext import commands
import json
import os

key = "e"
client = discord.Client()
bot = commands.Bot(command_prefix = '.')
random = ['MayBe' , 'Yes' , 'No' , 'Probbly' , 'Likey' , 'unlikey']
@bot.event
async def on_ready():
print("BOT ONLINE")
channel = bot.get_channel(1004036302594920508)
await bot.change_presence(activity=discord.Game('Sky Craft '))
await channel.send("I Am Reloading :orange_square:")
await channel.send("Done Reload :white_check_mark:")
@bot.event
async def on_message(message):
if message.author == bot.user:
return
if message.content.startswith("!user"):
await message.delete()
await message.channel.send(f"Hello {message.author}")
if message.channel.id == 1004054901787201646:
channel = bot.get_channel(1002154446442209393)
await message.delete()
await channel.send(f"Test bot Server » {message.author} » {message.content}")
if message.channel.id == 1002154446442209393:
channel = bot.get_channel(1004054901787201646)
await message.delete()
await channel.send(f"Sky Craft » {message.author} » {message.content}")
if message.channel.id == 1002154446442209393:
channel = bot.get_channel(100215444644220939)
await channel.send(f"{message.author} » {message.content}")
if message.channel.id == 1004054901787201646:
channel = bot.get_channel(1004054901787201646)
await channel.send(f"{message.author} » {message.content}")
#-------------------------------------------------------------------------------
@bot.command()
async def ping(ctx):
await ctx.send('Pong!')```

shrewd apex
shrewd apex
slate swan
unkempt canyonBOT
#

Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.

>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."

Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.

shrewd apex
#

^^

slate swan
#

k

#

rannum = ['1',
'2']
em = discord.Embed(title=f"You got {rannum}!")

#

i dont get it

shrewd apex
#

what are u trying to do get a random number?

slate swan
#

yeah

shrewd apex
#

if u just need the list there seems nothing wrong with what u sent

#

!d random.choice

unkempt canyonBOT
#

random.choice(seq)```
Return a random element from the non-empty sequence *seq*. If *seq* is empty, raises [`IndexError`](https://docs.python.org/3/library/exceptions.html#IndexError "IndexError").
slate swan
#

rannum = ['1',
'2']
em = discord.Embed(title=f"You got {random.choice(rannum)}!")

#

yes?

shrewd apex
#

!e

import random
x = random.choice([1, 2])
print(f"{x}")
unkempt canyonBOT
#

@shrewd apex :white_check_mark: Your 3.11 eval job has completed with return code 0.

2
shrewd apex
#

yes

slate swan
#

k

#
@commands.cooldown(1, 10, commands.BucketType.user)
async def coinflip(ctx):
    coinside = ['`Heads`',
                '`Tails`']

    em = discord.Embed(title=f"Flipping a coin!", description=f"will it be heads or tails? :)")
       em.set_image(f"https://media.giphy.com/media/V57jUkC3eZFsym7iwE/giphy.gif")
             
    await ctx.send(embed=em, delete_after=5)
    await asyncio.sleep(5)
             
    em = discord.Embed(title=f"You got {random.choice(coinside)}!")
    await ctx.send(embed=em)```

something is wrong with my code its not working
shrewd apex
#
@bot.command(name="coinflip")
@commands.cooldown(1, 10, commands.BucketType.user)
async def coinflip(ctx):
    coinside = ['`Heads`', '`Tails`']
    em = discord.Embed(title=f"Flipping a coin!", description=f"will it be heads or tails? :)")                                                                       em.set_image(url=f"https://media.giphy.com/media/V57jUkC3eZFsym7iwE/giphy.gif")
    await ctx.send(embed=em, delete_after=5)
    await asyncio.sleep(5)
    em = discord.Embed(title=f"You got {random.choice(coinside)}!")
    await ctx.send(embed=em)
slate swan
#

what did u change here?

shrewd apex
#

u edited urs smh

#

it should wrok now

slate swan
#

still no work

shrewd apex
#

whats the error?

slate swan
#

no error shows nothing

shrewd apex
#

are u sure u are using the code i gave rn

slate swan
#

yes i am

shrewd apex
#

urs dosent have url=

slate swan
#

oh

shrewd apex
#
       em.set_image(f"https://media.giphy.com/media/V57jUkC3eZFsym7iwE/giphy.gif")

slate swan
#

now it works

shrewd apex
#

url='xyz'

#

👍

slate swan
#

it works now, thanks bro

robust fulcrum
#

Guys why i am getting this error even i have given the function the url of image

glad cradle
#

!d discord.Embed.set_image

unkempt canyonBOT
#

set_image(*, url)```
Sets the image for the embed content.

This function returns the class instance to allow for fluent-style chaining.
robust fulcrum
#

Pk

#

Ok

glad cradle
#

if image is a url you should do embed.set_image(url=image)

robust fulcrum
#
@bot.command()
async def info(ctx,pokemo):
    pokemo = pokemo.lower()
    poke = pokemon(pokemo)
    num = poke.number()
    image = poke.image()
    embed = embeds(f" :emoji_3: #{num} {pokemo}","** **",discord.Color.green())
    embed.set_image(image)
    await ctx.send(embed=embed)
robust fulcrum
#

Ok

robust fulcrum
slate swan
#

Yeah

quasi sparrow
#

Why doesn't this work?

#

Btw there is an actual token in there

silk fulcrum
#

intents = discord.Intents...
intent.message_content...

#

also, any errors?

quasi sparrow
#

No

#

It give me this

quasi sparrow
silk fulcrum
#

(AKA Terminal in PyCharm)

quasi sparrow
#

Ok so in terminal what do i do?

silk fulcrum
#

py filename.py

quasi sparrow
#

Ok hold on

quasi sparrow
slate swan
#

is it possible to do verification on a button in plain discord.py? If so, how?

glad cradle
quasi sparrow
#

I think so

silk fulcrum
#

show us file structure

quasi sparrow
slate swan
#

show with token

silk fulcrum
#

file structure

#

dont listen this guy ^^

slate swan
#

rude

quasi sparrow
silk fulcrum
quasi sparrow
#

This is all it shows

silk fulcrum
#

and second it's not py format

#

it should be bot.py

#

not Bot

#

rename it

quasi sparrow
#

Nvm got it

silk fulcrum
quasi sparrow
#

Now it shows this

silk fulcrum
quasi sparrow
quasi sparrow
silk fulcrum
#

well, that's not the whole token but showing it is not good idea anyways

silk fulcrum
quasi sparrow
#

I will reset it

quasi sparrow
silk fulcrum
#

idk what does that mean, but i guess discord package installed so now you can run py bot.py

silk fulcrum
#

yeah, you'd better just do intents = discord.Intents.all() instead of those 2 lines, you don't need to care a lot about intents rn

quasi sparrow
#

Ok

#

Now if i run it give me this

silk fulcrum
quasi sparrow
#

Ok

#

Give me this

silk fulcrum
#

what?

hardy yoke
#

screenshots are 100% easier to read than a photo

silk fulcrum
#

yeah...

quasi sparrow
#

Disc is on my phone and python on my laptop

glad cradle
#

thx for the token

hardy yoke
#

discord is also available on laptops

quasi sparrow
#

I already reset it😂

slate swan
#

Well log in to discord on your browser on the laptop, not only that you are putting yourself at massice security risk constantly showing your token. Do you have any basic python knowledge btw?

quasi sparrow
slate swan
#

You can't off, you didn't even know how to name a file. My best advice would be to is learn some basic understanding of coding before delving into this.

robust fulcrum
#

How can I use the local image in set_thumbnail?

slate swan
robust fulcrum
#

Bruh

#

It's related to discord bot

slate swan
#

Don't Bruh me thanks, yet still a media question.

robust fulcrum
silk fulcrum
#

bruh i just forgot, it's smth like attachment://filename.fileformat

#

yeah it is

robust fulcrum
robust fulcrum
slate swan
#

How to do veryfy onclick button in d.py because i didn't see any tutorials in youtube

glad cradle
#

you need to use d.py v2.0

silk fulcrum
#

oh wait me dumb

robust fulcrum
#

Oh thanks

silk fulcrum
#

like that, edited

robust fulcrum
#

Ok

slate swan
#

set_image takes a url kwarg, it doesnt take any args

silk fulcrum
#

oops

slate swan
#

this error on my slash command here is code ```py
@app_commands.command(name="post", description="post a gamepass")
@commands.cooldown(1, 3600, commands.BucketType.user)
async def post(self, interaction: discord.Interaction, gamepassID: str):
#view = discord.ui.View() # Establish an instance of the discord.ui.View class
#style = discord.ButtonStyle.blurple # The button will be gray in color
#gamepass = discord.ui.Button(style=style, label="GAMEPASS", url=gamepass)
#view.add_item(item=gamepass)
gamepass=requests.get(f"https://api.roblox.com/marketplace/game-pass-product-info?gamePassId={gamepassID}").json()
embed=discord.Embed(description="your gamepass has successfully been posted in | #1004310613146734682",color=color.color)
await interaction.response.send_message(embed=embed)

      channel = self.client.get_channel(1004310613146734682)
      embed=discord.Embed(title=f"new post from {interaction.user}", description=f"donate bobux to {gamepass['Creator']['name']}\n `Robux` = {gamepass['PriceInRobux']}\n`gamepass` = **https://www.roblox.com/game-pass/{gamepassID}/{gamepass['name']}**",color=color.color)
      await channel.send(embed=embed)
#

read the last line

#

i did?

#
          channel = self.client.get_channel(1004310613146734682)
#

@slate swan

#

i got that

#

? how is getting a channel related to syncing a command

#

thats for the command?

#

should i take it out then add it? after?

#

well if you read the error ....

#

its still not working?

#

how did you sync

#
  @commands.command()
  @commands.is_owner()
  async def sync(self, ctx):
    op = await self.client.tree.sync()
    await ctx.send(f"```py\n{str(op)}```\n**DONE.**")
#

sync cmd

#

did you use the command before running your post cmd?

#

yea

#

wanna see full error

#

@slate swan

#

the command was fine intill i added

#

gamepassID: str

slate swan
#

does the gamepassID option appear on discord bte?

thin raft
#

Is that in a cog?

slate swan
#

yeah seems like that

thin raft
cold tide
#

How to fix

vocal snow
#

using a laptop or desktop would be a good start

cold tide
#

No... it doesnt matter

#

ive made bots on mobile.

#

i just dk why it wants a uri when ive selected scopes

#

@vocal snow

cold sonnet
#

it generates the url...

cold tide
#

Idk what you mean.

#

ive never had this issue before.

cold sonnet
#

you click shit and you get the url

#

you don't give the url

cold tide
#

I didnt give a url

#

i just selected scopes

cold sonnet
#

well you don't have to do anything

#

just select the scopes

cold tide
#

I did

#

it doesnt work...

south needle
#

what scope did yu select

cold tide
#

Bot then admin

south needle
#

hmm should work, maybe uncheck and recheck

cold tide
#

Nope

cold sonnet
#

what is telling you that it didn't work

south needle
#

super weird

lethal moat
#
with open ("./configuration.json","r") as config:
  bot_token = config["BOT_TOKEN"]
  prefix = config["PREFIX"]
  guild_id = config["GUILD_ID"]
  staff_guild_id = config["STAFF_GUILD_ID"]
  manager_role = config["TICKET_MANAGER_ROLE_ID"]
  logs_channel_id = config["LOGS_CHANNEL_ID"]
  mute_role_id = config["MUTED_ROLE_ID"]

have I gone blind?

cold sonnet
#

I tried it and it generated the url for me

#

are you sure you selected stuff?...

#

it only asks for redirect url if you select something other than bot

slate swan
cold tide
#

I needed to turn one intent off and it worked

#

LoL ima idiot

slate swan
#

i need help with a cool down error for slash commands

lethal moat
#

sorry its been a long time since I have done this

paper sluice
lethal moat
slate swan
#
  @commands.Cog.listener()
  async def on_app_command_error(interaction: discord.Interaction, error: app_commands.AppCommandError):
    if isinstance(error, app_commands.MissingPermissions):
      embed=discord.Embed(color=color.color,description=f"you are missing the **permission(s)** ``" + ", ".join(error.missing_permissions) + '``')

      return await interaction.response.send_message(embed=embed)
    elif isinstance(error, app_commands.MissingRequiredArgument):
      embed=discord.Embed(color=color.color,description=f"you are missing a **required argument** ``{error.param}``")
      return await interaction.response.send_message(embed=embed)   
    elif isinstance(error, app_commands.CommandOnCooldown):
      embed=discord.Embed(color=color.color,description=f"cooldown, try **again** in ``{error.retry_after:.2f}s``",ephemeral =True)
      await interaction.response.send_message(embed=embed)

error still

silk fulcrum
#

in your isinstance

slate swan
#

thats what i have sorry

#

thats old code but i got that and it dont work

silk fulcrum
#

what's new code?

slate swan
#
  @commands.Cog.listener()
  async def on_app_command_error(interaction: discord.Interaction, error: app_commands.AppCommandError):
    if isinstance(error, app_commands.MissingPermissions):
      embed=discord.Embed(color=color.color,description=f"you are missing the **permission(s)** ``" + ", ".join(error.missing_permissions) + '``')

      return await interaction.response.send_message(embed=embed)
    elif isinstance(error, app_commands.MissingRequiredArgument):
      embed=discord.Embed(color=color.color,description=f"you are missing a **required argument** ``{error.param}``")
      return await interaction.response.send_message(embed=embed)   
    elif isinstance(error, app_commands.CommandOnCooldown):
      embed=discord.Embed(color=color.color,description=f"cooldown, try **again** in ``{error.retry_after:.2f}s``",ephemeral =True)
      await interaction.response.send_message(embed=embed)
crystal glen
#
client.command()
async def allname(ctx, member = discord.Member):
    n = 1
    for member in ctx.guild.members:
        try:

            await member.edit(nick=f"Haryad V{n}")
            n += 1
            time.sleep(0.5)
        except:
            pass

I have this but I want to do
?allname Haryad
How do I do it? 🥲

silk fulcrum
#

im not sure if there is on_app_command_error listener

slate swan
crystal glen
silk fulcrum
crystal glen
#

No I want to use the command to change everyone's nickname
?allname Haryad
?allname asdoyuifgasd8fgqwed

silk fulcrum
slate swan
#

bro?

crystal glen
#
@client.command()
async def allname(ctx, member = discord.Member):
    n = 1
    for member in ctx.guild.members:
        try:

            await member.edit(nick=f"{member} V{n}")
            n += 1
            time.sleep(0.5)
        except:
            pass
#

So like this?

slate swan
#

...

slate swan
#

like he said

#

member: discord.Member

silk fulcrum
#

and you also might not have a member named like your query, so it'd be better to do member: str

crystal glen
#
@client.command()
async def allname(ctx, member: str):
    n = 1
    for member in ctx.guild.members:
        try:

            await member.edit(nick=f"{member} V{n}")
            n += 1
            time.sleep(0.5)
        except:
            pass

slate swan
zealous jay
#

What are you passing member arg for if it gets its value from the loop?

slate swan
#

comman*

silk fulcrum
silk fulcrum
crystal glen
#

No That's not what I mean...

#

Haryad is not a member ffs

#

Haryad is a string

silk fulcrum
crystal glen
#

?allname string
Should change everyone's name to string

#

How do I do it?

slate swan
#

@silk fulcrum DANG IT

zealous jay
#

Do you need the n += 1 thing?

silk fulcrum
#

ill check docs @slate swan

slate swan
#

tysm

silk fulcrum
crystal glen
zealous jay
#
@client.command()
async def allname(ctx, new_nick: str):
    n = 1
    for member in ctx.guild.members:
        try:

            await member.edit(nick=f"{new_nick} V{n}")
            n += 1
            time.sleep(0.5)
        except:
            pass
crystal glen
#

Ummm, It doesn't work

lethal moat
zealous jay
#

Send the error

crystal glen
#

I don't get an error

zealous jay
#

huh

crystal glen
#

Bruh

zealous jay
#

maybe the except is hiding the error

#

your bot doesn't have enough permissions

crystal glen
#

Now it works

zealous jay
#

good

crystal glen
#

Thanks ❤️

zealous jay
#

no problem

silk fulcrum
#

for who did write all this?```py
import asyncio

@client.command()
async def allname(ctx, *, name: str):
n = 1
for member in ctx.guild.members:
try:
await member.edit(nick=f"{name} V{n}")
n += 1
await asyncio.sleep(0.5)
except:
pass```

slate swan
#

@silk fulcrum find anything

silk fulcrum
slate swan
#

is thjere a way i can make a error just for that command?

zealous jay
#

Yeah this would be better

async def allname(ctx, *, new_nick: str):
slate swan
#

can you make it for me just for cooldsown

crystal glen
zealous jay
#

add the , *,

crystal glen
#

Thanks

silk fulcrum
#
@some_app_commands_decorators()
async def mycommand(...):
    ...

@mycommand.error
async def mycommand_error(self, interaction: discord.Interaction, error):
    if isinstance(error, app_commands.CommandOnCooldown):
        e = discord.Embed(color=color.color, description=f"cooldown, try **again** in ``{error.retry_after:.2f}s``")
        await interaction.response.send_message(embed=embed, ephemeral=True)```
#

@slate swan i guess this

#

mycommand replaced with your command name

slate swan