#discord-bots

1 messages · Page 34 of 1

slate swan
#

:)

scarlet widget
#

what is a good discord py tutorial

slate swan
#

how could i go on about getting all text channels using a guild id?

silk fulcrum
#

one day... i'll make my own tutorial

silk fulcrum
#

!d discord.ext.commands.Bot.get_guild -- to get guild

unkempt canyonBOT
silk fulcrum
#

!d discord.Guild.text_channels -- all text channels

unkempt canyonBOT
#

property text_channels```
A list of text channels that belongs to this guild.

This is sorted by the position and are in UI order from top to bottom.
slate swan
#

got it,m thanks

zealous jay
#

uuh for some reason on_invite_create is not working

Here are my intents

#

I don't see any errors on the console

sick birch
#

Can we see the on_invite_create function?

zealous jay
#

oh sorry i forgot

sick birch
#

Is the cog being loaded properly?

zealous jay
#

the description is quite long

silk fulcrum
#

class invite_events 😭

zealous jay
#

yes

sick birch
#

Cog should be named InviteEvents, by the way

zealous jay
#

oh bruh

sick birch
#

Do you get the print statement print("LA VEOOOO") when you create an invite?

slate swan
#

not exact code

slate swan
slate swan
sick birch
unkempt canyonBOT
#

property text_channels```
A list of text channels that belongs to this guild.

This is sorted by the position and are in UI order from top to bottom.
slate swan
#

got it

zealous jay
#

I'll go change it haha

#

So, leaving the horrible class naming, why isn't it working?

slate swan
#

how do i create a webhook in a chanel?

silk fulcrum
unkempt canyonBOT
#

await create_webhook(*, name, avatar=None, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Creates a webhook for this channel.

Requires [`manage_webhooks`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_webhooks "discord.Permissions.manage_webhooks") permissions.

Changed in version 1.1: Added the `reason` keyword-only parameter.
silk fulcrum
slate swan
# unkempt canyon

tried this, returns

RuntimeError: Timeout context manager should be used inside a task```
silk fulcrum
slate swan
unkempt canyonBOT
#

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

zealous jay
#

okay so it seems like if I create an invite without modifying its expiring date or stuff like that it wont appear on the audit

slate swan
#

robin you should know better pithink

#

xD

zealous jay
#

pobre robin

sick birch
slate swan
silk fulcrum
#

hi oki ✌️

slate swan
#

hi master✌️

slate swan
#

await channel.create_webhook(name='webhook')

RuntimeError: Timeout context manager should be used inside a task```
swift pumice
#

quadro

#

el pablo

slate swan
#

that was perfect spanish👀

zealous jay
#

La revolucion

slate swan
#

i just want to get help

swift pumice
slate swan
cloud dawn
#

We are not miracle workers.

slate swan
#

panda youre a miracle!

cloud dawn
#

True he prob didn't put it an an async context.

silk fulcrum
slate swan
#

😭

cloud dawn
#

My traceback is 10

slate swan
cloud dawn
#

!traceback

unkempt canyonBOT
#

Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.

A full traceback could look like:

Traceback (most recent call last):
  File "my_file.py", line 5, in <module>
    add_three("6")
  File "my_file.py", line 2, in add_three
    a = num + 3
TypeError: can only concatenate str (not "int") to str

If the traceback is long, use our pastebin.

slate swan
#
    guild = client.get_guild(int(config["guildid"]))
    channels = guild.channels
    for channel in channels:
        if channel.name == 'webhook-test':
            await channel.create_webhook(name='webhook')```
#
Exception in thread Thread-2:
Traceback (most recent call last):
  File "C:\Users\aisil\AppData\Local\Programs\Python\Python38\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "C:\Users\aisil\AppData\Local\Programs\Python\Python38\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "c:/Users/aisil/Desktop/waifu/main.py", line 132, in main
    asyncio.run(create_webhooks())
  File "C:\Users\aisil\AppData\Local\Programs\Python\Python38\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Users\aisil\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 616, in run_until_complete
    return future.result()
  File "c:/Users/aisil/Desktop/waifu/main.py", line 145, in create_webhooks
    await channel.create_webhook(name='webhook')
  File "C:\Users\aisil\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\channel.py", line 471, in create_webhook
    data = await self._state.http.create_webhook(self.id, name=str(name), avatar=avatar, reason=reason)
  File "C:\Users\aisil\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\http.py", line 192, in request
    async with self.__session.request(method, url, **kwargs) as r:
  File "C:\Users\aisil\AppData\Local\Programs\Python\Python38\lib\site-packages\aiohttp\client.py", line 1117, in __aenter__
    self._resp = await self._coro
  File "C:\Users\aisil\AppData\Local\Programs\Python\Python38\lib\site-packages\aiohttp\client.py", line 448, in _request
    with timer:
  File "C:\Users\aisil\AppData\Local\Programs\Python\Python38\lib\site-packages\aiohttp\helpers.py", line 635, in __enter__
    raise RuntimeError(
RuntimeError: Timeout context manager should be used inside a task```
sick birch
slate swan
sick birch
#

Where are you calling it from?

slate swan
#

wdym?

sick birch
#

Inside where are you calling it from? A command? Event?

slate swan
#

from input xD

zealous jay
#

Should I be worried?

silk fulcrum
#

minute 😳

zealous jay
#

what does that mean?

sick birch
slate swan
#

im not sure what the error means but it seems like it was invoked in the incorrect spot lol

#

never seen that error actually

silk fulcrum
#

me2

slate swan
#

if input is xyz i'm calling asyncio.run(create_webhooks())

#

so youre running a coroutine while the bot isnt even prepared?

#

wdym not even prepared

silk fulcrum
#

not ready

slate swan
# slate swan wdym not even prepared

you would need to run asyncio.run before the bot starts as bot.run is like a blocking loop meaning youre also giving asyncio.run ownership of the loop

sick birch
#

It should only be used once in your program to kickstart the asynchronous event loop

slate swan
#

and youre trying to get a channel object from the bots cache when the bot hasnt even been deployed lol

#

aaa, ok

sick birch
#

An easy spot to put it in would be inside of a command

silk fulcrum
#

AsyncioEventLoop.run_until_complete is good ig

#

well in this case it wont help ig

slate swan
#

should be in a command as told, better for debugging/testing

cloud dawn
limber bison
#

if i type

!poll hello sir
ok ok
hm hm
done done

if create an embed
question : hello sir
1 : ok ok
2: hm hm
3: done done

how can i brack string like thissssssssssssss

sick birch
#

Well no, not like that. Awaiting the coro, I mean

cloud dawn
unkempt canyonBOT
#

@cloud dawn :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | Hello
002 | World!
slate swan
#

panda how can you forget that💀

#

its from left to right always

limber bison
cloud dawn
#

You distracted me with gif

slate swan
#

my badpithink

winged mason
#

!e
a= 60
b = 80
c = a+b
print(c)

unkempt canyonBOT
#

@winged mason :white_check_mark: Your 3.10 eval job has completed with return code 0.

140
slate swan
#

#bot-commands

winged mason
#

oh sry my bad

slate swan
#

no worries

slate swan
#

Yow

#

I'm still getting this error

#

Traceback (most recent call last): File "/home/container/main.py", line 9, in <module> bot = discord.Bot(command_prefix='$', activity=activity, status=discord.Status.online, intents=discord.Intents.all()) AttributeError: module 'discord' has no attribute 'Bot'

#

On my pc it works, but on my host not

vocal snow
slate swan
#

only pycord has that attribute

slate swan
slate swan
vocal snow
#

how did you install it on your host

slate swan
#

its probably clashing with something

vocal snow
#

run pip show py-cord and show

slate swan
#

Cant

maiden fable
slate swan
sage nebula
#

What host u usin?

slate swan
vocal snow
#

it's py-cord

slate swan
#

How do i install?

vocal snow
#

the way you install any other pypi package

#

!dashmpip

unkempt canyonBOT
#
Install packages with `python -m pip`

When trying to install a package via pip, it's recommended to invoke pip as a module: python -m pip install your_package.

Why would we use python -m pip instead of pip?
Invoking pip as a module ensures you know which pip you're using. This is helpful if you have multiple Python versions. You always know which Python version you're installing packages to.

Note
The exact python command you invoke can vary. It may be python3 or py, ensure it's correct for your system.

winged mason
slate swan
#

Requirement already satisfied: py-cord in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (2.1.0) Requirement already satisfied: aiohttp<3.9.0,>=3.6.0 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from py-cord) (3.7.4.post0) Requirement already satisfied: attrs>=17.3.0 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from aiohttp<3.9.0,>=3.6.0->py-cord) (22.1.0) Requirement already satisfied: typing-extensions>=3.6.5 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from aiohttp<3.9.0,>=3.6.0->py-cord) (4.3.0) Requirement already satisfied: chardet<5.0,>=2.0 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from aiohttp<3.9.0,>=3.6.0->py-cord) (4.0.0) Requirement already satisfied: yarl<2.0,>=1.0 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from aiohttp<3.9.0,>=3.6.0->py-cord) (1.8.1) Requirement already satisfied: async-timeout<4.0,>=3.0 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from aiohttp<3.9.0,>=3.6.0->py-cord) (3.0.1) Requirement already satisfied: multidict<7.0,>=4.5 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from aiohttp<3.9.0,>=3.6.0->py-cord) (6.0.2) Requirement already satisfied: idna>=2.0 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from yarl<2.0,>=1.0->aiohttp<3.9.0,>=3.6.0->py-cord) (3.3)

winged mason
#

then ur good to go i guess

slate swan
#

Ok

vocal snow
#

to prevent any clashing

winged mason
vocal snow
winged mason
#

i gave these incase u need some help

obsidian lintel
#

Does anyone know the disnake equivalent to this?

async def balance(self, ctx: commands.Context, member: nextcord.Member = None):
slate swan
#
async def balance(self, ctx: commands.Context, member: disnake.Member | None = None): 
#

i fixed the annotation btw lol

obsidian lintel
#

not valid paramater annotation , is that something to do with the rest of the code?

slate swan
#

thats odd im pretty sure that is a correct parameter annotation

obsidian lintel
#

Perplexes me

pale turtle
obsidian lintel
#

ye

pale turtle
#

So why is everyone using disnake or nextcord and not just discord.py

slate swan
#

personal preference

hushed galleon
#

by the time danny came back plenty of devs already switched libraries, and they're still getting maintained so there isnt that big of a reason to switch back

winged coral
#

^

#

Everyone went and found a new library, learnt it, got familiar and then danny was like nvm were back

slate swan
#

wasnt really new

#

more like a library that was a competitor

winged coral
#

It was new to the user

slate swan
#

wasnt really new either only change mostly was new endpoints and namespaces everything was mostly the same

winged coral
#

Yeah, most libs were forks or similar. I just meant people found libraries they hadn’t used before, so they were new, to the user

#

And it’s a pain converting old projects over to a new library even if it’s just decorators being changed

slate swan
#

more like they experimented with the lib and stuck with it, is a better way to say it

slate swan
#

getting crazy error when trying to make a discord bot

import discord

TOKEN = "not here for reasons"

client = discord.Client()

@client.event
async def on_ready():
    print("{0.user} is now online!".format(client))

client.run(TOKEN)

error:
https://paste.pythondiscord.com/ecahevoqos.py

hoary arch
#

@slate swan

slate swan
#

im on macos

limber bison
#

await interaction.response.send_message("hello")

'Button' object has no attribute 'response'

slate swan
#

?

marsh violet
slate swan
#
@client.group(invoke_without_command=True)
async def help(ctx):
    embed=discord.Embed(title="Help Commands", color=Color.green)
    embed.add_field(name="Moderation", value="!help Moderation", inline=True)
    embed.add_field(name="Other", value="!help other", inline=True)
    embed.add_field(name="Neutral", value="!help Neutral", inline=True)
    embed.set_footer(text="For a more in-depth explination on each command, simply type `!help <command>` (replace <command> with the command you want help with)")
    await ctx.send(embed=embed)```
#

nothing works, the entire group doesnt functoin

marsh violet
# limber bison 🤔

async def <name>(self, interaction) -> async def <name>(self, button, interaction)

outer violet
#

Did I do something wrong? I thought it would’ve shown the component name in the field name (it’s in hikari-tanjun)


info = {}
    for component in ctx.client.components:
        cmds = ctx.client.iter_commands()
        info[str(component)] = ", ".join([cmd.name for cmd in cmds])

    if not obj:
        embed = hikari.Embed(
            description="""Welcome to DJ BMO's help!
Find all the commands available on this panel.""",
            color=0x77F2F2,
        )
        for component, cmds in info.items():
            embed.add_field(name=component, value=cmds, inline=False)```
limber bison
#

Traceback (most recent call last):
File "D:\ph\lib\site-packages\discord\ui\view.py", line 423, in _scheduled_task
await item.callback(interaction)
File "c:\Users\Kamal kishore\Desktop\Project 0\commands\admin\poll.py", line 41, in button3
await interaction.response.edit_message(view=self)
File "D:\ph\lib\site-packages\discord\interactions.py", line 782, in edit_message
raise InteractionResponded(self._parent)
discord.errors.InteractionResponded: This interaction has already been responded to before

mean ?

brazen seal
#
import discord
from discord.ext import commands

client = commands.Bot(command_prefix=".")
client.remove_command("help")

@client.event
async def on_ready():
    print("test")


@client.command()
async def help(ctx):
    await ctx.channel.send("pong")

Hey my bot look like this and when i write .help

#

nothing gonna happend

sick birch
brazen seal
sick birch
#

Do you have an on_message?

brazen seal
#

no

sick birch
#

!intents are you intents set up properly?

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default discord.py has all intents enabled except for Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

intents = Intents.default()
intents.members = True

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

For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.

sick birch
brazen seal
limber bison
sick birch
sick birch
brazen seal
# sick birch That's a good starting point, then
import discord
from discord import Intents
from discord.ext import commands

intents = Intents.default()
intents.members = True
client = commands.Bot(command_prefix=".")
client.remove_command("help")

@client.event
async def on_ready():
    print("test")


@client.command()
async def help(ctx):
    await ctx.send("pong")
  
#

still nothing

#

i dont get anything when i write .help

#

but print("test") i got

sick birch
#

You also need intents.message_content = True, and make sure you enable it on your dashboard as well

sick birch
#

Right

brazen seal
#

dont

sick birch
#

Do you have intents.message_content = True enabled in your code as well?

brazen seal
#
import discord
from discord import Intents
from discord.ext import commands

intents = Intents.default()
intents.message_content = True
intents.members = True
client = commands.Bot(command_prefix=".")
client.remove_command("help")

@client.event
async def on_ready():
    print("test")


@client.command()
async def help(ctx):
    await ctx.send("pong")
    

sick birch
#

Try removing client.remove_command("help")

brazen seal
#
import discord
from discord import Intents
from discord.ext import commands

intents = Intents.default()
intents.message_content = True
intents.members = True
client = commands.Bot(command_prefix=".")
client.remove_command("help")

@client.event
async def on_ready():
    print("test")


@client.command()
async def test(ctx):
    await ctx.send("pong")
    
#

i changed this command to "test"

#

and still dont work

slate swan
#

how to check for 2 words in on message event

#

like if 'lol' or 'alex' in message.content:

#

or doesnt work sadly

brazen seal
sick birch
tough lance
unkempt canyonBOT
#

When checking if something is equal to one thing or another, you might think that this is possible:

# Incorrect...
if favorite_fruit == 'grapefruit' or 'lemon':
    print("That's a weird favorite fruit to have.")

While this makes sense in English, it may not behave the way you would expect. In Python, you should have complete instructions on both sides of the logical operator.

So, if you want to check if something is equal to one thing or another, there are two common ways:

# Like this...
if favorite_fruit == 'grapefruit' or favorite_fruit == 'lemon':
    print("That's a weird favorite fruit to have.")

# ...or like this.
if favorite_fruit in ('grapefruit', 'lemon'):
    print("That's a weird favorite fruit to have.")
#

Hey @brazen seal! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me

Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!

brazen seal
#
import discord
from discord import Intents
from discord.ext import commands

intents = Intents.default()
intents.message_content = True
intents.members = True
client = commands.Bot(command_prefix=".")
client.remove_command("help")

@client.event
async def on_ready():
    print("test")


@client.command()
async def test(ctx):
    await ctx.send("pong")
    

can someone test this code?

#

i dont have any idea why it cant work correctly

slate swan
tough lance
brazen seal
limber bison
#

(url=ctx.guild.icon.url) ??????????//

sick birch
brazen seal
#

can i set color embed as a hex?

hazy oxide
#

Ya

limber bison
brazen seal
brazen seal
sick birch
brazen seal
#

where?

sick birch
#

Ah if you want to use RGB, use the discord.Colour.from_rgb function

#

!d discord.Colour.from_rgb

unkempt canyonBOT
#

classmethod from_rgb(r, g, b)```
Constructs a [`Colour`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Colour "discord.Colour") from an RGB tuple.
sick birch
#

Damned british spelling

hazy oxide
brazen seal
#

dont work

hazy oxide
#

Not a string

hazy oxide
brazen seal
#

thanks

brazen seal
heavy folio
#

!d discord.Colour typehint kolor to discord.Colour

unkempt canyonBOT
#

class discord.Colour(value)```
Represents a Discord role colour. This class is similar to a (red, green, blue) [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.10)").

There is an alias for this called Color...
brazen seal
#

i dont understand

hazy oxide
#

kolor: discord.Colour = 00fff7

heavy folio
#

oh and for the default it'd be better if you did something like kolor: discord.Colour = discord.Colour(00fff7)

brazen seal
#

Thanks it works

slate swan
#
@client.group(invoke_without_command=True)
@commands.cooldown(1,15,commands.BucketType.user)
async def updates(ctx):
    embed=discord.Embed(title="Updates", description="Updates to the bot", color=Color.orange)
    embed.add_field(name="Help Command Rewrite", value="`!updates help-rewrite`")
    embed.add_field(name="New Command", value="`!updates newcommand_1`")
    await ctx.send(embed=embed)
#

its not working, the entire group doesnt work

past heath
#

so i migrated dpy 2.0 having some problems setting up the bot turns on but doesn't respond to my command anything i can do? It also doesn't give off any errors.

slate swan
#
@client.group(invoke_without_command=True)
async def help(ctx):
    embed=discord.Embed(title="Help Commands", color=Color.green)
    embed.add_field(name="Moderation", value="!help Moderation", inline=True)
    embed.add_field(name="Other", value="!help other", inline=True)
    embed.add_field(name="Neutral", value="!help Neutral", inline=True)
    embed.set_footer(text="For a more in-depth explination on each command, simply type `!help <command>` (replace <command> with the command you want help with)")
    await ctx.send(embed=embed)```
#

same with this

past heath
past heath
#

what error is it giving

slate swan
#

none

#

nothing happens when I type the command

past heath
#

try removing the "@client.group" things u put see if that works

#

wait

slate swan
#

the embed doesnt work

past heath
#

u dont even have the command thats why lol

slate swan
#

wdym?

past heath
#

WAIT mb

#

put the

deep osprey
#

can I remove my bot from a server where I am not owner at?

upbeat gust
slate swan
past heath
#

yeah nvm

#

see look @slate swan

upbeat gust
#

Don't help people when you're asking for help

slate swan
upbeat gust
past heath
#

u dont have a decorator

upbeat gust
slate swan
#

()?

upbeat gust
#

It's commands.group

past heath
#

like

#

@bot.command

#

or @commands.command (if using cogs)

past heath
#

nvm

upbeat gust
past heath
#

im trippin

#

but u have no decorator

#

thats the problem

brazen seal
#

i can't import buttons ThinkingCeption

upbeat gust
slate swan
brazen seal
past heath
upbeat gust
#

look at the example

upbeat gust
brazen seal
upbeat gust
upbeat gust
#

You can install 2.0 using

#

python3.8 -m pip install -U git+https://github.com/Rapptz/discord.py (you need python 3.8 or later)

#

check out the migration guide in the docs

brazen seal
past heath
#

migration guide sucks

upbeat gust
upbeat gust
#

you can make it better then

slate swan
#

like that?

past heath
#

im just saying its not as helpful still having problems with it

upbeat gust
brazen seal
past heath
upbeat gust
slate swan
upbeat gust
#

Add ctx

past heath
#

@slate swan new to coding?

#

with dpy

slate swan
past heath
#

oh its cool

upbeat gust
#

Go learn python first

past heath
#

yeah try to learn both at the same time in a balanced way

brazen seal
upbeat gust
upbeat gust
brazen seal
upbeat gust
brazen seal
#

ok

past heath
slate swan
#

oh my god

#

the problem

#

was, Color.<color>

#

I had to replace it with one of these: 0x9e0000

brazen seal
#

How to get id of message which user answering?

deep osprey
#
@bot.command()
@commands.is_owner()
async def leave(ctx, * , guild_name):
    guild = discord.utils.get(bot.guilds, name=guild_name)
    if guild is None:
        await ctx.reply("I don't recongize that server!")
        return
    await bot.leave_guild(guild)
    await ctx.reply(f"Done, Removed the bot from {guild.name} server!")``` why doesn't that work?
slate swan
deep osprey
#

It's not the issue, It always doesn't recongize the server

pale turtle
#

R u sure there is even a thing bot.leave_guild?

#

Try guild.leave()

deep osprey
deep osprey
# pale turtle Try guild.leave()
@bot.command()
@commands.is_owner()
async def leave(ctx, * , guild_name):
    guild = discord.utils.get(bot.guilds, name=guild_name)
    if guild is None:
        await ctx.reply("I don't recongize that server!")
        return
    await guild.leave(guild)
    await ctx.reply(f"Done, Removed the bot from {guild.name} server!")``` still not recongizing the server
pale turtle
#

First it's pnly guild.leave(), and are sure this is the exact server name?

deep osprey
#

yes

pale turtle
#

Try it with id

deep osprey
#

did that too

pale turtle
#

Try to add that to the beginning of the command and tell me what it says:

print([guild.name for guild in bot.guilds])
deep osprey
#

['PIF']

pale turtle
#

That's the server you are trying to leave?

deep osprey
#

nope

pale turtle
#

Ok. Are you sure thr bot is currently in the server you do want to leave? And intents are enabled right?

deep osprey
#

Yes

#

btw the bot is in 2 other servers (and PIF)

#

why did it say PIF only?

pale turtle
#

U sure intents are enabled?

#

Send the bot constructor

deep osprey
#
intents = discord.Intents.all()
intents.members = True```
pale turtle
#

Show where you defined bot

deep osprey
#

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

pale turtle
#

Uh weird

deep osprey
#

so where do you think the problem came from?

slate swan
#

!d discord.Embed

unkempt canyonBOT
#

class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.

len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.

bool(b) Returns whether the embed has any data set.

New in version 2.0.

x == y Checks if two embeds are equal.

New in version 2.0...
pale turtle
#

What did u change

deep osprey
#

I was testing on the test bot and my mistake is I didn't add that bot to other servers.

#

but when I added it, worked

pale turtle
#

Lol

ebon island
#

Why is button.style typed as an integer when the documentation has string labels for each like danger?

sick birch
fading marlin
#

Button.style returns the corresponding style value from ButtonStyle (idk if that wording is correct), which is an Enum

limber bison
#

How can I generate a random code ?

deep osprey
#

Depends on the code

#

letters only or characters, numbers and letters

limber bison
#

!e
import
secrets secrets.token_hex(15)

unkempt canyonBOT
#

@limber bison :x: Your 3.11 eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     import 
003 |            ^
004 | SyntaxError: invalid syntax
limber bison
#

!e
import secrets
print(secrets.token_hex(2))

#

2 mean ?

unkempt canyonBOT
#

@limber bison :white_check_mark: Your 3.10 eval job has completed with return code 0.

c3fc
zealous jay
#

I keep getting rate limited for some reason

rugged shadow
unkempt canyonBOT
#

secrets.token_hex([nbytes=None])```
Return a random text string, in hexadecimal. The string has *nbytes* random bytes, each byte converted to two hex digits. If *nbytes* is `None` or not supplied, a reasonable default is used.

```py
>>> token_hex(16)  
'f9bf78b9a18ce6d46a0cd2b0b86df9da'
zealous jay
rugged shadow
#

that's for the number of bytes

rugged shadow
#

but sending too many requests will

#

what are you doing with your bot?

zealous jay
#

I just restarted it several times

rugged shadow
#

and are you hosting it on replit?

zealous jay
#

could that be it?

#

nope, im just testing it in my pc

rugged shadow
zealous jay
#

oh

rugged shadow
#

are you spamming, or

limber bison
#

What's it return ?

zealous jay
#

Its not sending messages on other servers at the moment tho

rugged shadow
zealous jay
#

Im just testing an on_invite_create event

#

But at the moment I start it I get the warning

rugged shadow
limber bison
brazen seal
zealous jay
rugged shadow
zealous jay
#

!paste

rugged shadow
#

what's get_configured_channel?

zealous jay
#

I'll paste it

#

it connects to a mongodb database

#

and gets the configured channel on that server

#

you configure it with another command

rugged shadow
rugged shadow
zealous jay
#

yeah

rugged shadow
#

Are there any other features in your bot? Or is it just the invite feature causing rate-limits

zealous jay
#

I'll procced to explain them

#

When an user joins the server it checks for the configured channel in that server, it also searches if that user has any bans (it checks on the bans the bot saved in the database from every server its in) and sends a message containing the ban count

When a user gets banned it saves the ban in the database

When a user gets unbanned it deletes the ban from the database

When the bots joins a server it fetchs all the bans that guild has and saves them in the database

It also has a few commands to display bans and reason from x user

#

And the invite thing, when an invite is created it sends a message with info

#

And there's also some other commands that no one can use except for me and Im not using them so 🤷‍♂️

#

Commands seems to work tho but I keep getting that warning when I start the bot

limber bison
#

If i edit button lable , is there any rate limit ?

#

Like i use it in a poll , in which at start when I ping everything more then 10k ppl come at once to vote

#

Will it able to handle it ?

deep osprey
silk fulcrum
deep osprey
#

I mean, a tool which removes unnecessary indentations

zealous jay
silk fulcrum
#

to remove indents

deep osprey
#

there are a lot of lines

shrewd apex
#

use black

silk fulcrum
#

and to format code Ctrl + Shift + I in vscode if im not mistaking

#

googleit

zealous jay
#

Not hosting rn, just testing on my pc

shrewd apex
#

what warning then?

zealous jay
shrewd apex
#

are u doing something in on_ready?

zealous jay
#

maybe when I sync commands?

shrewd apex
#

don't change presence in on_ready

zealous jay
#

and when should I do it?

deep osprey
#

do a task loop function to change it every 5 seconds

#

and call the function in on_ready

zealous jay
#

well it updates when it joins/leaves a server so I will only call it once

#

instead of looping

zealous jay
#

yep

deep osprey
#

then what's your problem?

zealous jay
#

that I keep getting rate limited for some reason

silk fulcrum
zealous jay
#

uh

#

I don't get it

silk fulcrum
deep osprey
#

well, what's the correct way to update number of servers where the bot is in then?

zealous jay
#

I do it with an event

#

on_guild_join

silk fulcrum
#

^^

zealous jay
#

It does it once when it starts and then updates it when it joins/leaves servers with events

tacit storm
deep osprey
#

someone expert here told me to do this

@tasks.loop(seconds=5)
async def status():
    await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=f"{len(bot.guilds)} servers!"))
  
@bot.event
async def on_ready():
    status.start()
    print("We have successfully logged in as {0.user}".format(bot))```
zealous jay
#

I mean the guild count wont update unless the bot joins/leaves a guild so I think its better to use events

#

Instead of constantly updating

deep osprey
#

yes I didn't know about on_guild_join

#

thank you 😄

zealous jay
#

no problem

zealous jay
#

anyways, I keep getting rate limited for some reason 🥲

silk fulcrum
#

well if your bot joins servers very fast, like every 5 sec he gets invited, it makes sence to make a loop to not get ratelimited

tacit storm
tacit storm
zealous jay
#

I do not have a loop

tacit storm
#

o

silk fulcrum
#

you dont get context

deep osprey
silk fulcrum
#

he's changing presence in on_ready

tacit storm
#

yikes.

zealous jay
#

In case its something from there

tacit storm
zealous jay
#

oh I was about to ask that

#

okay so, I change it in the constructor?

zealous jay
#

by constructor you are talking about this?

silk fulcrum
#

yes

tacit storm
#

if you want to truly get an accurate count on prescense updating when your bot joins a server, make a basic tasks.loop with the duration of 5 minutes so that you dont get ratelimited + it checks for the bot server count every 5 minutes for updates.

silk fulcrum
#

!d discord.ext.commands.Bot

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, intents, **options)```
Represents a Discord bot.

This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") you can do with this bot.

This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.

Unlike [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client"), this class does not require manually setting a [`CommandTree`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CommandTree "discord.app_commands.CommandTree") and is automatically set upon instantiating the class.

async with x Asynchronously initialises the bot and automatically cleans up.

New in version 2.0.
silk fulcrum
tacit storm
#

no

zealous jay
#

im trying to understand

gleaming anvil
tacit storm
#

its not better necessarily

tacit storm
zealous jay
#

thats what Im doing

silk fulcrum
tacit storm
gleaming anvil
zealous jay
#

nope

#

I don't think anyone is inviting/kicking the bot rn

gleaming anvil
#

thats because the bot is not joining a server currently

zealous jay
#

also I still need that event because

When the bots joins a server it fetchs all the bans that guild has and saves them in the database

gleaming anvil
#

you can use setup hook to change the presence for the first time

silk fulcrum
gleaming anvil
#
async def setup_hook():
    await bot.wait_until_ready()
    await bot.change_presence(...)
bot.setup_hook = setup_hook
gleaming anvil
slate swan
#

just make it async😏

tacit storm
gleaming anvil
slate swan
tacit storm
gleaming anvil
#

yea~

silk fulcrum
#

well, that warning he's getting essentially means that your code is blocking for more than x seconds

zealous jay
#

should I wait until ready to load cogs?

slate swan
# gleaming anvil bot = await Bot(**kwargs)
class Dog:

    async def __new__(cls) -> "Dog":
        await (instance:=super().__new__(cls)).__init__()
        return instance
    
    async def __init__(self) -> None:
        pass

async def main() -> None:
    await Dog()

😳

silk fulcrum
#

it blocks heartbeat

gleaming anvil
#

depends, in most cases no

silk fulcrum
#

:(

zealous jay
#

So... where should I change presence then?

gleaming anvil
slate swan
gleaming anvil
silk fulcrum
gleaming anvil
#

and let the on_guild_join events stay

gleaming anvil
zealous jay
#

uuuh 'NoneType' object has no attribute 'change_presence'

gleaming anvil
#

full code?

slate swan
zealous jay
#
    async def setup_hook(self) -> None:
        await self.change_presence(
            status=discord.Status.online, 
            activity=discord.Activity(type=discord.ActivityType.watching, 
            name=f'{len(self.guilds)} servers! | g!help'))

        self.session = aiohttp.ClientSession()

        target_dir = Path.cwd() / 'cogs'

        for cog in target_dir.rglob('*.py'):
            await self.load_extension(f'cogs.{cog.parent.name}.{cog.stem}')

        await cltree.sync(guild=discord.Object(770698123915165747))
        self.synced = True
        print('All commands are now synced.')
silk fulcrum
slate swan
gleaming anvil
zealous jay
#

oh srry

gleaming anvil
slate swan
silk fulcrum
#

btw wait_until_ready is probably not what is designed for setup_hook, which is done before the bot is setup

silk fulcrum
zealous jay
#

how long should It take

#

the until_ready thing

silk fulcrum
#

30000 years

zealous jay
slate swan
gleaming anvil
zealous jay
#

well its been like

#

a minute

gleaming anvil
#

is the bot online?

zealous jay
#

no

gleaming anvil
#

mm yeah then what master said, you cant use wait_until_ready there sadly

#
async def change_s():
    await bot.wait_until_ready()
    await bot.change_presence(...)
    
async def setup_hook():
    asyncio.get_event_loop().create_task(change_s())
bot.setup_hook = setup_hook
``` but you can do this
silk fulcrum
#

what the hook is this

dull terrace
#

How many people here work in teams

shrewd apex
#

just create a task loop

gleaming anvil
#

asher does 😳

slate swan
#

imagine

dull terrace
#

90% of bots i see have multiple people working on it, surely not necessary 7739monkathink

shrewd apex
gleaming anvil
#

L

slate swan
shrewd apex
zealous jay
#

Like this?

#

Now the bot is online but there's no presence

gleaming anvil
#

yes this should for sure work given that asyncio is imported

zealous jay
gleaming anvil
shrewd apex
#

just use a taskloop smh

gleaming anvil
#

well thats another thing lol

#

youre ratelimited

silk fulcrum
#

just bruhing do it in a bot definition and that's it

zealous jay
#

but the whole point of this was that Im getting rate limited

#

that's why I am here

gleaming anvil
silk fulcrum
#

why would you need all that to just get it async

silk fulcrum
gleaming anvil
#

but rip dpy, they wont let u

silk fulcrum
#

actually you can even make a command

zealous jay
#

will any of this fix the rate limit thing?

silk fulcrum
#

not necessary

shrewd apex
#

my messages all invisible today

zealous jay
#

the thing is I don't care about the presence, I just want to avoid getting rate limited for some reason

dull terrace
#

why are you being rate limited?

zealous jay
#

I don't know 😭

silk fulcrum
#

thats what he's asking for

dull terrace
#

are you getting rate limited when you start your bot?

zealous jay
#

yes

gleaming anvil
sick birch
#

Is your bot running on replit?

dull terrace
#

i kept getting that with a library i used to use, spacing on the name

#

went away when i switched

silk fulcrum
zealous jay
#

idk if session id is important

sick birch
#

I'd suggest set up proper logging with the logging module to see get to the root of the issue

silk fulcrum
#

btw its shard id None

gleaming anvil
#

that means they are using Bot, not AutoShardedBot

silk fulcrum
#

ohkay

zealous jay
slate swan
zealous jay
#

the latest version

#

idk I updated today and the suddenly appeared lol

slate swan
#

yeah it does but im not sure if it should show

dull terrace
#

oh yeah, i used to use interactions-py, that was the one that would always get me rate limited

slate swan
#

because even 1.7.3 had it and i never got the logging messages

silk fulcrum
slate swan
#

i never really get logging messages if its outside of the file im running lmao

zealous jay
#

🤷‍♂️

zealous jay
#

I honestly have no idea and Im confused af

slate swan
#

being a programmer in a nutshell

dull terrace
#

i mean you could just comment out random parts of the code you run on start up and see when it goes away

slate swan
#

something that can ratelimit you quick is reactions

zealous jay
#

dont use reactions

slate swan
#

thats good

zealous jay
#

and there's barely any commands

#

and they are only in my guild lmao

#

its pretty weird

dull terrace
#

weird, you'd think reactions are fairly easy for discord to process

zealous jay
slate swan
#

i get the little ratelimited block on mobile all the time since ratelimits on reactions is so low

zealous jay
#

I don't see anything new on the console

dull terrace
#

wasn't there some meme with reactions

#

like people said there was an easter egg if you reacted really fast a few times and it would mute you

#

i've never had to use logging 7739monkathink

zealous jay
slate swan
zealous jay
slate swan
#

like what degree

zealous jay
#

oh

#

I mean doctoral would be nice

#

I guess we'll se

slate swan
#

mhm nice

brazen seal
#

how to send message visible to one player?

silk fulcrum
#

ephemeral

brazen seal
#

thx

slate swan
#

!d discord.InteractionResponse

unkempt canyonBOT
#

class discord.InteractionResponse```
Represents a Discord interaction response.

This type can be accessed through [`Interaction.response`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.Interaction.response "discord.Interaction.response").

New in version 2.0.
slate swan
#
interaction.response.send_message("Text here", ephemeral=True)
silk fulcrum
#

ephermal

#

💀

slate swan
#

HELP
ImportError: cannot import name 'tasks' from 'discord.ext' (unknown location)

#

Traceback (most recent call last): File "C:\Users\genni\OneDrive\Documenten\Lars Boost bot\main.py", line 1, in <module> import discord, json, requests, os, httpx, base64, time, subprocess File "C:\Users\genni\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\__init__.py", line 25, in <module> from .client import Client File "C:\Users\genni\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 53, in <module> from .webhook import Webhook File "C:\Users\genni\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\webhook\__init__.py", line 12, in <module> from .async_ import * File "C:\Users\genni\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\webhook\async_.py", line 52, in <module> from ..channel import PartialMessageable ImportError: cannot import name 'PartialMessageable' from 'discord.channel' (C:\Users\genni\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\channel.py)

silk fulcrum
slate swan
silk fulcrum
#

then what?

slate swan
#

Oh

#

Yeah fixed this, but this not

#

File "C:\Users\genni\OneDrive\Documenten\Lars bot\main.py", line 2, in <module>
from discord.ext import tasks, commands
ImportError: cannot import name 'tasks' from 'discord.ext' (unknown location)

zealous jay
#

well I guess I'll ask again tomorrow about the rate limit thing

slate swan
#

?

cursive pelican
slate swan
cursive pelican
#

upgrade?

slate swan
#

What then?

zealous jay
#

-U

cursive pelican
#

python -m pip uninstall discord && python -m pip install discord

zealous jay
#

isn't it -U?

cursive pelican
#

?

#

sure but uninstall works too

slate swan
#

Collecting discord Using cached discord-1.7.3-py3-none-any.whl (1.1 kB) Collecting discord.py>=1.7.3 Using cached discord.py-1.7.3-py3-none-any.whl (786 kB) Requirement already satisfied: aiohttp<3.8.0,>=3.6.0 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from discord.py>=1.7.3->discord) (3.7.4.post0) Requirement already satisfied: async-timeout<4.0,>=3.0 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py>=1.7.3->discord) (3.0.1) Requirement already satisfied: multidict<7.0,>=4.5 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py>=1.7.3->discord) (6.0.2) Requirement already satisfied: chardet<5.0,>=2.0 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py>=1.7.3->discord) (4.0.0) Requirement already satisfied: yarl<2.0,>=1.0 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py>=1.7.3->discord) (1.8.1) Requirement already satisfied: attrs>=17.3.0 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py>=1.7.3->discord) (22.1.0) Requirement already satisfied: typing-extensions>=3.6.5 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py>=1.7.3->discord) (4.3.0) Requirement already satisfied: idna>=2.0 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from yarl<2.0,>=1.0->aiohttp<3.8.0,>=3.6.0->discord.py>=1.7.3->discord) (3.3) Installing collected packages: discord.py, discord Successfully installed discord-1.7.3 discord.py-1.7.3

slate swan
#

And i dont need discord.py bcs then i'll get more errors

cursive pelican
#

try again

slate swan
#

No

cursive pelican
#

its in discordpy

#

python -m pip discord.ext.tasks try this

gleaming anvil
slate swan
cursive pelican
slate swan
#

ImportError: cannot import name 'tasks' from 'discord.ext' (unknown location)

#

Still get this err

gleaming anvil
cursive pelican
#

pip install discord[tasks]

cursive pelican
slate swan
#

i'll get these
Traceback (most recent call last): File "C:\Users\genni\OneDrive\Documenten\Lars Boost bot\main.py", line 1, in <module> import discord, json, requests, os, httpx, base64, time, subprocess File "C:\Users\genni\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\__init__.py", line 25, in <module> from .client import Client File "C:\Users\genni\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 53, in <module> from .webhook import Webhook File "C:\Users\genni\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\webhook\__init__.py", line 12, in <module> from .async_ import * File "C:\Users\genni\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\webhook\async_.py", line 52, in <module> from ..channel import PartialMessageable ImportError: cannot import name 'PartialMessageable' from 'discord.channel' (C:\Users\genni\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\channel.py)

gleaming anvil
unkempt canyonBOT
gleaming anvil
#

!pip discord

unkempt canyonBOT
cursive pelican
#

no, discord comes with discord.ext

gleaming anvil
#

they are different

cursive pelican
#

yea. mirror package. Meaning discord installs discordpy

slate swan
#

Boys help me :p

gleaming anvil
#

theres no guarantee for that.

cursive pelican
#

look at their installation above, it does install it

gleaming anvil
#

doesnt means it essentially doesnt override it

slate swan
#

C:\Users\genni\OneDrive\Documenten\Lars bot>pip show discord Name: discord Version: 1.7.3 Summary: A mirror package for discord.py. Please install that instead. Home-page: https://github.com/Rapptz/discord.py Author: Rapptz Author-email: License: UNKNOWN Location: c:\users\genni\appdata\local\programs\python\python310\lib\site-packages Requires: discord.py Required-by:

gleaming anvil
#

yeah its overrided

slate swan
# gleaming anvil uninstall discord and install discord.py

Then ill get these
Traceback (most recent call last): File "C:\Users\genni\OneDrive\Documenten\Lars Boost bot\main.py", line 1, in <module> import discord, json, requests, os, httpx, base64, time, subprocess File "C:\Users\genni\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\__init__.py", line 25, in <module> from .client import Client File "C:\Users\genni\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 53, in <module> from .webhook import Webhook File "C:\Users\genni\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\webhook\__init__.py", line 12, in <module> from .async_ import * File "C:\Users\genni\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\webhook\async_.py", line 52, in <module> from ..channel import PartialMessageable ImportError: cannot import name 'PartialMessageable' from 'discord.channel' (C:\Users\genni\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\channel.py)

gleaming anvil
#

!d discord.channel.PartialMessageable

unkempt canyonBOT
#

class discord.PartialMessageable```
Represents a partial messageable to aid with working messageable channels when only a channel ID is present.

The only way to construct this class is through [`Client.get_partial_messageable()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.get_partial_messageable "discord.Client.get_partial_messageable").

Note that this class is trimmed down and has no rich attributes.

New in version 2.0...
gleaming anvil
#

did you delete it first?

slate swan
#

yes i delete it first

#

Found existing installation: discord 1.7.3 Uninstalling discord-1.7.3: Would remove: c:\users\genni\appdata\local\programs\python\python310\lib\site-packages\discord-1.7.3.dist-info\* Proceed (Y/n)? y Successfully uninstalled discord-1.7.3

#

This is so frustraded

brazen seal
#

how to delete message?

silk fulcrum
unkempt canyonBOT
#

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

Deletes the message.

Your own messages could be deleted without any proper permissions. However to delete other people’s messages, you need the [`manage_messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission.

Changed in version 1.1: Added the new `delay` keyword-only parameter.
slate swan
#

Oh
Xd

slate swan
gleaming anvil
#

reinstall discord.py

slate swan
#

How

gleaming anvil
brazen seal
slate swan
# gleaming anvil pip uninstall discord.py pip install discord.py

Collecting discord.py Using cached discord.py-1.7.3-py3-none-any.whl (786 kB) Requirement already satisfied: aiohttp<3.8.0,>=3.6.0 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from discord.py) (3.7.4.post0) Requirement already satisfied: yarl<2.0,>=1.0 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py) (1.8.1) Requirement already satisfied: typing-extensions>=3.6.5 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py) (4.3.0) Requirement already satisfied: multidict<7.0,>=4.5 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py) (6.0.2) Requirement already satisfied: attrs>=17.3.0 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py) (22.1.0) Requirement already satisfied: chardet<5.0,>=2.0 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py) (4.0.0) Requirement already satisfied: async-timeout<4.0,>=3.0 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py) (3.0.1) Requirement already satisfied: idna>=2.0 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from yarl<2.0,>=1.0->aiohttp<3.8.0,>=3.6.0->discord.py) (3.3) Installing collected packages: discord.py Successfully installed discord.py-1.7.3

#

Requirement already satisfied: idna>=2.0 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from yarl<2.0,>=1.0->aiohttp<3.8.0,>=3.6.0->discord.py) (3.3)

#

With discord.py still gets this error, without discord.py get the other error
C:\Users\genni\OneDrive\Documenten\Lars Boost bot>py main.py Traceback (most recent call last): File "C:\Users\genni\OneDrive\Documenten\Lars Boost bot\main.py", line 1, in <module> import discord, json, requests, os, httpx, base64, time, subprocess File "C:\Users\genni\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\__init__.py", line 25, in <module> from .client import Client File "C:\Users\genni\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 53, in <module> from .webhook import Webhook File "C:\Users\genni\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\webhook\__init__.py", line 12, in <module> from .async_ import * File "C:\Users\genni\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\webhook\async_.py", line 52, in <module> from ..channel import PartialMessageable ImportError: cannot import name 'PartialMessageable' from 'discord.channel' (C:\Users\genni\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\channel.py)

gleaming anvil
slate swan
#

Yes i did

brazen seal
slate swan
#

the method returns None lol

silk fulcrum
#

yeah

slate swan
silk fulcrum
slate swan
#

it returns None😏

silk fulcrum
#

also why are you not asleep

slate swan
silk fulcrum
#

its 1 am

slate swan
slate swan
brazen seal
#

it returns

silk fulcrum
#

it returns None

#

the coro itself

#

it sends the message, ofc

#

but the function doesnt give you a message

brazen seal
#

okay and how can i delete it?

slate swan
silk fulcrum
#

that you can delete

mossy warren
#

hey, are you guys able to help me with something?

brazen seal
#

How?

slate swan
#

Broooo

#

Someone help me
from discord.ext import commands, tasks ImportError: cannot import name 'tasks' from 'discord.ext' (unknown location)

sick birch
unkempt canyonBOT
#

await delete_original_response()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Deletes the original interaction response message.

This is a lower level interface to [`InteractionMessage.delete()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionMessage.delete "discord.InteractionMessage.delete") in case you do not want to fetch the message and save an HTTP request.
slate swan
sick birch
sick birch
#

Try reinstalling then

slate swan
#

I already did 5 times

#

the whole issue is probably due to name clashing lol

#

How do i reinstall?

mossy warren
# silk fulcrum yes?

can you get the user id and then mention them like you can with slack
something like:

user = msg.get('user_id')
await msg.channel.send(f'hello <@{user}>')
slate swan
# sick birch Try reinstalling then

Collecting discord Using cached discord-1.7.3-py3-none-any.whl (1.1 kB) Collecting discord.py>=1.7.3 Using cached discord.py-1.7.3-py3-none-any.whl (786 kB) Requirement already satisfied: aiohttp<3.8.0,>=3.6.0 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from discord.py>=1.7.3->discord) (3.7.4.post0) Requirement already satisfied: chardet<5.0,>=2.0 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py>=1.7.3->discord) (4.0.0) Requirement already satisfied: multidict<7.0,>=4.5 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py>=1.7.3->discord) (6.0.2) Requirement already satisfied: async-timeout<4.0,>=3.0 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py>=1.7.3->discord) (3.0.1) Requirement already satisfied: typing-extensions>=3.6.5 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py>=1.7.3->discord) (4.3.0) Requirement already satisfied: yarl<2.0,>=1.0 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py>=1.7.3->discord) (1.8.1) Requirement already satisfied: attrs>=17.3.0 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py>=1.7.3->discord) (22.1.0) Requirement already satisfied: idna>=2.0 in c:\users\genni\appdata\local\programs\python\python310\lib\site-packages (from yarl<2.0,>=1.0->aiohttp<3.8.0,>=3.6.0->discord.py>=1.7.3->discord) (3.3) Installing collected packages: discord.py, discord

sick birch
# brazen seal

You have 2 different interactions so it's confused on which one to delete

slate swan
sick birch
brazen seal
#

thx Robin

silk fulcrum
silk fulcrum
mossy warren
#

wait is user id already a variable?

slate swan
#

its an attribute

mossy warren
sick birch
mossy warren
slate swan
sick birch
#

!d discord.Member.mention

unkempt canyonBOT
slate swan
#

Bro nobody is helping me

#

!d discord.Message.author

unkempt canyonBOT
slate swan
#

File "C:\Users\genni\OneDrive\Documenten\Lars Bot 2\main.py", line 2, in <module> from discord.ext import commands, tasks ImportError: cannot import name 'tasks' from 'discord.ext' (unknown location)

silk fulcrum
#

removed word Boosts

slate swan
#

Ok?

silk fulcrum
#

boost bot

slate swan
#

Yes?

sick birch
silk fulcrum
#

idk why you removed it

slate swan
slate swan
sick birch
# slate swan But how can i fix?

You'll need to take a good look at your filesystem and see if you've got any other folders or files named "discord" or similar that could be clashing

sudden crypt
#

hey anyone here a discord dev looking for a job?

slate swan
#

you check dirs that have such a name or check if you have a corrupted installation

silk fulcrum
unkempt canyonBOT
#

9. Do not offer or ask for paid work of any kind.

sudden crypt
slate swan
#

you can check its src or errors if they get raised in its src or you can use pip list if you have any other packages that can cause name clashing

sick birch
#

I'm guessing it's not a corrupt installation given you just reinstalled it

slate swan
#

yup

sick birch
#

But do what Okimii said, people get confused between pip install discord and pip install discord.py, may cause issues

slate swan
#

But i have litterly the same bot in other file and other name & it works

sick birch
#

So use that instead

slate swan
#

``Package Version


aiohttp 3.7.4.post0
anyio 3.6.1
async-timeout 3.0.1
attrs 22.1.0
certifi 2022.6.15
chardet 4.0.0
charset-normalizer 2.0.12
colorama 0.4.4
datadispatch 1.0.0
discord 1.7.3
ffmpeg-python 0.2.0
future 0.18.2
h11 0.12.0
httpcore 0.14.7
httpx 0.21.3
idna 3.3
imageio-ffmpeg 0.4.7
multidict 6.0.2
numpy 1.23.2
pip 22.2.2
py-cord 2.1.0
requests 2.27.1
rfc3986 1.5.0
setuptools 63.2.0
sniffio 1.2.0
typing_extensions 4.3.0
urllib3 1.26.11
yarl 1.8.1``

silk fulcrum
#

pycord 😭

slate swan
silk fulcrum
#

i said to check if there are any third party

sick birch
#

Looks like we found it

mossy warren
sick birch
#

Doesn't pycord use the same namespace as discord?

sick birch
#

I'm guessing that's what the error is then

slate swan
sick birch
#

This is why one should always use venvs when possible

silk fulcrum
#

i responded first with checking if there are 3rd party libs and what i get?

slate swan
#

Ok what do i need to do?

sick birch
slate swan
#

idc if you dont believe me but i was about to say "this screams pycord and dpy clashing" 😭 ✌️

#

WARNING: Skipping pycord as it is not installed.

sick birch
#

Pycord is just all around strange huh

slate swan
#

very

silk fulcrum
sick birch
slate swan
silk fulcrum
#

bruh

slate swan
#

blame pycord for having trash src

sick birch
slate swan
#

I'm getting this if uninstall py-cord File "C:\Users\genni\OneDrive\Documenten\Lars Boost bot\main.py", line 1, in <module> import discord, json, requests, os, httpx, base64, time, subprocess ModuleNotFoundError: No module named 'discord'

silk fulcrum
#

wbruh

sick birch
#

Well now make sure you have pycord installed, given we just told you to uninstall pycord

#

You need to have either discord.py installed or pycord, but not both

slate swan
#

what are those imports btw

white perch
#
            players = [ctx.author, arg]
            answer_1 = ""
            answer_2 = ""
            async def rock_callback(interaction):
                if not interaction.user in players:
                    return await interaction.response.send_message(ephemeral=True, embed=discord.Embed(description=f":x: This isn't your interaction menu.", colour=discord.Colour(error(ctx.guild.id))))
                if interaction.user == ctx.author:
                    if answer_1 == "":
                        answer_1 = "rock"
                        return await interaction.response.send_message(ephemeral=True, embed=discord.Embed(description=f":AdvancedBotTick: You selected `rock`.", colour=discord.Colour(success(ctx.guild.id))))```
#
UnboundLocalError: local variable 'answer_1' referenced before assignment```
slate swan
#

YES

white perch
slate swan
#

It works lets go

silk fulcrum
sick birch
#

Go with a dedicated view subclass, it's best for passing state around

silk fulcrum
#

yeah ^^

slate swan
#

since you referenced the global and then you tried to reassign a value to it meaning the error was raised because the value was assigned locally and referenced before lol

shrewd apex
slate swan
shrewd apex
#

wut what?👀

sick birch
#

huh

slate swan
#

im not sure what you mean lol

white perch
# slate swan since you referenced the global and then you tried to reassign a value to it mea...
            players = [ctx.author, arg]
            class Rock:
                def __init__(self):
                    answer_1 = ""
                async def rock_callback(interaction): 
                    if not interaction.user in players:
                        return await interaction.response.send_message(ephemeral=True, embed=discord.Embed(description=f":x: This isn't your interaction menu.", colour=discord.Colour(error(ctx.guild.id))))
                    if interaction.user == ctx.author:
                        if answer_1 == "":
                            answer_1 = "rock"
                            return await interaction.response.send_message(ephemeral=True, embed=discord.Embed(description=f":AdvancedBotTick: You selected `rock`.", colour=discord.Colour(success(ctx.guild.id))))
                rock.callback = rock_callback
            r = Rock()``` Does this seem right
#

i'm sorry im new to using classses in such cases

white perch
silk fulcrum
#

class Rock 💀

#

without even subclassing

slate swan
#

and interaction would be self so allot of attribute errors will be raised lol

shrewd apex
white perch
#

oh thanks

#

i think im starting to understand now

slate swan
shrewd apex
#

... ;-; nvm

slate swan
white perch
#

im on my way to doing it (hopefully correctly)- how do i define ctx.author and the player, and also how do i pass the players list i defined earlier?

silk fulcrum
# white perch
  • @button (lowercase)
  • you define the function in a class, not in __init__ method, so put it one indent lower (remove one tab)
  • async def func(): will require getting self since it's a class + callback of a button will always get button argument, so it will be async def rock_callback(self, interaction, _button):
  • you can make ctx a required argument in View's init method (def __init__(self, ctx)) and do self.ctx = ctx, so you can use self.ctx in your callback
  • answer_1 doesn't get it self, so you need to do self.answer_1 == '' instead of just answer_1 (same with answer_1 = "rock")
  • to define players you can again simply do self.players = your_players_list so then you can use self.players in callback
slate swan
#

lowecrase

white perch
#

Thanks

#

Basically, view = RPS(ctx, playerlist) is what i shall also do in my rps command code right

silk fulcrum
#

yeah

white perch
#

similar to functions while calling a class

#

Thanks! ill do all of this and get the code working

silk fulcrum
#

also, btw, PEP 8: line should contain maximum of 120 symbols (just recommendation)

white perch
#
NameError: name 'button' is not defined. Did you mean: 'Button'?```
silk fulcrum
#

well, discord.ui.button then, since you didnt import it

white perch
#

I imported it though

#
from discord.ui import Button```
silk fulcrum
#

lowercase...

white perch
#

oh there too?

silk fulcrum
#

they're different

white perch
#

oop okay!

silk fulcrum
#

you import Button and use button

#

different names at least

white perch
#

Got it!

unkempt canyonBOT
#
PEP not found

PEP 9001 does not exist.

vale wing
#

No

silk fulcrum
#

haha

slate swan
dim ruinBOT
#
**PEP 9001 - The Final Style Guide for Python Code**
Status

Provisional

Created

01-Apr-2022

Type

Standards Track

silk fulcrum
slate swan
#

why

#

just why

silk fulcrum
#

at least 120 characters long

zealous jay
silk fulcrum
zealous jay
#

oh april 1

silk fulcrum
#

its august 14

slate swan
#

half the august passed

silk fulcrum
#

:(((

vale wing
#

Oh mo work soon

silk fulcrum
#

i underestimated PEPs

slate swan
#

its a real pep

#

i use blurple to this day

white perch
#

Is this correct- my bot doesnt respond to it though

#
class RPS(discord.ui.View):
    def __init__(self, ctx, players):
        self.answer_1 = ""
        self.answer_2 = ""
        self.ctx = ctx
        self.players = players
    @discord.ui.button(label="Rock", style=discord.ButtonStyle.green, emoji="🪨")
    async def rock_callback(self, interaction):
        if not self.interaction.user in self.players:
            return await self.interaction.response.send_message(ephemeral=True, embed=discord.Embed(description=f":x: This isn't your interaction menu.", colour=discord.Colour(error(self.ctx.guild.id))))
        if self.interaction.user == self.ctx.author:
            if self.answer_1 == "":
                self.answer_1 = "rock"
                return await interaction.response.send_message(ephemeral=True, embed=discord.Embed(description=f":AdvancedBotTick: You selected `rock`.", colour=discord.Colour(success(self.ctx.guild.id))))```
vale wing
silk fulcrum
vale wing
#

Ratio 😡

silk fulcrum
#

1 - just here
2 - hastebin

white perch
#

with the assumption that Exenifix was on mobile so he cant properly read codeblocks on discord, i used a bin for him

silk fulcrum
#

wait what??

white perch
#

error is a function which fetches a specified color from the database in my code

silk fulcrum
#

bruh why's it called error

vale wing
#

Run formatter on that code

white perch
white perch
vale wing
#

Interesting

white perch
#

that's why

silk fulcrum
#

heaqou

#

so it doesnt give any error?

white perch
#

nope

#

No error

silk fulcrum
#

and what happens when you execute the command?

white perch
#

Nothing happens

#

wait ill try using try except to diagnose

silk fulcrum
#

i guess these conditions aren't met then

white perch
#

No those are met

#

I just used try except
got this error: 'RPS' object has no attribute 'children'

silk fulcrum
#

do raise(e) instead of print

#

so full traceback will happen

white perch
#

It's not printing anything in raise

silk fulcrum
#

?

grim oar
#

raise ain't a function bro

white perch
#

except Exception as e: raise(e)

#

oop

silk fulcrum
#

uh oh

white perch
#

What's the correct syntax for it?

grim oar
#

raise e

white perch
#

Ohh okay

grim oar
#

only raise works too

white perch
#

Nope not printing anything

silk fulcrum
#

print(traceback.format_exc()) lolmao

grim oar
#

What's the problem, I haven't read the full convo

silk fulcrum
#

bot deosnt respond with a view

#

hes making a rps command

grim oar
#

Oh interaction stuff, good luck

white perch
#

just searched that error in this channels history

silk fulcrum
#

yeah

white perch
#

^

#

people say to add super().init()

silk fulcrum
#

actually yes

white perch
#

Is that a valid solution to this issue

silk fulcrum
#

read an example

#

it is there

white perch
#

Yup it is there but uhh i don't understand why super init is used- mind explaining that pls (im trying to understand the code and not blindly copy ))

silk fulcrum
#

super() is instance of the original class (that you are subclassing, right now - discord.ui.View), so you have your own __init__ and super().__init__() is calling the original init for the class

white perch
#

Oh

#

Works so far!

#

TypeError: RPS.rock_callback() takes 2 positional arguments but 3 were given though when i click the button

silk fulcrum
#

show your callback func

white perch
#
class RPS(discord.ui.View):
    def __init__(self, ctx, players):
        super().__init__()
        self.answer_1 = ""
        self.answer_2 = ""
        self.ctx = ctx
        self.players = players
    @discord.ui.button(label="Rock", style=discord.ButtonStyle.green, emoji="🪨")
    async def rock_callback(self, interaction):
        if not self.interaction.user in self.players:
            return await self.interaction.response.send_message(ephemeral=True, embed=discord.Embed(description=f":x: This isn't your interaction menu.", colour=discord.Colour(error(self.ctx.guild.id))))
        if self.interaction.user == self.ctx.author:
            if self.answer_1 == "":
                self.answer_1 = "rock"
                return await interaction.response.send_message(ephemeral=True, embed=discord.Embed(description=f":AdvancedBotTick: You selected `rock`.", colour=discord.Colour(success(self.ctx.guild.id))))```
buoyant quartz
#

why is my channel the only one that no one has talked in

silk fulcrum
#

in my list I said that callback will always take button argument so you need async def ...(self, interaction, _button):, you probably wont use _button, but it is given and you are forced to take it

white perch
#

oh