#General Help

1 messages · Page 2 of 1

nocturne hazel
#

Ty

balmy flame
#

sorry im not seeing a way

#

but i can give you code that deletes itself thats not ephemeral

nocturne hazel
balmy flame
#

yeah

#

isnt the point of a ephemeral message for you to only see it

#

seems counter productive to delete it

slender lintel
#

#970690142476058734

nocturne hazel
balmy flame
#

OK THIS MAY MAY MAY SOUND REALLY DUMB

#

Wait nvm

balmy flame
#

and istg if its a simple answer i will scream

#
@tasks.loop(seconds = 10)
async def change_status():
        await bot.change_presence(status=discord.Status.idle, activity = status)
```why dosent this work
balmy flame
#

THERE IS NONE

#

THATS THE THING

slow dome
#

what is cycle

balmy flame
#

its swapping status's

#

cycle has the status's

slow dome
#

does it return anything?

balmy flame
#

its a simple import

#

from itertools import cycle

slow dome
#

that returns a list

#

when you already have a list

balmy flame
#

that is my list

slow dome
#

and expecting activity to be a list

balmy flame
#

im using discord.ext tasks and cycle

#

OH

slow dome
#

you can't delete ephemeral messages

nocturne hazel
crimson coral
#

nop

#

can only dismiss manually

#

though if you reload the client they should be gone

hot python
#

url buttons can’t have callbacks, so you need to add them with view.add_item

balmy flame
#

can you add guild_ids to bot events so they only happen in that server

#

for example your bot is welcoming people into your server and dming them

#

but it does that for all servers

slender lintel
#

You can make a list containing the guild ids in which you want the event to react to

In the specific event you can make an if statement checking if the authors guild id is in that dictionary

balmy flame
#

would a list work?

slender lintel
#

I meant list sorry

balmy flame
#

so for example @bot.event(guild_ids = [some random guild])

slender lintel
#

no

balmy flame
#

then how?

slender lintel
#
@bot.event
async def on_message(msg):
   if msg.guild.id in a_list:
       #Your code
jagged oak
#

Hi guys, can someone tell me how can I make the slash command /unload <cog> work?
bot.unload_extension() <-- this is not working i guess

slender lintel
balmy flame
#

wouldnt i have to change msg

#

i should just take out the param

#

manke it member

crimson coral
#

it's the same format as load and reload

slender lintel
#

It should prob work

jagged oak
crimson coral
#

are you trying to remove slash commands?

slender lintel
crimson coral
#

or regular commands

crimson coral
#

slash commands are a bit different

jagged oak
#

ok, i think i got it 😕

crimson coral
jagged oak
#

I want that, when unloading a file, the slash commands stop appearing in the chat

balmy flame
#

would this work?

#
async def  on_member_join(ctx, member):
   if member.guild.id in guilds:
       embed = discord.Embed(title = "welcome")
       await ctx.member.send(embed = embed)````
crimson coral
#

i think you could try:

  • get a list of application commands in the cog
  • with sync_commands, get all application commands on the bot but remove said commands
balmy flame
#

ah

slender lintel
#

It's an event not command

balmy flame
#

yeah no context

slender lintel
#

member.send would be enough also

balmy flame
#

gotcha

balmy flame
crimson coral
#

should be

balmy flame
#

i just tried it

#

i wont work

crimson coral
#

is guilds a list of guild ids?

slender lintel
#

Error?

balmy flame
#

yeah

balmy flame
crimson coral
#

all integers right?

#

if they're strings then that's the issue

balmy flame
#

they're not strings

idle linden
#

bot.guilds is a list of Guild objects

balmy flame
#

hmmm

crimson coral
#

yeah but they've made their own guilds list

#

or are you actually using bot.guilds

balmy flame
#

OH the account wasnt verified

slender lintel
#

oh

balmy flame
#

so it didnt know who to send to

slender lintel
#

hmm

balmy flame
#

ok everythings good

slender lintel
#

Ohk noic

balmy flame
#

also do you have to say a parameter to send a dm

#

i thought dm.send worked to

crimson coral
#

no just member.send

balmy flame
#

what if member isnt defined

crimson coral
#

uhhhh

slender lintel
#

It should

crimson coral
#

if it's on_member_join you'll always get a member object

slender lintel
#

Be defined at all cost

balmy flame
#

no i mean in a slash command

crimson coral
#

if you don't get the member or user object, just fetch it yourself

balmy flame
#

yeah that would prob work

#

thanks

slender lintel
#

Heroku is a hosting platform which provides 550 free hours per month but by adding a credit/debit card (without paying) you get 1000 hours. So do you get 1000 hours per month or is it only one time?

crimson coral
#

i think it's total, but i wouldn't use heroku for hosting anyway

#

generally you should avoid "free" solutions because they are NOT built for a task like bot hosting (despite it being possible)

#

e.g... replit is a popular one these days

balmy flame
#

ctx.author.send works

crimson coral
#

yues

#

since ctx.author is a member/user object

balmy flame
#

yeah

#

so i can put that in a try except statment right

crimson coral
#

yeah that should work

slender lintel
#

But I'm broke f I had money i would go for better servers ;/

crimson coral
#

you can get pretty cheap servers

#

like 1$ or 2 per month

slender lintel
#

I don't even have a cent

#

I'm that broke

#

F

crimson coral
#

rip

balmy flame
#

ploxhost is for $1.50

spiral raft
#
Traceback (most recent call last):
  File "D:\banbot\lib\site-packages\discord\client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "D:\banbot\lib\site-packages\discord\bot.py", line 1147, in on_connect  
    await self.sync_commands()
  File "D:\banbot\lib\site-packages\discord\bot.py", line 683, in sync_commands
    permissions = [
  File "D:\banbot\lib\site-packages\discord\bot.py", line 686, in <listcomp>   
    if perm.guild_id is None
AttributeError: 'function' object has no attribute 'guild_id'```
#

Just a bug in the library or?

south ermine
#

What version?

#

Add what did you do?

spiral raft
agile tundra
#

yeah

#

send your code

#

then I can help i guess

#

but just the part

spiral raft
#
import discord
from dotenv import dotenv_values

config = dotenv_values(".env")

bot = discord.Bot()

@bot.event
async def on_ready():
    print(f"We have logged in as {bot.user}")

@bot.slash_command(guild_ids=[456413000887435285], permissions=[discord.commands.permissions.is_owner()])
async def reload(ctx):
    for cog in cogs_list:
        bot.reload_extension(f'cogs.{cog}')
    await ctx.respond("Reloaded")

bot.run(config['DISCORD_API_TOKEN'])
agile tundra
#

hmmm

spiral raft
#

But the traceback doesnt trace back to my code.

agile tundra
#

I think its a error in the libary @peak abyss

#

Error for you

nocturne hazel
#

Quick question, can you have a select menu to a modal?

crimson coral
unique flume
#

is discord.errors.NotFound: 404 Not Found (error code: 10008): Unknown Message a message i should be concerned about fixing? everything else works perfectly. can go more into detail if needed but i read #932108949652648026 message that it was apparently pretty harmless so wanted to verify whether that's true and i should just not worry about it, or if i should address it further

crimson coral
spiral raft
#

It seems to work tho.

unique flume
spiral raft
#

Ah I see.

crimson coral
#

Fair enough, but you should probably handle the exception instead of just letting it error (if this is a regular occurrence)

spiral raft
#

Rlly need to learn about the decorators once...

unique flume
#

gotcha, will work on it

spiral raft
agile tundra
#

Bruh

ember basin
#

my sllash command isnt appearing

#

i registered it in my cog with commands.slash but i dont see it on discord

#

anything else i need to do?

cedar badger
#

how do i make the "" with a hotkey

haughty narwhal
#

Anyone know the code for getting profilepic url from ctx.author?

#

Nope, I managed to figure it out via the docs. It is ctx.author.display_avatar

#

yeah. I meant display avatar. my fault

cedar badger
#

How can I generate number? for example make each modal submitted application 1, 2 3 and so on

south ermine
#

you can do an autoincrement column with mysql

cedar badger
#

what

ember basin
#

do slash commands work from cogs

south ermine
#

you would just store the highest number somewhere and then reference/update it for each application

south ermine
ember basin
#

did u ever figure this out

south ermine
#

Command groups? Yes

lusty dragon
#

how can i upgrade to py-cord 2.0.0b7 ?

#

when i'm installing it in vps, it installs the 1.7.3

balmy flame
robust nebulaBOT
#

Install pycord:

pip install py-cord```
Install pycord beta:
```pip uninstall discord.py
pip install py-cord==2.0.0b5```
Install pycord alpha from git:
```pip uninstall discord.py
pip install git+https://github.com/Pycord-Development/pycord```
balmy flame
#

oh b7 should be on github im pretty sure

haughty narwhal
#

how do i completely uninstall pycord?

cedar badger
#

pip uninstall py-cord

lusty dragon
#

its a linux machine

cedar badger
lusty dragon
crimson coral
#

How even

shell shuttle
#

The correct command is pip install py-cord==2.0.0b7

#

Oh I guess the error says that

lusty dragon
#

pip3 works

crimson coral
thin trellis
#

Is the channel Option Type for application commands already fixed on the master branch?

crimson coral
pastel wadi
#

Is it possible to pass arguments to an view to determin how many buttons should be active?

crimson coral
#

Just add an _init_ function (remember to super) and add an extra argument there you can pass in

pastel wadi
#

I realized I'm dumb with Python, thanks!

crimson coral
#

All good

pastel wadi
#

I was passing arguments in the subclassing definition and was bewildered, ah well

#

Perhaps another question: I can pass the arguments, but it would be the decorator that actually attaches the button to the view. So how would I make the decorator conditional?

balmy flame
#

im having a problem

#

i made a discord button thats supposed to send a embed with a truth or dare question

#

but it keeps sending the name question

grave wraith
#
>>> field2 = embed.fields[2]
>>> print(field2 == embed.fields[2])
False
``` why doesn't it return True?
barren cedar
#

how do you do slash command groups in a cog?

daring flint
#

Not worth a whole thread, but has anyone had issues with clear_single_reaction complaining that it requires 2FA? I didn't think bots needed 2FA

(Edit: Turns out 2FA is inherited by the application owner)

barren cedar
nocturne sage
#
async def cmnd(ctx):
    select = Select(
    placeholder="Pick a category",
        options=[
            discord.SelectOption(label="One"),
            discord.SelectOption(label="Two"),
            discord.SelectOption(label="Three"),
            discord.SelectOption(label="Four"),
            discord.SelectOption(label="Five"),
    ])
    async def my_callback(interaction):
        await interaction.response.send_message()
```how can i make the `await interaction.` to edit it? wadda i use for edits? ![think](https://cdn.discordapp.com/emojis/846423939558801488.webp?size=128 "think")
#

i did await interaction.message.edit but it gives an error altho it still works

balmy flame
#

oh it works nvm

slow dome
high patio
#

Is there a way to send dm's from interactions?

slow dome
#

It’s not supposed to be used as a response tho

faint badger
frosty slate
#

how do i get an input from a modal?

#

i need to get the input and parse it into a spreadsheet

slow dome
#

?tag ex

slow dome
#

check views

jolly horizon
#

can someone give me an example that works (with imports) for buttons, i cant find any that work

jolly horizon
#

i forgot to mention im using discord.py not pycorfd

south ermine
#

please ask in the discord.py server then, this is pycord support.

jolly horizon
hazy haven
#
Traceback (most recent call last):
  File "C:\Users\hayha\PycharmProjects\pythonProject3\venv\lib\site-packages\discord\bot.py", line 1098, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Users\hayha\PycharmProjects\pythonProject3\venv\lib\site-packages\discord\commands\core.py", line 331, in invoke
    await injected(ctx)
  File "C:\Users\hayha\PycharmProjects\pythonProject3\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: TypeError: 'str' object cannot be interpreted as an integer
    @discord.command(name='random-choice', description='Randomly choose a # of winners from given choices')
    async def random_item(self, ctx, items: discord.Option(str, 'put items here, separated by a space'), winners=1):
        item_list = items.split()
        winner_list = []
        for x in range(winners):
            choice = random.choice(item_list)
            winner_list.append(choice)
        await ctx.respond(winner_list)

Pycord v2.0.07b: not sure why this is erroring, nothing looks wrong to me. The items parameter is not the issue either, I have isolated that. any ideas? (it is a beta build of the lib, so it could be a bug?)

steep verge
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]```
#

why is this happening?

nocturne hazel
#

Yo, is there a simpler way to do this so i dont have to write await ctx.message.delete() on every command?

#

I just want it to auto delete the message the command was in

grave wraith
grave wraith
#

or at least a way to bypass this

fair cradle
#

Is it possible to disable a Button for an specific User?

nocturne sage
teal shadow
#
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 181, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/runner/PyBot/cogs/funny.py", line 138, in marry
    if member.id in marriages_members:
AttributeError: 'NoneType' object has no attribute 'id'

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 360, in invoke
    await ctx.command.invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1505, in invoke
    await ctx.invoked_subcommand.invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 927, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/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: 'NoneType' object has no attribute 'id'```
crude rampart
#

how to use quotes with a jump to original button?

#

sth like this

#

how to add that jump button

#

oh I found out it's just an embedded link

balmy flame
#

I'm a better help then jab

worthy basin
# teal shadow Help me

If the user does not enter in a username, member will default to None. This command should require a member unless you can marry yourself or something. Otherwise you will need tocheck if member is None before using member.id

slender lintel
#

"[jump text here](url here)"

hushed dove
#

Why do bots have the "Use application commands" perms? Can 1 bot use application cmds of a 2nd bot?

hazy haven
lusty dragon
hushed dove
plush tusk
#

how i can add Cooldown on command in cogs?

coarse marsh
#

Why when i create a new embed with a button if i restart the bot the message need to be resended or the button says "Interaction failed"?
How i can do a button permanent?

stray smelt
stray smelt
#

lemme fix

coarse marsh
#

i mean its a cogs problem

#

because its not working only if i use it on a cogs

stray smelt
coarse marsh
#

ill send you all

stray smelt
ripe pagoda
#

@stray smelt @coarse marsh What was the fix? I would like to know for myself.

slender lintel
#

my slash commands wont appear

#

anyone?

surreal haven
#

So, I'm currently trying to install py-cord==2.0.0b7
I uninstalled discord, discord.py, discord_components, buttons, nextcord.

What I typed in the terminal: pip install py-cord==2.0.0b7

The error messages:

WARNING: Ignoring invalid distribution -ywin32 (c:\users\no\appdata\local\programs\python\python37\lib\site-packages)
ERROR: Could not find a version that satisfies the requirement py-cord==2.0.0b7 (from versions: 1.7.3)
ERROR: No matching distribution found for py-cord==2.0.0b7
WARNING: Ignoring invalid distribution -ywin32 (c:\users\no\appdata\local\programs\python\python37\lib\site-packages)
WARNING: Ignoring invalid distribution -ywin32 (c:\users\no\appdata\local\programs\python\python37\lib\site-packages)```
slow dome
high patio
clever lava
#

looks like discord updated again

high patio
#

kick it from your server, and invite it back with this

clever lava
#

i want permissions decorator baaaack 😭

slender lintel
high patio
#

Semd screenshot of your oauth2

#

send*

slender lintel
#

out of the 5

high patio
#

Oh

slow dome
#

are the slash commands guild or global

slender lintel
slow dome
#

via guild_ids?

slender lintel
#

yes

slow dome
#

or debug_guilds

slender lintel
#

guild_ids

slow dome
#

try updating your client and restart the bot

slender lintel
#

how would i do that

#

updating my client

#

and i have restarted my bot

#

many times

clever lava
slow dome
#

Phone = app store/ play store

high patio
#

reset client secret, I think

slow dome
#

desktop = upper left corner

slender lintel
#

im currently hosting on repl

slow dome
#

click green download button thingy

slender lintel
#

😭

slow dome
slender lintel
#

im on web discord rn

slow dome
#

refresh

slender lintel
#

ok

#

still

#

@slow dome

slow dome
#

show code

slender lintel
#

it worked just fine before

#

like

slow dome
#

slash commands need a description

slender lintel
#

i just added a new cmd and all of a sudden this started happening

#

they do have it

#

lmfao

slow dome
#

and permissions are broken

slender lintel
#

aaaaa

#

this is stressful

slow dome
#

discord was like how do we make people use slash commands? release an update so it breaks everything

slender lintel
#

lufgiusdfuigh

#

im gonna die myself

high patio
#

When did they update?

#

Was it today?

crimson coral
#

Few days ago, breaking api change with no warning and no version bump + other issues 🙃

#

Though they at least apologised for it

high patio
#

Also just a quick question

Traceback (most recent call last):
  File "AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "AppData\Local\Programs\Python\Python39\lib\site-packages\discord\bot.py", line 1147, in on_connect
    await self.sync_commands()
  File "AppData\Local\Programs\Python\Python39\lib\site-packages\discord\bot.py", line 770, in sync_commands
    await self._bot.http.bulk_upsert_command_permissions(self._bot.user.id, guild_id, guild_cmd_perms)
  File "AppData\Local\Programs\Python\Python39\lib\site-packages\discord\http.py", line 359, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 405 Method Not Allowed (error code: 0): 405: Method Not Allowed```
#

Is this uh

#

because of outdated lib?

#

Or intent mayne?

crimson coral
#

Because of the changes discord made

#

You can safely ignore it

high patio
#

Yea, I figured

#

gonna create an error handler

#

just to stop getting this

#

lol

slender lintel
#

How to make forum channel?

south ermine
#

Wait until you're whitelisted

slate stirrup
#

How do I delete the default help panel

high patio
#
help_command=None```

on

```discord.ext.commands.Bot
slate stirrup
#

Then I can make a custom one ?

iron valve
#

Hello,
Is it possible to get the custom status a User himself sets? I can get the Game the User is playing via member.activities but I can't seem to be able to get the custom status one can set?

high patio
#

What you mean?

#

activities = guild.get_member(user.id).activities

#

For Custom Activities

iron valve
#

Got it to work sorry, I guess I didn't wait long enough for it to sync

random kayak
#

Hi, is there a way to get a guild's roles in order? Or at least check if a role is higher than another?

ornate spade
#

check role.position

thorny cargo
#

RuntimeWarning: Enable tracemalloc to get the object allocation traceback
#

Can someone suggest if there is any fix for this?

#

I am trying to get list of users with a certain role, through a command

#

Also, how to check the user ID of user who ran the command? (Above warning I shared is for the below code)

@bot.command()
async def getuser(ctx, role: discord.Role):
    print("Debug-Inside getuser()")
    await ctx.send("Loading...")
    await ctx.send("\n".join(str(member) for member in role.members))
    ctx.respond("Done")
south ermine
#

you need to await your ctx.respond

thorny cargo
thorny cargo
thorny cargo
south ermine
#

it looks predefined to me...

thorny cargo
#

role = get(ctx.guild.roles, id=defBoostRole) didn't work

south ermine
#

what is get()?

#

is that a method you wrote?

#

or did you just import get from discord.utils

thorny cargo
#

Yes

south ermine
#

what doesn't work? do you get back None?

#

did you read the error?

#

your command name is invalid, probably the capital B

thorny cargo
south ermine
#

it's discord

#

you can read up on the discord dev docs

thorny cargo
grave wraith
stable tiger
#

state of # help... despair haha

south ermine
#

yeah we really need a faq

stable tiger
#

chat, random question, this "Integations" menu is cool and all but can it hide slash commands from me(as server admin) as well ? 😄 anybody knows anything? it hides things from non-adminds just fine but idk

little isle
#

Does bridge.Bot not honor debug_guilds?

little isle
unique glacier
#

Hello I'm trying to get poetry setup with my project though everytime I run poetry init I get this error which I don't how to fix

Error:

poetry init

This command will guide you through creating your pyproject.toml config.

Package name [reko]:  Reko
Version [0.1.0]:  0.4.4-beta
Description []:  
Author [TechnoTalksDev <>, n to skip]:  
License []:  

  OSError

  [WinError 1920] The file cannot be accessed by the system: 'C:\\Users\\chcha\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\python.exe\\Scripts'

  at C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0\lib\pathlib.py:1095 in stat
      1091│
      1092│         Return the result of the stat() system call on this path, like
      1093│         os.stat() does.
      1094│         """
    → 1095│         return self._accessor.stat(self, follow_symlinks=follow_symlinks)
      1096│
      1097│     def owner(self):
      1098│
      1099│         Return the login name of the file owner.
potent rivet
#

I keep getting an error saying my token must be of type str, not NonType

#

idk how to fix it

past gate
#

stack tracE?

potent rivet
#

what

#

idk this is just what i get

past gate
#

is there a TOKEN enviroment variable in your enviroment? @potent rivet

past gate
#

theres your issue

potent rivet
#

I think i know what you mean

#

TOKEN is only in the .env

past gate
#

what do you think os.getenv('TOKEN') does

past gate
potent rivet
#

gets token from env

potent rivet
past gate
#

@potent rivet

potent rivet
past gate
#

and your env file?

#

minus your token ofc

potent rivet
past gate
#

yeah no

potent rivet
#

thats what the guide said

past gate
#

thats not how a env file should be structured

#

thats a bug with the formatting..

potent rivet
#

so how do i make it work

past gate
#

.env files are just KV pairs

#

so

#
KEY=VALUE
KEY2=VALUE2```
potent rivet
#

So I don't need the quotation mark thing?

#

just TOKEN = token

past gate
#

just TOKEN=your token

potent rivet
#

ok ty

dapper quiver
#
    channel = channel.name
    name = channel.split("reps-")
    print(int(name[1]))
    rename = name + 1
    other_channel = bot.get_channel(971111822356795402)
    print("f", rename)
    await other_channel.edit(name=f'reps-{rename}')

So the code above should just rename my channel to reps-number_here of course, now the name of the channel right now is just reps-0, the first print statements gets printed but after that, the next print does not and subsequently, the channel is never renamed

south ermine
#

You can only rename a channel twice every 10 minutes

dapper quiver
#

well I havent renamed it all yet

south ermine
#

do you have permissions to rename channels?

dapper quiver
#

Yep admin perms

#

But as I say, the print never happens so yeah

south ermine
#

name is a list, you can't add 1 to a list

dapper quiver
#

oh you're right, so would I just convert name[1] into an int I guess

cloud lotus
#
import discord
ModuleNotFoundError: No module named 'discord'
#

how to fix this??

south ermine
#

?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
cloud lotus
#

I already installed it still showing the error

past gate
#

can you pip list @cloud lotus

cloud lotus
past gate
#

are you sure thats the error?

cloud lotus
#

yes It was working fine few day back now I'm getting that error

past gate
#

thats odd

cloud lotus
#

idk what happened notlikethis

past gate
#

hm 🤔

crude rampart
#

is this limited to messages that are in the internal cache?

#

or it will fetch it from the API if it isn't in the internal message cache

wraith folio
#

how do you create webhooks with code?

#

like i know you can make them in the channel settings, and there's also Webhook.from_url() which you can use to use those ones that you made yourself, but how would you do it where the bot makes it itself?

south ermine
#

b!rtfm pycord TextChannel.create_webhook

open bearBOT
wraith folio
#

wow i cant believe i missed that facepalm

#

thank you

crude rampart
#

When Trying to fetch a message with its ID it is throwing an exception:

Ignoring exception in on_raw_reaction_add
Traceback (most recent call last):
  File "C:\Users\felix\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\felix\Desktop\py\dc_msgtrack\main.py", line 18, in on_raw_reaction_add
    message = bot.get_message(id=payload.message_id)
AttributeError: 'Bot' object has no attribute 'get_message'

Code is as follows:

# load in packages and libs
import discord
from discord.ext import commands
from log import log

# read token
with open('token.txt','r',encoding='utf8') as tokenfile:
    token = tokenfile.read()

bot = commands.Bot(intents=discord.Intents.all(),prefix='.')

@bot.event
async def on_ready():
    log('Connected to Discord')

@bot.event
async def on_raw_reaction_add(payload):
    message = bot.get_message(id=payload.message_id)
    log(message)
    # log(payload.message_id)
    log(payload.member.id)

bot.run(token)
crude rampart
south ermine
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
crude rampart
stable torrent
#

3rd codeblock

#

aka alpha

crude rampart
#

so the issue I'm facing is known and will be fixed in a future release?

stable torrent
#

its already fixed in alpha

#

but not in beta

crude rampart
#

want to confirm is the current release (old version not 2.0 beta) affected by this?

stable torrent
#

fck

#

here you go

wraith folio
#

how would i take an image link and convert it to a bytes-like object?

past gate
#

huh

stable torrent
#

its kinda

#

stackoverflow 10m views post kinda thing

past gate
#

why would you need to convert a URL to bytes

#

🤔

wraith folio
#
  1. i cant find anything that works then . _.
  2. im trying to make webhooks with avatars, and im storing them as urls
stable torrent
#

you can specify avatar as url, no?

#

just get it from url and turn in to bytes

#

🤔

wraith folio
#

it wont accept urls, only "bytes-like object"

#

hang on let me try that

#

also is it required to download the image for it to work?

stable torrent
#

don't think so

wraith folio
#

every solution i can find seems to do that

stable torrent
#

im pretty sure you can just read bytes

#

from url

#

with BytesIO

#

i think i've done this several times

#

it should work with aiohttp

dapper quiver
#
@bot.slash_command(name='nothin', guild_ids=slash_guilds)
async def nothin(ctx):
    basic_bot = Button(label='Basic Tier Bot', style=discord.ButtonStyle.blurple)
    interm_bot = Button(label='Intermediate Tier Bot', style=discord.ButtonStyle.green)
    advanced_bot = Button(label='Advanced Tier Bot', style=discord.ButtonStyle.red)

    await ctx.respond('test')
    view = View()
    view.add_item(basic_bot)
    view.add_item(interm_bot)
    view.add_item(advanced_bot)

    await ctx.respond(view=view)```

Any reasons for that error?
#

great, I made a new bot application and now another bot command just disappeared and the rest are still here

crude rampart
#

how do I get a message that is not in its internal message cache?

south ermine
crude rampart
#

it is giving me a 403 forbidden error

wraith folio
#

how would i speed up (<built-in method _overlapped.GetQueuedCompletionStatus>)?

crimson gale
#
# @param {string} plant (key)
# @return {JSON} lastState```
has anyone ever seen this type of type hinting for python?
fair cradle
#

is it possible to make my select menü persistent?

crimson gale
#

persistent view

stable anvil
crimson gale
#

you also need messages

stable anvil
#

Share the code

#

And full traceback

slender lintel
#

how can i make this think?

crimson gale
#

you mean choices?

slender lintel
crimson gale
#

choices kwarg in Option. must contain a list of the input type max. 25 elements

crimson gale
#

idk im working with an aws lambda function here

#

this is old shit some dude made that i need to update

past gate
#

🤔

#

looks like some C# docstring pattern

crimson gale
#

i was instructed to follow the conventions used in the script

#

maybe a c# developer having had to use python or something?

#

theres also return keywords on some of the helper functions when it isnt necessary

crimson gale
#

i wont fiddle around with the documentation much but ill use more line efficient conventions in some places

#

theres also no usage of f-strings anywhere in this script

past gate
#

rip.

#

also you did .bot() and not .Bot()

ornate spade
mossy wyvern
past gate
#

do pip list

mossy wyvern
#

What now.

past gate
#

send it here

mossy wyvern
#

okay

past gate
#

hm ok

#

can you show your project structure

mossy wyvern
#

whats that?

past gate
#

show me the folder your bot.py is in

mossy wyvern
#

it's a file on desktop

past gate
#

do you have another file on your desktop called discord.py

mossy wyvern
#

i renamed that bot file to bot.py

past gate
#

hm

#

any other?

mossy wyvern
#

i do actually

#

deleted it now

past gate
#

try now

mossy wyvern
#

what is coro

past gate
#

its bot.event

mossy wyvern
#

oops

#

Thanks! Works nicely now!

prime frost
#

Anyone know how to fix this or what it means

past gate
#

its harmless

#

but you can just update to the master branch

#

if you want to get rid of it

slender lintel
#

Is there an event which gets executed before on_ready?

stable anvil
slender lintel
#

I se thanc

coral stratus
#

Has anyone done discord authorization with bearer and fastapi?

wild wolf
#

I installed pycord but it says no module named 'discord'

past gate
#

and send the output

wild wolf
#
------------------ ---------
MarkupSafe         2.1.1
multidict          6.0.2
numpy              1.22.3
pip                22.0.4
py-cord            2.0.0b7
pycord             0.1.1
pygame             2.1.2
requests           2.27.1
setuptools         58.1.0
urllib3            1.26.9
Werkzeug           2.1.2
yarl               1.7.2
wild wolf
# past gate run `pip list`
------------------ ---------
MarkupSafe         2.1.1
multidict          6.0.2
numpy              1.22.3
pip                22.0.4
py-cord            2.0.0b7
pycord             0.1.1
pygame             2.1.2
requests           2.27.1
setuptools         58.1.0
urllib3            1.26.9
Werkzeug           2.1.2
yarl               1.7.2
merry thicket
#

Its a simple reason: Discord doesnt always update it quickly.

#

To fix it, what you could do is make a list/array with guild ids, and to put change to:

@client.command(name='ping', guild_ids=[ids])
...
#

In that way, you simple tell the bot that the guild(s) in the list are the testing guilds, and that these should update ASAP once the bot restarts.

#

You can do it however you like, you can make a variable list for it too.

#
varlistids = [ids]
@client.command(name='ping', guild_ids=varlistids)
# OR
@client.command(name='ping', guild_ids=[ids])
#

Let me know if it works

#

Wait, is that even a slash command?

#
@bot.slash_command(guild_ids=[your, guild_ids, here])
async def hello(ctx):
    await ctx.respond("Hello!")```
#

It isn't.

#

You use @client.command instead of @client.slash_command

#

Ah my bad.

#

Did you invite the bot correctly?

#

Okay, weird.

#

I also wouldnt know the issue then.

#

Also, another question: how do I update to the latest main branch on a Raspberry Pi/Linux system?

wild wolf
#

I installed pycord but it says no module named 'discord'

------------------ ---------
MarkupSafe         2.1.1
multidict          6.0.2
numpy              1.22.3
pip                22.0.4
py-cord            2.0.0b7
pycord             0.1.1
pygame             2.1.2
requests           2.27.1
setuptools         58.1.0
urllib3            1.26.9
Werkzeug           2.1.2
yarl               1.7.2
merry thicket
#

That could be correct.

#

Does the bot work correctly though?

wild wolf
#

the import discord doesn't work

#

the from discord.ext.commands import Bot also doesn't work

half marsh
#

Is there a timeout for interaction to respond?

slender lintel
#
import discord
from discord.commands import slash_command
from discord.ext import commands

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

    @slash_command(guild_ids=[guild_id])
    async def testing(self, ctx, color: str, animal: str):
        await ctx.respond(f"You picked {color} and {animal}.")

def setup(bot):
    bot.add_cog(Testing(bot)) ```
Whenever am loading this extension and running my bot, testing command is not showing up
#

Am using py-cord 2.0.0b4

half marsh
slender lintel
crimson gale
terse plinth
slender lintel
terse plinth
#

interesting

slender lintel
#

Am still using v2.0.0b4

#

And name is not an issue afaik, as if name argument is not given then it takes the method name as the name of the command

terse plinth
#

ye ik that, in the past i used slash commands by defining name, description in the event handle

slender lintel
#

Ohh it worked now, it was a typo xD, didn't noticed my bad

#

I mistyped, bot.load_extension('ttesting') instead of bot.load_extension('testing')

terse plinth
#

General Python Help lmao
My discord bot is hosted on an online server. Problem is that the sever file structure is different from my local machine. i,e
the path 'C:\Python\images' is 'C:/Python/images'. Is there any way to use the os module to avert this issue with a try-except block for every cog?

stable torrent
#

i think pathlib can do that

wild wolf
#

I installed pycord but it says no module named 'discord'

------------------ ---------
MarkupSafe         2.1.1
multidict          6.0.2
numpy              1.22.3
pip                22.0.4
py-cord            2.0.0b7
pycord             0.1.1
pygame             2.1.2
requests           2.27.1
setuptools         58.1.0
urllib3            1.26.9
Werkzeug           2.1.2
yarl               1.7.2
terse plinth
#

it isnt supposed to

wild wolf
#

then why would this happen

terse plinth
#

then re-install

#

!install

robust nebulaBOT
#

Install pycord:

pip install py-cord```
Install pycord beta:
```pip uninstall discord.py
pip install py-cord==2.0.0b5```
Install pycord alpha from git:
```pip uninstall discord.py
pip install git+https://github.com/Pycord-Development/pycord```
wild wolf
#

ok

#

which one should I install?

terse plinth
#

pycord is stable i.e very few bugs
pycord beta is semi stable i.e a few more bugs
pycord alpha is WIP i.e you can expect a lotta bugs

#

depending on your need

slender lintel
#

Autocomplete interactions can be used for modal text inputs?
Or they're just for slash command options?

terse plinth
#

although i would recommend pip install py-cord

wild wolf
#

nope

#

still not working

terse plinth
#

what IDE do you use? sometimes it helps to restart your IDE or your System

#

works for me to restart VS-Code when i install a new library

wild wolf
#

I know I use pycharm for coding

terse plinth
wild wolf
terse plinth
#

. . .

wild wolf
#

sorry for being dumb and annoying

terse plinth
#

like restat your pc

wild wolf
#

oh

#

ok

terse plinth
#

like that

terse plinth
wild wolf
#

It's updating 10 %

stiff nebula
#

What is a user command?

terse plinth
#

Those are user commands, useful for things like translation etc

wild wolf
#

nope, it still says

stiff nebula
brazen hill
#

hello, why does message.content output blank? (i am using discord.Bot and my bot object) can anyone help pls thank you :)

terse plinth
wild wolf
#

I restarted it but it is still not working

glossy thicket
#

Hello, since today I no longer see my slash commands so what was visible and I haven't changed anything can someone help me

brazen hill
#
Traceback (most recent call last):
  File "main.py", line 1, in <module>
    import discord
  File "/home/runner/musket-amateur/venv/lib/python3.8/site-packages/discord/__init__.py", line 25, in <module>
    from .client import Client
  File "/home/runner/musket-amateur/venv/lib/python3.8/site-packages/discord/client.py", line 53, in <module>
    from .webhook import Webhook
  File "/home/runner/musket-amateur/venv/lib/python3.8/site-packages/discord/webhook/__init__.py", line 12, in <module>
    from .async_ import *
  File "/home/runner/musket-amateur/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/musket-amateur/venv/lib/python3.8/site-packages/discord/channel.py)
#

why does it say this?

crimson coral
brazen hill
#

ok

#

can i just do

#
pip uninstall -y -r <(pip freeze)
#

and uninstall everything in one go

crimson coral
#

ehhh

#

that'll probably uninstall a lot of other packages you don't wanna touch

#

what shows when you do pip freeze

brazen hill
#

ok

cloud lotus
#

Is there any way to extract all users which have a some specific role, like extracting all users who have mods role??

exotic cape
exotic cape
random kayak
#

This should do exactly what you need

#

Or, if you want to check if a member has one of the roles inside a list of roles, I did something similar here:

return len(set(member.roles) & set(roles_list)) > 0
#

Basically does an intersection of user's roles and the list of roles I want to check, if the result is higher than 0 (there are intersecting roles), then the member has one of those roles. Can return instead of len() only the intersection and you'll get a set of the roles the user has

cloud lotus
grave wraith
crimson gale
#

get role, get members attribute of the role

random kayak
# cloud lotus How can I use this I checked the docs many times still can't figure out 😅

So you'd need to get the role first (which can be done in various ways, depending on your case, I'll give an example of getting the role through the id from context):

@commands.command()
async def get_members_of_role(ctx):
  role = ctx.guild.get_role(123456) # desired role id to find users of
  return role.members

It's as easy as that. Get the role class from the guild then get the members from the role.

random kayak
grave wraith
#

that's a good idea, thank you

random kayak
#

No problem! It might have to do something with the class' __equal__() which doesn't check correctly or lets python deal with it

tropic fractal
#

When you bot.reload_extension is it meant to re-map slash commands

#

because I pulled an update then decided to reload extensions instead of restarting the whole bot

#

and the callback didn't change

#

Nevermind I was being thick

thin trellis
#

When will this error be fixed? In a new beta version or in the stable v2?

Traceback (most recent call last):
  File "c:\Users\MA\Documents\PythonBots\Rubicon\env\lib\site-packages\discord\client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\MA\Documents\PythonBots\Rubicon\env\lib\site-packages\discord\bot.py", line 1147, in on_connect
    await self.sync_commands()
  File "c:\Users\MA\Documents\PythonBots\Rubicon\env\lib\site-packages\discord\bot.py", line 770, in sync_commands
    await self._bot.http.bulk_upsert_command_permissions(self._bot.user.id, guild_id, guild_cmd_perms)
  File "c:\Users\MA\Documents\PythonBots\Rubicon\env\lib\site-packages\discord\http.py", line 359, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 405 Method Not Allowed (error code: 0): 405: Method Not Allowed```
random kayak
thin trellis
#

Ah okay 👍

#

Yea discord should announce releases for lib developer a bit earlier at least xD

little isle
#

My bridge commands aren't all showing up as slash commands. I have debug_guilds set, and I've even waited over an hour. Using b7

cloud lotus
#

I want to get the list of all members in server but it is only printing one member any fix for this??

for member in ctx.guild.members:
  print(f'{member}')
random kayak
little isle
#

They do show, yes, and show as synced

random kayak
little isle
random kayak
little isle
#

Got it. That's frustrating. I don't seem to have this issue with another bot of mine

crimson gale
cloud lotus
crimson gale
#

theres your issue

cloud lotus
#

should I enable all?

crimson gale
#

use Intents.default() to get an Intents object with everything but the privileged intents enabled

#

and then afterwards set the members attribute of the resulting object to True

cloud lotus
#

okay tysm

slender lintel
#

getting all these and it makes the bot crash after a few hours

cloud lotus
#

any use case of this command??

high patio
#

How do I get member object from user id?

#

say I have

user = await bot.get_or_fetch_user(id)

#

I want to do it to add roles to it

#

so it has to be a member object

exotic cape
earnest jungle
#

I am not sure why I am getting this error

high patio
#

await user.add_roles(role)
is not working

#

role = discord.utils.get(ctx.guild.roles, name = "Role")

exotic cape
exotic cape
#

@bot.slash_command(guild_ids=Whitelisted_Guilds,name='honor', description='give the top members an Honorary Role')
async def honor(ctx, from_top: int, to_top: int):
    r = requests.get(f'https://mee6.xyz/api/plugins/levels/leaderboard/{guild_id}')
    res = r.json()
    topmembers = ''
    guild = bot.get_guild(guild_id)
    
    # amount = int(amount)
    if str(ctx.author.top_role) == adminRole:

        for i in range((from_top-1), to_top):
            # topmembers += f'''{i+1}. <@{res['players'][i]['id']}>\n'''
            member = await guild.fetch_member(int(res['players'][i]['id']))
            role = discord.utils.get(member.guild.roles, name='Honorary')
            await member.add_roles(role) 
            embed = discord.Embed(title='Honored :crown:', description=f'''Top {i+1} Member of the month <@{res['players'][i]['id']}> has become a(an) {role.mention} ''')
            await ctx.respond(embed=embed)
            await asyncio.sleep(1)

    else:
        embed = discord.Embed(title='Command Execution Failed!', description=f'**Reason:** {ctx.author.mention} has no permission', color=GeneralColor, timestamp=TimeNow)
        await ctx.respond(embed=embed, ephemeral=True)

I used this to give roles to top members in mee6 leaderboards
you could modify it to your liking. but what you want should be

member = await guild.fetch_member(member_id)
role = discord.utils.get(member.guild.roles, name='test')
await member.add_roles(role)

try it without the await too if it would work. if not, then do it like this.

high patio
#

I will try

iron wind
carmine smelt
#

can we create forum channel like this in any discord server

iron wind
#

I usually get this error:

IndexError: list index out of range```
How can i wait for bot to load embed image?
also Try Except IndexError didn't work
glossy thicket
#

is it possible to call a modal with a button?

thin trellis
#

Yes

willow saffron
#

Hii! I just restarted my bot, now commands don't work anymore for the guilds. Is there any fix around? I know this is caused by the permissions-v2 issue.

slate stirrup
#

Hello I can't remove the default help panel

#

I can't

#

Even with
help_command = none

dawn bridge
#

Hey guys, how can I get a guild ban list?

cloud lotus
#

I want to send DM to all the members who have role dms but it is send DM to only 1 user any fix??

@bot.bridge_command(guild_ids=[])
async def dm(ctx, *, message):
    """Send DMs"""

    member: discord.Member
    async for member in ctx.guild.fetch_members():
        memberRoles = [role.name for role in member.roles]
        if "dms" in memberRoles:
            #print(member)
            #print(memberRoles)
            #print(f'{message}\n')
            
            channel = await member.create_dm()
            embedMsg = discord.Embed(
                title=f'Sent by {ctx.author}',
                description=message
            )
            try:
                await channel.send(embed=embedMsg)
                await ctx.respond("Message sent!")
            except:
                await ctx.respond("Unsucceful while sending DM, please tell mentioned users to turn on their DMs.")
            finally:
                return
            
    # print(member)
    await ctx.respond('message sent')
slender lintel
#

hi i have a question how i can buttons with url ? The url should also contain ctx and member

merry thicket
#

Read the docs

#

I believe its the following though:

slender lintel
merry thicket
#

button_test = Button(url="https://google.com")

#

Quick example though

slender lintel
#

my problem is member and ctx url is clear.

merry thicket
#

Do you have an error message?

slender lintel
#

no im sorry my question is how i can ctx and member import in class

#

is that even possible?

merry thicket
#

What do you mean with a class?

cloud lotus
#

I guess you use self in class

slender lintel
#

ye

slender lintel
#

so wait

#

show url yk?

class avatars(discord.ui.Button):
    def __init__(self):
        super().__init__(label="Download this", 
        custom_id="interaction: avatars",           
        url=f"how i can here member and ctx use?", 
        style=discord.ButtonStyle.gray) 
#

when i add member: discord.Member in init is a error there

#

And then I have to add something in the command but idk

cloud lotus
slender lintel
#

thanks but..
so this working but when i added member.id / member.avatar in url is a error there..

Code:

class avatars(discord.ui.Button):
    def __init__(self, member: discord.Member):
        super().__init__(label=f"Download this {member.name}", 
        custom_id="interaction: avatars",                                 url=f"https://cdn.discordapp.com/avatars/{member.id}/{member.avatar}.jpg",
        style=discord.ButtonStyle.gray)


class Buttons(commands.Cog):
    @slash_command()
    async def avatar(self, ctx, member: discord.Member):
        view = discord.ui.View(timeout=None)

        view.add_item(avatars(member))

        await ctx.respond("ye")
        await ctx.send(f"Button:", view=view)

Error coming

#
Ignoring exception in command avatar:
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\Buttons.py", line 25, in avatar
    view.add_item(avatars(ctx))
  File "C:\Users\zReaxrYT\PycharmProjects\Discord\extensions\Buttons.py", line 9, in __init__
    super().__init__(label=f"Download", custom_id="interaction: avatars",
  File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\ui\button.py", line 100, in __init__
    raise TypeError("cannot mix both url and custom_id with Button")
TypeError: cannot mix both url and custom_id with Button

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: TypeError: cannot mix both url and custom_id with Button
crimson gale
slender lintel
#

okay wait

crimson gale
#

also .avatar is an Asset

slender lintel
#

ye its working thanks

high patio
#

Only admins can use slash command on my server, anyone know why?

#

No regular users can use

#

and uh, there is no permission restriction in the commands

exotic cape
stiff dagger
#

What would the decorator for message_command in a cog be

stray smelt
#
@discord.commands.message_command()
async def example(self , ctx : discord.ApplicationContext ,  message : discord.Message):
potent rivet
#

I'm trying to put my token in a .env file and i keep getting an error that the token has to be a string, can anyone help

past gate
#

wasnt this literally fixed 24h ago

past gate
potent rivet
#

it no work

#

oop

balmy flame
#

its a str

#

so wrap it

#

"token"

#

```TOKEN = "token"````

#

thats it

potent rivet
#

not NoneType

#

bot.run(os.getenv('TOKEN'))

#

this is right?

random kayak
#

Can you check if it's actually set in your env variables?

#

Do an export `cat .env`

potent rivet
random kayak
#

Nono, in console

#

So that it'll set up all variables that you have in the .env file

#

*if you're on windows, the command is different*

potent rivet
#

yeah i am

random kayak
# potent rivet yeah i am

Looked for a Windows version, couldn't find one that would be worth the hustle. The easiest way would be to install the dotenv module on python and do something like:

import os
from os.path import join, dirname
from dotenv import load_dotenv

dotenv_path = join(dirname(__file__), '.env')
load_dotenv(dotenv_path)

.... bot code here ....

bot.run(os.getenv('TOKEN'))
potent rivet
#

.-.

#

it no work still eee

#

wait

#

no

#

why do i have 2 python 3.8.2's?

#

there should be quotation marks around token right?

random kayak
#

Yes, there should be

potent rivet
#

ok well I did your thing and it still gives an error

random kayak
#

What error?

potent rivet
#

same one

#

token must be of type str, not NoneType

random kayak
#

A few ideas that might help:

  • in .env, make sure you have TOKEN=insert_token_here without spaces and have variable in caps
  • try this too:
from dotenv import load_dotenv, find_dotenv

load_dotenv(find_dotenv())
... same code for the rest ...
  • don't put " in .env
  • make sure .env is in the same folder with main.py; if it's in the same folder you can also try load_dotenv() without passing the path/find function
#

If none fix it, you might want to manually set it with set TOKEN=insert_token_here since I blame Windows 😄

potent rivet
random kayak
#

What error do you get without spaces?

potent rivet
#

and 3 that say parts of my token arent defined

random kayak
#

What file is that error on? Shouldn't be on .env though

exotic cape
# potent rivet

pip install python-dotenv

main.py

import discord
import os
from dotenv import load_dotenv

load_dotenv()

token = os.getenv('BOT_TOKEN')

bot = discord.Bot()


bot.run(token)

.env

BOT_TOKEN=tokenhere
#

i did mine and without quotation on the bot token and it is working fine

stable torrent
#

is @has_permissions works ok with permissions v2?

wraith folio
#

im trying to figure out how modals work, and i copied this code from a video:```python
import pycord
import config
from pycord.ui import InputText, Modal
from pycord.ext import commands

intents = pycord.Intents.all()
bot=commands.Bot(intents = intents, command_prefix = None)

@bot.event
async def on_ready():
print('Online!')

class MyModal(Modal):
def init(self) -> None:
super().init('A Modal')
self.add_item(InputText(label='Short Input', placeholder='Placeholder'))
self.add_item(
Input_text(
label='Long Input',
value='Default',
style=discord.InputTextStyle.long
)
)

async def callback(self, interaction: pycord.Interaction):
    embed = discord.Embed(title='Your Modal Results', color=discord.Color.burple())
    embed.add_field(name='First Input', value=self.children[0].value,inline=False)
    embed.add_field(name='Second Input', value=self.children[1].value,inline=False)
    await interaction.response.send_message(embeds=[embed])

@bot.slash_command(guild_ids = [513201373169319937], name= 'modal')
async def test(ctx):
modal = MyModal()
await ctx.interaction.response.send_modal(modal)

bot.run(config.TOKEN)```but when i run it i get this error: pycord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access. what's causing this?

slow dome
#

?tag missing.access

hearty rainBOT
#

dynoError No tag missing.access found.

slow dome
#

?tags missing

hearty rainBOT
#
Tags (1)

missing_access

slow dome
#

?tag missing_access

hearty rainBOT
wraith folio
#

ah, ive never had to deal with any other scopes before NikoThink

wraith folio
#

?tag 405

hearty rainBOT
#

dynoError No tag 405 found.

wraith folio
#

?tag method not allowed

hearty rainBOT
#

dynoError No tag method found.

wraith folio
#

?tag HTTPException

hearty rainBOT
#

dynoError No tag HTTPException found.

wraith folio
slow dome
#

check #library-updates

wraith folio
#

the issue seems to be with guild_ids HmmGe

#

whenever i run it with that i get the 405 error

#

waiting for the slash command to go through to check to see if the modal works

south ermine
#

everyone gets that error, doesn't matter if you use guild_ids

jovial tusk
#

umm, I keep getting this error everytime i start the bot, whats going wrong here??

#

btw, im using discord.ext.commands.Bot

slow dome
#

check #library-updates

#

in other words, it's not your fault

brazen hill
#

ya

#

i tried that and succeded

quick isle
#

need help, thats the part that causes the error

latency = SlashCommandGroup("latency", "get bot latency")


@latency.command()
async def embed(self, ctx):
    embed = discord.Embed(title="Latency",
                          description=f"`{round(self.bot.latency * 1000)}ms`",
                          color=discord.Colour.blue())
    await ctx.send(embed=embed)

this is the error

#

Ignoring exception in command latency embed:
Traceback (most recent call last):
File "C:\Users\lemmi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 122, in wrapped
ret = await coro(arg)
File "C:\Users\lemmi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 839, in _invoke
await self.callback(ctx, **kwargs)
TypeError: embed() missing 1 required keyword-only argument: 'ctx'

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

Traceback (most recent call last):
File "C:\Users\lemmi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 1103, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\lemmi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 345, in invoke
await injected(ctx)
File "C:\Users\lemmi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 122, in wrapped
ret = await coro(arg)
File "C:\Users\lemmi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 1101, in _invoke
await command.invoke(ctx)
File "C:\Users\lemmi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 345, in invoke
await injected(ctx)
File "C:\Users\lemmi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 128, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: embed() missing 1 required keyword-only argument: 'ctx'

#

i dont know that i did wrong

terse plinth
#

how do i make my prefix commands non-case-sensitive?
I want >>help and >>HeLp to trigger the same command

quick isle
terse plinth
#
def fetch_prefix(client, message):
    guild_info = MAIN_DB['guild_information'].find_one({'_id' : message.guild.id})
    return guild_info['prefix']

client = commands.Bot(
    command_prefix = fetch_prefix,
    help_command = None,
    intents = discord.Intents.all(),
    debug_guilds = [GUILD-ID]
)
quick isle
#

am i allowed to dm you? @terse plinth

terse plinth
#

ye sure

fresh brook
#

How do you disconnect a user from a channel?

wraith folio
#

so I tried making a class that makes making modals way easier, and it works great. the only problem is that when you submit everything, it does this:

#

i get the output printed in the console, everything else works fine and i dont know why this is causing me issues completelydistraught

#

any help would be really appreciated

ornate spade
#

I guess you need to respond to the interaction

random kayak
#

In general how much RAM do bots with PyCord take for 1 server only and not so many functionalities? Considering what hosting machine size to start with before analyzing if more is needed

wraith folio
#

so for some reason it seems to only close when you send the message you want to send inside of the modal

wraith folio
#

it seems that modals only work right when they're in the form of their own class object

ornate spade
#

try removing modal.stop

wraith folio
#

same issue sad

slate heron
#

Just follow that

wraith folio
#

yeah but the thing is i dont want the modal itself to send a message

#

i just want to get the inputs from the user, then have it do some other stuff

slate heron
#

Then remove the send

wraith folio
#

also, does it have to be as its own class?

#

when i do that it doesnt close the modal after you click submit

#

that's the issue

slate heron
#

Well, you're using a slash command, either way it needs a return otherwise, you'll just get an error. This will only show the return message to the user that used it.
await interaction.response.send_message("Submitted", ephemeral=True)

slate heron
atomic thistle
#

discord.ext.commands.Bot is not working. I tried everything I could, but the bot won't respond to the commands

from discord.ext import commands
import discord

bot = commands.Bot(command_prefix=">>", intents=discord.Intents.all())

@bot.command()
async def test(ctx, arg):
    print("test")
    await ctx.send("testing")

bot.run("TOKEN")

No error is showing up. even the print("test") is not printing test. Can anyone help here?

slate heron
#

The bot runs right? You can see it online in your server?

atomic thistle
#

yes

#

I can

slate heron
#

So I assume >>test does not work

atomic thistle
#

yes. It doesn't

past gate
#

what version of pycord?

atomic thistle
#

the development one. I did using pip install -U git+https://github.com/Pycord-Development/pycord

past gate
#

can you pip show py-cord

atomic thistle
#

wait

past gate
#

ok, have you enabled the intents on the developer portal?

atomic thistle
#

yes

past gate
#

hm

atomic thistle
wraith folio
#

try reinstalling pycord?

wraith folio
#

do you need the dev one?

atomic thistle
#

I was using the slash command and buttons. I just downloaded dev one because I saw somewhere saying the normal one didn't have them yet

wraith folio
#

well, that's wrong

#

im using the current one and i dont have that problem shrug

past gate
#

what even is the 'normal' one

atomic thistle
#

Ohk then. So I just do pip install py-cord?

wraith folio
#

yeah

#

see if that works

atomic thistle
slate heron
#

1.7 is normal, Idk if that has buttons?

past gate
#

that'll install 1.7.3

#

essentially

#

so no

wraith folio
#

hang on let me see what version ive got

atomic thistle
#

ohh

#

ok I'll wait

#

👍

slate heron
#

pip install py-cord==2.0.0b7

past gate
#

he has b7

slate heron
#

That's the most up to date beta

past gate
atomic thistle
#

uhh

#

So what do I do now? install it?

wraith folio
#

oh

#

well i was wrong

#

apparently i am using the dev version nikoNervous

atomic thistle
#

I didn't yet uninstall pycord

past gate
#

can you pip list

#

im just curious of something

atomic thistle
#

I send all of what it showed? image or copy paste?

past gate
#

whatever you want

atomic thistle
#
Package            Version
------------------ ---------
aiohttp            3.8.1
aiosignal          1.2.0
async-generator    1.10
async-timeout      4.0.2
atomicwrites       1.4.0
attrs              21.4.0
certifi            2021.10.8
cffi               1.15.0
chardet            4.0.0
charset-normalizer 2.0.12
clashroyale        4.0.1
coc.py             2.0.0
colorama           0.4.4
et-xmlfile         1.1.0
ffmpeg-python      0.2.0
frozenlist         1.3.0
future             0.18.2
humanfriendly      10.0
idna               3.3
imageio-ffmpeg     0.4.5
iniconfig          1.1.1
multidict          6.0.2
numpy              1.22.3
openpyxl           3.0.9
packaging          21.3
pandas             1.4.2
pluggy             1.0.0
py                 1.11.0
py-cord            2.0.0b7
pycparser          2.21
PyNaCl             1.4.0
pyparsing          3.0.7
pyreadline3        3.4.1
pytest             7.1.1
python-box         6.0.2
python-dateutil    2.8.2
pytz               2022.1
randomstuff.py     2.0.0
requests           2.27.1
schedule           1.1.0
six                1.16.0
tomli              2.0.1
typing_extensions  4.1.1
ujson              5.2.0
urllib3            1.26.9
yarl               1.7.2```
past gate
#

hm alright

slate heron
#

I think it's an intents issue

atomic thistle
#

uhh

past gate
#

he has them enabled in the code and the portal

atomic thistle
#

let me go check again on page

past gate
#

so not sure whats happened

slate heron
#

I just ran that code

atomic thistle
#

all are enabled

atomic thistle
slate heron
#

Exception has occurred: PrivilegedIntentsRequired

atomic thistle
#

I have it enabled

wraith folio
#

what are you inputting for arg?

atomic thistle
#

I just put random text while I was testing

#

But nothing worked

wraith folio
#

its gotta be a problem with your copy of pycord then

#

its working fine for me NikoShrug

atomic thistle
#

I will uninstall and install again and tell what happens

#

wait

#

not working

wraith folio
#

try adding this to your code and let us know if it prints anything

@bot.event
async def on_ready():
  print("I'm online!")
atomic thistle
#

I had this one. It showed that. I just didn't send it while sending here

#

it was this

@bot.event
async def on_ready():
  print(f"{bot.user} is online")
wraith folio
#

honestly i dont know NikoShrug

#

sorry

past gate
#

super weird tbh

atomic thistle
#

wait a sec

slate heron
#

I removed the intents, my bot is running, but the commands aren't registering either >.>

atomic thistle
#

Ohk so. I'm sorry. I was running a different file. It had the same file name and the bot token was also same. So that's why bot was coming online
Sorry for bothering so much. :/

past gate
#

lmao

atomic thistle
#

Now the commands are working.

wraith folio
#

so were you looking in the wrong directory?

atomic thistle
#

yeah

atomic thistle
#

:/

#

anyways, thanks.

chrome rose
atomic thistle
#

😒

chrome rose
#

why do u want bot to be offline

glossy thicket
#

Hello, I'm making a modal but I can't send the embed to a specific channel

slate heron
#

await bot.get_channel(channel_id).send(embed=embed)
Something like this?

glossy thicket
slate heron
#

You gave the wrong channel_id then

#

Or the bot can't see that channel

glossy thicket
slate heron
#

Sounds like your bot doesn't have the right permissions?

glossy thicket
slate heron
#

If you go to the channel that you're trying to send to, is the bot in the user list?

glossy thicket
#

He is an administrator

slate heron
#

Have you setup intents?

glossy thicket
slate heron
#

Weird

glossy thicket
#

'_MissingSentinel' object has no attribute 'request'

#

channel = await bot.fetch_channel(965366395254734858)

glossy thicket
slate heron
#

and channel is not None?

glossy thicket
slate heron
#

but you can't send() ?

exotic cape
#

this one

exotic cape
#

also do you have ctx argument on the command?

glossy thicket
glossy thicket
exotic cape
#

hmmmm

glossy thicket
exotic cape
#

ohh i see

glossy thicket
#
    def __init__(self):
        super().__init__("Tu recherches un graphiste ?")

        self.add_item(discord.ui.InputText(label="Description :", placeholder ="Entrer une courte description de ce que vous recherchez.", style=discord.InputTextStyle.long))
        self.add_item(discord.ui.InputText(label="Budget :", placeholder ="Entrer votre budget."))

    async def callback(self, interaction: discord.Interaction):
        user = interaction.user
        embed = discord.Embed(color=0x2f3136, description=
                            f":coc_arrow: **{user.name} recherche un graphiste !**\n\n" +
                            "> :coc_message: **» Description :**\n" +
                            f"{self.children[0].value}\n" +
                            "> :coc_message: **» Budget :**\n"
                            f"{self.children[1].value}\n"
                            )
                            
        embed.set_thumbnail(url=user.avatar)
        embed.set_image(url="https://i.ibb.co/RctGDPz/barrejaunecoc.png")

        button_contacter = Button(label="Contacter", style=discord.ButtonStyle.green)
        viewGraph = View(timeout=None)
        viewGraph.add_item(button_contacter)

        channel = await bot.fetch_channel(965367379796307999)
    
        await channel.send(embed=embed, view=viewGraph)```
exotic cape
#

try to remove the await on the channel

#

see if it would work

#

for the channel i am using channel = bot.get_channel()

glossy thicket
#

No, there is an error he asks for the await

exotic cape
#

ohhh

#

how about get_channel instead of fetch_channel?

glossy thicket
#

the channel exists...

slate heron
#

Can you print(channel) after the get and before send

glossy thicket
slate heron
#

Wrong ID or bot can't see the channel

#

You said you were using intents.all() ?

glossy thicket
slate heron
#

Go to server settings > integrations > your bot

#

Look at the permissions

glossy thicket
slate heron
#

Sorry I can't read that

exotic cape
#

i used this

@bot.command()
async def modal_slash(ctx: discord.ApplicationContext):
        """Shows an example of a modal dialog being invoked from a slash command."""
        class MyModal(discord.ui.Modal):
            def __init__(self, *args, **kwargs) -> None:
                super().__init__(*args, **kwargs)

                self.add_item(discord.ui.InputText(label="Short Input"))
                self.add_item(discord.ui.InputText(label="Long Input", style=discord.InputTextStyle.long))

            async def callback(self, interaction: discord.Interaction):
                embed = discord.Embed(title="Modal Results")
                embed.add_field(name="Short Input", value=self.children[0].value)
                embed.add_field(name="Long Input", value=self.children[1].value)
                await interaction.response.send_message(embeds=[embed])

        
        modal = MyModal(title="Modal via Slash Command")
        await ctx.send_modal(modal)
glossy thicket
exotic cape
#

that one worked for me

slate heron
#

You might need manage messages on

glossy thicket
exotic cape
glossy thicket
#

And then as soon as the modal is filled it sends itself to another channel

slate heron
#

also manage channels

exotic cape
#

i think you need a command that would send an embed with a button on a channel

#

then the call back would be to call the modal