#General Help

1 messages · Page 5 of 1

slender lintel
#

@crimson coral

#

this error comes up

#

AttributeError: 'NoneType' object has no attribute 'send'

crimson coral
#

slash command options have to be fully lowercase

tidal beacon
#

okay big

slender lintel
#

@crimson coral

#

help

crimson coral
#

not sure why the validation error isn't giving the message though

#

uhh let's see

slender lintel
#

dm me if u figure it out

#

i gtg

tidal beacon
crimson coral
#

matchID

tidal beacon
#

oh

#

that too

#

okay it works now

#

thanks for the help!

wide cloak
#

IN The close view?

#

but i dont want to to a respons

#

i only want to send a normal message

tidal beacon
#

If I wanted to take a string and replace every space with %20, ive tried using .replace() but it didn't work. I am attempting to format links to search for a username with spaces in it btw

pastel wadi
#
 statblock = SlashCommandGroup("statblock", "Generate various statblocks")
    #@commands.cooldown(3,180, commands.BucketType.user)
    @statblock.command(name="classic", description="Generates a statblocks according to the 4d6^3 (keep highest 3)")
    async def classic(self, ctx, characterName = ""):
      pass
    
    @statblock.command(name="d4", description="Rolls a d4")
    async def d4(self, ctx, amount = 1):
        pass

Is there any possible reason on this good planet, why characterName contained within the first command should cause a validationerror while the one below works perfectly fine without a hitch?

slender lintel
#

Hey is http{s://guide.pycord.dev/ offline?

#

space >:D

slender lintel
#

lol

#

you dont need a space for it to work

#

try

#

await ctx.send(embed=embed)

#

that works too

#

lol

#

oh ok

#

but it looks bad

#

Why doesn't it work? :((
Code:

@bot.slash_command()
async def xwarn_remove(ctx, member: Option(discord.Member)):
    with open("warns.json") as f:
        data = json.load(f)
        if str(member.id) in data:
            for element in data:
                element.pop(f"{member.id}", None)
                with open("warns.json", "w") as f:
                    data = json.load(data, f)

Error:

Ignoring exception in command xwarn_remove:
Traceback (most recent call last):
  File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 122, in wrapped
    ret = await coro(arg)
  File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 829, in _invoke
    await self.callback(ctx, **kwargs)
  File "C:\Users\zReaxrYT\PycharmProjects\Discord\main.py", line 76, in xwarn_remove
    element.pop(f"{member.id}", None)
AttributeError: 'str' object has no attribute 'pop'

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

Traceback (most recent call last):
  File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\bot.py", line 1098, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 331, in invoke
    await injected(ctx)
  File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 128, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'str' object has no attribute 'pop'

so i know element.pop is correct or not?..
but this error say no..

tough surge
#

.pop only works for lists

#

and it takes in the index as the argument

#

so for example

a = [1, 2, 3, 4]

removed = a.pop(1)

print(a) # [1, 2, 3, 4]
print(removed) # [1, 3, 4]
#

currently element is a str

obsidian garnet
#

One message removed from a suspended account.

#

One message removed from a suspended account.

slender lintel
tough surge
#

The index is removed from your member file

#

If you want to remove a specific member id then you have to find it’s index

tough surge
slender lintel
tough surge
#

You might be able to use list.index() but it depends on the way your data is set out

#

I have to go sleep so I hope someone else can help you

slender lintel
#

Okay good night and thanks

lament stag
#

how can i catch the page value on a paginator in a button click?

unborn cliff
#

what theme ?

potent rivet
unborn cliff
obsidian garnet
unborn cliff
#

nvm i have the one ur on

#

Anyway!!

user_list = "\n".join([f"Name: {name} - Number: {number}" for name, number in users])

Error: TypeError: cannot unpack non-iterable int object

I am so confused :(

obsidian garnet
gilded widget
unborn cliff
#
users = [(i, data[i]) if user.lower() in i.lower() else 0 for i in data]
unborn cliff
gilded widget
#

try printing out users or using debug to view your users and see what is being stored in there

#

from what I can tell it looks like your users list is actually a list of integers

unborn cliff
#

oh i see

unborn cliff
gilded widget
#

yeah, if there is a single int in there then you won't be able to unpack the list

unborn cliff
#

So im trying to figure out how to append each user into a list of strings and then print each one out.

gilded widget
#

if you really wanna use list comprehensions, you can probably do something like this

user_list = "\n".join([f"Name: {obj[0]} - Number: {obj[1]}" if isinstance(obj, tuple) else f"Number: {obj}" for obj in users])
#

don't recommend this though as its probably best to make it an actual for loop instead of list comprehension

unborn cliff
gilded widget
#

what does an int represent in your users list versus a tuple?

unborn cliff
#

its not supposed to be that

#

its supposed to be a list of data like "Name: John - Number: 445 514 6764"

slender lintel
#

i need help with dm the owner of server on command

#
@bot.command()
async def customrole(ctx, name):
    owner = ctx.guild.owner
    member = ctx.message.author
    await owner.send(f"{member}, wants to create a custom role called {name}.")
#

this is my error

#
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "main.py", line 74, in customrole
    await owner.send(f"{member}, wants to create a custom role called {name}.")
AttributeError: 'NoneType' object has no attribute 'send'

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

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

@south ermine

#

@south ermine

south ermine
slender lintel
#

sry

#

my bad

#

can u help tho?

#

jab

#

dude

#

someone help me

gilded widget
slender lintel
#

i do

gilded widget
#

try guild.fetch_members() maybe?

slender lintel
#

its not working

slow dome
slender lintel
#

gimme example

slow dome
#

?tag intetns

hearty rainBOT
#

dynoError No tag intetns found.

slow dome
#

?tag intents

#

?tag inetnts

hearty rainBOT
#

dynoError No tag inetnts found.

slow dome
#

?tag intents

#

?tag intents

hearty rainBOT
#
import discord
from discord.ext import commands

# Get specific intents for fine control
intents = discord.Intents()
intents.emojis = True
intents.guilds = True
intents.messages = True  # Required for prefix commands!
...
# Get all non-priveliged intents; this excludes presences, members and message_content 
intents = discord.Intents.default()

# Set priveliged intents: these must be enabled on dev portal
intents.members = True
intents.presences = True
intents.message_content = True  # Required for prefix commands >= 2.0.0b5

# Get all intents; all intents must be enabled on dev portal.
intents = discord.Intents.all()

# Apply intents when creating your bot
bot = commands.bot(prefix="?", intents=intents)
slow dome
#

nailed it

unborn cliff
hearty rainBOT
#
import discord
from discord.ext import commands

# Get specific intents for fine control
intents = discord.Intents()
intents.emojis = True
intents.guilds = True
intents.messages = True  # Required for prefix commands!
...
# Get all non-priveliged intents; this excludes presences, members and message_content 
intents = discord.Intents.default()

# Set priveliged intents: these must be enabled on dev portal
intents.members = True
intents.presences = True
intents.message_content = True  # Required for prefix commands >= 2.0.0b5

# Get all intents; all intents must be enabled on dev portal.
intents = discord.Intents.all()

# Apply intents when creating your bot
bot = commands.bot(prefix="?", intents=intents)
unborn cliff
slow dome
#

exactly

plush narwhal
#

why am i getting this error?

#

all other command groups works fine

crimson gale
#

remove them

plush narwhal
#

name change fixed it... but can't tell what caused this

crimson gale
#

you cant call subcommands

#

also that whole file is a nightmare to work with

#

consider separating and grouping commands into cogs

plush narwhal
#

i found out about cogs when i was done with most of the commands so for now i am just adding / on 3 to 4 remaining commands and will later add cogs

crimson gale
#

hm okay fair enough

tidal beacon
#

idk if anyone knows anything about sql stuff, but this code block is failing after the line 475 print statement.

sql = f"INSERT INTO lolmatches(guild_id, match_id, blue_one, blue_two, blue_three, blue_four, blue_five, red_one, red_two, red_three, red_four, red_five, winner) VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)"
            print("made it to line 475")
            await db.execute(sql, str(ctx.guild.id), int(matchid), str(blueIDlist[0]), str(blueIDlist[1]), str(blueIDlist[2]), str(blueIDlist[3]), str(blueIDlist[4]), str(redIDlist[0]), str(redIDlist[1]), str(redIDlist[2]), str(redIDlist[3]), str(redIDlist[4]), str("none"))
idle linden
#

AttributeError: 'BridgeExtContext' object has no attribute 'user'

terse plinth
#

For a data storage is it better to use MongoDB or jusy JSON files?

gilded widget
#

mongodb atlas is really good and not too hard to pick up

terse plinth
#

i see

#

also, do bots need nitro to use emojis from different servers?

gilded widget
#

i dont think so

dark zodiac
#

why does the guild.members list only contain the bot account?

#
>>> print('member_count: {}'.format(guild.member_count))
member_count: 1338
>>> print('true_member_count: {}'.format(len(guild.members)))
true_member_count: 1
crimson gale
#

you need the members intent to receive the full list

dark zodiac
#

yea just saw that, thanks

tidal beacon
#

is there a way to restrict slash commands to certain channels?

crimson gale
#

yes, go to interactions and switch off the channels you dont want it to be in

#

i think there are some decorators to set defaults for those

tidal beacon
#

okay cool

#

thx

kind mesa
#

Is there a way to get real image urls when i use activity.assets?
its currently just this

grand pebble
#

Hey guys! I am kinda new to pycord and have added this:

class TimeConverter(commands.Converter):
  async def convert(self, ctx, argument):
    args = argument.lower()
    matches = re.findall(time_regex, args)
    time = 0
    for v, k in matches:
      try:
        time += time_dict[k]*float(v)
      except KeyError:
        raise commands.BadArgument("{} is an invalid time-key! h/m/s/d are valid!".format(k))
      except ValueError:
        raise commands.BadArgument("{} is not a number!".format(v))
    return time

class Timeout(commands.Cog):
  def __init__(self, bot):
    self.bot = bot```

but I get this:
#

any clue on how to fix?

fair cradle
#

What is time_regex?

#

It is not defined

kind mesa
#

How can i get a Game Icon from the Application ID?

plush narwhal
#

How to make command accessible only in guilds?

#

Not in dm

brazen hill
#
Traceback (most recent call last):
  File "main.py", line 192, in <module>
    bot.run(os.getenv('TOKEN'))
  File "/home/runner/sir-aramis/venv/lib/python3.8/site-packages/discord/client.py", line 715, in run
    return future.result()
  File "/home/runner/sir-aramis/venv/lib/python3.8/site-packages/discord/client.py", line 694, in runner
    await self.start(*args, **kwargs)
  File "/home/runner/sir-aramis/venv/lib/python3.8/site-packages/discord/client.py", line 658, in start
    await self.connect(reconnect=reconnect)
  File "/home/runner/sir-aramis/venv/lib/python3.8/site-packages/discord/client.py", line 599, 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.
#

can anyone help

#

im on replit btw, pls ping me or dm on reply

#

@here can some one help @here

random kayak
#

?tag norepl

hearty rainBOT
#

Why NOT to use Repl as a hosting platform

You should not use Repl.it to host your bot.
It may be a nice option as its "free" but you should use something else considering the major flaws.

  • The machines are super underpowered.
    • This means your bot will lag a lot as it gets bigger.
  • You'll need a web server alongside your bot to prevent it from being shut off.
    • This isn't a trivial task, and eats more of the machines power.
  • Repl.it uses an ephemeral file system.
    • This means any file you saved via your bot will be overwritten when you next launch.

IMPORTATNT

  • They use a shared IP for everything running on the service.
    This one is important - if someone is running a user bot on their service and gets banned, everyone on that IP will be banned. Including you.

Please avoid using repl.it to host your bot. It's not worth the trouble.

If you're looking for free options, consider using AWS/Google Cloud Platform/Azure and its respective free tiers or just pay for an actual VPS.

stable torrent
stable torrent
surreal nimbus
#

repl.it is just bad, he's trying to warn him

stable torrent
#

yep, but he didn't even tried to help

#

he just said "DONT USE IT", like it was causing the error

surreal nimbus
#

true

random kayak
surreal nimbus
#

what is the alternative to using self inside a decorator (cuz you can't)?

stable torrent
#

nothing, if you are trying to access variables inside of __init__ iirc

surreal nimbus
#

yeah

#

cause I am trying to make views, but the label of the button is inside a decorator

#

and I am trying to put a value inside that label, but idk how

stable torrent
#

check examples in pycord's github

surreal nimbus
#

I found an example on stackoverflow

#

gonna try it out

#

ok, I'm just gonna try on constructing a button on my own without the decorator

#

yay it worked

merry thicket
#

Do application commands have an option for cooldowns?

slow dome
merry thicket
#

Thanks, Ill take a look at that

stiff nebula
#

Does anyone know where to find an exhaustive list of short codes of languages allowed in discord code blocks?

surreal nimbus
#

can you edit an ephemeral msg?

stiff nebula
random kayak
surreal nimbus
#

yeah, that's what I wanted to say

random kayak
#

I don't think you get access to it after you send it

surreal nimbus
#

yeah, well at least buttons work

#

nope, it's actually possible

#

it just worked for me

#

now, how on earth do I remove buttons from a message thinkCat

stiff nebula
surreal nimbus
#

yeah ik

#

but what is the attr for the button to be removed

stiff nebula
#

How do you mean?

#

You remove it from the list

surreal nimbus
#

like do I just do view.remove_item()?

stiff nebula
surreal nimbus
#

hm, there is a view.add_item() which adds the buttons

#

so maybe view.remove_item() exists, brb gonna check the docs

stiff nebula
surreal nimbus
#

yeah there is one

stiff nebula
#

Nice

surreal nimbus
#

cuz why on earth would they keep it in the storage if it can be closed

midnight cedar
#

they don't store it iirc, the client handles it

stiff nebula
#

You can edit it with interaction.edit_original_message btw

#

Does anyone know where to find an exhaustive list of short codes of languages allowed in discord code blocks?

surreal nimbus
#

damn it, it only removes the inactive button blobpain

#

ok, view.clear_items() exists too

random kayak
#

Going to the left -> language categories -> all

#

If you really want all of them

stiff nebula
surreal nimbus
#

h u h

#

I'm so confused

stiff nebula
#

hmm?

surreal nimbus
#

what do you want to do?

stiff nebula
#

Me?

surreal nimbus
#

yea

stiff nebula
#

You mean with the short codes?

#

Oh, just trying to recogonize them

#

Aka if someone is using the right ones I'll know

surreal nimbus
#

hmm

random kayak
surreal nimbus
stiff nebula
#

I mean sorry, some of them aren't

#

For instance, python, they have language-python

random kayak
#

Without the language- part

stiff nebula
random kayak
#

Python works too O.o

stiff nebula
#

True taht

random kayak
#
def foo():
  return "bar"
stiff nebula
#

I need them short codes unfortunately sad

random kayak
#

Well, shorter than that you ain't getting anywhere 😄 😄

stiff nebula
#

the shorter the better

surreal nimbus
#
def short_codes():
  return "pain"```
stiff nebula
#
raise ItAintShortEnough```
surreal nimbus
#

"it's still pain"```
ornate spade
#
def short_code():0```
#

why is this in this thread

stiff nebula
#

short codes? I need some help generally

#

all them shortcodes one could ever desire

surreal nimbus
rigid sandal
#
@client.slash_command(name='sell', description='Sell one of your roles to another')
async def sell(
    ctx,
    role=Option(discord.Role, "Choose your role")
):
    await ctx.respond(f"You chose {role}!")
``` is it possible to choose the guild's roles in the Option? I thought I would see a list of all the guild's roles, but it doesnt do that. Am I mistaken?
random kayak
plush narwhal
#

How to make command accessible only in guilds?

rigid sandal
#

has it not registered? I added debug_guilds

random kayak
#

It is registered for sure, what if you type the beginning of a role name?

plush narwhal
#

I have it in my code

#

Let me check

plush narwhal
#

Replce = with :

rigid sandal
#

Also the type of role is str not discord.role

rigid sandal
plush narwhal
#

Cool

plush narwhal
plush narwhal
#

Now someone help me with this
How to make command accessible only in guilds?

wide cloak
#

but i dont want to to a respons
i only want to send a normal message

crimson coral
#

You have to have a response somewhere

#

What I suggested was leave your regular .send, but then at the very end of your callback you include a response.send_message that's ephemeral just to say what happened

wide cloak
#

what do you mean?

crimson coral
#

Like at the very end of the callback you do something like await interaction.response.send_message("Success", ephemeral=True)

#

Outside of the if so it'll run regardless, but you might wanna customise the message a bit

random kayak
wide cloak
#
 @discord.ui.button(label='Ja', style=discord.ButtonStyle.green, emoji="✅", custom_id='closeja')
    async def closeja(self, button: discord.ui.Button, interaction: discord.Interaction):
            await interaction.response.defer()
            guild = interaction.user.guild
            team = guild.get_role(serverteam)

        #if team in interaction.user.roles:

            mycursor.execute("SELECT * FROM Tickets WHERE TicketChannelID=%s", (interaction.channel.id,))
            data = mycursor.fetchone()
            
            user = await guild.fetch_member(data[3])

            if user:
                await interaction.channel.set_permissions(user, view_channel=False)


                em = discord.Embed(description=f'Das Ticket wurde von {interaction.user.mention} geschlossen!', timestamp=datetime.now(), colour=colour().main)
                em.set_author(name=interaction.user.name, icon_url=interaction.user.display_avatar.url)

                em2 = discord.Embed(description=f'Dein Ticket wurde von {interaction.user.mention} geschlossen!', timestamp=datetime.now(), colour=colour().main)
                em2.set_author(name=interaction.user.name, icon_url=interaction.user.display_avatar.url)

                message = await interaction.response.send_message(embed=em, view=Closed())
                #message = await interaction.channel.send(embed=em, view=Closed())

                log = bot.get_channel(log_id)
                em=discord.Embed(title="Log - Close", description=f"{interaction.user.mention} hat Ticket {interaction.channel.mention}({interaction.channel.name}) von {user.mention}({user.id}) geclosed!", timestamp=datetime.now(), color=colour().main)
                em.set_author(name=f"{interaction.user.name}#{interaction.user.discriminator}", url="", icon_url=interaction.user.display_avatar.url)
                em.set_footer(text=f"{interaction.user.id}")
                await log.send(embed=em)
                # manchmal error nach hier
                mycursor.execute("INSERT INTO ReopenMSG (reopen, TicketChannelID) VALUES (%s,%s)", (message.id, interaction.channel.id,))
                db.commit()

                # interaction.response.send_message # muss response

                try:
                    await user.send(embed=em2)
                except:
                    pass
                
                mycursor.execute("SELECT closenein FROM CloseMSG Where TicketChannelID=%s", (interaction.channel.id,))
                data = mycursor.fetchone()

                message2 = await interaction.channel.fetch_message(data[0])

                mycursor.execute("DELETE FROM CloseMSG WHERE TicketChannelID=%s", (interaction.channel.id,))
                db.commit()

                await message2.delete()
        
        #else:
            #await interaction.response.send_message(f"{emoji().error} Nur das Severteam, kann Tickets schließen!", ephemeral=True)
plush narwhal
random kayak
plush narwhal
#

how does that works?

crimson coral
random kayak
crimson coral
#

But you can use an internal check if you want to stay on the current beta

plush narwhal
crimson coral
#

When did you install it? Might need to update it a bit

plush narwhal
#

yesterday

crimson coral
#

But if you are on the latest master it's @discord.guild_only()

#

That should work then

plush narwhal
plush narwhal
plush narwhal
crimson coral
#

Nope

#

Though remember if it's a global command you'll have to wait for an update

plush narwhal
lost cloud
#

i need help, I'm new to coding

#

How do i create an guild owner only command

#

I been struggling for hours

keen prawn
#

Anyone know why discord.ext.commands.cooldown doesn't work on slashcommands in 2.0.0b7?

frigid lark
wide cloak
#
@bot.event
async def on_member_update(before, after):
    # check if user has tebex role
    roleids = [973887804486598696, 973887673821433916, 973882126527250542, 973608966145835118, 973608857039417394, 973607879653330984, 973607779015213096, 973606870130515999, 973606684389961808]
    # check if roleid in in list roleids

how should i do it?

#

i thought about fetching every role and check if its in the after.roles

crimson coral
#

you can get all of the IDs in after.roles by list comprehension, e.g. roles = [role.id for role in after.roles]

keen prawn
wide cloak
wide cloak
#

or this:

roleids = [973887804486598696, 973887673821433916, 973882126527250542, 973608966145835118, 973608857039417394, 973607879653330984, 973607779015213096, 973606870130515999, 973606684389961808]
if before.roles != after.roles and [role.id for role in after.roles if role.id in roleids]:
     ...
clever lava
#

how to add multiple buttons to a single message?

#

does anyone know?

#
await ctx.respond(embed=embed, views=[view, view2])
#

i tryed this and failed

slow dome
#

each view has 5 rows

#

each row can fit 5 buttons

clever lava
#

nice but how

slow dome
clever lava
#

ty

clever lava
ocean timber
#

Is it possible to make slash commands only visible in specific channels?

slow dome
#

you don't need 2 views

wide cloak
#

is it possible to disable a button from an other callback?

slow dome
#

yeah

#

if you know something about the button and can access the view itself

sterile junco
#

How use have 2 checks for a command?

slow dome
#

what type of checks

sterile junco
#
@client.command()
@commands.has_permissions(administrator=True)
@commands.has_any_role('test')
async def test(ctx):
    await ctx.reply('success')
#

like this but it doesnt work

slow dome
#

wdym doesn't work

sterile junco
#

like i want a user with the role test or any admin to use a command

#

how to do that

slow dome
#

and what does the current one do?

sterile junco
#

Admins can use it

#

I tried from my alt with the role test and it showed missing permissions

#

Nvm

#

Apparently the command only works if you have both admin perms and test role

wide cloak
#

can i delete this message when pressing the first button?

sterile junco
#

Anyone knows how?

sterile junco
#

Use await ctx.delete() or something

#

Send your code

tough karma
#

it doesn't work..

#

@bot.command()
async def auto(ctx):
user = ctx.message.author
role = discord.utils.get(user.server.roles, name="staff")
await user.add_roles(role)
await ctx.send("you got the role!!!")

#

the problem :

#

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

Traceback (most recent call last):
File "C:\Users\thegi\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ext\commands\bot.py", line 360, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\thegi\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ext\commands\core.py", line 927, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\thegi\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ext\commands\core.py", line 190, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Member' object has no attribute 'server'

sudden path
#

discord.utils.get(ctx.guild.roles, ...)

#

ctx has all context, user, message, server

fair vector
#
@bot.command()
async def dungeon(self, ctx: commands.Context, *targets: list[discord.User]) -> None:
    ...

how to convert rest of arguments to discord.User?

#

i know i can just find user by id, but i wanna know are there any easier ways?

stable spruce
#
async for msg in channel.history(limit=None, after=date):``` I'm using this function wrong? I pass this date `2022-05-11 22:28:27.593047` which i get from `datetime.utcnow()` but I loop over messages which have ```
text
2022-05-11 22:06:33.161000+00:00
``` older timestamp, which I don't want to do, idk what's the problem I think I understood the docs about this function correctly
obsidian cosmos
#

has anyone experienced an issue with attachments not populating in discord.InteractionMessage.attachments? my bot is awaiting on user message and checking the list but it is empty when i send an image or video

leaden swallow
#
Ignoring exception in on_connect
Traceback (most recent call last):
  File "C:\Users\cwals\Documents\GitHub\novabot-dev\.venv\lib\site-packages\discord\client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\cwals\Documents\GitHub\novabot-dev\.venv\lib\site-packages\discord\bot.py", line 1025, in on_connect
    await self.sync_commands()
  File "C:\Users\cwals\Documents\GitHub\novabot-dev\.venv\lib\site-packages\discord\bot.py", line 685, in sync_commands
    await self.http.bulk_upsert_command_permissions(self.user.id, guild_id, guild_cmd_perms)
  File "C:\Users\cwals\Documents\GitHub\novabot-dev\.venv\lib\site-packages\discord\http.py", line 357, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 405 Method Not Allowed (error code: 0): 405: Method Not Allowed

Anyone having a similar issue?

barren cedar
leaden swallow
small raptor
#

Hey

#

I'm having some trouble with the slash commands. My import statement for discord.commands is no longer working.
It is as follows:

from discord.commands import slash_command

It claims that discord.commands does not exist. Is it in a new location now?

clever lava
#

so permissions decorator rip

#

then im using commands.ext

#

can i manage only guild permissions with it or i can do a command just for me?

clever lava
#

BRUH HOW

#

i need dis

sudden path
#

b!rtfm attachment

open bearBOT
# sudden path b!rtfm attachment

I couldn't find a documentation with the name attachment! Maybe you used to command wrong? Correct Usage: <prefix>rtfm <docs> [<term>] (eg. b!rtfm py cool)
List of Documentations you can search:
python
pycord
discord.py
yarsaw
nextcord
disnake

sudden path
#

b!rtfm pyc attachment

small raptor
#

The runtime error is:

Traceback (most recent call last):
  File "C:\Users\...\...\...\venv\lib\site-packages\discord\ext\commands\bot.py", line 606, in _load_from_module_spec
    spec.loader.exec_module(lib)
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "C:\Users\...\...\...\extensions\....py", line 11, in <module>
    from discord.commands import slash_command
ModuleNotFoundError: No module named 'discord.commands'
#

This is using Pycord 1.7.3 from pip/PyPi.

slow dome
#

you need pycord 2.0.0b7

#

?tag install

hearty rainBOT
#
  1. Uninstall discord.py or any other forks of discord.py you might have with the namespace discord.
python -m pip uninstall discord.py discord -y
  1. Install py-cord
python -m pip install py-cord

Installing other builds:
Note: You need to have git installed. Use !git to find out how to install git.

Updating the module to Alpha (unstable):

pip install -U git+https://github.com/Pycord-Development/pycord

Updating to beta:

pip install py-cord==2.0.0b7
small raptor
slow dome
#

no space

small raptor
#

👍

alpine totem
#

anyone suddenly having issues with slash commands?

shadow pike
#

anyone know what event is emitted when a guild member's account is purged? not the initial "deletion", which is only a deletion market, but the purge that happens after the waiting period that fully deactivates it as a messageable target and transitions it to the Deleted User <hash> name

#

is it just a MEMBER_REMOVE?

unborn cliff
#

How would I check if someone dms the bot ?

south ermine
unborn cliff
midnight cedar
#

ddevs server could probably answer that

little tapir
#

how to send the entire traceback as a form of msg ?

stiff nebula
stiff nebula
#

np

stable anvil
#

for some reason the slash commands don't register when i use debug_guilds in bot constructor, only works if i have guild_ids in slash command decorator, anyone know why?

brazen hill
#

hello?

#

Traceback (most recent call last):
File "D:\Program Files (x86)\Python 3.10\lib\site-packages\aiohttp\connector.py", line 969, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs) # type: ignore # noqa
File "D:\Program Files (x86)\Python 3.10\lib\asyncio\base_events.py", line 1064, in create_connection
raise exceptions[0]
File "D:\Program Files (x86)\Python 3.10\lib\asyncio\base_events.py", line 1049, in create_connection
sock = await self._connect_sock(
File "D:\Program Files (x86)\Python 3.10\lib\asyncio\base_events.py", line 960, in _connect_sock
await self.sock_connect(sock, address)
File "D:\Program Files (x86)\Python 3.10\lib\asyncio\proactor_events.py", line 705, in sock_connect
return await self._proactor.connect(sock, address)
File "D:\Program Files (x86)\Python 3.10\lib\asyncio\windows_events.py", line 817, in _poll
value = callback(transferred, key, ov)
File "D:\Program Files (x86)\Python 3.10\lib\asyncio\windows_events.py", line 604, in finish_connect
ov.getresult()
OSError: [WinError 121] The semaphore timeout period has expired

#

like why

#

the intentions are okay

surreal nimbus
#

It's not intents

#

It's a WinError (a windows error)

#

Not a pycord error

tough karma
#

class verify(discord.ui.View):
@discord.ui.button(label="Click me!", style=discord.ButtonStyle.primary)
async def button_callback(self, button, interaction):
await interaction.response.send_message("....")
@bot.command()
async def auto(ctx):
user = ctx.message.author
role = discord.utils.get(ctx.guild.roles, name="staff")
await user.add_roles(role)
await ctx.send("you got the role!!!", view=verify)

#

ptoblem:

#

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

Traceback (most recent call last):
File "C:\Users\thegi\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ext\commands\bot.py", line 360, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\thegi\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ext\commands\core.py", line 927, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\thegi\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ext\commands\core.py", line 190, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: to_components() missing 1 required positional argument: 'self'

wooden coyote
#

commands are not appearing

#

as well as "Command not found error"

#

as it may be relating to the 405: Method Not Allowed Error.

#

I tested group commands on the main py file instead of its own cog

#

it works

brazen hill
surreal nimbus
brazen hill
#

thx

#

i have python 3.7 installed so is that also okay

surreal nimbus
#

3.7 is too old

#

3.8-3.9

slate stirrup
#

How can I resolve this problem The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Users\thegi\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ext\commands\bot.py", line 360, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\thegi\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ext\commands\core.py", line 927, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\thegi\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ext\commands\core.py", line 190, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: to_components() missing 1 required positional argument: 'self'

surreal nimbus
surreal nimbus
#

it's discord API sending false errors because of slash permissions v2

fair cradle
#

can i get modal input with returning the value in the modal callback?

pastel wadi
#

Is there an established docker image anyone would suggest for a pycord bot? Just getting into docker and researching

crimson coral
#

it hasn't rolled out fully to all clients/guilds, so you may see inconsistency in syncing behavior

paper harbor
#

ah ok

#

thx alot

half marsh
#

keep getting this, is it happen because the code are slow before the loop starting again?

slate stirrup
#

How do we join the if statement to a button like if button == "button1"

crimson coral
slender lintel
#

Hi, I am struggeling with setting up a object, can someone help me with that? I never really done OOP before :D

slate stirrup
#

How do I make the button or select never dies like after a time it says interaction failed

south ermine
#

make the view persistent

#

?tag ex

slate stirrup
#

How to know which one used the button like in message ctx.message.author

shadow pike
surreal nimbus
#

b!rtfm pyc on_interaction

open bearBOT
surreal nimbus
#

@slate stirrup here, use the on_interaction function

crimson coral
#

(note it's much better to use callbacks instead of the generic on_interaction event)

clever lava
#

?install

#

?tag install

hearty rainBOT
#
  1. Uninstall discord.py or any other forks of discord.py you might have with the namespace discord.
python -m pip uninstall discord.py discord -y
  1. Install py-cord
python -m pip install py-cord

Installing other builds:
Note: You need to have git installed. Use !git to find out how to install git.

Updating the module to Alpha (unstable):

pip install -U git+https://github.com/Pycord-Development/pycord

Updating to beta:

pip install py-cord==2.0.0b7
slender lintel
#

Hey how i can open two modals and the info wait for two modal and then send this message?

candid venture
#

I'm reading the docs on PermissionsV2 for setting default permissions, can I not set permissions at a role level anymore like with the @permissions decorator?

slow dome
candid venture
#

That's not what I mean, I'm reading the Pycord docs that have been updated for permissions v2

#

This is all I'm seeing, so I can only assume that I can't set command permissions at a role level from the bot and will have to manually do it from the server.

slow dome
#

yeah

candid venture
#

Fabulous, is this just until there's more dev work done by the maintainers or is this a limitation of the Discord API now?

#

Because it seems like a step backwards to not have this option anymore

crimson coral
#

aka bot tokens don't cut it, it's all via the UI now

candid venture
#

Great job Discord 👎 stupid decisions

#

OK thanks for the info!

crimson coral
#

all good

#

all in all it's a better option for bots on a scale but inconvenient for devs used to being able to adjust permissions on their end

slow dome
#

discord: use slash commands
also discord: slash commands also don’t work

crimson coral
#

well at least they got global command syncing down to instant before enforcing them... with the delay anyway

unborn cliff
#
@commands.Cog.listener()
    async def on_message(self, message):
        if message.guild is None:
            if "red or blue" in message.content.lower():
                await message.respond("shut up bunk")
#

this doesnt work

slow dome
#

?tag message_content

hearty rainBOT
#

dynoError No tag message_content found.

slow dome
#

?tags message

hearty rainBOT
#
Tags (1)

message-content

slow dome
#

?tag message-content

hearty rainBOT
unborn cliff
slow dome
#

it

#

is

#

the opposite

#

message content will only appear in DMs and messages where it is mentioned

unborn cliff
crimson coral
#

you either want message.reply or message.channel.send

frank vapor
#

What would ListPageSource in pycord?

crimson coral
unborn cliff
crimson coral
#

you sure that's message.respond?

unborn cliff
crimson coral
unborn cliff
#

oh

slow dome
plush lintel
#

umm i am trying to let my bot to join the voice channel

#
@bot.command()
async def play(ctx, url : str):
    voiceChannel = discord.utils.get(ctx.guild.voice_channels, name=f"shadowvoice1")
    voice = discord.utils.get(bot.voice_clients, guild=ctx.guild)
    await voiceChannel.connect()```
#

pydiscord.ext.commands.errors.CommandInvokeError: Command raised an exception: RuntimeError: PyNaCl library needed in order to use voice

#

error

idle linden
#

That error is very self-explanatory

gilded widget
#

lmao

idle linden
#

what was the way to format a traceback for sending it via a discord message

#

#969580926885580801 message
nvm

slender lintel
#

Is there a way to gray out buttons for other users besides the user that executed the command?
Or at least not allow others to press a button?

crimson gale
#

return True to allow callback to be processed, return False to prevent (and respond to the interaction manually)

slender lintel
#

I see thonk thank you

crimson gale
#

modals have a wait() method

#

but the issue is with sending the other modal

#

because you can only send a modal as a response

umbral junco
#

Hey is a modal form out in pycord?

worthy basin
#

Yes it is

#

b!rtfm pyc ui.Modal

umbral junco
#

pog pog

#

mind sending an example too

#

there must be an example thing too right

supple ravineBOT
#

Here's the modal dialogs example.

umbral junco
#

Thanks

thin trellis
#

Hello,
what could be reason for the bot not working after a few hours?
Like I start my bots on vps works fine but after a few hours slash commands says "The application did not respond " or something
and normal message commands also stopped working

Issue on vps?

#

After restarting they work fine again

#

I thought that might be connection issues from the vps hosting but that seems not the case
Services like the database are working just fine

idle linden
#

sounds like something might be blocking, but that's just a guess

open siren
#

umm so i just started coding a bot today after a long time of 2 years and was looking through the guide, i used the same code, did all the procedures but im getting an error every time.

Ignoring exception in on_connect
Traceback (most recent call last):
  File "C:\Users\user\AppData\Roaming\Python\Python310\site-packages\discord\client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\user\AppData\Roaming\Python\Python310\site-packages\discord\bot.py", line 1147, in on_connect
    await self.sync_commands()
  File "C:\Users\user\AppData\Roaming\Python\Python310\site-packages\discord\bot.py", line 643, in sync_commands
    registered_guild_commands[guild_id] = await self.register_commands(
  File "C:\Users\user\AppData\Roaming\Python\Python310\site-packages\discord\bot.py", line 473, in register_commands
    prefetched_commands = await self.http.get_guild_commands(self.user.id, guild_id)
  File "C:\Users\user\AppData\Roaming\Python\Python310\site-packages\discord\http.py", line 353, in request
    raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access

my code is :

import discord
import os
from dotenv import load_dotenv

load_dotenv() # load all the variables from the env file
bot = discord.Bot(debug_guilds=[my guild id here])

@bot.event
async def on_ready():
    print(f"{bot.user} is ready and online!")


@bot.command(name="hello", description="Say hello to the bot")
async def hello(ctx):
    await ctx.send("Hey!")

bot.run(os.getenv("TOKEN")) # run the bot with the token

someone please help

hot python
#

did you invite the bot with the applications.commands scope?

slender lintel
#

Hey I need some help in #974652298523463701

orchid horizon
#

yo

#

anyone know what this error means?

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: JSONDecodeError: Extra data: line 1 column 72 (char 71)
crimson coral
#

you worked poorly with your json

#

think you have multiple records inside a single json file which isn't allowed

orchid horizon
#

ah

#

I was trying to make an economy system

crimson coral
#

probably approaching the format wrong

#

what does it look like currently

slender lintel
#

Hey how i can edit a message with id?

orchid horizon
#

srry for the late reply

#

I fell asleep

#

now I got a new error after making a few changes

#
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: unsupported operand type(s) for +: 'int' and 'str'
idle linden
#

you're trying to concat without casting

orchid horizon
orchid horizon
#

thanks anyway

#

I think I'm just too sleepy

#

should go to sleep soon

sudden path
#

b!rtfm pyc get_message

turbid kettle
#

Hi, is there a way to get 2 modals in a row?

#

I'm looking for something like when the first Modal is finished it will need to popup a new Modal

open siren
idle wagon
#

Someone knows how to install py-cord[voice] in docker? Because I have error

minor fox
#

Just looking for inspiration.
Slash commands has sorta made implementation of developer-only commands a little less elegant. I was wondering if anyone had some interesting methods on administrating their bot without using Discord commands? I suppose directly interacting with it via SSH would also work but figured I'd ask.

minor fox
#

Otherwise you're installing two different versions of pycord. Also, if you're running on linux, you need to install the listed system requirements.

minor fox
# idle wagon dashboard

Possible, but I'd want to avoid a public facing dashboard website. Would really need to ensure best practices on that.

idle wagon
minor fox
#

That looks like Alpine linux to me but I could be wrong.

#

I assume your hypervisor is Docker on Ubuntu, though. But the program itself is running in an Alpine Linux container.

idle wagon
minor fox
minor fox
#

Just my guess, though. I've never tried voice stuff with PyCord.

idle wagon
#

Xd which I am not attentive

minor fox
#

No worries, hahaha

idle wagon
#

I sit with doker all day

#

😅

minor fox
#

😁 Reading docs all day sorta melts the brain after a while. I've been there

idle wagon
#

I just didn't think to finish reading this sentence😂

#

I read this and nothing more. Hah

idle wagon
random kayak
#

Is it possible to change bot's avatar? Was looking at the Bot & Client classes but doesn't look like there's some change_avatar() or something

random kayak
idle wagon
random kayak
idle wagon
slender lintel
#

bot.user.edit(avatar=link/iamge)

minor fox
idle wagon
#

I cry

tidal beacon
#

I currently have this slash command, the options are not showing up for the integration but the command works fine otherwise. Any ideas on whats going wrong with this?

idle wagon
#

Someone knows you know how to fix it?(docker)

stoic locust
#

not sure why i'm getting this, any help?

idle wagon
#

install py-cord==2.0.0b4 or older

stoic locust
#

or git clone

idle wagon
#

pip install py-cord==2.0.0b4

stoic locust
#

i just git cloned, ty tho

idle wagon
#

Ok

stray gate
#

Hey guys.
How to use custom emoji in label of button?

surreal nimbus
#

for emojis, that is

#

if you want normal text too, you can put your emoji in emoji= and text in label

stray gate
surreal nimbus
#

idk, maybe try using the invisible char in the label, might stretch the buttons a bit, not sure though

#

the invisible char is \u200b btw

tidal beacon
#

@crimson coral having another slash command issue, for this one it runs fine the options do not show up though. Everything is lower case so im not sure what I am doing wrong on it.

wide cloak
#

hi i saw this.

@bot.event
async def on_message_delete(message:discord.Message):
    guild = message.guild
    if message.guild:
        print(message.author)

    # get message deleter from auditlog
    try:
        audit_logs = await guild.audit_logs(limit=1, action=discord.AuditLogAction.message_delete).flatten()
        deleter = audit_logs[0].user
        #channel = audit_logs[0].channel
        print(deleter)
        #print(channel)
    except IndexError:
        return

how do i use this channel thing from the docs

daring flint
#

I think I know the answer, but just as a sanity check, are you able to have any arguments for Message application commands?

For an easy to understand example, if I wanted to have a "RemindMe" type command, you'd right-click and select Remind, and then get a prompt for the duration

random kayak
#

Can it be checked what invite link a user used to join the server? I'd like to have users receive different roles based on the URL they join

random kayak
vivid phoenix
#
TypeError: object TextChannel can't be used in 'await' expression

ok im either being dumb or the latest update to support forum channels broke somit

wide cloak
random kayak
unborn cliff
#

is there a way to check if someone is boosting a certain amount of times. ?

weak hearth
#

can someone help me fix this error?

#

i have tried everything

unborn cliff
slender lintel
solid salmon
#

heya
how can i create a slashcommand and add a default role permission to it?

stable tiger
#

b?rtfd default_permissions

solid salmon
#

with older versions of py-cord something like this worked for me

@bot.slash_command(
    guild_ids=[GUILD_ID],
    default_permission=False,
    permissions=discord.CommandPermission(314100296819277824, 1)
)
#

but ye... permissions v2 ruined it i guess

#

and if so, how?

#

they're only showing discord permissions not roles

nocturne mountain
unborn cliff
#

is there a way to check if someone is boosting a certain amount of times. ?

slender lintel
#

Hey how i can edit a message with id?

unborn cliff
#

iirc

slender lintel
unborn cliff
#

You can just do

#

message.edit

slender lintel
unborn cliff
#

You want to edit another bots msg ?

#

or just the same bots message

slender lintel
unborn cliff
#

Example ?

random nova
#

your bot can only edit messages it sends

slender lintel
random nova
#

ok
you would either have to get the message first using the id, or if it’s in the same command you can do:
msg = await ctx.send(“hi”)
await msg.edit(edited message)

slender lintel
#

so how i can with id not in ide

#

?

unborn cliff
#

OH ik what he wants

slender lintel
unborn cliff
#

he wants to do something like

bot:hello bruh (edited)

/edit msgid: 676798967867 message: bruh

slender lintel
#

and argument is msgid and message ?

unborn cliff
#

Those are just names of the arguments

slender lintel
#

yeah also ctx, msgid, message so?

unborn cliff
#

yea

#

But i dont know if you can specify a message you wanna edit.

slender lintel
#

ohh

#

I'm just trying

random nova
#

You can using this method:

msg = bot.get_message(the_message_id)
await msg.edit("hi")
unborn cliff
#

Guess you can then

slender lintel
#

thanks guys prayadge

random nova
#

no problem!

unborn cliff
#

i helped :D

dusk gale
#

Can await self._bot.http.bulk_upsert_command_permissions(self._bot.user.id, guild_id, guild_cmd_perms) be bypassed in sync_commands when starting the bot? To avoid the v2 perms issue and it returning error 405 Method Not Allowed.

stable tiger
#

u can upgrade to master where v2 is supported already

slender lintel
# random nova You can using this method: ```py msg = bot.get_message(the_message_id) await msg...

So i have this

    @slash_command(description="🧸› Add Feature to the Embed (Admin / Management) 🔐")
    async def zembed_create2(self, ctx, msgid):
        msg = bot.get_message(msgid)
        await msg.edit(content="test")

but error is there..

Ignoring exception in command zembed_create2:
Traceback (most recent call last):
  File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 122, in wrapped
    ret = await coro(arg)
  File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 825, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "C:\Users\zReaxrYT\PycharmProjects\Discord\extensions\Modal.py", line 63, in zembed_create2
    await msg.edit(content="test")
AttributeError: 'NoneType' object has no attribute 'edit'

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

Traceback (most recent call last):
  File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\bot.py", line 1098, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 331, in invoke
    await injected(ctx)
  File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 128, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'NoneType' object has no attribute 'edit'
dusk gale
#

Never mind, I figured it out rather quickly. Cheers.

hot python
slender lintel
slender lintel
hot python
#

no you're replacing the part that edits the message. replace msg = bot.get_message(msgid) with msg = await ctx.channel.fetch_message(msgid)

slender lintel
#

yeah thanks its working! rooDuck

hot python
#

np

unborn cliff
#

is there a way to check if someone is boosting a certain amount of times. ?

unborn cliff
dusk gale
#

Getting a Import "discord.commands" could not be resolved error on the master branch 🤔

oblique carbon
idle wagon
#

hi does anyone know how to run ffmpeg in docker?

slender lintel
#

how can i fix it?

#

hmm..can u give me that code?

#

in text

idle wagon
#
import discord


intents = discord.Intents.all()

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


@bot.event
async def on_ready():
    print("BOT Ready!")
    print("Name: {}".format(bot.user.name))
    print("ID: {}".format(bot.user.id))

bot.run("TOKEN")
slender lintel
#

WHERE I PUT THE TOKEN?

idle wagon
slender lintel
#

ok thx

#

T_T

#

how can i fix it..

idle wagon
#

you install py-cord?

dusk gale
#

I'm getting object TextChannel can't be used in 'await' expression when using await channel.send(embed), but when I remove await it says channel.send was never awaited 🤔

slender lintel
#

yes

idle wagon
#

hmm

slender lintel
#

i install py-cord.

idle wagon
#

use venv

slender lintel
#

what is venv?

idle wagon
slender lintel
#

ah...

#

now i use pycord, but this err didn't fix.

slow dome
#

what?

heavy fern
#

hmm

#

Anyone able to help with my prefix

unborn cliff
# slow dome what?

Hey, could i get some help with 2 things ??

  1. How can i check how many boosts someone has?
  2. How could I compare two keys in one dictionary??
#

like {"bruh": 123 , "hurb": 556}

I want to compare the keys of those two

slow dome
#

well, dict.keys() lists all the keys of a dict

unborn cliff
#

dict.keys() isnt iterable pretty sure

slow dome
#

I think it is

unborn cliff
#

im trying to sort keys alphabetically

also why is everyone ignoring question 1 like cmonnnn

slow dome
#

you can’t

unborn cliff
#

ok well ive been trying to get an answer like that for agese

unborn cliff
slow dome
#

for loop?

unborn cliff
#

this is what I have so far

nameDict = {"Darryl": "2341", "Cecil": "9102", "Beth": "3258"}


def sortDict(nameDict : dict):
    newDict = {}

    for key, value in nameDict.items():
        tmp = str(key).lower()
        if tmp[0] > tmp[1]:
            newDict[key] = value
#

it doesnt work obv but im stuck here

unborn cliff
slow dome
#

there’s dict.sort()

#

but I think it’s just alphabetically sorted

unborn cliff
#

thats the thing im trying to sort using my own sorting algorithm

orchid horizon
#

hi I would like to ask how do you make a ctx.respond but it's private

#

so that only the ctx.author can see it

unborn cliff
orchid horizon
#

alright thanks

unborn cliff
#

How would I check for the version i currently have of pycord ??

heavy fern
#

hello, currently running bot on replit. found a solution for the ratelimit on the platform. i'm wondering if there are any downsides to doing this:

try:
    bot.run(os.getenv('TOKEN'))
except:
    os.system("kill 1")```
gilded widget
#

curious, is this not valid under the new option rewrite system?

    @commands.slash_command()
    async def spotify_info(self,
                           ctx: discord.ApplicationContext,
                           member: discord.Member = discord.Option(
                               description="Enter the mention or ID of a member.",
                               required=True
                           ),
                           ) -> None:
#

I'm currently on the latest master branch commit

#

the option itself is visible but the description does not appear and it is not a required argument

#

same thing happens here:

    @commands.slash_command()
    async def reload(self,
                     ctx: discord.ApplicationContext,
                     cog: str = discord.Option(
                         description="Select the cog to reload.",
                         choices=["config", "development", "general", "moderation"],
                         required=True
                     ),
                     ) -> None:
#

no choices appear either

gilded widget
#

not an issue with the slash command decorator afaik, worked fine with the same decorator before modifying how the options are written

silver arrow
#

how to add a specific role to a user

#

await self.lmbot.add_roles(role=)

#

in tthe role option do we give the name of tthe role?

sudden path
#

You pass a role object

silver arrow
# sudden path You pass a role object

if i am doing something like this
user = interaction.user.id role = discord.utils.get(user.guild.roles, name="Student") await self.lmbot.add_roles(user, role=role)
i get an error
role = discord.utils.get(user.server.roles, name="Student") AttributeError: 'int' object has no attribute 'guild'

cyan delta
#

when i type import dis discord is not suggested ( only dis and disutils )

sudden path
#

No idea why you're doing user.server.roles

#

When you can simply do interaction.guild.roles

#

And add_roles is for the member object.

silver arrow
#

yea

#

i think i sovled

#

that

sudden path
#

So interaction.user.add_roles()

silver arrow
#

ok

sudden path
#

Read the docs. And read your own code when an error shows up.

jovial tusk
#

How do I work with cogs and Views?

#

is there any special methods/classes which makes Views easier to work with Cogs?

eternal mason
#

seems like all methods fetching text channels have gotten bugged

#

all my bots died so hard

crisp spire
#

im getting a 405 method not found error in the terminal

#

but my commands seem to work

solar berry
#

How do you get the invite link someone used when they join the server?

finite cliff
#
Ignoring exception in on_connect
Traceback (most recent call last):
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 352, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\bot.py", line 793, in on_connect
    await self.register_commands()
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\bot.py", line 338, in register_commands
    to_update = update_guild_commands[guild_id]
KeyError: 910860626837004308```
#

whats this error?

ornate spade
#

something's wrong with the ID

#

is the bot in that server?

silver arrow
slender lintel
#

Hey, how i can check if the bot has the channel permissions? If not, an error should come

stray smelt
#

did slash permission v2 release?

silver arrow
stray smelt
#

what channel that you specify can I see?

#

You can specify the channel by using client.get_channel() method.
Here is some example.

channel = self.bot.get_channel(channel id here)
await channel.send(embed = embed)
oblique carbon
foggy lance
#

not able to use ctx.reply

#

or await self.client.fetch_channel(id)

#

any reason?

solid salmon
# foggy lance

try to use the master branch. I had this issue before too

stray smelt
stray smelt
foggy lance
jovial chasm
#

is it possible to align only two fields in a row in embeds?

red tendon
crimson coral
crimson gale
#

do note that inline=False forces fields with that attribute to their own row no matter what

foggy lance
#
pip install -U git+https://github.com/Pycord-Development/pycord
#

installed using this

red tendon
#

to install it

#

cuz it seems like you are using replit

wide cloak
#

how to send a modal in a interaction without response

red tendon
terse plinth
#

Why is the embed limited to that size? I want it to span wider

#

is there any way of doing that??

red tendon
terse plinth
#

oof F

red tendon
#

if phone it will be smaller

#

and cut off half

terse plinth
#

BRUH

#

lmao

red tendon
terse plinth
#

i mean, their fault if they usin discord mobile

#

couldnt be me

wide cloak
red tendon
wide cloak
#

i have responed to the interaction before

slender lintel
#

Im getting RuntimeWarning: coroutine 'Client._run_event' was never awaited when trying to use discord.Bot.dispatch apparently it cant find the event loop for some reason, does anyone know how to solve this?

red tendon
#

an interaction can only be responded ones

wide cloak
#

i know

#

that is my question

red tendon
wide cloak
#

is there a way to do a thing like followup.send_modal

red tendon
slender lintel
surreal nimbus
#

How do I make a command both a user command and a slash command?

slender lintel
#

Hey, how i can several datetime formate usen?

        time_give = {"d": 86400, "h": 3600, "m": 60, "s": 1}
        time_giveaway = int(time[:-1]) * time_give[time[-1]]
        timestamp = (datetime.datetime.now() + datetime.timedelta(seconds=time_giveaway)).timestamp()
        timestamps = int(round(timestamp))

So when i use 1h 30m is not working.. I know have to re use something but how?

so only 1d or 1h or 1m or 1s is working but not more..
also 1m 1s is not working..
Error:

#
Traceback (most recent call last):
  File "C:\Users\zReaxr\PycharmProjects\Discord\venv\lib\site-packages\discord\bot.py", line 1098, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Users\zReaxr\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 331, in invoke
    await injected(ctx)
  File "C:\Users\zReaxr\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 128, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: ValueError: invalid literal for int() with base 10: '1m 1'
Ignoring exception in command giveaway:
Traceback (most recent call last):
  File "C:\Users\zReaxr\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 122, in wrapped
    ret = await coro(arg)
  File "C:\Users\zReaxr\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 825, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "C:\Users\zReaxr\PycharmProjects\Discord\extensions\Commands.py", line 45, in giveaway
    time_giveaway = int(time[:-1]) * time_give[time[-1]]
ValueError: invalid literal for int() with base 10: '1m 1'

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

Traceback (most recent call last):
  File "C:\Users\zReaxr\PycharmProjects\Discord\venv\lib\site-packages\discord\bot.py", line 1098, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Users\zReaxr\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 331, in invoke
    await injected(ctx)
  File "C:\Users\zReaxr\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 128, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: ValueError: invalid literal for int() with base 10: '1m 1'
pallid flume
#

How do I create a button for a slash cog command?

jolly charm
#

Hey, sorry for a noob question. Just started off with python and I wanted to make a bot which is interactive, shows buttons with some images. Sort of like you've to choose an image from a list of images.
And... I just got to know(or maybe i'm wrong) about the weird stuff of official discord not providing much support. I'm having trouble with running some alternatives and discord-components library is working for me.

Problem is, Button class object is not iterable and I want to make buttons according to the input provided by the user.. and that can vary.
Any help is much appreciated.

wide cloak
#
await interaction.followup.send(view=BadFeedback(title="Willkommen im lol!"))

why isnt this working?
error:

Ignoring exception in view <FeedbackView timeout=None children=1> for item <Feedback placeholder='Gib uns Feedback...' min_values=1 max_values=1 options=[<SelectOption label='Sehr Schlecht' value='Sehr Schlecht' description='Bewerte bitte unseren Support!' emoji=<PartialEmoji animated=False name='⭐' id=None> default=False>, <SelectOption label='Schlecht' value='Schlecht' description='Bewerte bitte unseren Support!' emoji=<PartialEmoji animated=False name='⭐' id=None> default=False>, <SelectOption label='Ausreichend' value='Ausreichend' description='Bewerte bitte unseren Support!' emoji=<PartialEmoji animated=False name='⭐' id=None> default=False>, <SelectOption label='Gut' value='Gut' description='Bewerte bitte unseren Support!' emoji=<PartialEmoji animated=False name='⭐' id=None> default=False>, <SelectOption label='Sehr Gut' value='Sehr Gut' description='Bewerte bitte unseren Support!' emoji=<PartialEmoji animated=False name='⭐' id=None> default=False>] disabled=True>:
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/discord/ui/view.py", line 371, in _scheduled_task
    await item.callback(interaction)
  File "/root/NarcoCityTicketBot/main.py", line 980, in callback
  File "/usr/local/lib/python3.9/site-packages/discord/webhook/async_.py", line 1546, in send
    data = await adapter.execute_webhook(
  File "/usr/local/lib/python3.9/site-packages/discord/webhook/async_.py", line 213, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.0.components.0: The specified component type is invalid in this context
uneven flax
#

Hello im trying to do a select role menu, it works but sometimes i have an error that i dont understand. here is my code and the error

wide cloak
midnight cedar
#

can't send a modal with a message

#

you need interaction.response.send_modal

wide cloak
#

i responed already

midnight cedar
#

nothing I can do about thay

#

discord limitation

wide cloak
#

can i edit the view without response?

midnight cedar
#

yes

wide cloak
midnight cedar
#

just do a message edit with the view

wide cloak
#

my current code:

**self.disabled = True
        await interaction.response.edit_message(view=self.view)

        if data <= 3:
            print(data)
            await interaction.followup.send(view=BadFeedback(title="Willkommen im lol!"))
wide cloak
midnight cedar
#

no

#

interaction.message.edit

terse plinth
#

how do you mention @everyone in a message?

wide cloak
midnight cedar
terse plinth
#

sorry i framed the question wrong

#

i want a command to recognise when i do >>hug @everyone

#

how do i detect when @everyone has been mentinoed?

midnight cedar
#

Well

#

@everyone would literally be in the message content

terse plinth
#

yea

#

lmaoo

slender lintel
terse plinth
#

im having smoothbrain moment

midnight cedar
wide cloak
clever lava
#
Traceback (most recent call last):
  File "main.py", line 2, in <module>
    import discord
  File "/home/runner/bot-TBW/venv/lib/python3.8/site-packages/discord/__init__.py", line 25, in <module>
    from .client import Client
  File "/home/runner/bot-TBW/venv/lib/python3.8/site-packages/discord/client.py", line 53, in <module>
    from .webhook import Webhook
  File "/home/runner/bot-TBW/venv/lib/python3.8/site-packages/discord/webhook/__init__.py", line 12, in <module>
    from .async_ import *
  File "/home/runner/bot-TBW/venv/lib/python3.8/site-packages/discord/webhook/async_.py", line 52, in <module>
    from ..channel import PartialMessageable
ImportError: cannot import name 'PartialMessageable' from 'discord.channel' (/home/runner/bot-TBW/venv/lib/python3.8/site-packages/discord/channel.py)
#

bro wtf even is this error

#

i coded literally the simpliest concept of bot possible

#
import discord
import os

bot = discord.Bot()

@bot.event
async def on_ready():
  print("on-line")

TOKEN = os.everion['TOKEN']
bot.run(TOKEN)
#

the bot dont have even a single command wtf is the error

#

i installed pycord v7

jolly charm
jolly charm
stable tiger
#

@jolly charm dont dm me or others/dont ping / be patient ; #help-rules

Make a constructive post, show your code/errors.

And describe what you exactly want. I'm sorry, but you both in dms and here you dont make much sense (considering you didnt show any code)

jolly charm
# stable tiger <@806414522599866388> dont dm me or others/dont ping / be patient ; <#8818918407...

I don't know how to code that.. that is the exact problem. I haven't used pycord.. coz it's not working for me, discord_components is though.
Here's a code which doesn't work on my end (also doesn't give errors), i've installed pycord.

import discord
from discord.ui import Button,View
from discord.ext import commands

bot = commands.Bot(command_prefix=">>>")

@bot.command()
async def hello(ctx):
    button = Button(label="Click me!",style=discord.ButtonStyle.green, emoji="👋")
    view = View()
    view.add_item(button)
    await ctx.send("Hi",view=view)

from config import TOKEN
bot.run(TOKEN)
jolly charm
slender lintel
#

How are you planning on getting N buttons tho?

#

You could just use a for loop and at the end use view.add_item

slender lintel
jolly charm
#

While implementing buttons through discord_components, i tried to do a for loop, then append button to a list.. as components is usually a list of list of buttons..
That didn't work since buttons are objects and objects aren't iterable

jolly charm
stable tiger
stable tiger
jolly charm
turbid kettle
#

How do you put a timestamp on the Embed?

sudden path
#

timestamp=datetime.datetime.utcnow()

stable tiger
#

usually it means you have not properly done "uninstall all other discord libraries -> install fresh py-cord" operation

sterile junco
#

How to pass a tuple to @commands.has_any_role()?

#

Like I have roles as a list of roles

#

I want to use it like @commands.has_any_role(roles)

sterile junco
sterile junco
sage birch
#

Hi, I'm wondering if there's any way I can set permissions for Slash Commands inside a Slash Command Group. Eg:
Managers can use /mod ban
Moderators can use /mod mute
Trial Mods can use /mod warn

As far as I'm aware, Discord's Integration menu only allows you to set permissions for the surface level commands/groups

midnight cedar
#

you can use checks to accomplish this though, they'd be on the bot side not on the client thoufh

sage birch
#

I see

#

Thanks

random kayak
clever lava
#

im getting depressed

#

my bot have literally 13 lines of code

#
import os
import discord

bot = discord.Bot()

tbw = [974818131728015360]

@bot.event
async def on_ready():
  print("on-line")

TOKEN = os.everion['TOKEN']
bot.run(TOKEN)
#

this is the entire bot

#

STILL CANT START IT

#
Traceback (most recent call last):
  File "main.py", line 2, in <module>
    import discord
  File "/home/runner/TBW/venv/lib/python3.8/site-packages/discord/__init__.py", line 25, in <module>
    from .client import Client
  File "/home/runner/TBW/venv/lib/python3.8/site-packages/discord/client.py", line 53, in <module>
    from .webhook import Webhook
  File "/home/runner/TBW/venv/lib/python3.8/site-packages/discord/webhook/__init__.py", line 12, in <module>
    from .async_ import *
  File "/home/runner/TBW/venv/lib/python3.8/site-packages/discord/webhook/async_.py", line 52, in <module>
    from ..channel import PartialMessageable
ImportError: cannot import name 'PartialMessageable' from 'discord.channel' (/home/runner/TBW/venv/lib/python3.8/site-packages/discord/channel.py)
#

help please

#

i cant do this anymore

sudden path
#

@clever lava

clever lava
#

what

#

oh i didnt saw it

clever lava
#

or where should i go

gilded widget
clever lava
#

k

#

ty

#

NICE

Traceback (most recent call last):
  File "main.py", line 4, in <module>
    bot = discord.Bot()
AttributeError: module 'discord' has no attribute 'Bot'
gilded widget
#

what version of pycord are you on

#

pip list or python -m pip list

#

python -m discord -v also works

clever lava
#

py-cord 2.0.0b7

#

there is no package called discord since i uninstalled it

paper schooner
#

how to add description to a slash option?

clever lava
#
Option(str, description="description here")
#

here

#

the first arg should be the type of the option

#

in this case its an string

#

for example when you need a member mention

#
Option(discord.Member, description="choose a member")
paper schooner
#

nice, thank you

clever lava
#

will tell you the syntax hold on

paper schooner
#

another quick question, how to add slash commands to server commands? (because global slash takes ~1 hour to update, right? and I need to test something quickly)

clever lava
#

hm

paper schooner
#

I tried searching on docs but no quick answer, hmm

clever lava
#

so you right click the server you want to make the command

#

click on copy id

#

then you create a variable

#

named everything you want

#

like this

test_server = [id goes here]

@bot.slash_command(guild_ids=test_server)
...
paper schooner
#

oh huh, alright! 👌

clever lava
# clever lava will tell you the syntax hold on

about this one

from discord.commands import Option

@bot.slash_command(guild_ids=[...])
async def test(ctx, option1 : Option(str, description="description goes here")):
  await ctx.respond(option1)
#

you need to import options first

paper schooner
#

okay

#

wait discord.commands doesn't work for me HmmGe

clever lava
#

wat

paper schooner
#

no such reference

clever lava
#

wtf

#

which pycord version are you using

gilded widget
#

make sure you've uninstalled all other discord libraries and install the latest pycord version 2.0.0b7

clever lava
#

i deleted the entire sht then created another screw it

paper schooner
#

Oh right

clever lava
#

and still giving me errors

paper schooner
#

I need to uninstall previous py-cord before installing the 2.0

#

ok wait

clever lava
#
import os
import discord

bot = discord.Bot()

tbw = [974818131728015360]

@bot.event
async def on_ready():
  print("on-line")

@bot.slash_command(guild_ids=tbw)
async def test(ctx):
  await ctx.respond("Hello world")

TOKEN = os.everion['TOKEN']
bot.run(TOKEN)
#

can anyone please help im getting mad with this bot

#

this is the simpliest concept possible of a bot

paper schooner
#

hmmmmm cat

clever lava
#

and just dont work

paper schooner
#

wut is that os.everion

clever lava
#

its an thing to hide my token

paper schooner
#

ah

clever lava
#

idk im not english native

paper schooner
#

I tested this

#

it starts but no slash command :/

#

just like in my bot

#

weird

clever lava
#

ye

paper schooner
#

daamn and I wanted to submit the bot in about 8 minutes for some itch.io jam

#

guess I can't xD

clever lava
#

im almost giving up

paper schooner
#

the bot didn't show up in the sidebar when typing / but when I typed /test it worked

clever lava
#

hm

#

i think your problem is having other bots in same server

#

thats why when you type the command shows up

#

no way

#

NOWAY

#

THANK GOD

#

after all day long

#

why its so hard to create a bot aaaaaaaaaa

paper schooner
#

lolol, gz

crude spade
#

For some reason, slash commands are not being registered despite the fact I have one implemented AND I have the server ID in the list of debug_guilds for the bot.
I enabled DEBUG level logging and looking in the log there are lines that say this:

2022-05-14 00:08:48,202:DEBUG:discord.bot: Skipping bulk command update: Commands are up to date

There are no errors.
I have kicked the bot from my server and had it rejoin several times. I have also removed and readded the integration.
I have made sure it has the correct permissions (both Administrator and application.commands).
I'm using the latest version of the library from the github repository .

clever lava
crude spade
#

Are you asking me? Because I don't understand your question.

clever lava
#

idk

#

anyone who knows

crude spade
#

I've had this problem for over a week now.
If I can't resolve it I'll switch to another library and let other developers know about the issue.

clever lava
#

sad

slender lintel
#

Hey how i can say time in Modal? i have tried so: time=self.children[0].value (in async def callback(self, interaction: discord.Interaction, time=self.children[0].value):).

idle wagon
#

Someone knows how to pass custom_id?

crude spade
#

I switched to another fork of discord.py and got commands working there.
Goodbye.

gilded widget
#

okay lmao

vestal kelp
#

I have a quick question regarding part of the documentation. What is the atomic attribute for member.add_roles

#

Whoever ends up answering, please ping me so I can ensure I see the answer

jolly charm
jolly charm
pallid flume
#

hey guys, i really need help

#

i want to use discord buttons on my slash commands but i use cogs

#

how do i add buttons in my cogs?

gilded widget
jolly charm
#

!hello gives no output.

gilded widget
#

yeah you don't have intents

#

?tag intents

hearty rainBOT
#
import discord
from discord.ext import commands

# Get specific intents for fine control
intents = discord.Intents()
intents.emojis = True
intents.guilds = True
intents.messages = True  # Required for prefix commands!
...
# Get all non-priveliged intents; this excludes presences, members and message_content 
intents = discord.Intents.default()

# Set priveliged intents: these must be enabled on dev portal
intents.members = True
intents.presences = True
intents.message_content = True  # Required for prefix commands >= 2.0.0b5

# Get all intents; all intents must be enabled on dev portal.
intents = discord.Intents.all()

# Apply intents when creating your bot
bot = commands.bot(prefix="?", intents=intents)
jolly charm
# gilded widget yeah you don't have intents

ok i'm using this code now, and it still doesn't work

import discord
from discord.ext import commands

intents = discord.Intents.default()
#intents = discord.Intents()
#intents.messages = True
bot = commands.Bot(command_prefix='!',intents=intents)

@bot.event
async def on_ready():
    print(f"{bot.user} is ready and online!")

@bot.command()
async def hello(ctx):
    await ctx.reply("Hey!")


from config import TOKEN
bot.run(TOKEN)
#

i've this commented out portion.. and both gives not error

#

also this on_ready func() is always getting executed well

gilded widget
#

if you're on a version >= 2.0.0b5 you also need intents.message_content and the message content intent enabled in the dev portal

jolly charm
gilded widget
#

yes, go to your app, bot tab, then enable the message content intent