#General Help

1 messages Β· Page 23 of 1

midnight cedar
#

yes skykings is in python

#

and i don't know how mongo works

slender lintel
#

oof and alr nice

#

Nice, I have pycord installed, strange..

midnight cedar
#

update

slender lintel
#

it's in my venv

slender lintel
midnight cedar
#

postgres

slender lintel
#

ah alr

#

Should i use postgres or?

slender lintel
#

nice :))

#

not able to help u srry, but ik a venv is a virtual enviroment, but whats it used for

slender lintel
midnight cedar
#

it's up to you

slender lintel
slender lintel
midnight cedar
#

mongo is similar to json

#

i think it actually uses something called bjson

#

or jsonb

#

postgres is an SQL standard db

slender lintel
#

what does postgres use?

#

alr

midnight cedar
#

relational db

#

got tables with rows

slender lintel
#

so whats more simple (lol)

midnight cedar
#

couldn't tell you

#

never used mongo

#

from what i've seen though

#

sql queries make more sense

crimson gale
#

mongo is basically just json structured documents

#

no relational fields at all so its not suitable for that application

slender lintel
#

Might give postgres a go ig

#

Why does this happen? It has worked in other embeds

        suggest = discord.Embed(title=f"Suggestion by {interaction.user} Under Review <@&988496229229002792>)``` (Theres more code in that line but dosent need sent)
slender lintel
#

Yeah, Is it cause its in the title?

#

mentions dont work in titles

slender lintel
#

alr

slender lintel
#

just ctx.respond?

#

await ctx.respond("message here", embed=embed)

#

ty

slender lintel
# slender lintel await ctx.respond("message here", embed=embed)
 async def callback(self, interaction: discord.Interaction):
        m = await interaction.response.send_message("Suggestion send!", ephemeral=True)
        suggest = discord.Embed(title=f"Suggestion by {interaction.user} Under Review ",color=discord.Color.blue())
        suggest.add_field(name="Your Suggestion: ", value=self.children[0].value)
        suggest.set_footer(text=f"Message id: {m.id} ")
        channel = self.bot.get_channel(987396375069224960)
        embed = await channel.send(" Ping: <@&988496229229002792>", embed=embed)
        await embed.add_reaction('β˜‘')
        await embed.add_reaction('❌')```
Connected to bot: FelBot
Ignoring exception in modal <Modals.Suggestions.Suggestions object at 0x00000212475EAB60>:
Traceback (most recent call last):
  File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ui\modal.py", line 260, in dispatch 
    await value.callback(interaction)
  File "C:\Users\jackd\Documents\Felbcord Py\Modals\Suggestions.py", line 18, in callback
    await embed.add_reaction('β˜‘')
UnboundLocalError: local variable 'embed' referenced before assignment
#

why do i get this error?

#

i dont see embed being used before it

#

you named

#

your embed

#

suggest

#

it should be embed=suggest

#

Hey, any ideas why this is not recognised?

import discord
from discord.ext import commands


intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix="-", intents=intents)
    intents.message_content = True
AttributeError: 'Intents' object has no attribute 'message_content'
slender lintel
#

should I use the pre version?

#

uh

slender lintel
slender lintel
#

I don't get why

#

did you intall this

#

lol

#

?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

  2. 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 release candidate:
pip install py-cord==2.0.0rc1

slender lintel
slender lintel
#

@slender lintel

#

but you said you did
pip install -U pycord which is not py-cord

#

also the normal py-cord

#

is version 1.7.3 I think

#

BRUH

#

yeah

#

u right

#

πŸ˜‚

#

just forgot the -

#

@slender lintel should I use the 2.0.0 version?

slender lintel
#

but if I don't use it, the other error appears again

slender lintel
slender lintel
slender lintel
#

well it's recognised but:

sleek grove
#

guys how can make a response that only the ctx author can see?

slender lintel
slender lintel
slender lintel
#

I imported message in the function

slender lintel
#

remove mesage

slender lintel
#

@slender lintel now messages is not recognised

#

should I try with something else than on_ready?

slender lintel
slender lintel
slender lintel
#

I need to check embeds

#

no no no no

#

OH

#

ok

#

I'm dumb

#

sorry

#

ok

#

was going to explain but if you got it πŸ‘

slender lintel
#

?

#

@slender lintel

slender lintel
#

BRUH

#

ok know I gotta concentrate

#

πŸ˜‚

#

@slender lintel Thanks for your help

#

I got another error but I'll find it by myself

#

Gl

vestal kelp
#

Anyone know why my task is not starting? I have all imports correct, not getting any errors with it either. Tried looking it up, but can't find the reason it isn't running.

graceful robin
#
['cogs.moderation', 'cogs.events']
Traceback (most recent call last):
  File "C:\Users\maksi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 727, in _load_from_module_spec
    setup(self)
  File "d:\Desktop\peer\cogs\events.py", line 19, in setup
    client.add_cog(events(client))
  File "C:\Users\maksi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 597, in add_cog
    raise discord.ClientException(f"Cog named {cog_name!r} already loaded")
discord.errors.ClientException: Cog named 'events' already loaded

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

Traceback (most recent call last):
  File "d:\Desktop\peer\bot.py", line 34, in <module>
    client.load_extension(cog)
  File "C:\Users\maksi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 787, in load_extension
    self._load_from_module_spec(spec, name)
  File "C:\Users\maksi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 732, in _load_from_module_spec
    raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'cogs.events' raised an error: ClientException: Cog named 'events' already loaded

Code:

cogs = []

for filename in os.listdir("./cogs"):
    if filename.endswith(".py"):
        cogs.append("cogs." + filename[:-3])

print(cogs)

if __name__ == "__main__":
    for cog in cogs:
        client.load_extension(cog)
#

Had this problem a few days ago

#

and i still havent figured out how to fix it

slender lintel
#

Oh god, I had this and It was a pain to fix because trying to fix it I made it 100x worse but I forgot how to fix it lol

graceful robin
#

oof

slender lintel
#

Anyone has an idea of how I could get this working? It's currently not finding any, even if I put some messages with the right regex in the channel

token_regex = re.compile(r'/[\w-]{24}\.[\w-]{6}\.[\w-]{27}/')


@bot.event
async def on_ready():
    print("bot connected")
    channel = bot.get_channel(988378560249090119)
    embed = ""

    async for message in channel.history(limit=60000):
        if token_regex.search(message.content) in message.embeds:
            embed = message.embeds[0].description
            log = "{0.content}{1}".format(message,embed)
            print(log)
brave lagoon
#

is it possible to take a file as a argument for a slash command ?

supple ravineBOT
#

examples/app_commands/slash_options.py lines 49 to 65

@bot.slash_command(name="attach_file")
@option(
    "attachment",
    discord.Attachment,
    description="A file to attach to the message",
    required=False  # The default value will be None if the user doesn't provide a file.
)
async def say(
    ctx: discord.ApplicationContext,
    attachment: discord.Attachment,
):
    """This demonstrates how to attach a file with a slash command."""
    if attachment:
        file = await attachment.to_file()
        await ctx.respond("Here's your file!", file=file)
    else:
        await ctx.respond("You didn't give me a file to reply with! :sob:")```
supple ravineBOT
#

examples/app_commands/slash_options.py line 4

from discord import option```
slow dome
#

this is option btw

brave lagoon
#

I see option is very usefull !

sleek grove
#

guys is there any way to disable a file only for a specific guild

#

so a module

slow dome
#

file?

sleek grove
#

yes

slow dome
#

So you want the app commands in that file only register in that guild, or only outside of that guild?

sleek grove
#

so i type in .disable fun and it make the fun cog isn't warking for the guild

slow dome
#

if it is, then return

#

else, don't

sleek grove
#

ok and is there a way that isn't that much elaborate

slow dome
#

well, it should be stored persistently, right?

sleek grove
#

yes

#

can i do a event if command from fun.py is used check...

slow dome
#

instead of using database, textfiles are fine until they become too long

sleek grove
#

and is there a event to check that?

dawn wagon
#

Hello

#

Hi guys i have a question. How can i check if the member from e.g. /userinfo [MEMBER] is a real member e.g. if someone types /userinfo blabdfhbsd how can i check if thats a real member and send a message saying smth like "That member is not a real User"

tawny shore
#

Does user command work in cogs?

sleek grove
#

Yes (i code with him)

past gate
slender lintel
#

How do i fix pip? (Pip is not a reconized script)

brave lagoon
#

Is there a maximum number of pages for the paginator ?

edgy breach
#

hey

#

does anyone know how i would create a thread in pycord?

slender lintel
slender lintel
slender lintel
vestal kelp
slender lintel
#

@dawn wagon you can just use

if message.author == client.user:
    return
if message.author.bot: return (smth like this)
worthy basin
# dawn wagon Is there any way?

If you are using slash commands you can use options to make it only possible to pass real users.

user: discord.User should work iirc

#

Using prefix commands you could fetch the user and catch the error.

#

member: Option(discord.Member)
if the above does not work

scenic leaf
#

hi i need some help what am i doing wrong here ?

class Help(commands.Cog):
    """ A collection of the commands for moving the bot around in you server.

            Attributes:
                bot: The instance of the bot that is executing the commands.
    """

    def __init__(self, bot):
        self.bot = bot

    class Select(discord.ui.Select):
            def __init__(self):
                options=[
                    discord.SelectOption(label="Option 1",emoji="πŸ‘Œ",description="This is option 1!"),
                    discord.SelectOption(label="Option 2",emoji="✨",description="This is option 2!"),
                    discord.SelectOption(label="Option 3",emoji="🎭",description="This is option 3!")
                    ]
                super().__init__(placeholder="Select an option",max_values=1,min_values=1,options=options)
                
    @commands.slash_command(name = "help", description= "Shows Help Message", Guild_ids=config.Guilds, pass_context=True, hidden = True)
    async def Help(self, ctx):
        await ctx.send("Menus!",view=Select())


            
def setup(bot):
    bot.add_cog(Help(bot))
#

its inside a cog

#

and i want to use a drop down menu with my help command

#

so i can select the help category

#

but its not working

reef dove
#

how can i get the application commands of my bot? i tryna see the ids so i could manually delete 2

#

huh

worthy basin
# scenic leaf hi i need some help what am i doing wrong here ? ```py class Help(commands.Cog):...

What "is not working"?
ctx.send sends a message instead of responding to a slash command
You should use ctx.respond

I think your issue is that you are not passing a View but rather a select this should be an easy fix. In your command you can create a view view = discord.ui.View() than add your select to the view
with View.add_item(Select()) than view=view

You also should not name your select class Select as it might override things unexpectedly. You could name it something like HelpSelect

reef dove
#

ice do u know how to fix that?

#
import requests
from pprint import pp

spooky_id = "939049331586113566"
token = "shhh"

header = {
        'Authorization' : f'Bot {token}'
}

requests.get(f'https://discord.com/api/v9/applications/{spooky_id}/commands', headers=header)
worthy basin
reef dove
#

no, what im trying to do is to get all my current application commands so i can delete 2

#

manually delete 2

#

using this

#

im just trying to get the application command id

worthy basin
#

With pycord? or with HTTP?

reef dove
#

http

#

can i do it with pycord? if yes how

worthy basin
#

You can access all endpoints available to bots via pycord methods

reef dove
#

all im trying to do is to get my application command id... πŸ˜‚

#

could u tell me how it could be done using pycord?

reef dove
#

so bot.get ... ?

#

like

#

1 sec

#

name? name of the command?

#

so should be like

worthy basin
#

name like /hello would be hello

reef dove
#

can i just do an on ready event?

worthy basin
#

Normally API calls in on_ready breaks things but it should be fin if you are doing it once and than removing the code

reef dove
#

twice tbh

#

2 cmds

worthy basin
reef dove
#

would this be fine lol

worthy basin
reef dove
#

πŸ‘

#

huh

#

they are just in 1 guild tho

#

im trying to remove them from the guild

slender lintel
reef dove
#

yes long time ago x)

slender lintel
#

if yes then just do
await spooky.sync_commands(force=True)

worthy basin
#

specify the guild ID in the remove... function

languid hollow
#

Are cogs more memory efficient than pasting all the commands in one file (another info on separate)

reef dove
#

still not working lol

reef dove
#

wait is a tortoise error

slender lintel
#

o ok

worthy basin
#

Yeah try what Xout said

scenic leaf
reef dove
#

wait it was a tortoise error

#

1 sec

#

πŸ˜‚

worthy basin
languid hollow
#

I’ve got limited ram even though it’s free for other hosts you require to send in personal details which I’m not a fan of

#

60mb ram 😭

worthy basin
scenic leaf
#

i now have this

    class HelpSelect(discord.ui.Select):
            def __init__(self):
                options=[
                    discord.SelectOption(label="Option 1",emoji="πŸ‘Œ",description="This is option 1!"),
                    discord.SelectOption(label="Option 2",emoji="✨",description="This is option 2!"),
                    discord.SelectOption(label="Option 3",emoji="🎭",description="This is option 3!")
                    ]
                super().__init__(placeholder="Select an option",max_values=1,min_values=1,options=options)
                
    @commands.slash_command(name = "help", description= "Shows Help Message", Guild_ids=config.Guilds, pass_context=True, hidden = True)
    async def Help(self, ctx):
        view = discord.ui.View()
        await ctx.respond("Menus!",view=view)
#

this is what you meant right ?

#

because idk where you said to put the View.add_item(Select())

worthy basin
reef dove
#

@worthy basin do u have sql / tortoise knowledge? im having a bad issue with my models ;/

languid hollow
#

For the view = discord.ui.view

#

You need to put in the class in it

slender lintel
languid hollow
#

I believe

worthy basin
reef dove
worthy basin
reef dove
#

models not registered lol

#

but they're connected

scenic leaf
#
@commands.slash_command(name = "help", description= "Shows Help Message", Guild_ids=config.Guilds, pass_context=True, hidden = True)
    async def Help(self, ctx):
        view = discord.ui.View()
        options = View.add_item(Select())
        await ctx.respond("Menus!",view=view)
reef dove
scenic leaf
#

like so ?

slender lintel
reef dove
#

πŸ˜‚

#

wtf

#

probably the issue is coming from the Models

#

lemme see

worthy basin
languid hollow
#

Correct me if I’m wrong but didn’t the highlighted one need changing?

worthy basin
reef dove
#

yes antinuke models issues...

languid hollow
#

Since in the view variable he needs to reference the class

scenic leaf
#

but now HelpSelect is yello

worthy basin
reef dove
#

fixed the db.. sorry about that

worthy basin
slender lintel
#

but since it is

#

or self.HelpSelect() I think actually

#

wait

#

no hm

reef dove
#

will do t his

#

this*

worthy basin
#

what Xout said
also your help select __init__ function is indented once to many

languid hollow
#

Also, I have a command that is able to change cooldown depending on the users interaction, how would I make sure that the command uses the new cooldown value?

scenic leaf
languid hollow
#

The command gets the cooldown via a file and casts it to int

scenic leaf
#

self.HelpSelect() does resolve it being yellow

worthy basin
#

πŸ‘

scenic leaf
#

it now posts

#

but if i select a option it does nothing

#

and says This interaction failed

supple ravineBOT
#

Here's the dropdown example.

slender lintel
scenic leaf
#

ooh there

#

mybad

reef dove
#

i don't think that on ready worked to delete the cmd

slender lintel
reef dove
#

nope

worthy basin
reef dove
#

i will try to do it in the cog..

languid hollow
#

The only problem is that the command uses the cooldown value assigned to it during the start of the script and not the values after it which is frustrating

reef dove
#

is not even printing that is ready.. that's why im saying

worthy basin
languid hollow
#

Yes

reef dove
#

@worthy basin

#

guild ids cannot be used

scenic leaf
#

it breaks it

reef dove
#

str? don't they ask for the name of the cmd?

languid hollow
worthy basin
languid hollow
#

I’ll let you know if it’s working when I see online

reef dove
#

how could i do that?

worthy basin
#

name and guild_ids than pass that object into the remove

#

I gtg now :/

reef dove
#

await exp cannot be used cuz "None Type"

#

lol

#

alr woolfy cya

#

wait is not a coroutine

craggy rapids
#

btw why the label on :onpage doesnt changed when :before button pressed?

sullen marten
craggy rapids
#

what?

#

edit the view?

#

await onpg.label?

sullen marten
#
await interaction.response.edit_message(embed=embed, view=self.view)
sullen marten
#

just self, not self.view

craggy rapids
#

ok i got it

sullen marten
#

guys, is there a way to add checks to slash commands?
if i try to manually assign like:

@slash_command(checks=[check1, check2])
async def ...

this isn't actually working
..and i can't find any docs about this

slow dome
sullen marten
sullen marten
solar berry
#

I'm trying to nest dictionaries into a tree and i cant figure out how to do it
basically if I had a list with ["a", "b", "c"]
I want to nest it into {"a": [{"b": [{"c": []}]}]}
would anyone know how to do this

solar berry
#

nvm i figured it out

cunning dragon
#

Are there any examples on how the forms work?

#

nvm think i found, it goes by a different name

dull skiff
#
[ffmpeg] Destination: ORIGINAL SONG MVMantra Hujan - Kobo Kanaeru hololive Indonesia 3rd Gen-SF-_47-oCtk.mp3
Deleting original file ORIGINAL SONG MVMantra Hujan - Kobo Kanaeru hololive Indonesia 3rd Gen-SF-_47-oCtk.webm (pass -k to keep)
Ignoring exception in command play:
Traceback (most recent call last):
  File "c:\Users\Teddy\Documents\bot discord python\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "c:\Users\Teddy\Documents\bot discord python\main.py", line 125, in play
    os.rename(file, "song.mp3")
AttributeError: module 'discord' has no attribute 'FFmpegPCAudio'```
#

can someone help?

#
async def play (ctx, url : str):
    song_there = os.path.isfile("song.mp3")
    try:
        if song_there:
            os.remove("song.mp3")
    except PermissionError:
        await ctx.send("Wait for current song to stop or use 'stop' command")
        return

    voiceChannel = discord.utils.get(ctx.guild.voice_channels, name="Musik")
    await voiceChannel.connect()
    voice = discord.utils.get(bot.voice_clients, guild=ctx.guild)



    ydl_opts = {
        'format': 'bestaudio/best',
        'postprocessors': [{
            'key': 'FFmpegExtractAudio',
            'preferredcodec': 'mp3',
            'preferredquality': '192',
        }],
    }
    with youtube_dl.YoutubeDL(ydl_opts) as ydl:
        ydl.download([url])
    for file in os.listdir("./"):
        if file.endswith(".mp3"):
            os.rename(file, "song.mp3")
    voice.play(discord.FFmpegPCAudio("song.mp3"))```
dull skiff
#

miss 1 word=eror

#

so nice

dull skiff
#
Traceback (most recent call last):
  File "c:\Users\Teddy\Documents\bot discord python\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "c:\Users\Teddy\Documents\bot discord python\discord\ext\commands\core.py", line 855, in invoke
    await self.prepare(ctx)
  File "c:\Users\Teddy\Documents\bot discord python\discord\ext\commands\core.py", line 789, in prepare
    await self._parse_arguments(ctx)
  File "c:\Users\Teddy\Documents\bot discord python\discord\ext\commands\core.py", line 697, in _parse_arguments
    transformed = await self.transform(ctx, param)
  File "c:\Users\Teddy\Documents\bot discord python\discord\ext\commands\core.py", line 542, in transform
    raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: msg is a required argument that is missing.```
#

can someone help?

#
async def play (ctx, url : str, msg):
        try:
            voice_client = await msg.author.voice.channel.connect()
            voice_clients[voice_client.guild.id] = voice_client
        except:
            print("error")
        try:
            url = msg.content.split()[1]

            loop = asyncio.get_event_loop()
            data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=False))

            song = data['url']
            player = discord.FFmpegPCMAudio(song, **ffmpeg_options)

            voice_client[msg.guild.id].play(player)
            await ctx.reply(f"Playing {url}", mention_author=True)

        except Exception as err:
            print(err)```
#

this is the code

crimson gale
#

self explanatory

terse plinth
#

instead, change msg.author.voice.channel.connect() to ctx.author...

#

the ... just means the rest of the syntax

dawn wagon
#

Smth like if member is not in ctx.guild.members:

terse plinth
#

if a member is not a real member, discord will raise an exception commands.MemberNotFound

#

it will do the same if a user isnt on the server

dawn wagon
#

Yeah but it will send an error in the console

#

And i wanto prevent that

dull skiff
#

'Context' object has no attribute 'content'

#

i got this

#
async def play (ctx, url : str):
        try:
            voice_client = await ctx.author.voice.channel.connect()
            voice_clients[voice_client.guild.id] = voice_client
        except:
            print("error")
        try:
            url = ctx.content.split()[1]

            loop = asyncio.get_event_loop()
            data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=False))

            song = data['url']
            player = discord.FFmpegPCMAudio(song, **ffmpeg_options)

            voice_client[ctx.guild.id].play(player)
            await ctx.reply(f"Playing {url}", mention_author=True)

        except Exception as err:
            print(err)```
half marsh
dull skiff
#

'VoiceClient' object is not subscriptable now i got this

#

same code(changed to ctx.message.content.split)

rugged needle
#

Is there a way for the bot to tell the differences between a thread being created and it joining a thread

#

pls ping in reply

half dust
#

I wanted to make a simple tic-tac-toe bot. I have everything working except for a turn system. I already stored the two people playing in a list and made a turn variable, but when trying to change the turn variable in any way, I get many errors. Is there an easier way of doing it other than people[turn]?

high condor
#

how do i edit the message sent from ctx.respond()? i tried doing interaction.original_message() but i got a AttributeError: 'coroutine' object has no attribute 'edit'

surreal lagoon
high condor
slender lintel
#

Hey Guys!
There there a way to, for a button on click, to just continue with the main function.

        a = await ctx.send("abc", view=View(ctx.author, msg))
        # if button is clicked continue
        #else dont
        print("e")
dull skiff
#

'VoiceClient' object is not subscriptable

#

can someone help?

#
async def play (ctx, url : str):
        try:
            voice_client = await ctx.author.voice.channel.connect()
            voice_clients[voice_client.guild.id] = voice_client
        except:
            print("error")
        try:
            url = ctx.message.content.split()[1]

            loop = asyncio.get_event_loop()
            data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=False))

            song = data['url']
            player = discord.FFmpegPCMAudio(song, **ffmpeg_options)

            voice_client[ctx.guild.id].play(player)
            await ctx.reply(f"Playing {url}", mention_author=True)

        except Exception as err:
            print(err)```
#

this is the code

#

the bot can connect but cant play music

slender lintel
surreal lagoon
#
def __init__(self, ctx: Context, content: list[str]):
  self.ctx = ctx,
  self.content = content

Why does ctx get the type tuple[Context]?? It should just be the context object

slender lintel
#

is there no way to do that with a button?

surreal lagoon
slender lintel
slender lintel
#

NVM

#

it is a button

#

i though it was a menu

#

srry

#

np xd

rugged needle
#

And is there a way to use commands in threads? Or maybe, even better, trigger an event whenever a bot gets pinged in a thread

#

And what's on_thread_update?

scenic leaf
#

im trying to get the data of this api

@commands.slash_command(name = "advice", description= "gives you some advice", Guild_ids=config.Guilds)
    async def advice(self, ctx):
        async with aiohttp.ClientSession() as cs:
            async with cs.get("https://api.adviceslip.com/advice") as r:
                res = await r.json()
                print(res)

thats my code and it returns this Application Command raised an exception: ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8', url=URL('https://api.adviceslip.com/advice%27)
whats going wrong cause i never saw this error before

past gate
#

well the website is responding with a different mimetype than expected

smoky fog
#

Hi

#

how to get inviter id

scenic leaf
smoky fog
past gate
#

what status code does the website return?

scenic leaf
#

nothing it just works

#

thats the link

#

it just returns
{"slip": { "id": 15, "advice": "If it ain't broke don't fix it."}}

#

that

past gate
#

hmm

#

ill take a look

scenic leaf
#

that would be great !

past gate
#

yeah it appears the server responds with the incorrect mimetype leading clients to throw errors

#

you could work around that by parsing the result of r.text into JSON via json.loads

scenic leaf
#

hmm okey

past gate
#

maybe add in a try-except just incase it returns something other than JSON

scenic leaf
#

so like await r.json(r.text)

past gate
#

no

#

text is part of the response object

#

just like json()

scenic leaf
#

ah okey

smoky fog
#

hi

#

guys

#

how to get the inviter id

#

i mean when somebody join the bot get the person that he invited and get his id

#

@scenic leaf @past gate

past gate
#

could you please stop pinging me

scenic leaf
#

im not sure about getting the id but this is what i use when someone invites someone else

@bot.command()
async def invites(ctx, usr: discord.Member=None):
    if usr == None:
       user = ctx.author
    else:
       user = usr
    total_invites = 0
    for i in await ctx.guild.invites():
        if i.inviter == user:
            total_invites += i.uses
    await ctx.send(f"{user.name} has invited {total_invites} member{'' if total_invites == 1 else 's'}!")
#

it gets who invited who and how many they have invited allready Xd

smoky fog
#

ok thanks

scenic leaf
#

no problem

past gate
# scenic leaf ah okey

looking into the internals of the aiohttp lib, I've realised you could just pass the content_type kwarg to the json() function call on the response with the expected content type from the server which in this case will be text/html (for some reason)

scenic leaf
#

okey can you guide me to a doc or piece of code that does that

#

cause im not know with aiothttp that well yet

past gate
#

just res = r.json(content_type='text/html')

kind mesa
#

When i try to print the message object i get TextChannel' object has no attribute 'news'. Is there a fix for it?

hollow reef
#

Is it possible to edit a response?

graceful robin
scenic leaf
grave wraith
#

Why does

await ctx.respond(f"Ping {role.mention}",allowed_mentions=discord.AllowedMentions(roles=True))
``` not ping on a slash command?
dawn wagon
#

Guys pls help. Does anyone know how to check if the user from e.g. /userinfo [member] is a member on the server and if not send a msg like "User is not on this server" to prevent error in console

grave wraith
#

just make a try except statement

smoky fog
#

any help?

dawn wagon
#

Lol

past gate
slender lintel
#

it is possible to select in modal ?

smoky fog
past gate
grave wraith
smoky fog
smoky fog
grave wraith
# dawn wagon How
try:
  [your_code]
except YourException:
  [what should happen if that exception gets raised]
past gate
#

so its hard to tell which one is throwing the error without your code

smoky fog
#

this is the code

past gate
smoky fog
past gate
#

whats is the current error being thrown?

past gate
terse plinth
smoky fog
past gate
#

can you send the error

smoky fog
#

ok

past gate
#

clearly line 88 is not working properly then

smoky fog
#

usr = gld.get_member(int(last))

#

last variable needs a number

#

do i put any id?

frigid lark
smoky fog
frigid lark
#

Still pain

smoky fog
#

yes

#

idk how to change theme ;-;

frigid lark
#

Is that replit?

smoky fog
#

yes

smoky fog
frigid lark
#

And not the ID

smoky fog
#

oh

frigid lark
smoky fog
#

right?

frigid lark
#

Try it

drifting spindle
upbeat hill
#

how do you get a bot to edit a specific message from an interaction?

drifting spindle
#

interaction.response.edit_message()

smoky fog
drifting spindle
upbeat hill
drifting spindle
drifting spindle
#

Or you can add a field to embed.add_field_to

#

But if you think to edit a perticular word or line it not possible

#

It possible if you make a variable

#

Of the part and you write with f string

upbeat hill
smoky fog
#

you mean i have to change usr.id?

coral lynx
#

heyo! I just recently started switching from discord.py to use slash command etc, everything running smoothly until i attempted to get a paginator to response to the context interaction, it just raises a 404 Unknown interaction error, anyone have any advice?

steep verge
#

From message.attachments, how would I turn one into a discord.File type?

ornate fog
#

file = await message.attachments[index].to_file()

steep verge
#

thanks

coral lynx
scenic leaf
#

how do i replace words in a message cause i have this

@bot.event
async def on_message(message):
    input = message.replace(' ', '+')

but it says Message' object has no attribute 'replace'

slender lintel
#

Select on modals work ?

slender lintel
slender lintel
scenic leaf
#

aah thanks !

slender lintel
scenic leaf
#

how would i prevent the bot from reacting to its own messages Xd

#
@bot.event
async def on_message(message):
    input = message.content.replace(' ', '+')
    async with aiohttp.ClientSession() as cs:
        async with cs.get(f"https://api.popcat.xyz/chatbot?msg={input}") as r:
            res = await r.json()
            response = res["response"]
            members = message.guild.members # also works with ctx.guild.members
            for member in members:
                if member.bot == True:
                    print('Member is bot')
                else:
                    print('Member is not bot')
                    await message.channel.send(response)
#

is what i now have

#

but it reacts to its own messages haha

#

like breh Xd

slender lintel
# scenic leaf ```py @bot.event async def on_message(message): input = message.content.repl...
@bot.event
async def on_message(message):
    if message.author.bot:
        return
    input = message.content.replace(' ', '+')
    async with aiohttp.ClientSession() as cs:
        async with cs.get(f"https://api.popcat.xyz/chatbot?msg={input}") as r:
            res = await r.json()
            response = res["response"]
            members = message.guild.members # also works with ctx.guild.members
            for member in members:
                if member.bot == True:
                    print('Member is bot')
                else:
                    print('Member is not bot')
                    await message.channel.send(response)```
scenic leaf
#

thank you !!

#

it works

slender lintel
#

np

#
view = Confirm()
                    await view.wait()
                    if view.value is None:  # If the user didn't press the button
                        await msg.edit_original_message(embed=discord.Embed(title=f"Power | {server.capitalize()}", description=f"Timed out waiting for confirmation, Aborting.", color=embed_color).set_footer(text=embed_footer).set_author(name=embed_header, icon_url=embed_icon))
                        return
                    elif not view.value:    # If the user cancelled
                        await msg.edit_original_message(embed=discord.Embed(title=f"Power | {server.capitalize()}", description=f"Cancelled, Aborting.", color=embed_color).set_footer(text=embed_footer).set_author(name=embed_header, icon_url=embed_icon))
                        return
                    await msg.edit_original_message(embed=discord.Embed(title=f"Power | {server.capitalize()}",description=f"Confirmed, continuing with the operation.",color=embed_color).set_footer(text=embed_footer).set_author(name=embed_header, icon_url=embed_icon))

it's result never gets shown

golden stone
#

Hey ahh i want my bot to delete it's message like take an break for 10 sec and after that deletes it's message

slender lintel
#

Hey,
I can't seem to find a way for a message from slash command to be only visible for the user that launched the command.

#

Hi, not code related but i made a feature that creates invites for all server that its in and gives them to me. Is that allowed or against the ToS? Becuase some random guy said he's gonna report me for it if i dont remove it

slender lintel
slender lintel
#

Ok

slender lintel
#

i've got this error

  File "/Volumes/Danya disk/Windows Hall/Programer/Py-cord/KeyBot/bot.py", line 41, in <module>
    async def keyadd(ctx, key: Option(name="ΠΊΠ»ΡŽΡ‡", description="ΠšΠ»ΡŽΡ‡ ΠΎΡ‚ ΠΈΠ³Ρ€Ρ‹ Π² Steam",input_type="Key"),
TypeError: Option.__init__() missing 1 required positional argument: 'input_type'```


How can i fix it?
dull skiff
#

can someone help?

#

nvm

#

i fix it

slender lintel
drifting spindle
drifting spindle
drifting spindle
unborn silo
#

you can use ephemeral messages with embeds right

#

does it only work with ctx.respond

#

or can you send an embed ephermeral

#

?tag emphermal

hearty rainBOT
#

dynoError No tag emphermal found.

unborn silo
#

?tag ephermeral

hearty rainBOT
#

dynoError No tag ephermeral found.

#

dynoError No tag ephermeral found.

unborn silo
#

?tag ephemeral

hearty rainBOT
#

An 'ephemeral' message is one that's only visible to the person who invoked a command. If you ever got a command error with a blue background, this is an example of one.

To do this, set ephemeral=True when you first use an ApplicationContext. (This includes .defer()ing it; the choice of whether a message is ephemeral or not must be made up front. If you .respond() to a deferred message, setting the ephemeral flag at that time will have no effect.)

This is the equivalent of hiddene=True if you're coming from interactions.py

unborn silo
#

lol nvm

slender lintel
#
import discord
import os
import motor
import MongoDB
from dotenv import load_dotenv
from discord.ext import commands
from discord import slash_command
bot = commands.Bot(command_prefix='>', intents=discord.Intents.all(),debug_guilds=[964126154774679582,740616442034258002,965533467557371944], activity=discord.Activity(type=discord.ActivityType.watching, name='Over The Felbcord'))
('mongodb+srv://FoolishBlue:<password>@cluster0.90c9j48.mongodb.net/?retryWrites=true&w=majority')
motor = motor.motor.asyncio.AsyncIOMotorClient(str(bot.connection_url))
db = mongo['felbot']


load_dotenv()
directories = ["./commands", "./Embeds","./Events","./Modals"]

for directory in directories:
   for filename in os.listdir(directory):
      if filename.endswith(".py"):
         bot.load_extension(f"{directory[2:]}.{filename[:-3]}")
@bot.event
async def on_ready():
    print('Connected to bot: {}'.format(bot.user.name))
   
    
@bot.event
async def on_application_command_error(ctx, error):
    if isinstance(error, commands.CommandOnCooldown):
        await ctx.respond(error,ephemeral=True)
    else:
      raise error






bot.run(os.getenv("TOKEN"))```
error:
Traceback (most recent call last):
  File "C:\Users\jackd\Documents\Felbcord Py\main.py", line 4, in <module>
    import MongoDB
ModuleNotFoundError: No module named 'MongoDB'
(in <password> i did have pass but ofc removed it)
#

Idk whats wrong?

languid hollow
#

reinstalll the module i guess?

dull skiff
#

can someone help?

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

class Suggestions(discord.ui.Modal):
    def __init__(self,bot,*args, **kwargs) -> None:
        self.bot = bot
        super().__init__(*args, **kwargs)
        self.add_item(discord.ui.InputText(label="Your Suggestion: ", style=discord.InputTextStyle.long))

    async def callback(self, interaction: discord.Interaction):
        m = await interaction.response.send_message("Suggestion send!", ephemeral=True)
        suggest = discord.Embed(title=f"Suggestion by {interaction.user} Under Review ",color=discord.Color.blue())
        suggest.add_field(name="Your Suggestion: ", value=self.children[0].value)
        suggest.set_footer(text=f"Message id: {m.id} ")
        channel = self.bot.get_channel(987396375069224960)
        embed = await channel.send(" Ping: <@&988496229229002792>", embed=suggest)
        await embed.add_reaction('β˜‘')
        await embed.add_reaction('❌')


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


    @slash_command(name="suggest", description="suggestions")
    @commands.cooldown(1,7200, commands.BucketType.user)
    async def modal_slash(self,ctx: discord.ApplicationContext):
        await ctx.send_modal(Suggestions(self.bot, title="Suggestion"))
        db = db['FelBott']
        mid = await collection.find_one({'_id':{m.id},mdata})
        await collection.insert_one(mdata)
 

def setup(bot):
    bot.add_cog(Suggest(bot))``` Why am i getting all these errors?
#

m is defined lol

dawn wagon
#

Hello guys i have a question. How can i fix the error. I wanted to make an addrole command but if someone e.g. types /addrole asidg then theres an error. I tried to fix it with if member == ctx.guild.members: and else: but that clearly doesnt work. Pls help :P

ornate fog
#

The concerter cant xonvert to member

slender lintel
dawn wagon
#

thank you

#

ill try that

slender lintel
#

But that wont fix it

dawn wagon
ornate fog
dawn wagon
#

and how do i check if its not an member lol

ornate fog
#

The pycord converter already does

#

Just catch the error

dawn wagon
#

how xd

ornate fog
#

In your handler

slender lintel
ornate fog
#

Make a isinstance check

#

In error handler

dawn wagon
#

ok

#

wait

ornate fog
#

?tag python

hearty rainBOT
#

its is very difficult to help you if you don't understand python first.
As it stands, you do not or cannot show that you understand the basic fundamentals of Python. Please continue to learn Python first, as pycord is a Python framework and as such requires that you have a confident grasp on these fundamentals . For now, pause your current project and when you have learned enough Python you can then pick it back up and continue where you left off (if at all possible).** You cannot drive a truck if you do not know how to drive at all.**

cool free resources are
w3school
freecodecamp.org

there are also a lot of python programming tutorials out there a youtube search will give a lot awesome content. If you need help with python there is a python server for that where they will be more that happy to help you with these thing, you can also ask for python help in #881309540639997952.

python server: https://discord.gg/python

slender lintel
#

i was just dumb

#

but now i have this

dull skiff
#

i try to push my bot to heroku but i got this error:
Push failed: cannot parse Procfile.

slender lintel
#

Traceback (most recent call last):
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "C:\Users\jackd\Documents\Felbcord Py\main.py", line 31, in on_application_command_error
raise error
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 993, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 357, in invoke
await injected(ctx)
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 134, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'Bot' object has no attribute 'mongoConnect'

dawn wagon
past gate
dull skiff
ornate fog
dawn wagon
#

Like that?

#

xd

dawn wagon
#

OH

#

MEMBERNOTFOUND

past gate
dawn wagon
#

NOW I GET IT

#

HAHAH

#

thanks

dull skiff
slender lintel
past gate
ornate fog
#

You calling it on the wrong object

dull skiff
#

so why i cant push:")

#

btw ii push with github

past gate
#

not sure

slender lintel
ornate fog
slender lintel
#

Can you explain? Im using a tutoital and tryna understand it but ive got confused

icy sluice
#

how do I use the discord API directly to fetch a user?

ornate fog
#

Please learn basic python.

For real pycord is not a beginner lib.

Its a reference error the bot does not have a mongoConnect method.

dawn wagon
#

Like that @ornate fog ?

#

I dont know any other way

ornate fog
#

You got red lines everywhere.

#

What do you think is my awnser xD

dawn wagon
#

idk

#

xd

past gate
ornate fog
#

For u the same lern basic python first.

Hint: you brackets are wrong

slender lintel
past gate
past gate
ornate fog
#

Nanidafq

past gate
#

the structure goes py if, elif then else

#

not if else elif

slow dome
past gate
#

^

slow dome
#

Just a suggestion

slender lintel
ornate fog
dawn wagon
#

HAHAH TO MUCH ERRORS XDDDDDDDDDDD

slate stirrup
#

?tag install

past gate
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

  2. 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 release candidate:
pip install py-cord==2.0.0rc1

ornate fog
dawn wagon
slow dome
ornate fog
#

The rest you have to figure out by yourself because it depends on your implentation

past gate
slender lintel
ornate fog
dawn wagon
#

i dont get it xd

dawn wagon
#

Yes i looked it up

#

And i understand it

#

but i dont get it the same way

#

xd

slow dome
dawn wagon
#

D:

#

xd

slender lintel
slender lintel
past gate
dawn wagon
#

Like this

#

?

#

;D

slender lintel
#

:O

#

gjgj

#

you are learning

slow dome
#

wow you can read

past gate
#

holy shit

#

no way

slender lintel
dawn wagon
dawn wagon
slender lintel
dawn wagon
#

yes ik

tropic fractal
#

Modals do timeout internally right...
right?

dawn wagon
#

xd

slender lintel
dawn wagon
#

but thats the error "MemberNotFound"

#

what am i doing wrong xddddddddddddddddddddd

tropic fractal
slender lintel
#

did you not do

from discord.ext.commands.errors import MemberNotFound```?
slow dome
#

I think default is 30?

slender lintel
#

smh

dawn wagon
#

my brain cells are 0 rn i swear xd

slow dome
#

b!rtfm pyc modal.timeout

open bearBOT
slender lintel
#

Isn't default like 2 minutes?

#

or 120 secs

slow dome
#

wait you can't change it

#

huh

ornate fog
slow dome
#

because discord limitation

#

at least it's not documented by discord

tropic fractal
#

I'm looking in modal.py and I'm finding no text references to "time(out)"

ornate fog
tropic fractal
#

+1

dawn wagon
#

Now that error is here D: xd

tropic fractal
#

If you dismiss a modal on a command with max concurrency it just makes the wait() hang forever, blocking the entire command

slender lintel
#

you can get the user with ctx.author

slender lintel
#

It only takes in 3 arguments

dawn wagon
#

its an addrole cmd so when smone types !addrole blah then the bot will send "User blah not found" you get me xd?

ornate fog
dawn wagon
ornate fog
slender lintel
tropic fractal
dawn wagon
#

ok thanks

tropic fractal
#

I could go open a PR tbh

dawn wagon
#

will .format() work maybe?

tropic fractal
#

jesus christ how beefy is the repo

slender lintel
slow dome
#

so it's just the bare minimum

tropic fractal
ornate fog
dawn wagon
#

I like that song

slender lintel
#

You would want to delete that

ornate fog
dawn wagon
#

Bruh i hate my life my friend must go know so i cant go on with fixin the damn errors D:

ornate fog
#

As 3rd party packages hell yea
But why as native.
Is so out of scope for pycord

slow dome
#

but ipc, not really

dawn wagon
#

Does anybody know a non webbased VERY GOOD python programm to code together? I searched my ass up but didnt find a single good programm

#

Were using pycharm code together

#

on his pc

slow dome
dawn wagon
#

So when hes not online i cant code

slow dome
#

or just github and anything

past gate
#

just make a github repo

dawn wagon
ornate fog
# slow dome but ipc, not really

Yea same
I can see pages
But ipc is totaly out of scope

But pages also firs better as 3rd party tbh but i can see why its in hwre

past gate
#

so you can make code changes without the need to wait for the other party

dawn wagon
slender lintel
#

not sure if this works if the host is offline

dawn wagon
#

im already doing that w/ my friend

#

but its on his pc

#

so when hes off I CANT CODE :(

snow citrus
#

github is best way

slender lintel
#

agreed

slender lintel
dawn wagon
slender lintel
snow citrus
#

are you searching through bing or what

dawn wagon
#

xd

#

can you code in real time there

slender lintel
#

and your collaborators can also see the changes

dawn wagon
#

bruh thats not what i wanted D:

#

i want real time coiding and a cloud

#

is that so hard xd

rugged needle
#

I just released a new version of my bot to heroku, ended up getting this:

2022-06-21T19:06:51.915449+00:00 app[worker.1]: Traceback (most recent call last):
2022-06-21T19:06:51.915469+00:00 app[worker.1]:   File "/app/DiscordBot.py", line 2, in <module>
2022-06-21T19:06:51.915531+00:00 app[worker.1]:     import discord
2022-06-21T19:06:51.915540+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/discord/__init__.py", line 25, in <module>
2022-06-21T19:06:51.915630+00:00 app[worker.1]:     from .client import Client
2022-06-21T19:06:51.915638+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/discord/client.py", line 53, in <module>
2022-06-21T19:06:51.915745+00:00 app[worker.1]:     from .webhook import Webhook
2022-06-21T19:06:51.915757+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/discord/webhook/__init__.py", line 12, in <module>
2022-06-21T19:06:51.915852+00:00 app[worker.1]:     from .async_ import *
2022-06-21T19:06:51.915861+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/discord/webhook/async_.py", line 49, in <module>
2022-06-21T19:06:51.915971+00:00 app[worker.1]:     from ..channel import PartialMessageable
2022-06-21T19:06:51.916000+00:00 app[worker.1]: ImportError: cannot import name 'PartialMessageable' from 'discord.channel' (/app/.heroku/python/lib/python3.10/site-packages/discord/channel.py)

Still get the same error after reverting the changes

haughty juniperBOT
#
dawn wagon
#

any programm out there?

mild hatch
#

do you mean like a google docs but for coding

dawn wagon
#

YES EXACLTY

slow dome
#

replit

dawn wagon
#

But not repl it

#

it has 1gb ram

#

and is slow as hell

slow dome
#

you are asking for too much

slender lintel
dawn wagon
#

how much is that

slender lintel
#

7$ a month?

#

i think

slow dome
slender lintel
idle linden
#

google console/cloud

rugged needle
dawn wagon
idle linden
rugged needle
#

I updated it to rc1 with this release, but reverting the changes (which also made it to be b4 again) didn’t help either…

dawn wagon
#

Thats just a cload

#

Not a ide

idle linden
#

well ide then you've got jetbrains, vscode, sublime, but as you said they aren't cloud, replit is the only cloud ide that actually lets you run stuff, so you can pick that, or grab yourself a cheap vps or a vps sharing (causes more problems), if you do get a vps, jetbrains and vscode will allow you to deploy and run your stuff easily from the ide

slender lintel
#

error:
TypeError: list indices must be integers or slices, not str

db = ['FelBot']
        collection = db['FelBott']
        m = await collection.find_one({'_id':m.id},m.id)
        await collection.insert_one(m.id)```
Why do i get this error? (I have been tryna figure it out for so long)
idle linden
#

collection = db['FelBott']

slender lintel
#

im proably being stupid

slender lintel
#

Whats wrong on that line?

idle linden
#

you are indexing using a string

slender lintel
#

I am connecting my db, Showing what collection isnt that right? (Could you show an example)

#

@idle linden

rugged needle
slender lintel
frank wadi
#

py-cord==2.0.0b4

#

;o

slender lintel
#

its rc1

frank wadi
#

is rc1 better?

slender lintel
#

yeah, latest

frank wadi
#

a oke

rugged needle
#

that's what I did when I started to get the error, py-cord==2.0.0b4 is what I had before, but yeah, even reverting all my changes back to how it'd been when it worked didn't help...

idle linden
#

I guess I'm too scatterbrained right now to understand your code, unless you're not showing your whole code

tropic fractal
supple ravineBOT
ornate fog
#

Ill take a look when im home

slender lintel
#

it would also make sense as your error is mentioning that you are missing an await

rugged needle
#

Got it fixed by removing unnecessary requirements

tropic fractal
slender lintel
#

ah ok

languid glade
#

how to send dm

slender lintel
languid glade
#

thank you.

slate stirrup
#

?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

  2. 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 release candidate:
pip install py-cord==2.0.0rc1

reef dove
#

I'm currently having issues with my models

whitelisted = fields.ManyToManyField("models.UserModel", on_delete=fields.SET_NULL, null=True)
logs_channel = fields.ForeignKeyField("models.ChannelModel", on_delete=fields.SET_NULL, null=True)

reef dove
#

sorry?

#

this error happens when im trying to init the database...

slender lintel
reef dove
#

just asking because is about the model

icy sluice
#

how do i fetch a users avatar directly from the discord API?

sudden path
#

b!rtfm pyc fetch_user

rugged needle
#

How do I check if a channel is a thread?

past gate
#

b!rtfm pyc thread

past gate
#

b!rtfm pyc channel

past gate
#

im guessing using that?

rugged needle
#

ig that's it, thx

upbeat hill
#

anyone got a pip install for sqlite?

scenic leaf
#

i have a question i found a website called rapidapi and they have this request thingy for python

url = "https://new-world-server-status.p.rapidapi.com/servers"

headers = {
    "X-RapidAPI-Key": "",
    "X-RapidAPI-Host": "new-world-server-status.p.rapidapi.com"
}

response = requests.request("GET", url, headers=headers)

print(response.text)

but i always use

async def Valostrat(self, ctx, map, side):
        async with aiohttp.ClientSession() as cs:
          async with cs.get(f"https://api.diah.info/valorant/roulette.php?format=json&map={map}&side={side}") as r:
            res = await r.json()
            name = res["name"]
            embed=discord.Embed(title="Valorant strats", color=config.EMBED_COLOR)
            embed.set_author(name="BBS", url="https://blackbullstudio.eu",icon_url="https://www.blackbullstudio.eu/wp-content/uploads/2022/06/Master-Black.png")
            embed.add_field(name="Name", value=name, inline=True)
            await ctx.send(embed=embed)

how would i use the above code in the below one ?

#

i think they are kinda the same

#

just a difrent way

languid glade
#

how to show slash commands to only certain roles?

slender lintel
slender lintel
upbeat hill
#

yep sorted it out

#

thanks :)

slender lintel
#

np

slender lintel
scenic leaf
#

okey ill try

vocal crane
#

i got the module downloaded but the import couldnt be resolved

#

idk why it used to work then stopped

slender lintel
#

Error?

vocal crane
#

import discord could not be resolved

slender lintel
vocal crane
#

the latest

#

the git one

slender lintel
#

try 2.0.07b

#

!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
vocal crane
#

i did same thing @slender lintel

#

matter of fact i uninstalled that to install the alpha

#

because it wasnt working

slender lintel
#

You have no other libraries installed?

vocal crane
#

ofc i do

slender lintel
#

*discord libraries

vocal crane
#

nope

slender lintel
#

ok

vocal crane
#

and i used to have it downloaded in an env (pycord) but idk what happened and i cant get in the env anymore

#

@slender lintel all good it was VScode i switched to pycharm and it works

vocal crane
#

thanks for the help!!

slender lintel
#

I tried xd

scenic leaf
#
def get_guild(bot, command):
    """Gets the guild a command belongs to. Useful, if the command was sent via pm."""
    if command.guild is not None:
        return command.guild
    for guild in bot.guilds:
        for channel in guild.voice_channels:
            if command.author in channel.members:
                return guild
    return None

that code will return

    if command.guild is not None:
AttributeError: 'NoneType' object has no attribute 'guild'
#

what is going wrong here ?

#

i run this code

 @commands.slash_command(name = "play", description= "plays music from spotify or youtube", Guild_ids=config.Guilds, pass_context=True, hidden = True)
    async def _play_song(self, ctx, *, link: str):

        current_guild = utils.get_guild(self.bot, ctx.message)
slender lintel
scenic leaf
#

trying now

#

allright that works

languid hollow
#

So for the purge

#

The respond from the ctx doesn't get sent by the bot

#

but deletes the message only

upbeat hill
#

how do you disable a certain button in the same class from another button's callback?

languid hollow
#
for child in self.children:
      child.disabled = True

await.....
upbeat hill
tired dock
#

Does guild.get_member() make an API call each time?
Or is it cached?
Asking to avoid hitting a ratelimit

languid hollow
#

and disable it that way

#

as it interates through the self.children compare it with the button label that you want to disable

upbeat hill
#

Ah okie. Thanks

slender lintel
languid hollow
#

Has anyone used dynamic cooldown? I want to know if dynamic cooldown refreshes the cooldown each time a new value is given to the command

languid hollow
#

Yes to both of the questions?

slow dome
languid hollow
#

would you need any event to update it or does it do it on its own, I have not used it

#

so i'm quite lost

slow dome
languid hollow
slow dome
#

So you just put a function there instead of an actual number

#

the function should take a discord.Message and return a cooldown

#

or None

languid hollow
#

can you give an example please

slow dome
#
def get_cooldown(message):
  if message.author == 123:
    return discord.ext.commands.Cooldown(1.0,1)
  else:
    return discord.ext.commands.Cooldown(5.0,1)

@bot.command()
@discord.ext.commands.dynamic_cooldown(get_cooldown, type=BucketType.user)
async def command_name(ctx):
  pass
#

ofc bot has to be defined and discord and buckettype imported

languid hollow
#

Awesome I understand it!, Thank you!

idle linden
#

Why is this happening to my test account, I am in a server with it, and i don't think bots can turn that on since they can't have friends

dull skiff
#

can someone help me? i want to deploy my bot to heroku but i got some error

drifting spindle
#

You haven't entered correctly buildpacks

#

And also show your runtime.txt

dull skiff
#

what should i write

#

different tutorial different method

dull skiff
#

and also i got some error while run my bot(no error yesterday)

#

the error says raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

#
async def play (ctx):
        try:
            voice_client = await ctx.author.voice.channel.connect()
            voice_clients[voice_client.guild.id] = voice_client
        except:
            print("error")
        try:
            url = ctx.message.content.split()[1]

            loop = asyncio.get_event_loop()
            data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=False))

            song = data['url']
            player = discord.FFmpegPCMAudio(song, **ffmpeg_options)

            voice_client.play(player)
            await ctx.reply(f"Playing {url}", mention_author=True)

        except Exception as err:
            print(err)```
and the only one code that i use loop is this
keen root
dull skiff
#

but same error

drifting spindle
drifting spindle
#

I already said why you use ytdl player

#

It's cheap

dull skiff
#

so what should i write in the runtime

dull skiff
drifting spindle
#

You will get some tutorial

drifting spindle
dull skiff
#

and i dont see they make runtime.txt file

drifting spindle
dull skiff
fresh brook
#

How come printing the dm channel (ctx.channel) returns Direct Message with Unknown User ?

#

Full code

    @commands.slash_command(description = 'Report Game')
    async def report_game(self, ctx):
        await ctx.respond("Please follow the instructions as they appear.", ephemeral = True)
        def check(msg):
            print(ctx.channel)
            return msg.author == ctx.author and msg.channel == ctx.channel
        await ctx.send("Please send your zip file with replays inside.")
        message = await self.client.wait_for("message", check = check)
    
        print("PASSED")
drifting spindle
fresh brook
#

?

fresh brook
#

Do I have to set a timeout? Ive never had to before

drifting spindle
supple ravineBOT
#

Here's the wait for event example.

fresh brook
drifting spindle
fresh brook
#

ah

#

Also ty for reminding me about the timeout

#

Will implement it

dull skiff
#

i just succesfully deploy my bot to heroku but why my bot is still offline?

dull skiff
#

sorry my brain too small i forget

dull skiff
drifting spindle
dull skiff
#

from heroku deploy its say succes deploy to heroku

drifting spindle
dull skiff
#

from setting?

dull skiff
drifting spindle
supple ravineBOT
#
Converts a message's components into a :class:`View`.

The :attr:`.Message.components` of a message are read-only
and separate types from those in the ``discord.ui`` namespace.
In order to modify and edit message components they must be
converted into a :class:`View` first.

Parameters
-----------
message: :class:`discord.Message`
    The message with components to convert into a view.
timeout: Optional[:class:`float`]
    The timeout of the converted view.

Returns
--------
:class:`View`
    The converted view. This always returns a :class:`View` and not
    one of its subclasses.```
#

Couldn't find documentation for discord.ui.View.refresh.

dull skiff
slender lintel
#

what version of pycord has the most fetures?

#

?instakk

#

?install

#

?tag install

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

  2. 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 release candidate:
pip install py-cord==2.0.0rc1

drifting spindle
#

!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
drifting spindle
#

last one

slender lintel
#

sooo whats best one?

#

ok

drifting spindle
#
msg = await channel.fetch_message(message)
view = discord.ui.View.from_message(msg)
await db.buttonroles.insert_one({"guild": ctx.guild.id, "channel": channel.id, "role": role.id, "name":name})
view.add_item(RoleButton(role, name))
await msg.edit(view=view)
for child in view.children:
child.add_item(Role)
self.bot.add_view(view)
await ctx.respond("Done")

When i add button to a message the button will work but old buttons are stop why ?

#

if anyone knows help me

slender lintel
#

@drifting spindle

#

What has channged?

drifting spindle
#

Yes

slender lintel
#

in dev

drifting spindle
slender lintel
drifting spindle
slender lintel
#

oh

#

so it removed nothing

#

from old version?

drifting spindle
vivid nacelle
drifting spindle
drifting spindle
#

But when i restart all button working

vivid nacelle
#

Oh that’s not my topic then.
@inland laurel care to explain him?