#discord-bots

1 messages Β· Page 787 of 1

slate swan
#

πŸ‘οΈ πŸ‘οΈ

velvet tinsel
#

import nextcord as disnake

arctic wraith
#

personally just reppin' disnake

#

have to support them somehow, haha

velvet tinsel
#

import life as pytho-

vivid jetty
#

but my system is easier, all I have to do is this and I have working slash commands:

slash_int.BotClient.CLIENT = client
slash_int.BotClient.TOKEN = TOKEN
slash_int.BotClient.VERBOSE = True
slash_int.BotClient.AUTO_UPDATE_GUILDS = True
slash_int.BotClient.RATE_LIMIT_MODE = 1
slash_int.BotClient.DEFER_AFTER = 1.5
slim ibex
#

import python as c#

vivid jetty
#

and the last 4 lines are all unnecessary settings

arctic wraith
#

I mean

vivid jetty
#

the downside is i can only play with the new toys for slash commands

#

so I cant add menus and buttons when responding to messages

slate swan
#

why even make a third party lib for slash commands that any fork has

solid crypt
#

btw u guys know the diffrence between bot.command and client.event?

vivid jetty
#

and being bored

arctic wraith
#
bot = disnake.Bot()

@bot.slash_command()
async def ping(inter: disnake.CommandInteraction):
    """Pongs your Ping!"""
    await inter.response.send_message("Pong!")

bot.run(<token>)
```and you have working slash commands
vivid jetty
#

yeah ill defs need to check out disnake

arctic wraith
#

iirc nextcord syntax is very similar though

vivid jetty
#

im not scanning 20k lines of code for bugs tho

#

so its either drop in or nothing lol

#

Im just a hobby programmer, danny come back picardcrying

solid crypt
arctic wraith
#

somehow most of my bot's code isn't tied to any specific fork so I could probably jump ship in <30 minutes

slate swan
#

danny wont

arctic wraith
#

which is also the only reason I'm considering migrating to hikari

vivid jetty
#

yeah

#

I mean again, I am enjoying my own solution to this, it just sucks I cant use it for normal message commands

#

thats why I was wondering if there is a 100% drop in

left crater
#

How can i detect only images in previous messages

#

can i use channel.history

stable igloo
#

Hi, 'Im a beginner, and I wanted to add a "daily" command to a bot using mongoDB as a database
Here is what I have:

cluster = pymongo.MongoClient("the url")
db = cluster["UserData_db"]
coll = db["UserData_coll"]
@client.command()
@commands.cooldown(1, 60*60*24, commands.BucketType.user)
async def daily(ctx):
    daily_earn = randint(20,30)
    await ctx.send(f"Here is your daily income, **{daily_earn}**")
    await coll.uptade_one({"_id": ctx.author.id}, {"$inc": {"money": +daily_earn}})

But when I execxute the command on discord there is this error :
Command raised an exception: TypeError: 'Collection' object is not callable. If you meant to call the 'uptade_one' method on a 'Collection' object it is
failing because no such method exists.
I don't know if I should post this here or in #databases

languid elk
#

pls rob

#

okayyy

#

pls bal

#

okayyyyyyyyyyy

slate swan
#

you can use a member argument

#

make it a int

#

!e

a = 9.0
print(int(a))
unkempt canyonBOT
#

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

9
slate swan
#

then whats the problem?

#

use len

#

len(message.content)

#

!e

print(len("string"))
unkempt canyonBOT
#

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

6
slate swan
#

show

#

code

#

return your bots msgs

#

its detecting all messages including its own

quick gust
#

lines or letters?

slate swan
#

yes

#

it clearly shows

#

so you're trying to make a max line rule

#

no \n is a built in to make a new line

#

dont you have to calculate how much letters the msg has and split them to know how many new lines theres in a msg since discord has a max line when you hit a max chars in a line

desert heart
#

String.count("\n") would give you the number of new lines, including any blank lines

slate swan
#

but message.content doesnt return \n

#

its a string of a msg

desert heart
#

Yes it does return new lines. I'm not sure what you're talking about

slate swan
#

message.content doesnt return \n

#

doesnt discord have a max chars then it makes a new line so why not calculate the amount of chars and split it to know the amount of lines

#

or is there a better way?

desert heart
#

I still don't get what you mean. The new lines are absolutely returned in the content..If you're instead talking about wrapping lines then you should be clearer about that

#

?

maiden fable
#

Β―_(ツ)_/Β―

desert heart
#

Clearly not when someone is denying the existence of new lines in message content. But I think they are talking about wrapping

slate swan
#

like i said divide the amount of characters?

maiden fable
slate swan
#

does message.content even return \n?

desert heart
#

I showed you earlier

maiden fable
#

Oh it works

#
"a"
"b"
return ctx.message.content.count("\n")
#

this works

slate swan
#

let me check real quick

maiden fable
#

will return 4 since there is also the block quotes

slate swan
#

where is it

#

ddocs?

#

πŸ‘οΈ πŸ‘οΈ

#

oh lol

maiden fable
#

Lmao

slate swan
#

ill try it

maiden fable
#

U need to use discord web BTW

#

They removed dev tools in the app

slate swan
maiden fable
slate swan
#

what date

maiden fable
#

Since discord app is built on chromium

#

Idk a few months or smth ago?

slate swan
#

print(message.content.count("\n"))

#

ic

#

thats cool

#

can you send the whole payload or is that all?

#

lol

#

thank you lol

#

you made me learn how payloads look in discord

#

later lol

maiden fable
slate swan
#

i just didnt know what it had in it

#

i just didnt know how the response looks like bruh

maiden fable
#

!d discord.Guild.get_thread

unkempt canyonBOT
slate swan
#

hwo to do i make the bot deletes its own message

#

pls osmeone help

#

ctx preferally

slate swan
#

thats user input

#

not bot deleting own message

#

examlpe

#

$dog
asdasd <- delete this message from bot

#

next mesaseg

slate swan
keen talon
#

A = await ctx.send()
A.delete

#

Sorry not on pc pithink

slate swan
#

cant you do it directly and just use the delete_after kwarg

slate swan
#

@keen talon

keen talon
#

Not like that πŸ™‚

slate swan
#

disnake git examples😳

slate swan
keen talon
slate swan
weary birch
#

okay can anyone tell me why clonechannel command dont move channel to the place where it was before?

quaint scaffold
#

it just doesn't

weary birch
#

but it do move back to place for galaxies bot, why it dont for me?

glad palm
#

hey guys i want to make a /clear command for my bot, im having some trouble with the check= attribute of the .purge() function, can i have some help?

quaint scaffold
#

What is galaxies bot?

weary birch
#

iguess but that doesnt matter.

weary birch
quaint scaffold
#

Because the programmer coded it to

#

Clone isn't meant to move the channel, just like when you do it manually. You need to manually (code) it to do so

winter kiln
#
@client.command()
async def unban(ctx,*,member):
    banned_user = await ctx.guild.bans()
    member_name, member_disc = member.split("#")

    for ban_entry in banned_user:
        user = ban_entry.user

        if(user.name , user.discriminator) == (member_name,member_disc):
            
            await ctx.guild.unban(user)
            await ctx.send(f"unban {user.mention}#{user.discriminator}")
            link = await ctx.channel.create_invite(max_use = 2)
            await ctx.send("invite sent")
            await member.send(link)
winter kiln
slate swan
#

you can't, unless the bot is in another server in which that person is as well

winter kiln
#

You cant send an invite link using just username and tag?

brisk helm
#

<@&831776746206265384>

#

could you do something pls

slate swan
#

i need help withs this

daring olive
#

hello @slate swan, what are you doing?

slate swan
#

i am trying to run bot on a vps

slim ibex
quaint scaffold
daring olive
#

please respect the channel topics and use english to the best of your ability as per our #rules . thank you

slate swan
#

from distutils import command
import discord, os, json
from discord.ext import commands
from discord.ext.commands import CommandNotFound, CommandInvokeError
import datetime as datetime
from discord_components import (DiscordComponents, Button, ButtonStyle, Select, SelectOption)

intents = discord.Intents(messages=True, guilds=True, reactions=True, members=True, presences=True)
client = commands.Bot(command_prefix='=', intents=intents)
client.remove_command('help')

@client.event
async def on_ready():
DiscordComponents(client)
print(f'Launched: {client.user.name} // {client.user.id}')
await client.change_presence(activity=discord.Game(name=f'Soporte de GamaLifeRP'))

slate swan
quaint scaffold
slim ibex
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

quick gust
#

The error must be on the line above, show the relevant code

slate swan
#

@slim ibex anyway i can message you?

slim ibex
#

for?

slate swan
#

about your rogue project

slim ibex
#

uhh ok

slate swan
slim ibex
#

added

final iron
cedar stream
slate swan
dire folio
#

The error would be that one of the values is empty

#

For the embed

cedar stream
#

Can you just send the part thst isnt working

dire folio
#

Idk what part isn't working cause sometimes it works sometimes it doesn't

cedar stream
#

Ss the error

dire folio
#

One sec

dire folio
# cedar stream Ss the error
Ignoring exception in command apply:
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "main.py", line 832, in apply
    await channel.send(embed=emb3)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/abc.py", line 1065, in send
    data = await state.http.send_message(channel.id, content, tts=tts, embed=embed,
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 254, in request
    raise HTTPException(r, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embed.fields.1.value: This field is required

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

Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embed.fields.1.value: This field is required
cedar stream
#

There is way too much code, you could just put adding fields into a loop @dire folio

slate swan
maiden fable
#

wym lock?

cedar stream
maiden fable
slate swan
#
>>> import discord
>>> from discord.ext import commands
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'commands' from 'discord.ext' (unknown location)

is there something wrong with this code? it aint supposed to error out, i got pycord installed

outer flint
#

so, question, I was able to fully setup the bot on a fresh Fedora 35 pc
able to install all the requirements and dependencies
using python 3.10

when I lunch the bot I receive this error I've never seen thinku

cedar stream
maiden fable
#

Tf cannot make a thread???

#

Or my eyesight is weak?

#

Oh

cedar stream
maiden fable
#

I am the owner :stare:

#

!d discord.Thread.edit

unkempt canyonBOT
#

await edit(*, name=..., archived=..., locked=..., invitable=..., slowmode_delay=..., auto_archive_duration=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the thread.

Editing the thread requires [`Permissions.manage_threads`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_threads "discord.Permissions.manage_threads"). The thread creator can also edit `name`, `archived` or `auto_archive_duration`. Note that if the thread is locked then only those with [`Permissions.manage_threads`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_threads "discord.Permissions.manage_threads") can unarchive a thread.

The thread must be unarchived to be edited.
cedar stream
#

U may need community or something, idfk

maiden fable
#

I guess use this? @slate swan

#

Try using the locked arg

cedar stream
#

Or channel needs to be set up properly

maiden fable
#

Sure then (to your question in the DMs)

cedar stream
slate swan
cedar stream
#

Make one

slate swan
#

hmm

final iron
#

Not having a venv is a whole other issue

slate swan
#

i legit just got pycord installed as an external package

#

shouldnt be that much

final iron
#

Using pycord is a whole other issue

slate swan
#

nice

cedar stream
#

Lmfao

final iron
#

🧍

#

What you laughing at huh

dire folio
maiden fable
#

Whenever am here, why is there always either sarcasm or RPing going on

final iron
#

It's your aura

maiden fable
#

Ig this channel is just special

final iron
#

Because so many developers who create discord bots are new to programming

#

That's my guess

maiden fable
#

Ig

cedar stream
final iron
#

Yeah that's what I meant

#

They're so new they don't know anything

#

So you have to hold their hand through everything

cedar stream
#

Why bother with learning oop if u can just jump into asynchronous programming

dire folio
# cedar stream Elaborate?

I mean like in the previous code I sent, after answering a question the next embed would change (Enter your answer below) into your answer

final iron
#

Why bother learning python if you can just make a discord bot

cedar stream
#

Lmfao

zenith basin
dire folio
zenith basin
#
async def addxp(self, message, amount, user: commands.Greedy[discord.Member]):
members = user or [message.author]
 if isinstance(lvl, int):
                    for k in members:
                        for i in range(len(info)):
                            member = k
                            user_id = robloxpy.User.External.GetID(str(member.display_name))
                            #check if info[i][0] is nonexistent
                            try:
                                info[i][0]
                            except IndexError:
                                print("IndexError")
                                message.send("You have reached the max RANK! NICE")


                            if info[i][0] in [role.name for role in member.roles]:
                                if i != lvl:
                                    await member.remove_roles(discord.utils.get(member.guild.roles, name=info[i][0]))
                            if i == lvl:
                                await member.add_roles(discord.utils.get(member.guild.roles, name=info[i][0]))

Not giving or take role when u are not author

cedar stream
dire folio
maiden fable
dire folio
#

Oh

#

I thought it would be much harder

slate swan
#

Bc code will look chunky without variables

#

For example if I was to print a paragraph I would use a variable

final iron
slate swan
dire folio
#

I infact do know what one is

#

But I still have no idea how I would change the value @cedar stream

#

I got the easy bit which is the questions

quick gust
#

u just redefine it...?

cedar stream
quick gust
#

!e

a = "letter"
a = "not a number"
print(a)
unkempt canyonBOT
#

@quick gust :white_check_mark: Your eval job has completed with return code 0.

not a number
marble pilot
#

bruh thats basic python. if u dont even know how to change the value of a variable why do u even try discord.py

dire folio
#

Obviously ik how to redefine a variable

quick gust
#

I think I am not understanding your question then

marble pilot
#

ye lol

dire folio
#

this is what i have

for item in h_list:
  emb.add_field(name=item, value='(Enter your answer below.)')
  await channel.send(embed=emb)
  msg = await client.wait_for('message', check=check)

how would i change the value now

dire folio
#

the embed

marble pilot
#

just say emb =

cedar stream
#

embed = discord.Embed()

#

Boom, new instance

marble pilot
#

@dire folio u seem to me like u dont know python

dire folio
#

sorry but it's just not adding up in my head

marble pilot
#

bro

#

what

slate swan
#

Hey, so I need help with something. I have Pycord 2.0, and there is almost zero documentation for dropdowns (Selects) online. When I select something from the dropdown, the message changes (the callback works), but the selected option in the view itself doesn't.

# Imports

import discord
from discord import SelectOption

# Dropdowns

class HelpDropdown(discord.ui.Select):
    def __init__(self):
        super().__init__(
            options=[
                SelectOption(label="General", default=True),
                SelectOption(label="Economy"),
                SelectOption(label="Games"),
                SelectOption(label="Mail"),
            ],
            min_values=1,
            max_values=1
        )

    async def callback(self, interaction):
        if self.values[0] == "General":
            description = "**!help** :ArrowDown: \nShows this message."
        elif self.values[0] == "Economy":
            description = "Coming soon!"
        elif self.values[0] == "Games":
            description = "Coming soon!"
        elif self.values[0] == "Mail":
            description = "Coming soon!"
        
        embed = discord.Embed(description=description, colour=discord.Colour.blue())
        embed.set_footer(text="Do \"!help <command>\" to learn more about a command.")

        await interaction.response.edit_message(embed=embed)
slate swan
#

Is it a help server for Pycord, or a help server for their own wrapper?

marble pilot
slate swan
#

Ya, but a maintained version of it.

#

The Pycord Discord server has yet to help me.

marble pilot
#

well i dont really remember how to use pycord cuz the last time i used interactions was when discord components still existed

final iron
#

Just don't use pycord, simple

marble pilot
#

well it is an option^

#

lol

slate swan
final iron
#

!pypi disnake

unkempt canyonBOT
slate swan
#

Is it basically like another maintained version of Discord.py?

#

Because I don't want to rewrite my entire code.

#

πŸ˜…

final iron
#

It's a fork

slate swan
#

Oh ok.

#

Say less!

final iron
#

Just refactor discord to disnake and you're off to the races

slate swan
#

Ima test right now.

#

Thank you so much, kind sir!

slate swan
cedar stream
#

Lmao everyone switching to disnake

#

Probably best option

slate swan
#

Not mecreepy

cedar stream
slate swan
#

how do i make it so that any channel that starts with verify

#

it sends the embeds only once

#

kk thanks in advanced

soft vortex
#

How can I learn .py quickly?

maiden fable
#

!resources

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

left crater
#
async def on_message(message):
    if len(message.attachement) > 0 :
        await message.channel.send(content=message.attachments[0].url)```why is this not working?
slate swan
slim ibex
#

πŸ—Ώ

slate swan
#

depends on how fast you learn how much time you have how much passion you have and overall you cant learn it quickly since theres so much to learn

cunning osprey
#

what library are you guys using to make bots after discord.py got discontinued?

unkempt canyonBOT
cunning osprey
#

whats the difference between disnake and pycord and etc

final iron
#

Disnake is better

#

Boom easy

cunning osprey
#

oh

#

... πŸ˜…

final iron
#

I actually don't know why it's better

#

You'll have to find someone smarter than me

cunning osprey
#

okay aight ill just trust u

slate swan
#

channel not defined

#

@final iron

final iron
slate swan
#

bc u are a genuis

#

like einstein

#

or someting

final iron
#

Mhm

#

Can I see the entire function?

slate swan
#

So umm........I'm just rewriting my bot and now I'm not able to trigger events that are in cogs ;-;

#

kk

final iron
#

Channel should be defined

slate swan
#

yes but its not good

final iron
unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

final iron
#

Put the code in here

slate swan
#

kkkk

maiden fable
final iron
#

Pastebin fucks with formatting

slate swan
dry kelp
#
              if len(msg) > 30:
                em = discord.Embed(title="![error](https://cdn.discordapp.com/emojis/929402122074730638.webp?size=128 "error") Welcomer Error!", description=f"You can't go over 30 seconds!", color=discord.Color.red())
                await ctx.reply(embed=em, mention_author=False)
                return
final iron
dry kelp
#

why is this not checking?

slate swan
maiden fable
slate swan
slate swan
maiden fable
#

yea

slate swan
slate swan
maiden fable
#

I mean, its a common mistake many people can do

dry kelp
#
              if len(msg) > 30:
                em = discord.Embed(title="![error](https://cdn.discordapp.com/emojis/929402122074730638.webp?size=128 "error") Welcomer Error!", description=f"You can't go over 30 seconds!", color=discord.Color.red())
                await ctx.reply(embed=em, mention_author=False)
                return
maiden fable
slate swan
final iron
#

Maybe I'm missing something but channel should be defined

slate swan
#

where???

dry kelp
#

is not checking shit

final iron
#

It's commands.Context not Contexts

dry kelp
#
              if len(msg) > 30:
                em = discord.Embed(title="![error](https://cdn.discordapp.com/emojis/929402122074730638.webp?size=128 "error") Welcomer Error!", description=f"You can't go over 30 seconds!", color=discord.Color.red())
                await ctx.reply(embed=em, mention_author=False)
                return
#
            if welcome_db is not None:
              sql = (f"UPDATE welcome SET autodel = ? WHERE guild_id = ?")
              val = (msg, ctx.guild.id)

              if len(msg) > 30:
                em = discord.Embed(title="![error](https://cdn.discordapp.com/emojis/929402122074730638.webp?size=128 "error") Welcomer Error!", description=f"You can't go over 30 seconds!", color=discord.Color.red())
                await ctx.reply(embed=em, mention_author=False)
                return

              em = discord.Embed(title="![Ver](https://cdn.discordapp.com/emojis/858069322512859146.webp?size=128 "Ver") Welcomer Successful!", description=f"Auto Delete has been set!", color=discord.Color.from_rgb(black1, black2, black3))
              await ctx.reply(embed=em, mention_author=False)
            cursor.execute(sql, val)
            db.commit()
            cursor.close()
            db.close()
slate swan
#

thats what i did

final iron
#

See if you get an error

dry kelp
#

hellooooo???

maiden fable
#

Hi

dry kelp
#

can i get some help w that?

final iron
#

?

slate swan
dry kelp
final iron
# slate swan

When you're running the command you need to include channel

dry kelp
slate swan
#

where

dry kelp
#

[prefix]command #channel

final iron
#

When you're running the command

slate swan
#

if its not a specifitic chanensl

#

like mulitple chanenels

final iron
#

What?

dry kelp
#

????

slate swan
#

like

#

@final iron

#

plenty of channels

final iron
#

ok and?

slate swan
#

i cant put 1 channel

final iron
#

Then add *, before channel in your function arguments

#

I'm not sure how to describe what it does

slate swan
#

how do i make it one channel aggian

#

channel = "chanenl"

#

idk

final iron
#

What

vale wing
final iron
slate swan
#

ahaahaah

final iron
#

I already told you. You need to pass in channel when you're running the command

slate swan
#

@final iron

final iron
#

What

slate swan
#

i put it there

final iron
#

Put what in there

slate swan
#

channel

final iron
#

Okay?

slate swan
#

and its not defined

#

and i will soon cry

final iron
#

It is defined

#

That's not the error you're getting

slate swan
#

true

final iron
#

You made channel a required argument

slate swan
#

yes

#

?

final iron
#

When you run the command you need to add an argument for channel

slate swan
#

wait

#

wat

#

thats not what i wanted

final iron
#

Then change your code

slate swan
#

Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
How do I get the isinstance?

#

how do i make it so that when the embed is sent it looks for text

#

Trying to kick the bot or higher members

#

and if that text == something then it sends something

#

theres 3 embeds

#

in one command

slate swan
final iron
#

!d discord.ext.commands.MissingPermissions

unkempt canyonBOT
#

exception discord.ext.commands.MissingPermissions(missing_permissions, *args)```
Exception raised when the command invoker lacks permissions to run a command.

This inherits from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
final iron
slate swan
#

discord.ext.commands.errors.CommandInvokeError

final iron
#

Can we see how you're trying to do it?

slate swan
#
    @kick.error
    async def kick_error(self, error, ctx):

        if isinstance(error, commands.MissingPermissions):

            em0 = discord.Embed(title=f":no_entry: Error",
                                description=f"You do not have the required permissions.",
                                color=col_error)

            await ctx.reply(embed=em0, mention_author=False)

        if isinstance(error, commands.CommandInvokeError):

            em1 = discord.Embed(title=f":no_entry: Error",
                                description=f"You can't kick that member.",
                                color=col_error)

            await ctx.reply(embed=em1, mention_author=False)
final iron
#

Well

#

!d discord.ext.commands.CommandInvokeError

unkempt canyonBOT
#

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

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

So what about it doesn't work?

slate swan
#

raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

final iron
#

It's still sending in console?

slate swan
#

Yess

vale wing
#

@slate swan sorry couldn't find it

#

It has the special attribute for unwrapping

#

I don't remember it however

final iron
#

Are you sure it's from the kick command?

slate swan
#

it is

pliant gulch
#

!d discord.ext.commands.CommandInvokeError.original

slate swan
#

i use cogs and i only have kick loaded

unkempt canyonBOT
pliant gulch
#

"Unwraps" to get the actual error

slate swan
#

403 errors raise when you dont have permission to do such a request

pliant gulch
#

All the errors are just wrapped with CommandInvokeError

slate swan
#

πŸ‘οΈ πŸ‘οΈ

#

nice

#

sure

#

well youll have to add the kwargs in the super init

#

so the prefix and other kwargs

#

you cannot do such a thing

#
class Application(Bot):
    def __init__(self):
        super().__init__(command_prefix="")β€Š
#

example

vale wing
#

@slate swan found it

error = getattr(error, 'original', error)```
You need to unwrap the HTTP exception I believe
slate swan
#

what people do is they run a method which runs the bot in another file and not an instance

#

wdym?

echo wasp
#

how would i use the same json file for 2 different bots in 2 different folders

vale wing
#

Ok sure

vale wing
slate swan
#

just add a prefix and use slash commands?

slate swan
vale wing
#

Not recommended tho

slate swan
#

what ever i do

#

yes it is

#

adding the prefix and just add slash commands?

#

thats what im saying????

echo wasp
vale wing
#

!d disnake.ext.commands.slash_command ?

unkempt canyonBOT
#

@disnake.ext.commands.slash_command(*, name=None, description=None, options=None, default_permission=True, guild_ids=None, connectors=None, auto_sync=True, **kwargs)```
A decorator that builds a slash command.
slate swan
#

i am you add a random prefix and add slash commands?

pliant gulch
#

why did disnake put slash commands into the commands extension

#

slash commands are native

vale wing
echo wasp
maiden fable
vale wing
#

On a server just copy the absolute path for the file

slate swan
#

just check the python bot they use that method

#

like check the bot file and the main file

unkempt canyonBOT
slate swan
#

and you run the method in the file yes

#

why would it

vale wing
#

@slate swan are you a beginner in bot development

slate swan
#

no it doesnt?

#

your using the class to run a method inside it in another file which the run method had the dpy run to run the bot?

vale wing
#

I had a stroke reading this lmao

slate swan
#

not sure i dont do it like that

vale wing
#

@slate swan I don't quite understand what are you trying to do, but it really seems like you are trying to implement the cogs and extensions in a weird way sorry if I am wrong tho

slate swan
#

not ctrl c and ctrl v use it for guidance

slate swan
#

but hes not sure how to run the bot

vale wing
#

Superclass has run method

#

Put the super().run() into the end of the overwritten method

slate swan
#

yes so you do

BotSubclass().run()

which the run method has the dpy run method

vale wing
#

It inherits from superclass

slate swan
vale wing
#

Not really

#

Not sure what do you need it for tho

slate swan
#

a run method from the class that inherits the run method to run the bot

vale wing
slate swan
vale wing
#

I actually got invited to the development of this but when I saw AI and IDE I decided not to get in as I don't know a lot about that

slate swan
#

i got kicked for no reason lol

#

hold up

pliant gulch
#

Left that server cause someone in there can't remember who was acting kinda douchey πŸ‘οΈ πŸ‘οΈ

slate swan
# slate swan hold up
 ​    ​def​ ​run​(​self​) ​->​ ​None​: 
 ​        ​self​.​setup​() 
 ​        ​super​().​run​(​TOKEN​, ​reconnect​=​True​)

and you run the method

pliant gulch
#

no

slate swan
#

who

#

in a main file

pliant gulch
#

Dude with a picture of a goat or something as their pfp iirc?

slate swan
#

that server is kinda toxic

#

bot file != main file

#

you run the bot in the main and the bot file is the subclass

vale wing
#

That's about bot files hierarchy troll

slate swan
#

cogs

#

how do i wait for something in message

#

how do I kill a background task?

#

and if its not that it will send invalid

coral vessel
#

help my command did't work on Visual Studio its say command not found
but if i try on replit, its work, what wrong in my visual studio code?

@bot.command()
@commands.has_permissions(administrator=True)
async def test(ctx):
await ctx.send("test")

slate swan
#

you make a setup function with a for loop which loads all cogs in a cogs folder and you run the setup function in the run method

vale wing
unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

slate swan
#

bot wait for

#

message in context

#

no such thing

#

context is the context of a command

#

i meant context

#

as the word

#

not the python thing

#

then what do you want?

#

ok

#

example

#

if the message CONTAINS

coral vessel
slate swan
#

dog for example

#

it sends something

vale wing
#
if 'dog' in message.content```
slate swan
#

and if content not dog

#

make a check and so what exe said

#

invalid

#

else

vale wing
slate swan
#

i have 3 embeds

#

i want it to be linked to the 3rd one

slate swan
vale wing
#

@slate swan see check param of the wait_for in docs also please look at the examples in there

slate swan
#

?tag wait_for

novel apexBOT
#

This is not a Modmail thread.

slate swan
# slate swan

no you use the wait for and make a function and you use the check kwarg

coral vessel
slate swan
unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
slate swan
#

kinda confused

vale wing
#

@coral vessel alright there are no visible issues with your code, but do you get any errors?

slate swan
#

the connection sure

slate swan
#

hey folks sorry
is it possible to start a background task and then kill that same task later

coral vessel
vale wing
slate swan
#

🧠

vale wing
#

So the bot runs?

#

Sorry wrong

vale wing
slate swan
#

example btw

slate swan
vale wing
#

Shouldn't it be 'on_message' not just message?

slate swan
#

nope

vale wing
slate swan
#

check if message contains

#

right

slate swan
vale wing
#

That's da lambda function πŸ₯΅

slate swan
#

@vale wing on wait for events are like that
'on_raw_reaction'
would be
'raw_reaction'

sick birch
slate swan
#

^

#

and hey Robin hru

sick birch
#

hey πŸ‘‹ i'm good, you?

pliant gulch
sick birch
#

yeah not sure why they do it since the gateway just gives you events like MESSAGE_CREATE

slate swan
pliant gulch
#

Yea and plus all the events are string literals in discord.py

#

So you don't get auto suggestions from your IDE

#

Shameless plug but rin uses enums 😎

slate swan
vale wing
#

@slate swan so basically the function you parse to check accepts an argument depending on your event, in this case it will accept single argument Message. Then the function just returns whether the message matches your needs or not. If it does, the event waiter stops, if not it continues to wait for the event to make the check function return True

pliant gulch
slate swan
slate swan
pliant gulch
coral vessel
# vale wing So the bot runs?

yes, bot run, without error, i just can't call command its said "Command not found"
if running on VS Code, but its running well and command work with Replit.

slate swan
#

i want message contains

slate swan
# slate swan

nooo just message like the event youre waiting for

vale wing
slate swan
#

yes

slate swan
#

but i want it to be that

slate swan
#

go to vc 1

pliant gulch
slate swan
#

why is my mic suppressed

pliant gulch
#

Caching is a library abstraction

slate swan
#

?????

pliant gulch
#

But it's best to cache anyways

slate swan
pliant gulch
#

It would be stupid to not do so

vale wing
slate swan
#

how

#

kk

pliant gulch
slate swan
#

not sure what you ment

pliant gulch
#

It's a design choice to cache things

coral vessel
pliant gulch
#

A good design choice

slate swan
pliant gulch
#

Me

#

I told the code to cache

slate swan
#

bro😳

pliant gulch
#

πŸ‘οΈ πŸ‘οΈ

echo wasp
slate swan
#

@pliant gulch so gateway sends a msg and the bot has a message create event and it caches it?

#

wait no

#

bots dont cache msgs

pliant gulch
#

A message is sent > Gateway dispatches MESSAGE_CREATE > wrapper says oooh we got a new message. Let's shove this into the cache

slate swan
pliant gulch
#

Or somewhere else

#

In my old wrapper the cache was inside of the bot

#

Now the cache is inside of the object itself

#

E.g bot.messages vs rin.Message.cache

slate swan
pliant gulch
#

Natively no

#

Your wrapper does the caching

slate swan
#

do it does cache it but the bot doesnt have access to it?

pliant gulch
#

bro

slate swan
#

😳

pliant gulch
#

the Gateway only SAYS a message got created and sends back the message data

slate swan
#

yes

pliant gulch
#

It's UP to the WRAPPER/LIBRARY to cache it

slate swan
#

yes

pliant gulch
#

E.g the maintainers of said wrapper/library decide to make code that caches

#

The API by itself does not provide caching

slate swan
#

ik

pliant gulch
#

I'm so confused by what you asking

slate swan
pliant gulch
#

Your last question on whether or not the bot has access to the cache is dependent on the wrapper. It makes sense that the bot has access but there is always a case where someone decides not to

slate swan
#

nah nvm i just got confused with many things i have in my head

pliant gulch
#

It could be given internally, or publically

slate swan
pliant gulch
#

Up to the maintainers/contributors

echo wasp
slate swan
#

if mesage contains

#

i need that

slate swan
vale wing
#

Discord lagging awfully wth

slate swan
#

i get it now thx

vale wing
#

You could decorate that function with commands.Cog.listener and just add the cog with it to the bot

slate swan
#

or just add it to the subclass which i like better

vale wing
#

There may be a way to register an event listener but this is how you typically do that - cog or overwrite in the subcalss

slate swan
#

show

#

no no no

#

just on ready dont do self.run it will never work

#

ok make it mesage contains

#

and make it work

#

pllsssssssssssssssssssssss

vale wing
#

Why are you running it from a running bot wait_wut

slate swan
#

you run the run method in another file which is the main file

vale wing
#

When it logins and connects

pliant gulch
#

Isn't Application a subclass of commands.Bot already? Why are you subclassing the subclass again

echo wasp
coral vessel
# vale wing Shouldn't there be a prefix?

already test it with prefix, but still command not found, i think it VS code issue, cause my code work with Replit, did anyone know how to restore/reset default VS code without uninstalling?

pliant gulch
#

You should just do ```py
bot = Application(...)
bot.run(...)

#

Whatever your doing makes no sense

vale wing
#

bot.run() launches the asynchronous app which means none of the functions after it will be executed until the loop is closed, just for your info

slate swan
#

hes trying to subclass bot andy

pliant gulch
#

Hasn't he already?

#

Isn't that is what Application is

slate swan
#

like anything else?

pliant gulch
#

Inside of your subclass, E.g Application you add a method called on_ready

#

You give it the self param then now it's set as a listener implicitly

pliant gulch
#

Just make a cog then???

#

Why are you subclassing for that reason

wicked atlas
pliant gulch
#

You only need to subclass the bot when your adding something new, an API for doing things in another file exist already, E.g Cogs

wicked atlas
slate swan
#

@slate swan

from bot import BotSubclass
if "__name__" == "__main__":
    BotSubclass().run()

is how you run the bot which will just run the run method in the subclass which the run method runs the bot and the setup function to load all cogs and then just add the on_ready event below

pliant gulch
#

!d discord.ext.commands.Cog.listener

unkempt canyonBOT
#

classmethod listener(name=...)```
A decorator that marks a function as a listener.

This is the cog equivalent of [`Bot.listen()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.listen "discord.ext.commands.Bot.listen").
pliant gulch
#

You'd use this the same way you'd use bot.event etc

#

Except keep in mind the methods will be bound to your cog class

#

thus you need to give self in the method's signature

echo wasp
wicked atlas
echo wasp
vale wing
echo wasp
pliant gulch
#

Have you even read the manual I sent you before asking that question

echo wasp
wicked atlas
pliant gulch
#
class Gambling(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
``` this is shown in the example
#

πŸ‘οΈ πŸ‘οΈ as you can see it get's bot

outer violet
#

does anyone here know how to use fuzzywuzzy

pliant gulch
#

Do you realize you need to actually construct the Cog later or use the setup method

#

Thus you'd be giving your INSTANCE to the cog

#

bot.add_cog(Greetings(bot))

#

πŸ‘οΈ πŸ‘οΈ

#

or use the setup method
For some odd reason not covered in the original docs, but vco's tutorial shows it

slate swan
#

yeah thats just making an instance of the class and doing everything else

outer violet
raven pewter
#

Does this look right?

echo wasp
#

how would i make something like this in my bot?

warm forum
#

How can i mention a user my his username with a discord bot?

echo wasp
#

lol that is not how you make a cog

slate swan
unkempt canyonBOT
slate swan
raven pewter
slate swan
#

bro wut did you replied to the run msg?

echo wasp
#

@slate swan try this

from bot import Application
from disnake.ext.commands import Cog

bot = Application()
bot.run()

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

    @commands.Cog.listener()
    async def on_ready(self):
        print(self.bot.name, "is online")

bot.add_cog(Events(bot))```
echo wasp
slate swan
#

and no need for @commands.Cog

echo wasp
slate swan
#

you imported the cog class

normal moon
#

is there a way to ignore commands.errors.CommandNotFound?

echo wasp
#

i use that

echo wasp
slate swan
echo wasp
final iron
#

No error will be printed to console

slate swan
#

which dont

normal moon
#

thx

slate swan
#

then in the feature you wont know what error is happening

echo wasp
#

like the photo

slate swan
echo wasp
#

i sent

slate swan
#

if not use on_command_error

final iron
#

If you're doing on_command_error you'll need to add a print statement within an else block at the end printing the exception

#

So it only catches the errors that you specify

raven pewter
#

Wait does this guild offers BetterDisco-py help?

slate swan
final iron
normal moon
#

resolved thank you pep8

echo wasp
# slate swan on member join event takes a member obj use it and get the channel

i do this rn py @commands.Cog.listener() async def on_member_join(self, member: discord.member): if member.guild.id == 804864012184977438 : return if member.guild.id == 902404450432483378 : return channels = member.guild.channels for channel in channels: if ('welcome' in channel.name.lower()) or ('joins' in channel.name.lower()): #or ('testing' in channel.name) embed=discord.Embed(title=f"Welcome {member.name}", description=f"Thanks for joining {member.guild.name}!") embed.set_thumbnail(url=member.avatar_url) if isinstance(channel, discord.TextChannel): await channel.send(embed=embed)

final iron
raven pewter
final iron
#

I want to make sure it doesn't cause you any issues in the future

normal moon
#
from discord.ext.commands import CommandNotFound
@client.event
async def on_command_error(ctx, error):
  if isinstance(error, CommandNotFound):
    return
  raise error```
raven pewter
#

So I tried using the command it does not recognize the command

final iron
#

What's the library called?

slate swan
#

raise returns a function and raises the error

raven pewter
final iron
#

You sure?

raven pewter
#

It's orgin is

#

Disco-py

final iron
#

!pypi Disco-py

unkempt canyonBOT
raven pewter
#

Si

#

But it is old and outdated

slate swan
#

why use it

raven pewter
raven pewter
#

Which is stable and updated

slate swan
#

Bom dia

echo wasp
slate swan
#

Alguem me doa sonhos por favor

#

Sonhos

echo wasp
slate swan
slate swan
echo wasp
slim ibex
#

!pypi pillow

unkempt canyonBOT
echo wasp
#

how would i make it print the channels clickable and mention the user?

slim ibex
#

a command that does that?

final iron
#

Well

#

So

#

!d discord.Member.mention

unkempt canyonBOT
final iron
#

You can mention the member with this

#

And to mention the channel you would do <#channel id here>

echo wasp
#

can you show me an example?

#

please

#

@final iron

lapis lintel
pliant gulch
#

Why are you calling a property

#

This would error and say str is not callable

lapis lintel
#

He asked how to mention a user

pliant gulch
#

Yea... and that's not how you mention a user

lapis lintel
#

That's how you do it

#

Of course that is

pliant gulch
#

!e ```py
class A:
@property
def mention(self) -> str:
return "foo"

a = A()
a.mention()

final iron
unkempt canyonBOT
#

@pliant gulch :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 7, in <module>
003 | TypeError: 'str' object is not callable
pliant gulch
#

Do you see what your doing

#

You don't call a property lol

lapis lintel
pliant gulch
#

!d discord.User.mention

unkempt canyonBOT
#

property mention: str```
Returns a string that allows you to mention the given user.
final iron
#

!d discord.Member

unkempt canyonBOT
#

class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").

This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User").

x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.

x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.

hash(x) Returns the member’s hash.

str(x) Returns the member’s name with the discriminator.
echo wasp
#

i quess i'll wait

pliant gulch
#

πŸ‘οΈ πŸ‘οΈ

pliant gulch
#

Where does it say it's a method??

lapis lintel
#
@commands.Cog.listener()
    async def on_voice_state_update(self, member, before, after):
        support_channel = self.client.get_channel(
            support_utils.get_support_channel_id())
        alert_channel = self.client.get_channel(
            support_utils.get_channel_alert_id())

        if before.channel != support_channel and after.channel == support_channel:
            embed = disnake.Embed(
                title='A member has joined the support channel!',
                description=f'{member.mention} has joined the support channel!',
                color=0xFFFFFF
            )

So this won't work?

pliant gulch
#

Bro

#

In the snippet you sent you are USING it properly

#

You told him EARLIER to call IT

final iron
#

You're not calling it in that code

pliant gulch
lapis lintel
#

Oh fuck

echo wasp
#

that would thanks i used it like that in an embed

lapis lintel
#

HAAHHAHAAHAH

pliant gulch
#

🀦

lapis lintel
#

Im dying

#

HAHAHA

#

My bad

slate swan
#

Alguem me doa sonhos

#

No english

#

+atm

#

Sonhos

#

Sonhos

final iron
#

!rule 4

unkempt canyonBOT
#

4. Use English to the best of your ability. Be polite if someone speaks English imperfectly.

final iron
#

Also check out the nickname policy

dry kelp
#
    @welcome.command(aliases=["msg"])
    @commands.check_any(commands.is_owner(), is_guild_owner())
    async def message(self, ctx, *, msg):

        if msg == None:
            em = discord.Embed(title="![error](https://cdn.discordapp.com/emojis/929402122074730638.webp?size=128 "error") Welcomer Error!", description=f"Please provide a message!", color=discord.Color.red())
            await ctx.reply(embed=em, mention_author=False)
            return

        with open(prefix_path, "r")as f:
            prefixes = json.load(f)

        prefixes[str(ctx.guild.id)]
        p = prefixes.get(str(ctx.guild.id))

        query = "SELECT msg FROM  welcome WHERE guild_id = ?"
        val = (ctx.guild.id,)

        with sqlite3.connect('./database.sqlite3') as db:
            db.row_factory = sqlite3.Row
            cursor = db.cursor()
            cursor.execute(query, val)
            welcome_db = cursor.fetchone()

        if welcome_db is None:
            em = discord.Embed(title="![error](https://cdn.discordapp.com/emojis/929402122074730638.webp?size=128 "error") Welcomer Error!", description=f"First setup your welcome channel! `{p}Welcome Channel [Mention/ID]`!", color=discord.Color.red())
            await ctx.reply(embed=em, mention_author=False)
            return
            
        if welcome_db is not None:
            sql = (f"UPDATE welcome SET msg = ? WHERE guild_id = ?")
            val = (msg, ctx.guild.id)

            if int(msg) > 2048:
                em = discord.Embed(title="![error](https://cdn.discordapp.com/emojis/929402122074730638.webp?size=128 "error") Welcomer Error!", description=f"You can't go over `2048` characters!", color=discord.Color.red())
                await ctx.reply(embed=em, mention_author=False)
                return

            em = discord.Embed(title="![Ver](https://cdn.discordapp.com/emojis/858069322512859146.webp?size=128 "Ver") Welcomer Successful!", description=f"Welcome message has been set!", color=discord.Color.from_rgb(black1, black2, black3))
            await ctx.reply(embed=em, mention_author=False)
wicked atlas
dry kelp
#

i fixed it already

#

i didn't read the error at all

slate swan
#

len can be used in many things lol

wicked atlas
#

?

#

I know that it can, not sure what you're correcting though

slate swan
#

your saying it like if it can only get the length of a string

wicked atlas
#

ok then...

slate swan
rare saddle
#

How to display the number of participants from all servers where the bot is located?

glass tundra
#

Does anyone has any bot idea? Or any project I can help with?

slate swan
unkempt canyonBOT
#

for ... in get_all_members()```
Returns a generator with every [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") the client can see.

This is equivalent to:

```py
for guild in client.guilds:
    for member in guild.members:
        yield member
rare saddle
slate swan
#

yw

outer flint
#

Question
await ctx.send(file=discord.File(r".\files\gme.png"))
this works on Windows but not on linux [as in, the bot is hosted on a linux machine] what should be changed?

wicked atlas
#

should work on windows too

outer flint
#

uhm... doesn't seem to like it thinku

wicked atlas
#

How so?

outer flint
#

Something went wrong when tried to load extension cogs.ME: Extension 'cogs.ME' raised an error: SyntaxError: invalid syntax (ME.py, line 68)

wicked atlas
#

Well that has nothing to do with your filepath

outer flint
#

ah strange it told me only after I did those edits KEK

slate swan
#

For a cog with on_message event, can I change β€œif message.author == bot.user:” to β€œif message.author == commands.user”?

#

Or should I do smth else to make it

torn sail
#

The cog should take bot as an arguement. You can assign it to self.bot and use it in ur event

wanton cipher
#

Hi, I was wondering if there is a way to get the thumbnail on an embed to load/work before sending the embed

wanton cipher
#

when I send an embed, I am setting the thumbnail and it doesn't show up

cedar stream
#

It’ s cus It’ s not loaded on ur machine

wanton cipher
#

so then how can I load it?

cedar stream
#

Faster internet πŸ€·πŸΌβ€β™‚οΈ

#

It’ s client issue

wanton cipher
#

isn't there a way to get it to load before sending the embed?

cedar stream
#

No because every computer (my phone, your computer etc.) has to load the image for itself

wanton cipher
#

no, like

#

it's not a loading thing

#

it's just not adding a thumbnail

cedar stream
#

Ohh

#

Lmao sry

wanton cipher
#

nws

cedar stream
#

How did u implement it

wanton cipher
#

I am using an api

#

f"https://www.accuweather.com/images/weathericons/{str(weather_data['DailyForecasts'][0]['Day']['Icon']).zfill(2)}.svg"

cedar stream
#

Can you send a ss of code

#

Just embed part

wanton cipher
#
weather_embed = disnake.Embed(title=f"Weather", url=weather_data['Headline']['Link'])
weather_embed.set_thumbnail(url=f"https://www.accuweather.com/images/weathericons/{str(weather_data['DailyForecasts'][0]['Day']['Icon']).zfill(2)}.svg")
cedar stream
#

Try to make request to the url and print response

#

Url for image

wanton cipher
#

ahh

#
<ClientResponse(https://www.accuweather.com/images/weathericons/04.svg) [403 Forbidden]>
<CIMultiDictProxy('Server': 'AkamaiGHost', 'Mime-Version': '1.0', 'Content-Type': 'text/html', 'Content-Length': '306', 'Cache-Control': 'max-age=0', 'Expires': 'Sat, 29 Jan 2022 23:02:01 GMT', 'Date': 'Sat, 29 Jan 2022 23:02:01 GMT', 'Connection': 'close', 'Server-Timing': 'cdn-cache; desc=HIT', 'Server-Timing': 'edge; dur=1', 'Strict-Transport-Security': 'max-age=15768000 ; includeSubDomains ; preload')>
slate swan
#

some apis need a auth token to verify a request to it

cedar stream
#

If you are scraping the image then you can just copy the token from inspector

#

Otherwise generate an api key

slate swan
#

^

wanton cipher
#

the api is different, I have a key for that

slate swan
#

not how you do a request in that api hut youre probably missing a auth toke since a 403 error was raised

cedar stream
#

Go to that url in browser and go to inspect element/network then look at which request responds with an image and make identical request

wanton cipher
#

I am not gonna lie, I am pretty newbie when it comes to requests, I found some of my old code (which I am pretty sure I stole) and it works so I use it

#
async with ClientSession(headers=None) as session:
  async with session.get(link) as response:
cedar stream
#

Yes but you need right headers

wanton cipher
#

so, how would I pass proper headers?

cedar stream
#

You can see what headers u need in inspect element/network in ur browser

#

Go there and find the request that responds with the image

slate swan
cedar stream
#

And copy It’ s headers

slate swan
#

it will show the params

wanton cipher
#

there is nothing here

cedar stream
wanton cipher
cedar stream
#

Are u using an api or are you scraping

left crater
#
    channel = bot.get_channel(699577970117050399)
    messages = await channel.history(limit=500).flatten()
    for p in messages:
        print(p)``` this works but it prints the message id of all the messages instead of the content
slate swan
cedar stream
#

Print(p.content)

wanton cipher
left crater
#

Therefore I can’t

wanton cipher
cedar stream
#

messages is a list

cedar stream
#

So no docs

cedar stream
slate swan
left crater
#

@cedar stream it works but it skips images

#

is their a way to print the image url

cedar stream
#

Wdym skips inages

#

Images*

left crater
#

instead of where an image should be there is just empty space

cedar stream
cedar stream
#

Idk wym

left crater
cedar stream
wanton cipher
#

those are attachments

cedar stream
#

One sec

#

!d discord.Message

unkempt canyonBOT
#

class discord.Message```
Represents a message from Discord.

x == y Checks if two messages are equal.

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

hash(x) Returns the message’s hash.
cedar stream
#

To get images do p.attachments

#

p.content is just text

slate swan
#

my pfp is looking at the msg abovepithink

cedar stream
#

No, It’ s looking at my pfp

left crater
#

it works thanks bro

slate swan
cedar stream
left crater
#

what

slate swan
#

πŸ‘οΈ πŸ‘οΈ

cedar stream
#

Np*

#

Lmao πŸ˜‚

slate swan
#

the typo😭

cedar stream
#

O and p are next to each other

#

And the slowmode just makes it worse πŸ˜‚

slate swan
cedar stream