#General Help

1 messages · Page 31 of 1

slender lintel
#

iit doesn't shows

deep grail
#

So first of all those are the wrong docs

#

The pycord docs are at docs.pycord.dev

maiden slate
deep grail
maiden slate
#

but i wasnt the one who sent those docs*

slender lintel
deep grail
#

I'm not too familiar with how to get who invited someone

#

So I don't think I'll be of much help sry

deep grail
sage marlin
#

trying to update my music bot but i get this error discord.ext.commands.errors.CommandNotFound: Command "play" is not found

half marsh
#

I suggest you use try except and print the tb with traceback module

#

So you see exactly where the error is

maiden slate
#

how do i get a role from an id :0

misty glacier
#

How can i get the invitecode that the joined person used

toxic tapir
#

My question is a photo. Because the helper deleted it and I didn't wanna retype.

#

Basically I'm trying to fetch channel/delete it in on_raw_message_delete. Ain't working.

paper hawk
#

is it normal that the bot responds with "the application doesnt respond" after he did what he did

paper hawk
#

hmmm

slender lintel
#

await ctx.defer()

toxic tapir
slender lintel
paper hawk
#

i used the slash command help...he responded as he should...aber in the chat there's the message from him "the application doesnt respond"

toxic tapir
#

Probs simple

toxic tapir
#

I'm tryna fetch channel Id in on_raw_message_delete

slender lintel
#

use ctx.respond instead

paper hawk
#

yes

toxic tapir
#

I looked in the docs it shows channel_id, I tried that but tossed a error saying it's not callable.

toxic tapir
#

I looked in the cached_messages payload but there's no get_channel

#

And self.get_channel doesn't work

toxic tapir
slender lintel
#

oop

#

i remember they changed it once

paper hawk
#

okay, so i'll try it again with respond

slender lintel
#

instead of send do respond

toxic tapir
#

Lol tried like 100 diff things

slender lintel
#

rip

toxic tapir
#

So you can't fetch channel ids on_raw_delete?

paper hawk
#

discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'TextChannel' object has no attribute 'respond'

xDDD

paper hawk
#

await ctx.channel.respond("!Invite     , will give you my Invitelink\n"
                               "!Vote       will send you the Link to Vote for Thor\n"
                               "!Points     shows you how many Points you have\n"
                               "!Report-user [(user-id or user-name)    not the mention!!! \n"
                               "To report users to the Mod and receive Points "
                               "which are needed to reduce your Globalwarnings!\n"
                               "!Reduce     to reduce your Globalwarnings\n"
                               "!My-Warning     shows you how many Globalwarnings you have\n"
                               "Thor (or mention) hit (or other words for attack) [target.mention or "
                               "name with descriminator]\n"
                               "for example: @abstract tinsel hit @paper hawk\n"
                               "!Developer      , will mention the Developer, so you can write him or what ever\n"
                               "!Get-AntiSpambot        , will send you a DM with the Invitelink for the Bot\n"
                               "!Show_me [User-id or Mention] size(Optional)      ,will send you the Avatar of that User in the wanted size\n")

toxic tapir
#

What the hell

paper hawk
#

that the small part xDD

slender lintel
#

not ctx.channel.respond

toxic tapir
paper hawk
#

ooh so the channel isnt needed...okay

slender lintel
toxic tapir
#

I hate this.

#

😭

slender lintel
#

but its fun

toxic tapir
#

nah it ain't fun

#

only fun when it's done 😄

slender lintel
slender lintel
toxic tapir
#

the build up = agony

slender lintel
#

the testing part is fun

toxic tapir
#

I'd never want to be a full time dev

slender lintel
#

the coding and errors

#

is not fun

toxic tapir
#

full time dev would suck

#

horrible job in my opinion

#

sitting inside all day in pain

#

begging for it to work 😭

slender lintel
#

developers get paid alot

toxic tapir
#

not worth

slender lintel
#

like i heard html developers make like hundreds of thousands a year

toxic tapir
#

lawers get paid a lot 👀

#

so do pilots, doctors, and cops.

slender lintel
toxic tapir
slender lintel
paper hawk
#

is the bot with respond still able to send files?

cant find the .respond in the docs

paper hawk
#

havent used reply^^

#

always channel.send

toxic tapir
#

It's no different than sending a message

#

Wdum send file?

paper hawk
#

a pic

file=discord.File(Path + sep + "gifs" + sep + gifs[r])

toxic tapir
#

Yeah sending files works in respond.

paper hawk
#

alright

toxic tapir
#

I am 90% sure you still have to do .send_file tho

paper hawk
#

aah yes, the respond helped^^

slender lintel
#

hi, I have a question. How to add role if button clicked

#

?

slender lintel
#
 @commands.Cog.listener()
    async def on_presence_update(self, before, after):
        if before.activity != after.activity:
                print("runned this")
                with open("setup.json", "r") as log:
                    db = json.load(log)
                    log_channel = bot.get_channel(db['bot']['modules']['log_system']['channel_id'])
                    if before.activity == None:
                        embed = discord.Embed(title="New Status",
                                            description=f"{after.name} has created new status!\n`status`: {after.activity}")
                        embed.set_thumbnail(url=after.avatar.url)
                        embed.set_footer(text=f"user id: {after.id}")
                        await log_channel.send(embed=embed)
                    elif after.activity == None:
                        embed = discord.Embed(title="Status Update",
                                            description=f"{after.name} has removed their status")
                        embed.set_thumbnail(url=after.avatar.url)
                        embed.set_footer(text=f"user id: {after.id}")
                        await log_channel.send(embed=embed)
                    else:
                        embed = discord.Embed(title="Status Update",
                                            description=f"{after.name} has updated their status \nfrom:\n `{before.activity}`\nto:\n{after.activity}")
                        embed.set_thumbnail(url=after.avatar.url)
                        embed.set_footer(text=f"user id: {after.id}")
                        await log_channel.send(embed=embed)```

it is working fine as expected to send message on member status updates
but it is sending duplicate 2 messages with same content
i'm in `2.0.0b7`
ripe pagoda
#

So

#

It is running twice because the status is changing twice

#

once when the online changes

#

and a second time when the activity, or game changes

slender lintel
#

heheboi got the point thanks

ripe pagoda
#

😄

ripe pagoda
#

What do you already have?

#

Do you already have a button and a role? Or have you yet to start?

slender lintel
#

how can i check if the user executing a command has a lower or higher perm than the person mentioned

sturdy sentinel
#

Do I have to have to have message intents enabled in order to use bridge prefixed commands for any of the previous releases? A lot of people got confused when only slash commands worked and prefixed didnt on 2.0.0rc1

#

Or is there a version where I can use both without message intent?

slender lintel
#

which one is loweset

hazy tundra
#

check the comparison operators @slender lintel

slender lintel
#

ok

#

aoh

#

ah

#

position

hazy tundra
#

dont use position

#

better to use comparison operators

misty glacier
#

How can I make that a /command is only shown to people with admin rights?

slender lintel
slender lintel
misty glacier
#

:/

slender lintel
#

i remember u could make them show as disabled

#

or somethin

#

i think they removed that

latent mason
#
@bot.bridge_command()
async def ping(ctx:bridge.BridgeExtContext):
    if isinstance(ctx, bridge.BridgeContext):
        await ctx.send('Pong!')
    if isinstance(ctx,bridge.BridgeApplicationContext):
        await ctx.respond('Pong!')

it is the best way to write bridge commands

#

?

half marsh
#

So to reply a command you need not to worry about with what type do user using the command

frigid elm
#

ops

#

how do i connect from ubuntu to a postgresql database on my pc

sturdy sentinel
#

Is there a way to use prefixed commands without having message intent enabled as atm I cannot enable it so my users can get used to slash commands?

main willow
sturdy sentinel
main willow
#

Just above your bot = commands.Bot or whatever you are using

sturdy sentinel
#

will try

torpid siren
#

is it possible to only show members in a voice channel for a slash command option

#

I tried this autocomplete but it raises Autocomplete cannot be configured for this type of option

async def kick_autocomplete(ctx: AutocompleteContext):
    author = ctx.interaction.user
    
    if not author.voice:
        return []
    id = author.voice.channel.id
    if id not in rooms:
        return []
    
    members = []
    for member in ctx.interaction.guild.members:
        if member.voice:
            if member.voice.channel.id == id:
                members.append(member)
    
    return members
main willow
torpid siren
#

wait

#

actually no I can do that since I have somewhere to stock the members

#

thank you for the idea

twin light
#

whats is the name of the package? (pip install NAME)

main willow
#

so from discord import Option

twin light
#

i make slashcommands

torpid siren
torpid siren
main willow
torpid siren
#

i know but i would need to take the list of members that are in the same voc as the author

#

and i tried to access the author VoiceState using ctx.interaction.user.voice but pycord doesn't want that and raises Autocomplete cannot be configured for this type of option

main willow
#

I think you need to get a Member object of the user

#

nvm it does return both user and member

torpid siren
#

try installing pycord again maybe? py -m pip install py-cord

torpid siren
#

did you try installing it again?

twin light
torpid siren
#

are you using a virtual environment for your bot ?

vivid nacelle
#

Don’t ping users

twin light
#

No pycharm

vivid nacelle
#

Especially don’t ping devs

twin light
#

is perfect?

vivid nacelle
#

Wtf

minor breach
#

How do you send a paginator as a button click response.
Interaction.response has only three methods named, send_message, send_view, send_modal.

This is my View Class

class myView(View):
    reply_callback:callable = None
    def __init__(self, get_paginator:callable):
        super().__init__()
        self.reply_callback = get_paginator
        select_btn = Button(lable="CONFIRM")
        select_btn.callback = self.main_callback
    
    async def main_callback(self, interaction):
         paginator = self.reply_callback()
         # How to send this paginator received.
#

I can do paginator.send() but that will end the interactoin and it will cause Interaction Failed Error

#

Got it

#

its paginator.respond()

main willow
# twin light

It's from discord import Option as i said earlier

Can you type pip show py-cord in your terminal and show the output?

spring pawn
#

Trying to enable message_content, but when I try intents = discord.Intents.all() or intents = discord.Intents.default() and then intents.message_content = True, my bot just never initializes? No error message, but the print statement in the on_ready function just never runs

#

Am I missing something?

main willow
#

Did you specify the intents in the bot constructor?

slender lintel
#

Does someone have a bot with cogs boilerplate?

main willow
misty glacier
#

Ignoring exception in on_ready
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/discord/client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "/home/bots/discord/python/Ruby Network/listeners/onReadyListener.py", line 12, in on_ready
await self.bot.change_presence(activity=discord.Game(name="lol"))
AttributeError: 'Bot' object has no attribute 'change_presence'

frigid lark
hazy tundra
#

how to pass arguments along to a buttons instance?

frigid lark
sudden path
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

2a. Install py-cord
python -m pip install py-cord

2b. Update py-cord
python pip install -U 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

slender lintel
#

hey I am trying to make a feature which sends a dm to the user who's user id has been send in a channel this is code

@bot.listen()
async def on_message(message):
    if message.channel.id !=993199406469881967:
      return
    with open('image_urls.txt', 'r') as f:
        lines = f.readlines()
        g = random.choice(lines)
        e = discord.Embed(title='Hello, G',
                          description='**test**', color=0xcf24ff)
        e.set_image(url=f'{g}')
        e.set_footer(text='')
        user = await bot.fetch_user(message.content)
        await user.send(embed=e)```
error:
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 0): 404: Not Found
#

help please

slender lintel
slender lintel
slender lintel
#

bcs i dont know what in the code to look for with the just the error "NotFound"

slender lintel
# slender lintel bcs i dont know what in the code to look for with the just the error "NotFound"

Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\Admin\Desktop\sauceyy\venv\lib\site-packages\discord\client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "C:\Users\Admin\Desktop\sauceyy\main.py", line 157, in on_message
user = await bot.fetch_user(message.content)
File "C:\Users\Admin\Desktop\sauceyy\venv\lib\site-packages\discord\client.py", line 1570, in fetch_user
data = await self.http.get_user(user_id)
File "C:\Users\Admin\Desktop\sauceyy\venv\lib\site-packages\discord\http.py", line 355, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 0): 404: Not Found

slender lintel
#

message.content is a string

#

i guess the code cannot identify the ID as user id?

#

so turn it into an integer

slender lintel
# slender lintel so turn it into an integer

new error
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\Admin\Desktop\sauceyy\venv\lib\site-packages\discord\client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "C:\Users\Admin\Desktop\sauceyy\main.py", line 157, in on_message
user = await bot.fetch_user(int(message.content))
ValueError: invalid literal for int() with base 10: ''

midnight cedar
graceful robin
#

Can I get the guild the member just joined (on_member_join event)

midnight cedar
#

member has a guild attribute

graceful robin
#

thanks

quiet siren
#

i tried adding a cog:

#

but the commands dont register

#

no error nothing

#

what am i doing wrong

frigid lark
quiet siren
frigid lark
#

in the slash command

#

or are they global?

quiet siren
#

i want it to be global

frigid lark
#

does it work with the guild id?

quiet siren
slender lintel
#

try

from discord.commands import slash_command

@slash_command()```
#

this apparently fixes it for some people

quiet siren
#

alr

#

no that didnt work

#

i mean it didnt fix anything

slender lintel
#

is the cog loaded in?

midnight cedar
slender lintel
halcyon cairn
#

incorrect

quiet siren
halcyon cairn
#

Its @commands.slash_command()

slender lintel
halcyon cairn
#

apparently not. I just tested. without the commands, didn't work.

#

for me anyway

slender lintel
#

works for me fine

frigid lark
halcyon cairn
#

yup

midnight cedar
quiet siren
midnight cedar
#

did you make an on_connect event

quiet siren
slender lintel
midnight cedar
#

you just can't see the slash commands right

quiet siren
quiet siren
slender lintel
#

he says it works in his main.py so i assume he has the application.commands scope

midnight cedar
quiet siren
midnight cedar
#

where

quiet siren
halcyon cairn
#

dumb question, but do you have two functions with the same name? I've seen that here before. Naming the function of a slash command the same as another function. ANyway, I'll step back. Don't want to complicate things since you have someone assisting already. Too many cooks spoil the soup. lol

slender lintel
#

i see it no where in your repository

quiet siren
slender lintel
#
bot.load_extension("foldername.filename")```
#

ah

midnight cedar
quiet siren
#

done

midnight cedar
#

is it only the ones in the cog that don't appear?

midnight cedar
#

go back to discord.slash_command and try using commands.Cog

#

you can remove the load_extension as well

quiet siren
#

alr

#

File "c:\Users\MRS\Desktop\DefenderBot\Commands.py", line 872, in <module> class PollCommand(discord.Cog): File "c:\Users\MRS\Desktop\DefenderBot\Commands.py", line 880, in PollCommand async def poll(self, ctx, minutes : int, title, *options): TypeError: 'Cog' object is not callable PS C:\Users\MRS\Desktop\DefenderBot>

#

i assume i should remove the discord.Cog thing

sage marlin
#

HmmGe made a music play command, and it says Command "play" is not found

quiet siren
midnight cedar
#

such as?

quiet siren
# midnight cedar full traceback?

PS C:\Users\MRS\Desktop\DefenderBot> & C:/Users/MRS/AppData/Local/Microsoft/WindowsApps/python3.10.exe c:/Users/MRS/Desktop/DefenderBot/Commands.py Traceback (most recent call last): File "c:\Users\MRS\Desktop\DefenderBot\Commands.py", line 872, in <module> class PollCommand(): File "c:\Users\MRS\Desktop\DefenderBot\Commands.py", line 880, in PollCommand async def poll(self, ctx, minutes : int, title, *options): TypeError: 'Cog' object is not callable PS C:\Users\MRS\Desktop\DefenderBot>

#

thats the entire thing

midnight cedar
#

well now i'm just confused

supple ravineBOT
midnight cedar
quiet siren
# midnight cedar whats the updated code that you're using

`class PollCommand():
def init(self, bot):
self.bot = bot
self.numbers = ["1️⃣", "2️⃣", "3️⃣", "4️⃣ ", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣", "🔟"]
self._last_member = None

@commands.Cog()
@default_permissions(manage_messages = True)
async def poll(self, ctx, minutes : int, title, *options):
    if len(options) == 0:
        pollEmbed = discord.Embed(title = title, description = f"There are **{minutes}** minutes remaining!")
        await ctx.respond(f"Done! Created a poll with title: {title}!", ephemeral=True)
        msg = await ctx.send(embed = pollEmbed)
        await msg.add_reaction("👍")
        await msg.add_reaction("👎")
    else:
        pollEmbed = discord.Embed(title = title, description = f"There are **{minutes}** minutes remaining!")
        for number, option in enumerate(options):
           pollEmbed.add_field(name = f"{self.numbers[number]}", value = f"**{option}**", inline = False)
        await ctx.respond(f"Done! Created a poll with title: {title}, and your options!", ephemeral=True)
        msg = await ctx.send(embed = pollEmbed)
        for x in range(len(pollEmbed.fields)):
            await msg.add_reaction(self.numbers[x])

@commands.Cog()
async def hello(self, ctx, *, member: discord.Member = None):
    member = member or ctx.author
    if self._last_member is None or self._last_member.id != member.id:
        await ctx.send(f'Hello {member.name}~')
    else:
        await ctx.send(f'Hello {member.name}... This feels familiar.')
    self._last_member = member

`

midnight cedar
#

i meant commands.Cog for the class

quiet siren
#

ah

midnight cedar
#

so it would replace discord.Cog

#

and use discord.slash_command instead of commands.slash_command

midnight cedar
halcyon cairn
#

Just for reference, this is how I load my extensions. I have them all in a subdirectory called "Cogs_cmd"

#
cogfilescmd = [
  f"cogs_cmd.{filename[:-3]}" for filename in os.listdir("./cogs_cmd/") if filename.endswith(".py")
  ]

for cogfilecmd in cogfilescmd:
  try:
    client.load_extension(cogfilecmd)
    print(f'Loaded {cogfilecmd}')
  except Exception as err:
    print(err)
sage marlin
halcyon cairn
#

Figured I'd share how I have it, and you can modify as needed

midnight cedar
halcyon cairn
#

most people think they are the same though. lol. Many inaccurately call extensions "cogs"

#

I know I did at first. lol

midnight cedar
#

np

#

idk why discord.Cog is broken but ig it is

quiet siren
#

anyway

midnight cedar
#

should only be used with a discord.Bot anyways

quiet siren
#

ANOTHER ERROR WHEE
ill fix it tomorrow

#

i gotta sleep

midnight cedar
#

gn

quiet siren
#

cyaa

halcyon cairn
#

post the error when you can.

#

we'll help

quiet siren
#

ill remember that

#

i appreciate it

sage marlin
#

the music cog is the only cog that is not loading 😞

midnight cedar
leaden mesa
#

if I import a cog into another cog, I'd need to instantiate it, right?

torpid siren
#

does anyone knows how to make these fancy application shortcuts?

leaden mesa
#

I believe its the UserCommand, MessageCommand, and ApplicationCommand options

torpid siren
#

thank you very much :D

#

also do you know if this UserCommand thing will also be usable as a slash command?

#

or do i have to make 2 specific functions?

#

or can i just put them both as decorators and it will work (like that)

@slash_command()
@user_command()
async def my_command():
mild hatch
#

i just tested this, and yes it's possible

mild hatch
#

the only problem is that the user command function can only have 2 parameters (ctx and user)

#

so the slash command will only have to have those two and cant have any more

torpid siren
#

ok thank you so much!

little isle
#

I've got an embed with a thumbnail that is suddenly not showing.

The URL for the image is still valid, as in I can navigate to it, and the image loads just fine.

The embed worked fine yesterday. I haven't made any code changes.

The image is hosted on S3 and is publicly available. Nothing has changed in my S3 configuration since yesterday.

Any ideas why this might be happening?

torpid siren
little isle
#

There's no empty frame, if that's what you're asking

#

It looks like an embed that doesn't have a thumbnail set

torpid siren
#

have you tried with a different picture?

little isle
#

It works with different images, yeah (the URL is dynamically generated; this one in particular isn't working)

#

(The images are specified by users. Not all are on S3. I just know this one is because it's my own image, lol)

#

I suppose I should try:

A different S3-hosted (maybe smaller? different format?) image

The same image hosted elsewhere

graceful sapphire
#

Anyone having issues resetting their token for their bot?
I reset mine twice over 12 hours ago and its still only logging in with its original token 🙃

vale ice
#

Hello

little isle
#

Hm. The same image saved to a Discord channel will load in the embed.

vale ice
#

Slash command not working why?

sudden path
vale ice
sudden path
#

You didn't invite the bot with the application.commands scope

vale ice
#

like this?

main willow
vale ice
vivid nacelle
#

From now on you can re-add a bot just with the bot scope.
Discord automatically adds the application command scope (See #discord-api-updates)

vale ice
#

Its worked thank y'all

slender lintel
#

but i don't know how to add role with button

#

@ripe pagoda

graceful robin
#
await member.send(file=discord.file("captcha.png"))
TypeError: 'module' object is not callable

what does that mean

gilded widget
#

you're calling the module, not the class

graceful robin
#

thanks

frigid elm
#

how do i access a database that is in my window machine from my ubuntu VPS

#

ConnectionRefusedError: [Errno 111] Connect call failed ('127.0.0.1', 5432) it says this in the vps

crimson gale
#

because that points to localhost aka something in your local network

#

you cant use that in a different network and expect it to work

frigid elm
#

in pgadmin for the server connection i have the vps address and i modified my conf files and all

#

but it still wont work

little isle
frigid elm
#

listen_addresses = '*' this in postgresql.conf and

TYPE DATABASE USER ADDRESS METHOD

host all all 0.0.0.0/0 md5
host all all ::/0 md5 in pg_hba

#

this on my window machine

frigid elm
crimson gale
frigid elm
#

of the vps?

crimson gale
#

no, your public ip address

#

the network your computer is in

frigid elm
#

but i wanna connect on my vps

#

alr

#

ill put it wait

crimson gale
#

thats what you have to do if you want the vps to connect to a database that is hosted on your computer

frigid elm
crimson gale
#

local address? are you using ipconfig in the windows cmd?

frigid elm
#

Link-local

crimson gale
#

that shows you the computers local network ip address

#

something that isnt public

#

you need to use google or some other thing to get your public ip address

frigid elm
#

what is my ip on google wld work

crimson gale
#

and then theres the mess of having to port forward the desired port to point to your computer in the local network

frigid elm
#

TYPE DATABASE USER ADDRESS METHOD

host all all iplol md5
host all all iplol md5

#

like this

crimson gale
#

no, port forwarding is done on your router

#

you need to learn more about how networking stuff works

frigid elm
#

i was jst trynna make an economy bot Sob

crimson gale
#

if you dont want to go through the pain of this stuff then just use sqlite instead

frigid elm
#

but isnt postgresql better then sqlite

crimson gale
#

every database type has their cons and pros

frigid elm
#

kk

crimson gale
#

the pro of sqlite is that you dont need to deal with networking nonsense to make it work

frigid elm
#

alright

#

ill switch

crimson gale
#

do note that you may have to rewrite your sql queries

frigid elm
#

i tried sqlite once but it would say that dbb was locked

#

so idk

river mortar
#

How to tempban?

frigid elm
#

u ban the user and unban after a certain time

crimson gale
#

do you have a database to store the unban timestamp in?

steep verge
#

As Discord doesn’t support that with the ban coro.

crimson gale
#

and what i mentioned is the more persistent way of keeping track of when to unban

river mortar
midnight cedar
# frigid elm yea

i recommend putting the database on the vps, pretty sure if it's on the local network you don't have to deal with all this bullshit

frigid elm
lament nimbus
#

@slow dome so instead of using @commands..... i check inside the command if the user has roles?

lament nimbus
#

ooh

#

thanks

midnight cedar
#

use has_any_role

lament nimbus
lament nimbus
static edge
#

is there an event for on mention of a bot?

slow dome
static edge
#

kk, thanks

slate stirrup
#

?tag example

hearty rainBOT
#

dynoError No tag example found.

slate stirrup
#

?tag ex

slate stirrup
#

Hello can i get the source code of @supple ravine

slate stirrup
#

How do I make a menu (select menu) active for an infinite amount of time

vivid nacelle
#

persistent views

supple ravineBOT
#

Here's the persistent example.

vivid nacelle
#

search the guide

slender lintel
#

/help

#

__

graceful robin
#

So I have a wait_for function and a check for that function, the problem is that its all being executed in a dm and for some reason this check doesnt work

return m.author == member and m.channel == interaction.channel
graceful robin
#

no error message

#

why would there be an error message

deep grail
#

So does it just return False?

graceful robin
#

yes

spring pawn
deep grail
# graceful robin yes

print the ouput of m.author==member and also print the output of m.channel == interaction.channel

graceful robin
#

lemme switch to my alt account

deep grail
#

Alright

graceful robin
#

Alright

#

it returned
False
True

#

like i thought

#

m.channel == interaction.channel

#

returned false

deep grail
#

Alright

#

Send the code that calls the check btw

#

Oh i found the issue

graceful robin
#

what

deep grail
#
Note that due to a Discord limitation, DM channels are not resolved since there is no data to complete them. These are PartialMessageable instead.
graceful robin
#

yes i saw that

#

i honestly dont know what that means

deep grail
#

compare the ids then

#

wait actually wait one sec

#

yeah compare the ids

#

do m.channel.id == interaction.channel.id

graceful robin
#

alright

#

ill try that

deep grail
graceful robin
#
d:\Desktop\peer\app\cogs\event.py:85: RuntimeWarning: coroutine 'Messageable.send' was never awaited
  member.send("Sucks to be you")
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
#

👍

#

thanks

deep grail
#

yw

graceful robin
#

yes i know

deep grail
#

Alright

graceful robin
#

to show that it works

quiet siren
#

Ok so, what am i doing wrong
`Ignoring exception in command poll:
Traceback (most recent call last):
File "C:\Users\MRS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\commands\core.py", line 127, in wrapped
ret = await coro(arg)
File "C:\Users\MRS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\commands\core.py", line 877, in _invoke
await self.callback(self.cog, ctx, **kwargs)
TypeError: PollCommand.poll() got an unexpected keyword argument 'options'

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

Traceback (most recent call last):
File "C:\Users\MRS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\bot.py", line 992, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\MRS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\commands\core.py", line 358, in invoke
await injected(ctx)
File "C:\Users\MRS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\commands\core.py", line 135, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: PollCommand.poll() got an unexpected keyword argument 'options'
`

#

ping me if you can help C:

raven elm
#

how to chat in voice channel PikaShoot

lament nimbus
#

can i have an array for has_any_role?

#

so
@commands.has_any_role([id1,id2,id3])

#

or does it have to be (id1,id2,id3)

#

?

ornate fog
#

@commands.has_any_role(*[id1,id2,id3])

lament nimbus
#

i just changed it to

for role in message.author.roles:
    if role.id in allowed_roles:
        other code here
blazing vortex
#

there is a way to use an invite code to check if the invite exists or is valid?

ornate fog
blazing vortex
#

hmm thanks lemme try

ornate fog
#

thhis is the pycord method

blazing vortex
#

nice

ornate fog
#

its attached to bot

slender lintel
#

Hi

#

Skurwysyny

wicked ferry
#

I have a ques! My buttons stop working after 10-25 mins? why

torpid junco
#

Why my Lavalink not find Videos?

slender lintel
#

how to get user.avatar in pycord?

deep grail
#

If u want the url then user.avatar.url

deep grail
#

Do you stop the bot?

wicked ferry
#

i made it with on_interaction

glass dawn
#

i have problem using await interaction.followup.edit_message(message_id , embed = embed)
discord.errors.NotFound: 404 Not Found (error code: 10015): Unknown Webhook

#

im getting the id with: message_id = interaction.id

deep grail
glass dawn
wide cloak
#

is it possible to get the embed title from the current page (paginator)?

deep grail
vast patrol
#

does discord.ui work?

#

i wanna use buttons, but cant seem to find it

deep grail
deep grail
vast patrol
deep grail
#

Have u used views before @vast patrol

deep grail
vast patrol
#

discord.ui is not a thing

deep grail
#

Hm

#

Did you try to restart ur code editor?

#

Cuz buttons are on 2.0

vast patrol
#

=still can't find

deep grail
#

Does it throw an error?

#

When u try to import it

vast patrol
#

ModuleNotFoundError: No module named 'discord.ui'

deep grail
#

Hm then don't import it

#

Just use discord.ui.Button and see if there works

vast patrol
#

it doesn't

deep grail
#

R u sure ur on 2.0?

vast patrol
#

is it part of the official 2.0 or a dev build?

deep grail
#

Yes

#

It's official

vast patrol
deep grail
#

It's on the stable 2.0

deep grail
vast patrol
#

wait what

#

im confused now

deep grail
#

Ok

#

Uninstall dpy

#

Uninstall pycord

#

And then install pycord

vast patrol
#

i dont have dpy tho

deep grail
#

Try to uninstall dpy anyway

azure quest
#

Why does replit keep installing discord.py after removing it and having py-cord already installed

#

I have import discord

deep grail
#

Cuz it does import guessing

vast patrol
#

Successfully installed py-cord-2.0.0

deep grail
azure quest
vast patrol
deep grail
azure quest
#

Does that make sense

deep grail
deep grail
vast patrol
#

idk why u want all but k

deep grail
#

Just send it pls

vast patrol
#
aiohttp==3.7.4.post0
asgiref==3.5.2
async-timeout==3.0.1
attrs==21.4.0
cffi==1.15.1
chardet==4.0.0
Django==4.0.6
ffmpeg==1.4
idna==3.3
libnacl==1.8.0
multidict==6.0.2
py-cord==2.0.0
pycparser==2.21
pymongo==4.1.1
PyNaCl==1.4.0
six==1.16.0
sqlparse==0.4.2
typing_extensions==4.3.0
tzdata==2022.1
yarl==1.7.2
youtube-dl==2021.12.17
deep grail
#

Hmmmm

#

Are any of those libs exclusively for discord bot development?

vast patrol
#

pardon?

deep grail
#

Cuz then they might require dpy which is causing issues

vast patrol
#

none needs dpy tho

deep grail
#

Although I think dpy would be in pip freeze then

deep grail
deep grail
vast patrol
#

nope

#

cant start main if i have erros lol

azure quest
#

Thx for help i got it

deep grail
#

Go to idle

deep grail
deep grail
winged pagoda
#

I'm trying to check if an user has access to view a channel, and using permissions_for(user), but it returns a bit field/bitwise value? how can I use this hmmmge

#

or is there another way to check this

#

nvm can just do permissions.view_channel

vast patrol
#

and runned py -3 -m pip install -U py-cord[voice]

#

now i can't import discord XD

#

ok got it working

#

thanks

wide cloak
#

is it possible to get the embed title from the current page (paginator)?

dusk sable
#

Hey lads, is it possible to make the image of an embed an spoiler?

dusk sable
#

That's just regularly uploading a file tho. I meant in an embed

#

Or would this work in an embed as well

wide cloak
#

ah no nevermind

#

in the embed mh i dont know

dusk sable
#

I'll try to figure out some things. Thanks!

dusk sable
#

That's what I was thinking. I'm pretty sure I've seen it done before with something like making a steam game link a spoiler

wide cloak
#

yeah

misty glacier
#

How can i do a array like this:
array = ["name": ["id": 3173714231, "status": True]]?
And how can i change eg the name an the status?

snow citrus
#

@misty glacier

array = {"name": {"id": 3173714231, "status": True}}
print(array["name"]["id"])
#Output: 3173714231
array["name"]["status"] = False
print(array["name"]["status"])
#Output: False
deep grail
outer valley
#
Traceback (most recent call last):
  File "C:\Users\tassa\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\tassa\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 1042, in on_connect
    await self.sync_commands()
  File "C:\Users\tassa\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 644, in sync_commands
    registered_guild_commands[guild_id] = await self.register_commands(
  File "C:\Users\tassa\AppData\Local\Programs\Python\Python310\lib\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\tassa\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\http.py", line 353, in request
    raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
time#6296 has logged in```
#
import discord
from datetime import datetime
from discord.ext import commands

intents = discord.Intents.default()
intents.message_content = True
intents.members = True
bot = discord.Bot(debug_guilds=['id here'])
@bot.event
async def on_ready():
    print(f'{bot.user} has logged in')

@bot.command(description = ' is it working!')
async def ping(ctx):
    await ctx.send(f"i am working: {bot.latency*1000} ms.")
bot.run('')```
frigid lark
#

did you invite your bot with application.commands?

outer valley
#

nope

#

through the link

#

and it is in testing server and has all permissions

quiet siren
frigid lark
#

^

worthy basin
#

?tag forbidden

quiet siren
#

do you know how to do that?

outer valley
#

emm how i have never heard of it

quiet siren
#

uhm

worthy basin
#

?forbidden

quiet siren
worthy basin
#

dangit there is supposed to be a tag for this

quiet siren
#

lmao

quiet siren
#

and then

#

OAuth2

#

URL generator

hearty rainBOT
#

You get a 403 Forbidden (error code: 50001): Missing Access as error?
You might've added your bot in the past without the applications.commands scope.

What to do?
Old way: Re-add the bot with the applications.commands scope.

New way: Since 11/07/2022 discord automatically includes the applications.commands scope in OAuth. You just need to re-add the bot with the bot scope. See [#discord-api-updates@996103073111998544](#discord-api-updates message) for more infos.

quiet siren
worthy basin
outer valley
#

so i just have to do this again

#

thanks

worthy basin
#

yes

outer valley
#

it worked

quiet siren
vale ice
#

Hello

#

I have this problem

#

The bot was responding to me

#

But giving this error

slow dome
vale ice
#

It worked

past garnet
#

Do cog listeners override?

Like if I have a on reaction remove listener. will it not remove the reaction unless i do in the code?

slow dome
past garnet
slow dome
past garnet
misty glacier
#
winners = []
count = 4

for winner in range(count):
    user = random.choice(giveaways[giveawayID]["users"])
    if user in winners:
        continue
    winners.append(user)

How can I make the for loop run once more when continue is reached?

slow dome
misty glacier
#

True thx

past garnet
#

How do I add buttons to a view in a for loop?

slow dome
past garnet
past garnet
slow dome
#

what are you iterating?

past garnet
#

range

#

list of ints

slate stirrup
#

?tag slash_command

hearty rainBOT
#

dynoError No tag slash_command found.

slate stirrup
#

slash_command

slow dome
slate stirrup
#

Tnx

hoary moss
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: startswith first arg must be str or a tuple of str, not bytes

#

Am weirdly getting this error, am trying to create a webhook.

#

No idea why shrug

slow dome
#

show code?

past garnet
#

with a View is it possible to disable the buttons for one user but not another?

hoary moss
# slow dome show code?
@commands.command(name='setupLogging')
    async def logging(self, ctx, channel: Union[discord.TextChannel], ):
        await channel.create_webhook(avatar=self.client.user.avatar.url)```
slow dome
#

show full traceback?

hoary moss
#

sigh
One sec

hoary moss
# slow dome show full traceback?
Ignoring exception in command setupLogging:
Traceback (most recent call last):
  File "C:\Users\nicho\PycharmProjects\Rimuru\ve1nv\lib\site-packages\discord\ext\commands\core.py", line 184, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\nicho\PycharmProjects\Rimuru\cogs\logging\sub_logging.py", line 48, in logging2
    await channel.create_webhook(name='example name', avatar=self.client.user.avatar.url,
  File "C:\Users\nicho\PycharmProjects\Rimuru\ve1nv\lib\site-packages\discord\channel.py", line 566, in create_webhook
    avatar = utils._bytes_to_base64_data(avatar)  # type: ignore
  File "C:\Users\nicho\PycharmProjects\Rimuru\ve1nv\lib\site-packages\discord\utils.py", line 523, in _bytes_to_base64_data
    mime = _get_mime_type_for_image(data)
  File "C:\Users\nicho\PycharmProjects\Rimuru\ve1nv\lib\site-packages\discord\utils.py", line 509, in _get_mime_type_for_image
    if data.startswith(b"\x89\x50\x4E\x47\x0D\x0A\x1A\x0A"):
TypeError: startswith first arg must be str or a tuple of str, not bytes

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

Traceback (most recent call last):
  File "C:\Users\nicho\PycharmProjects\Rimuru\ve1nv\lib\site-packages\discord\ext\commands\bot.py", line 344, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\nicho\PycharmProjects\Rimuru\ve1nv\lib\site-packages\discord\ext\commands\core.py", line 951, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\nicho\PycharmProjects\Rimuru\ve1nv\lib\site-packages\discord\ext\commands\core.py", line 193, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: startswith first arg must be str or a tuple of str, not bytes
slow dome
hoary moss
#

uh

#

I'm 2.0.0rc1

slow dome
#

right, there's a 2.0.0

hoary moss
#

!install

robust nebulaBOT
#

Install pycord:

pip uninstall discord.py
pip install py-cord

Install pycord beta:

pip uninstall discord.py
pip install py-cord==2.0.0b7

Install pycord alpha from git:

pip uninstall discord.py
pip install git+https://github.com/Pycord-Development/pycord
slow dome
#

?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

2a. Install py-cord
python -m pip install py-cord

2b. Update py-cord
python pip install -U 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

hoary moss
#

Uh

#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: startswith first arg must be str or a tuple of str, not bytes

#

Still getting the same error

slow dome
#

if there's still an error, open an issue on github

hoary moss
#

I'm just trying to create a webhook 😓

slow dome
#

And I'm just trying to help

hoary moss
#

Alrighty just opened a github issue

#

THIS IS SO MUCH MORE CONVENIENT OH MY ABSOLUTE DUCKING WATER

#

Thanks to the Pycord team if your reading this for creating this :)

#

Is it possible to do bridge commands but prefix commands are done without replying to the original message?

hoary moss
#

Ohhh yup, so I can just do ctx.send?

slow dome
hoary moss
#

Perfect, thanks. Glad the bridge module exists, I was literally having an internal breakdown of how I'm gonna make a duplicate of everything

slow dome
#

it's why it exists

solar berry
#

Is there a way to disable caching bot messages

midnight cedar
#

not specifically messages from bots no

misty glacier
#
for message in ctx.channel.history(limit=100): <- Line 47 
    # do something

Ignoring exception in command clear:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/discord/commands/core.py", line 127, in wrapped
ret = await coro(arg)
File "/usr/local/lib/python3.9/dist-packages/discord/commands/core.py", line 877, in _invoke
await self.callback(self.cog, ctx, **kwargs)
File "/home/bots/discord/python/Ruby Network/commands/moderation/clearCommand.py", line 47, in clear
for message in ctx.channel.history(limit=amount):
TypeError: 'HistoryIterator' object is not iterable

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

Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/discord/bot.py", line 992, in invoke_application_command
await ctx.command.invoke(ctx)
File "/usr/local/lib/python3.9/dist-packages/discord/commands/core.py", line 358, in invoke
await injected(ctx)
File "/usr/local/lib/python3.9/dist-packages/discord/commands/core.py", line 135, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: 'HistoryIterator' object is not iterable

slow dome
#

Technically it’s iterable

#

just an async iterator

misty glacier
slender lintel
#

does anyone know how to calculate permissions

#

like if i give pycord a integer

#

or integers

#

can it tell me if i have admin

old plover
#

How can I actively listen to and process voice being captured?

slow dome
slender lintel
slow dome
#

kinda of

old plover
#

lmao

slender lintel
#

im too dumb

wheat topaz
#

Isn’t there an official Discord site to calculate permissions?

#

Wait no, there isn’t

slender lintel
#

im trying to make a dashboard

#

using the discord api

#

and i am really struggling with permissions

slow dome
#

and the | is bitwise or, I think

old plover
#

yeah

slender lintel
slow dome
#

8 does

slender lintel
#

i currently have theese 2 objects

guild = client.get_guild(int(id))
  user = await client.fetch_user(int(request.cookies.get("discord_id")))```
#

user object

#

and guild object

#

how can i figure out if the user has administrator

#

in the guild

#

do i fetch user from guild

#

and then use likek

#

guild_permissions.administrator

sudden path
#

Yes

slender lintel
#

alright

slender lintel
#

i cant find anything on it

slender lintel
#

oh wait

#

i put user

#

not member

#

lol

#

mb

slow dome
#

:)

slender lintel
#

thanks you

signal grotto
#

Sup guys, is it possible to update the guild id list on runtime, so the guild gets access to commands without restarting the bot?

old plover
slender lintel
#

no idea

#

are u trying to make like a talking ben bot?

#

that detects when a user is speaking

misty glacier
#

How can i add a deactivated button to a embed?

midnight cedar
supple ravineBOT
#

discord/voice_client.py lines 807 to 819

def recv_decoded_audio(self, data):
    if data.ssrc not in self.user_timestamps:
        self.user_timestamps.update({data.ssrc: data.timestamp})
        # Add silence when they were not being recorded.
        silence = 0
    else:
        silence = data.timestamp - self.user_timestamps[data.ssrc] - 960
        self.user_timestamps[data.ssrc] = data.timestamp

    data.decoded_data = struct.pack("<h", 0) * silence * opus._OpusStruct.CHANNELS + data.decoded_data
    while data.ssrc not in self.ws.ssrc_map:
        time.sleep(0.05)
    self.sink.write(data.decoded_data, self.ws.ssrc_map[data.ssrc]["user_id"])```
sudden path
#

b!rtfm pyc discord.Button

steep verge
#

How do you turn a message object into a dict?

gilded widget
stable torrent
#

time to contribute

#

¯_(ツ)_/¯

slender lintel
#

hi, so ive just recently made a new bot app and when i put the new token in its giving me this error, i cant really figure anything out but i know for a fact the token is valid

#

heres what im using to load the token

#
with open('token.json', 'r') as f:  
    token = json.load(f)['token']


#
client.run(token["token"])
stable torrent
#

print() your token before running the bot

slender lintel
#

ive done that yeah

stable torrent
#

is it your token?

slender lintel
#

yes

stable torrent
#

then token isn't valid

#

recheck it

#

also, i suggest using .env instead of .json files, you can read about it on google

old plover
#

Sounds a bit complicated

midnight cedar
#

you could just stop it from recording anything until a word is said

#

then save timestamp and record

old plover
#

I see

#

I wonder how I could detect when a word is said anyway

#

pass the decoded voice data through a speech to text?

midnight cedar
#

probably

steep verge
#

That sounds complicated but cool

slender lintel
#

these buttons do what they are supposed to do but the text below the buttons shows up anyway how can I make it stop

slow dome
slender lintel
#

I just dont want "This interaction failed" to show up when it did actually work

slow dome
#

respond somehow

errant verge
#

can i use dynamic cd with slash command?

deep grail
#

Yeah

deep grail
errant verge
#

uh could you elaborate?

past garnet
#

With cogs, How would I do something whenever a user joins?

errant verge
#
def custom_cooldown(self, user: discord.Message.author.id):
    if user == 92786442891169792:
        return None
    else:
        return Cooldown(rate = 1, per = 60)
#
@commands.dynamic_cooldown(custom_cooldown, commands.BucketType.user)

would this be the correct way to implement a dynamic cooldown on a slash command?

#

i tried it and couldn't get id from author

deep grail
#

Because I dont think u can get the message from the interaction

#

Cuz I'm not sure if it will work or not

runic flare
#

can anyone show me an example of using the create_custom_emoji method?

#

i can't figure out how to get an image in bytes that doesn't exceed the body max character count

supple ravineBOT
#

Here's the create private emoji example.

stable torrent
#

@runic flare

#

its the same, but you shouldn't specify roles for it

runic flare
stable torrent
runic flare
#

the difference is

stable torrent
#

im pretty sure you can just open image via default methods

runic flare
#

i'm getting my images from a saved file

#

not through a command

#
with open(number, "rb") as f:
  await ctx.guild.create_custom_emoji(
  name=ROLES.numbers_names[i], image=f.read())
#

and i get ```
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In name: Must be between 2 and 32 in length.

midnight cedar
#

emoji names have to be however long the error says

runic flare
#

oh crap

#

i misinterpreted the error 😭

#

mb ill try that thanks

stable torrent
#

you're welcome i guess

runic flare
#

ty 😭

quartz snow
#

is it possible to track those who are interested in the event?

lament nimbus
#

How would i get a button like that?

#

and for it to be active after i restart the bot?

supple ravineBOT
#

Here's the persistent example.

dusty flame
#

Hello I've been making a minecraft server manager bot, and for some reason after I changed something this line of code is erroring await context.respond(embed=emb)
Code: ```py
@bot.command(description="Starts the server")
async def start(context, server: str):
if ownerid == context.author.id:
for folder in os.listdir("./minecraft"):
if server == folder:
try:
with r(host=ip,port=mcservers[server]["port"],password=mcservers[server]["pass"]) as mcr:
resp = mcr.command('list')
await context.respond("Server is already online!")
except:
await context.respond("Starting server...")
os.chdir(f"/home/admin/coalminecraftservers/manager/minecraft/{server}/")
subprocess.Popen(["sh","start.sh"])
os.chdir(f"/home/admin/coalminecraftservers/manager")

lament nimbus
#

thanks

slender lintel
#

how can i set a limit to modal text amount

worthy basin
dusty flame
#

Thanks

#

Do I need to add an await?

slender lintel
dusty flame
#

Thank you

slender lintel
#

Hi
I using my raspberry pi 4 to host but
When I close the Putty my bot is stop to work
I am using Windows 10

dusty flame
worthy basin
#

The code you showed above was not the code for the error can you show that instead?

dusty flame
#

Here's the command I'm running

@bot.command(description="Gives list of servers")
async def servers(context):
    await context.defer()
    emb = discord.Embed(title="Servers")
    for server in os.listdir("./minecraft"):
        try:
            with r(host=ip,port=mcservers[server]["port"],password=mcservers[server]["pass"]) as mcr:
                resp = mcr.command('list')
            emb.add_field(name=server, value="Online")
        except:
            emb.add_field(name=server, value="Offline")
    await context.respond(embed=emb)
worthy basin
#

in this line you are missing a " before the pass key
mcservers = {"Friend_Server":{"port":00000,"pass":"password"},"Galacticraft":{"port":00000,"pass":"password"},"copsnrobbers":{"port":00000,pass":"password"}}

dusty flame
#

Oops I made that error while editing it It doesn't have that in the code

midnight star
#

Is there a way to put custom emojis in embed field titles ?

#

like animated ones

sour terrace
#

you can use custom emoji is embed's field name

lament nimbus
#

Is there a way to check what invite code somoene used to be invited?

lament nimbus
#

yeah but is there a way to do something like

@bot.event
async def on_member_join(member):
    print(f"Invited by {memeber.inviter}")

or something ?

lament nimbus
twilit cobalt
lament nimbus
#

hmm

#

i got a

ImportError: cannot import name 'PartialMessageable' from 'discord.channel'

error after getting discordutils

#

hmmm

#

ooh

#

uninstalled discord.py now its from discord.ext import commands, tasks
ImportError: cannot import name 'tasks' from 'discord.ext' (unknown location)

#

hmmm

slate stirrup
#

How can I make the bot sending what's it's sent to his dms In a channel

lament nimbus
#

nvm fixxedf

#

i think

#

thanks @twilit cobalt

twilit cobalt
#

Np 🙂

slender lintel
#

Could anyone help me out in #996783251186274324

craggy rapids
#

does Webhook.from_url cant executed with threading?

#

always got RuntimeError: Task <Task pending name='Task-233' coro=<sendw() running at /app/bgtasks.py:21> cb=[_run_until_complete_cb() at /app/.heroku/python/lib/python3.9/asyncio/base_events.py:184]> got Future <Future pending cb=[shield.<locals>._outer_done_callback() at /app/.heroku/python/lib/python3.9/asyncio/tasks.py:910]> attached to a different loop

midnight star
sour terrace
#

So does it works or not

graceful robin
#

slash command doesnt show up

#
@commands.slash_command(guild_ids=[972791561450573824], name="fish", description="Go fishing")
    async def fish(self, ctx):
        if await get_item(item_id="7fea4d63-c02a-4057-832a-ba460b8dedc2", by="uuid", inventory="Player", id=ctx.author.id) is not False:
            chance = randint(1, 100)

            for key, value in fish.items():
                if value > chance and chance < value:
                    await add_item(item=key, id=ctx.author.id)
                    item = get_item(item_id=key, by="uuid")
                    ctx.respond(f'You caught **{item["icon"]} {item["name"]}**!')
        else:
            await ctx.respond("You don't have the fishing rod!")
lament nimbus
#

i had that happen to me but thats because the class was the same name as a diffrent cog

slender lintel
graceful robin
#

i have like 10 other slash commands that work

frigid lark
#

It can take some time

graceful robin
#

it took too much time

#

its not a global command

#

its in a cog but other command in the cog work

#

ah wait

#

i just noticed

#

my last command also didnt register

steep verge
slow dome
steep verge
#

that too

graceful robin
#

alright

#

maybe thats the problem

#

Alright it works now

#

I reset my token and now my environment variable isnt working

vale ice
graceful robin
#

bro i know

tulip pelican
#

is there a way to know when an audit log has been edited? for example when you delete a message by someone else, it creates a new audit log, but if you delete another one, it doesn't create a new audit log but edits the old one

midnight horizon
#

i forgot completely how to use pycord, haven't used it in 2 years

#

tried to install it and got errors when running test code

hearty rainBOT
midnight horizon
#

well, installing makes the bot have many errors

south ermine
midnight horizon
#

ok, just a sec

#

2000+ characters

#

but basically i get the error: unauthorised

steep verge
midnight horizon
maiden slate
#

to make an argument optional do u just give it a default value or?

#

in a slash command

steep verge
hearty rainBOT
steep verge
slow dome
maiden slate
maiden slate
slow dome
#

it's keyword, anywhere

slow dome
maiden slate
#

wut u mean anywhere ? how do i make a specific argument optional

midnight horizon
steep verge
maiden slate
#

kk

midnight horizon
#

a no securing token bot gets the same error but says TOKEN instead of my token

#

it says that the discord library does not exist too

#

import discord could not be resolved

slow dome
supple ravineBOT
#

Here's the slash cog example.

midnight horizon
#

okay, now i don't have the discord library problem after installing all of the versions of pycord

#

but i still have this problem where the other things in the code won't say they are installed

#

for example

#

dotenv says its not installed

#

even though i uninstalled and then installed it 3 times

#

and i still get the discord.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized error

supple ravineBOT
#

Here's the slash options example.

hoary moss
#

Having a little problem with bridge commands.

#

I want to be able to send a message, and then edit it.

#

But we're forced to use ctx.respond, which message.edit doesn't work with. Are there any options?

#

Error specifically: discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'Interaction' object has no attribute 'edit'

#

Nevermind!

#

.edit_original_message instead solved my query, someone else asked the question in the Discord, just found it.

#

Thanks :)

midnight horizon
#

found out how to fix the not installed libraries, the code still gives an error tho

midnight horizon
#

here

#

i've been trying to fix this like half of my day

#

i just want to run my bot which has untouched code since the time it worked

wheat topaz
#

Hey @midnight horizon, I’ve looked out a little bit your problem and the error I’ve seen is that you probably sent an invalid token to Discord, most exactly an invalid token; and that is related to you dotenv problem; not pycord exactly. First, be sure that the token you are using is ok, next, Can you try to print what you get from your “os.getenv”

midnight horizon
#

i even copypasted the tutorial, didn't seem to help tho

#

also, i don't really know how to print it, but i can try

wheat topaz
#

Try to do a
print(os.getenv(‘TOKEN’))

midnight horizon
#
  File "c:\Users\vinic\Documents\Yiffiy Pycord\dotenv.py", line 2, in <module>
    from dotenv import load_dotenv
  File "c:\Users\vinic\Documents\Yiffiy Pycord\dotenv.py", line 2, in <module>
    from dotenv import load_dotenv
ImportError: cannot import name 'load_dotenv' from partially initialized module 'dotenv' (most likely due to a circular import) (c:\Users\vinic\Documents\Yiffiy Pycord\dotenv.py)```
wheat topaz
#

You probably have dotenv installed

#

Instead of python-dotenv

midnight cedar
#

you have a file named dotenv

#

name it something else

wheat topaz
#

Oh hey, Didn’t see that ^^

signal grotto
#

will a guild, that I add to a command in runtime, get access to the command and if not: how is it possible to add commands to a guild without restarting the bot everytime?

slow dome
midnight horizon
#

i think i just broke my python installation

#

stonks

#

i am now uninstalling and reinstalling python

signal grotto
midnight horizon
#

okay, fixed my python instalation

slow dome
midnight horizon
#

my .env indeed returns none, even tho i copied and pasted the tutorial, only change is that i put in my token

steep verge
#

And also send what you’re doing to load your .env

midnight horizon
#

that's all what's in it

steep verge
midnight horizon
#

its literally copy pasted from the example

#
import discord
import os # default module
from dotenv import load_dotenv

load_dotenv() # load all the variables from the env file
bot = discord.Bot(debug_guilds=[881207955029110855])

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

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

bot.run(os.getenv('TOKEN')) # run the bot with the token```
frigid lark
#

Is both in the same folder?

midnight horizon
#

yes, both are in the same folder

midnight horizon
#

the bot is my untouched code that stopped working

#

after 6 months of not opening it

frigid lark
#

and if you do it with a json file?

#

How do you host the bot?

midnight horizon
#

locally

#

i am the host

frigid lark
#

so you also can just use a json file

midnight horizon
#

well yes, but actually no cuz i don't know how to do that

#

you gotta understand that the example code isn't working

#

at least not for me

wheat topaz
#

Tbh if you are hosting it locally there’s no point imo in using “.env” unless you have a Full Stack Developer lurking at your pc from time to time

frigid lark
#

^

midnight horizon
#

its better for sending the error logs to people

#

most of the times i tested, the error logs showed the token

#

still, same thing, even with no env

#

discord.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized

#

and yes, i tried refreshing the code

#

no change

frigid lark
#

is the bot with applications.commands invited?

midnight horizon
#

and scopes

#

just to be sure

frigid lark
#

Eh

midnight horizon
#

the code worked perfectly 6 months ago

slow dome
#

Is this a Pycord specific issue. For example what if you used a different library

midnight horizon
frigid lark
#

what is your pip list?

midnight horizon
# frigid lark what is your pip list?
------------------ -----------
aiohttp            3.7.4.post0
async-timeout      3.0.1
attrs              21.4.0
certifi            2022.6.15
cffi               1.15.1
chardet            4.0.0
charset-normalizer 2.1.0
colorama           0.4.5
discord.py         1.7.3
idna               3.3
multidict          6.0.2
pip                22.1.2
praw               7.6.0
prawcore           2.3.0
py-cord            2.0.0
pycparser          2.21
PyNaCl             1.5.0
python-dotenv      0.20.0
requests           2.28.1
typing_extensions  4.3.0
update-checker     0.18.0
urllib3            1.26.10
websocket-client   1.3.3
wheel              0.37.1
yarl               1.7.2
youtube-dl         2021.12.17```
frigid lark
midnight horizon
#

yeah, i uninstalled it and it kept coming back

#

when i installed pycord

#

i can try uninstalling it again tho

#

same error happens, uninstalled discord.py and reinstalled pycord

#
------------------ -----------
aiohttp            3.7.4.post0
async-timeout      3.0.1
attrs              21.4.0
certifi            2022.6.15
cffi               1.15.1
chardet            4.0.0
charset-normalizer 2.1.0
colorama           0.4.5
idna               3.3
multidict          6.0.2
pip                22.1.2
praw               7.6.0
prawcore           2.3.0
py-cord            2.0.0
pycparser          2.21
PyNaCl             1.5.0
python-dotenv      0.20.0
requests           2.28.1
typing_extensions  4.3.0
update-checker     0.18.0
urllib3            1.26.10
websocket-client   1.3.3
wheel              0.37.1
yarl               1.7.2
youtube-dl         2021.12.17```
#

it is indeed gone

#

nothing changed tho

slow dome
#

uninstall py-cord

#

and reinstall py-cord

midnight horizon