#discord-bots

1 messages · Page 38 of 1

sick birch
#

The default python interpreter is written in C, yes

celest sparrow
#

in nextcord, its the same as bot.logout()

sick birch
#

Alternate implementations have been written in things like Rust, C#, Java, and even Python itself!

limber bison
sick birch
limber bison
gleaming anvil
#

you can write your own script which runs the bot and use it after logout

#

like a terminal command

gleaming anvil
#

the one you download from python site is the C interpreter

upbeat gust
#

The only good way to restart your bot is to shut it down and have your process manager handle it. You can shutdown your bot by running Bot.close().

Do use:

  • run your bot in a process manager such as:
    • systemd
    • openrc (gentoo, devuan)
    • runit (void linux)
    • supervisord
    • upstart (old ubuntu)
    • docker
  • manually reboot it

Do not use:

  • a bash loop (it can eat your C-c by rapidly spawning python and if your bot fails it won't stop it from constantly failing)
  • subprocess.call (you will eat your memory up by not letting your old processes die)
  • os.exec*
sick birch
#

Similar to a "bootstrap" compiler but not necessarily

slate swan
#

i have school tomorrow😔 ✌️

sick birch
#

Well yeah, no doubt about that. Just interesting, like a paradox

slate swan
#
while True:  input(exec(">>> "))

😳

#

one line interpreter

sick birch
#

oh yeah i suppose you could call it a day at that

slate swan
#

no hard codingyert

zenith basin
celest sparrow
zenith basin
#

hey guys

#

got a question

#

how can I get users pfp without

#

having a discord bot

#

I just want to use api

sick birch
zenith basin
#

????

sick birch
#

Oh, do you need it to be programatic?

zenith basin
#

ya

sick birch
#

You'd just go in that website and type someone's ID in

#

But if you want to use the API you'd have to use discord

#

Check the network tab while making a request on that website to see how

zenith basin
#

I found this

#

but but idk

upbeat gust
sick birch
upbeat gust
#

not talking about that website

sick birch
upbeat gust
#

I mean discords api using a user account

sick birch
#

🤔 though I think that requires a bot token so you may be right

upbeat gust
zenith basin
upbeat gust
#

so?

slate swan
#

How to check if message was sent by certain user?

#

I want to make an owner function but it wont work

#
@blacklist.command()
async def remove(ctx, member: discord.Member = None):
    user_id = member.id
    if str(ctx.message.author) in Owners:
            if user_id in BlacklistedUsers:
                try:
                    remove_user_from_blacklist(user_id)
                    embed=discord.Embed(title="User Removed From Blacklist", description=f"**{member.name}** has been successfully been removed from the blacklist", color=0x00ff11)
                    await ctx.send(embed=embed)
                except:
                    blacklist_error_remove
    if user_id in Owners:
        await ctx.send("**HEY**! Thats my owner! You cant do that!")```
#

!d discord.ext.commands.is_owner

unkempt canyonBOT
#

@discord.ext.commands.is_owner()```
A [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that checks if the person invoking this command is the owner of the bot.

This is powered by [`Bot.is_owner()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.is_owner "discord.ext.commands.Bot.is_owner").

This check raises a special exception, [`NotOwner`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.NotOwner "discord.ext.commands.NotOwner") that is derived from [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
slate swan
#

fixed ty

zenith basin
slate swan
#
@client.command()
@commands.command(aliases=['hban'])
@checks.not_blacklisted
@commands.has_permissions(ban_members=True)
@commands.cooldown(1, 3, commands.BucketType.user)
async def hackban(self, ctx, user_id: int, *, reason: str):
    if user in ctx.guild.members:
            user = await self.bot.get_or_fetch_user(user_id)
            embed = discord.Embed(
                title="Error!",
                description="An error occurred while trying to ban the user. Make sure ID is an existing ID that belongs to a user.",
                color=0xE02B2B
            )
            await ctx.reply(embed=embed, mention_author=False)

    else:
        await ctx.guild.ban(user)
        await ctx.guild.ban(user_id)
        user = await self.bot.get_or_fetch_user(user_id)
        embed = discord.Embed(
            title="User Banned!",
            description=f"**{user} (ID: {user_id}) ** was banned by **{ctx.author}**!",
            color=0x9C84EF
            )
        embed.add_field(
            name="Reason:",
            value=reason
            )
        await ctx.reply(embed=embed, mention_author=False)```

ERROR:

Traceback (most recent call last):
  File "c:\Users\Clicks\Desktop\Stuff\test.py", line 269, in <module>
    async def uyeai(self, ctx, user_id: int, *, reason: str):
  File "C:\Users\Clicks\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\core.py", line 1480, in decorator
    result = command(name=name, cls=cls, *args, **kwargs)(func)
  File "C:\Users\Clicks\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\core.py", line 1752, in decorator
    raise TypeError('Callback is already a command.')
TypeError: Callback is already a command.
#

like what

slate swan
#

you registed the command twice

slate swan
#

its the first line in the code you have given?

#

oh lmao

#

I thought, that @commands.command(aliases=['hban']) & @client.command() didnt do anything but call the command

#

no it registers the command

#

they get called internally

#

and the error was raised because you used 2 decos that register commands

#

I understand now

#
same code as before but with 1 deco

ERROR:

Traceback (most recent call last):
File "C:\Users\Clicks\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\bot.py", line 1330, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Clicks\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\core.py", line 983, in invoke
await self.prepare(ctx)
File "C:\Users\Clicks\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\core.py", line 900, in prepare
await self._parse_arguments(ctx)
File "C:\Users\Clicks\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\core.py", line 807, in _parse_arguments
transformed = await self.transform(ctx, param, attachments)
File "C:\Users\Clicks\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\core.py", line 659, in transform
raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: user_id is a required argument that is missing.

silk fulcrum
#

okimii hi! :)

slate swan
#

Hey master✌️

silk fulcrum
#

wait oki its 1 am go sleep

slate swan
#

its 12 am technically yert

silk fulcrum
#

0:56

#

who cares go sleeep

slate swan
#

no

#

its 10:57 here

slate swan
#
@client.command(aliases=['hban'])
@checks.not_blacklisted()
@commands.has_permissions(ban_members=True)
@commands.cooldown(1, 3, commands.BucketType.user)
async def hackban(self, ctx, user_id: int, *, reason: str):
    if user in ctx.guild.members:
            user = await self.bot.get_or_fetch_user(user_id)
            embed = discord.Embed(
                title="Error!",
                description="An error occurred while trying to ban the user. Make sure ID is an existing ID that belongs to a user.",
                color=0xE02B2B
            )
            await ctx.reply(embed=embed, mention_author=False)

    else:
        await ctx.guild.ban(user)
        await ctx.guild.ban(user_id)
        user = await self.bot.get_or_fetch_user(user_id)
        embed = discord.Embed(
            title="User Banned!",
            description=f"**{user} (ID: {user_id}) ** was banned by **{ctx.author}**!",
            color=0x9C84EF
            )
        embed.add_field(
            name="Reason:",
            value=reason
            )
        await ctx.reply(embed=embed, mention_author=False)```
#

Traceback (most recent call last):
File "C:\Users\Clicks\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\bot.py", line 1330, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Clicks\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\core.py", line 983, in invoke
await self.prepare(ctx)
File "C:\Users\Clicks\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\core.py", line 900, in prepare
await self._parse_arguments(ctx)
File "C:\Users\Clicks\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\core.py", line 807, in _parse_arguments
transformed = await self.transform(ctx, param, attachments)
File "C:\Users\Clicks\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\core.py", line 659, in transform
raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: user_id is a required argument that is missing.

#

user_id is added in async def hackban(self, ctx, user_id: int, *, reason: str):

#

Remove the self parameter

#

@slate swan

fickle sky
#

how do i make these using python can anyone help me

slate swan
#

what is "these"

#

ui buttons?

fickle sky
#

advance music bot system

#

with buttons

fickle sky
slate swan
#

woah that's a big question

fickle sky
#

xD

slate swan
slate swan
slate swan
#

you're not in a cog, so why do you need it?

#

hold on can you send more code?

#

!paste use this service

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.

slate swan
#

it could be another instance of using a cog wrong

slate swan
#

your sarcasm is totally dead, no offence

#

nvm

#

fixed

slate swan
vocal snow
#

Ur totally dead

slate swan
#

i pondered it for a bit but gave up cause it made no sense

slate swan
#

not the same stuff again

#

we can skip the whole Q&A bit if you just provide the code for quick diagnosis

slate swan
#

great

slate swan
#

wat

#

im as confused as timtoy

sudden crypt
#

how can i set the permisions on a voice channel when i create it to make it private

silent portal
#

Slash Commands >.<

vocal snow
#

You need to send the view in interaction.send

#

Also what is menus.Menu

#

And remove the try-except so you can see what the error is

hidden haven
#

I hate discord py so much ugh

#

Is there any reason why the code in the last if statement won't run? Assumedly everything above it is correct:

@client.event
async def on_message(message):
    if message.channel.name == 'welcome':
        author = message.author
        if not author.roles.find(name='member'):
            ....
vocal snow
#

I don't use nextcord sorry

hidden haven
#

oh so does author.roles return a list?

#

that would make sense

vocal snow
#

!d discord.Member.roles

unkempt canyonBOT
#

property roles```
A [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role") that the member belongs to. Note that the first element of this list is always the default [‘@everyone](mailto:'%40everyone)’ role.

These roles are sorted by their position in the role hierarchy.
hidden haven
#

oh so 'role' in author.roles should be it?

vocal snow
#

No it's a list of discord.Role not string

#

You can use filter or discord.utils.get

shrewd apex
#

it says Interaction has no attr bot thats not CTX it's an interaction object

shrewd apex
#

now u can check if not role

hidden haven
#

Thanks, yeah. So my bot works in my test server but fails in the actual one -- same code, same permissions. Intents are declared, but this error is raised when trying to assign roles: AttributeError: 'NoneType' object has no attribute 'id'

#

It assigns a role when the member joins, but then fails to assign one when they send their first message

shrewd apex
#

code👀

hidden haven
#

I'll send over a modified one. hold on

slate swan
#

There's no role named verify

hidden haven
#

It's a placeholder. The real code has a different role that I do not want to expose

slate swan
#

Then the role in the real code doesn't exist either.

hidden haven
#

wdym? it exists on the server

#

that holder role exists on both server A and server B. the code works in full on one but not the other, despite permissions being the same. that error that I mentioned above is raised in B and idk why or what it means

slate swan
#

maybe you lack guild members intents?

hidden haven
#

possibly, but i don't understand why it does assign the role in the first half but fails to assign or remove in the second

#

server member intents are on

silk fulcrum
#

Well, so I fixed the game, but it says "This interaction failed" every time I click the button, Is that because I don't respond with a message?

slate swan
#

yes, if you dont respond to the interaction in any way it shows This interaction failed

silk fulcrum
#

but i open the field

hidden haven
#

fixed my issue. switching to assigning roles by id and not name worked for whatever reason

slate swan
silk fulcrum
#

of course i thought of ephemeral msgs

slate swan
#

well you can do something else......

silk fulcrum
#

or that is the only way..

slate swan
#

you can defer the interaction but you really shouldnt lol

silk fulcrum
#

that wont really help

slate swan
#

blame discords api ez

silk fulcrum
slate swan
#

¯\_(ツ)_/¯

#

Hi okimi

slate swan
deep osprey
#
@bot.command()
@commands.is_owner()
async def view(ctx,arg):
    async with aiofiles.open(arg+'.txt', mode='r') as f:
        lines = await f.read()
        await ctx.reply(lines)
        await ctx.send(f"Total lines: {len(f.readlines())}")```
 why doesn't this code output the second message?
slate swan
#

mhm nice

slate swan
deep osprey
#

nope

vocal snow
#

Might want to check aiofiles docs

slate swan
#

it probably is

#

yup your right

silk fulcrum
#

@slate swan but can I delete that response message immediately?

#

didnt find anything in docs:(

deep osprey
silk fulcrum
#

well actually I found Interaction.delete_original_response

vocal snow
slate swan
silk fulcrum
#

but error says that there is only delete_original_message

slate swan
#

thats odd that an error was never raised about awaiting ctx.send

slate swan
slate swan
vocal snow
slate swan
vocal snow
#

could be because of a faulty error handler

swift pumice
#

🔄

slate swan
deep osprey
#

yes

slate swan
#

how do you use the command

swift pumice
deep osprey
#

"myPrefix" view txtfile

slate swan
#

!view txtfile

deep osprey
#

yeah

slate swan
#

and what's the file called

deep osprey
#

txtfile

slate swan
#

.txt ?

deep osprey
#

yep

slate swan
#

won't fix it but make it into a format string, where you async aiofiles

#

it's faster, and more readable

deep osprey
#

it's working well as it outputs lines of the txt file

slate swan
#

yeah but still, f strings are better

#

try iterating over each line perhaps? @deep osprey

deep osprey
#
for line in f:
  await ctx.send(f"{len(line)}")```?
slate swan
#

test it

deep osprey
#

still doesn't work

slate swan
#

error or doesn't send anything

deep osprey
#

doesn't send anything

slate swan
#

can you prnt it out

deep osprey
#

how can I do that?

slate swan
#

replace the last line with
print(f"Total lines: {len(f.readlines())}")

deep osprey
slate swan
#

ah

deep osprey
#

still nothing in the console

slate swan
#

do you have any error handlers?

deep osprey
#

yes

slate swan
#

try commenting them out

deep osprey
#

command handlers or the default handler?

slate swan
#

command handlers

deep osprey
#

I have each handler for each command and I got default handler

#

comment all of them?

slate swan
#

yeah

deep osprey
#

still nothing changed

slate swan
#

so weird

deep osprey
#

wait lemme do that function in a separate command

#

even the new command doesn't output

slate swan
#

what the

deep osprey
#

is there something wrong with file opening mode?

slate swan
#

No

#

I think I've figured it out

deep osprey
#

what's it?

slate swan
#

let me see

shrewd apex
slate swan
#

@deep osprey okay

#

so your problem was you were trying to print the length of a generator, just replace your last line with

await ctx.send(f"Total lines: {len(await f.readlines())}")
#

thats odd tho, wouldnt it still send the gen obj?

slate swan
deep osprey
#

Total lines: 0

slate swan
#

TypeError: object of type 'generator' has no len()

slate swan
slate swan
deep osprey
#

nope

slate swan
deep osprey
#

it's not 0 lines

slate swan
#

how many is it

slate swan
#

What's your code for that command now @deep osprey

deep osprey
#
@bot.command()
@commands.is_owner()
async def view(ctx,arg):
    async with aiofiles.open(arg+'.txt', mode='r') as f:
        lines = await f.read()
        await ctx.reply(lines)
        await ctx.send(f"Total lines: {len(await f.readlines())}")```
slate swan
#

what the hell, I reproduced your error

#

awaiting the read somehow makes the total lines 0

deep osprey
#

why is it saying 0 lines then?

slate swan
#

I'm not to sure

deep osprey
#

UGH

slate swan
#

dont call bot.event

#

in essence it's just

@bot.event

and not

@bot.event()
robust fulcrum
#

Guys can anyone here suggest me a command idea?

slate swan
#

@deep osprey I've been trying for a while, you probably have to count each line with a for loop

#

it's very weird, it's like you can only use one at a time or something @deep osprey

robust fulcrum
#

Guys how we can add a user cooldown to a messgse event?

shrewd apex
robust fulcrum
shrewd apex
# robust fulcrum How bro?

just make a dict to store user id and time the event was triggered then make a task loop to check and delete from that dict

slate swan
shrewd apex
#

just use read lines then

slate swan
#

it returns a list right?

shrewd apex
#

then u can do "".join(data)

#

simple

shrewd apex
robust fulcrum
#

I confused how to make task loop check

slate swan
#

Fixed

shrewd apex
#

that way u get both what's the problem

#

reaction roles out dated for 2.0 make button roles

#

¯\_(ツ)_/¯

#

idk ur code

slate swan
#

@deep osprey so basically, this should work

@bot.command()
@commands.is_owner()
async def view(ctx, arg) -> None:
    async with aiofiles.open(f'{arg}.txt', mode='r') as f:
        lines = await f.readlines()
        await ctx.reply(''.join(lines))
        await ctx.send(f"Total lines: {len(lines)}")
shrewd apex
#

u don't need to specify

slate swan
#

that package aiofiles has like no docs at all

shrewd apex
#

it so simple who need docs 👀 pithink

slate swan
#

Me

slate swan
slate swan
#

I hate my new keyboard smh so many typos

#

!paste

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.

shrewd apex
#

fetch the role once and print the role object var

robust fulcrum
shrewd apex
#

108

#

get the role seperately in another var and print

raven bolt
#

fard

deep osprey
left idol
vocal snow
#

super()._init_()

left idol
vocal snow
raven bolt
left idol
#

like super().__init__(combat)?

raven bolt
#

bro fr yoinked the pfp

#

i don't judge but damnn

shrewd apex
vocal snow
#

api gave it to me :D

#

oh wow you changed it

raven bolt
#

ykw nah bro i'm changing pfp here specifically

deep osprey
#

how to check if the .txt file got more than 2000 characters?

vocal snow
#

len()?

deep osprey
#

len(file) ?

vocal snow
#

no, file.read()

#

and then length of that

deep osprey
#

yeah i know

slate swan
#
async with aiofiles.open(...) as f:
  chars = len(await f.read())

if chars > 2000:
  ...

also rule 7

deep osprey
#

what's rule 7?

pale turtle
#

!rule 7

unkempt canyonBOT
#

7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.

shrewd apex
#

what was the problem with the recursion

silk fulcrum
#

okimii said that i really shouldn't do that

silk fulcrum
#

wait didnt you say me about that?

left idol
#

TypeError: expected Item not <class 'int'> what does <class 'int'> mean?

shrewd apex
#

hmm yeah i kinda noticed that yesterday couldn't say for sure without printing pos i think i told i to print pos

shrewd apex
silk fulcrum
#

idk if my way to stop it is good but itworks

deep osprey
#

So this is my code py @bot.command() @commands.is_owner() async def view(ctx, arg) -> None: async with aiofiles.open(f'{arg}.txt', mode='r') as f: lines = await f.readlines() x = len(lines) z = len(await f.read()) if z > 2000: await ctx.reply(''.join(lines[1:(x/2)])) await ctx.send(''.join(lines[(x/2):x])) await ctx.send(f"Total lines: {x}") else: await ctx.reply(''.join(lines)) await ctx.send(f"Total lines: {x}") I am trying to send the content of the text file even they are more than 2000 characters in 2 messages but it's not working

silk fulcrum
left idol
#

im getting the error in regards to
super().__init__(150, 5, 5, 3, 'Dark', 'Light', 'Tank')

silk fulcrum
#

more code? or full traceback

vocal snow
#

you don't pass those arguments to it

#

!d discord.ui.View

unkempt canyonBOT
#

class discord.ui.View(*, timeout=180.0)```
Represents a UI view.

This object must be inherited to create a UI within Discord.

New in version 2.0.
vocal snow
#

that's all you can pass

mossy jacinth
#

"Command.call() missing 1 required positional argument: 'context'" why?

vocal snow
mossy jacinth
#

oh

vocal snow
#

without full code can't help debug that

mossy jacinth
silk fulcrum
#

no

mossy jacinth
#

there is no more under await ctx.send...

#

except other commands

vocal snow
#

exactly?

#

we need to see the stuff above too

silk fulcrum
#

also it's better to name class with capital letter

#

Help

worn onyx
#

i have a problem in my code could anyone plzz help me?

silk fulcrum
silk fulcrum
#

I don't know where do you get your emoji from, but it's already a string, not an Emoji object, to get name from it

silk fulcrum
#

remove .name probably

deep osprey
primal moat
#

would on_guild_join be reliable for running code when my bot is added

#

all i wanna do is send to webhook when my bot gets added to a server

silk fulcrum
deep osprey
silk fulcrum
#

is there something in your text file?

deep osprey
#

yeah

silk fulcrum
#

uhm... do you have an error handler?

deep osprey
#

an error handler for each command

primal moat
mossy jacinth
#

how can i make this? This is not an emoji at the front

silk fulcrum
#

i'd do print at the start of command to see if it even gets runned, and if you have an error handler try disabling it so error can appear if there is one

silk fulcrum
unkempt canyonBOT
#

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

Defers the interaction response.

This is typically used when the interaction is acknowledged and a secondary action will be done later.

This is only supported with the following interaction types...
silk fulcrum
#

so if you are just making a slash command with getting an interaction, then: await interaction.response.defer()

worn onyx
silk fulcrum
deep osprey
silk fulcrum
# worn onyx

idk if this lib is actually called discord_components, but I really don't recommend using it

silk fulcrum
#

hm weirdo

#

I'd just send a txt file with the content... lmao

silk fulcrum
#

or install them...

#

if you want to use them for some reason....

deep osprey
junior verge
#

I'm so confused with this error, anyone got any idea what it means?

silk fulcrum
silk fulcrum
junior verge
#

I don't have that in my code?

#

That's what confuses me

deep osprey
# silk fulcrum idk, it should raise an error, probably it does not, because of error handler, y...
@bot.command()
@commands.is_owner()
async def view(ctx, arg) -> None:
    async with aiofiles.open(f'{arg}.txt', mode='r') as f:
        try:
            lines = await f.readlines()
            x = len(lines)
            z = len(await f.read())
            if z > 2000:
                await ctx.reply(''.join(lines[:2000]))
                await ctx.send(''.join(lines[2000:]))
                await ctx.send(f"Total lines: {x}")           
            else:
                await ctx.reply(''.join(lines))
                await ctx.send(f"Total lines: {x}")
        except Exception as e:
            raise e``` no output no errors
silk fulcrum
vocal snow
silk fulcrum
junior verge
silk fulcrum
junior verge
#

2.0

silk fulcrum
#

do pip list

#

you probably have 1.7.3 and 2.0 both

#

because Embed.Empty was removed in 2.0

junior verge
#

ohh i do

silk fulcrum
junior verge
#

Nah but in my whole code there, there is no single embed

silk fulcrum
junior verge
#

same error still

silk fulcrum
#

im not sure if it will only remove 1.7.3, so better do pip list after that to see if it removed properly

junior verge
#

2.0 is still there

silk fulcrum
#

and 1.7.3?

junior verge
#

Thats removed

silk fulcrum
#

hmmm.....

#

id better just reinstall it then

#

pip uninstall discord.py

#

pip install git+https://github.com/Rapptz/discord.py

junior verge
#

The official dpy 2.0 is coming soon right

junior verge
silk fulcrum
junior verge
#

yeah okay

silk fulcrum
junior verge
#

yeah sad

vocal snow
silk fulcrum
#

well i thought he meant a PyPi release

junior verge
#

Yeah

#

But idk about my error I don't get it

silk fulcrum
#

do you have any file or folder named discord?

junior verge
#

uh no

silk fulcrum
#

then.... im confused

junior verge
#

me too

#

exact error

silk fulcrum
#

from utils.util import Paginator?

junior verge
#

Yeah I use it

#

import pag not paginator

zinc reef
#

They removed Embed.Empty in recent commits

#

Hence your attribute error

junior verge
#

I don't have any embeds in that code.

silk fulcrum
#

from discord.ext.buttons import Paginator*

junior verge
vocal snow
junior verge
#

Its bit old code btw just trying to get it to work with 2.0

junior verge
silk fulcrum
#

None

junior verge
#

I mean what do I import?

vocal snow
#

find a 3p lib which is updated for dpy 2.0 or make your own

junior verge
#

oh

silk fulcrum
unkempt canyonBOT
#

class discord.ext.commands.Paginator(prefix='```', suffix='```', max_size=2000, linesep='\n')```
A class that aids in paginating code blocks for Discord messages.

len(x) Returns the total number of characters in the paginator.
silk fulcrum
vocal snow
#

that's specifically for codeblocks though

#

it's not a generic paginator class

silk fulcrum
#

well... but it's a paginator anyways)

vocal snow
#

i mean yeah if it's just text sure

#

you could subclass and modify it too

deep osprey
#
@bot.command()
@commands.is_owner()
async def view(ctx, arg) -> None:
    async with aiofiles.open(f'{arg}.txt', mode='r') as f:
        try:
            lines = await f.readlines()
            x = len(lines)
            z = len(await f.read())
            if z > 2000:
                await ctx.reply(f=discord.File(f,f'{arg}.txt'))
                await ctx.send(f"Total lines: {x}")           
            else:
                await ctx.reply(''.join(lines))
                await ctx.send(f"Total lines: {x}")
        except Exception as e:
            raise e``` doesn't send the .txt file
vocal snow
#

file kwarg

#

!d discord.TextChannel.send

unkempt canyonBOT
#
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/latest/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`File`](https://discordpy.readthedocs.io/en/latest/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
deep osprey
#

undefined name file

#
await ctx.send(file=discord.File(file,f'{arg}.txt'))```
silk fulcrum
#

why changed f in discord.File

vocal snow
#

why did you change f to file in discord.File()

deep osprey
#

still doesn't send the file

vocal snow
#

because you're reading before and you aren't resetting the file pointer

deep osprey
#
@bot.command()
@commands.is_owner()
async def view(ctx, arg) -> None:
    async with aiofiles.open(f'{arg}.txt', mode='r') as f:
        try:
            lines = await f.readlines()
            x = len(lines)
            z = len(await f.read())
            if z > 2000:
                async with aiofiles.open(f'{arg}.txt', mode='rb') as ff:
                  await ctx.send(file=discord.File(ff,f'{arg}.txt'))   
            else:
                await ctx.reply(''.join(lines))
                await ctx.send(f"Total lines: {x}")
        except Exception as e:
            raise e``` ok I tried that
junior verge
#

My bot now responds after like 10 seconds and does not error in the console, any clue why that happens?

#

Oh it does error but after like 10 seconds

golden tapir
#

does anyone thing its possible to make a googl translate bot?

golden tapir
#

how?

silk fulcrum
unkempt canyonBOT
golden tapir
#

thatnk you i will look into it

junior verge
silk fulcrum
#

.name is still here

silk fulcrum
junior verge
silk fulcrum
#

code?

junior verge
silk fulcrum
#

hm

junior verge
#

Myabe its the database because it needs to get the prefix from the database

#

and that just errored when i tried changing it

silk fulcrum
#

how do you get it?

junior verge
#

mongo

#

ill just remove that for now

silk fulcrum
#

ok

junior verge
#

@silk fulcrum that was the issue

silk fulcrum
#

lmao

potent light
#

I want to make my bot that's being developed in Discord 2.0 to work in all servers await bot.tree.sync() apparently requires the object of all the guilds that the server is supposed to work in.
I am thinking of looping over all the guilds that the bot is in, then create a list of objects of all the servers that the bot is in and pass it to sync(). The question that I have is whether there is a simpler method or not (such as a default command or something to make the bot work in all the servers).

silk fulcrum
#

POV: when you have a bot developed in Discord 2.0

heavy folio
#

ok mr fork user

heavy folio
silk fulcrum
#

actually I have this in my setup_hook and it works on all guilds without problems

heavy folio
#

auto syncing sucks

silk fulcrum
#

waht\

heavy folio
#

__A__uto __S__yncing (your command tree) __S__ucks, and here's why:
Syncing your command tree automatically causes extra unnecessary requests to be made, this is because you only need to sync when commands are updated.
*see ?tag whensync for a more enunciated list on when to sync.

What syncing does is send your commands to discord for one guild or globally. If you haven't changed your command's descriptions, added/removed commands, changed names, parameters, etc. you shouldn't sync, since you'd only be updating discord with the commands they already have without doing any changes, which is pointless and a waste of an API request to a limit with an already tight rate limit.
*see ?tag whatsync for a more enunciated on what syncing is, and how to do so.

Where should I sync instead?
It's better to sync using a normal (message) command (or even an on_message if you prefer Client) You can even use just a simple eval to do so.
*for example:?tag umbras sync command

*But I don't have the new message content intent... What now?
Bots can still receive message content when the bot is mentioned in it, or in DMs! You could set the bot prefix to commands.when_mentioned

*Why do I get a Missing Access error when trying to sync to a guild? -> See ?tag mas

shrewd apex
#

best use jishaku to sync ur commands pithink

potent light
potent light
shrewd apex
#

yes

#

passing None which is by default makes commands global

potent light
#

thanks!

silk fulcrum
#

all this code should be one indent lower (remove one Tab)

#

backspace

#

before backspace

#

after backspace

real grail
#

What is the cache in discord bots? (What is the concept)

silk fulcrum
real grail
silk fulcrum
#

nothing changed

real grail
#

Deleting tabs in block of code

silk fulcrum
#

how do you delete symbols?

#

isnt there a backspace button right below it?

#

or like next to it

robust fulcrum
silk fulcrum
#

it is delete

#

backspace deletes symbol which is before the cursor, and delete deletes symbol which is in front of the cursor

#

anyways you can delete a tab even with delete

#

before delete

#

after delete 4 times

#

also if your editor is smart then you can just select the code and press Shift+Tab

#

yes

real grail
#

this block

#

👍

marsh violet
#

that multi line string is also 1 space off I think

civic sphinx
#

Can any one make a bot?m

silk fulcrum
#

this is 5 spaces

#

u need 4

unkempt canyonBOT
#

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

silk fulcrum
#

InputText? wtf? are you using pycord?

#

InputTextStyle

#

no

#

in the style=discord.TextStyle.long

#

oh my bruh...

#

you cannot subclass with keywords

#

there cant be title=

#

and i gotta do something

#

nothing.....

silk fulcrum
trail dove
#

hey guys so im asking rn if all those discord py codes are outdated cuz the ban and kick commands aint working for me

silk fulcrum
#

help group 💀

#

ban and kick must work

trail dove
#

bruuhh

#

I tested this on my old laptop, didn't worked it but rn when i tested this on my new laptop like wth it just worked

silk fulcrum
#

shit happens

trail dove
#

but yeah im so happy rn that this shit worked finally

silk fulcrum
#

what does that mean

trail dove
silk fulcrum
#

ohkay

cold sonnet
#

youtube music bot

silk fulcrum
#

oh wait havent noticed

#

no

#

i dont think so

#

i havent even seen such an error

oblique root
#
in_memory_point_keeper = {}


def write_point_keeper_to_file(in_memory_point_keeper):
    with open('point-keeper.json', mode='a') as f:
        json.dump(in_memory_point_keeper, f)
        in_memory_point_keeper.update()


def add_points(user):
    try:
        with open("point-keeper.json", mode="r"):
            in_memory_point_keeper[f'{user.name}'] = int(in_memory_point_keeper[f'{user.name}']) + 1
            write_point_keeper_to_file(in_memory_point_keeper)
            in_memory_point_keeper.update()

    except KeyError:
        with open("point-keeper.json", mode="r"):
            in_memory_point_keeper[f'{user.name}'] = 1
            write_point_keeper_to_file(in_memory_point_keeper)
            in_memory_point_keeper.update()
    if message.channel.name == "test":
        for content_type in message.attachments:
            if content_type == "JPEG" or "PNG":
                print("point added")
                add_points(user)
{"Custom": 1}{"Custom": 2}{"Custom": 1}{"Custom": 1}{"Custom": 1}{"Custom": 1}{"Custom": 1}

it is saving points like this, each time the script gets restarted and when an image gets uploaded again, it starts a new one, how do i get it to just add to the point amount?

slate swan
quaint scaffold
slate swan
#

What lib is that?

#

I could help with d.py 2.0.0a, tho slash_command seems to be sum bad fork despair

slate swan
slate swan
#

"We think discord.py is a good library, however, it violates the API and does not follow the API guild schema."

torn sail
#

What does that mean

silk fulcrum
#

same question

#

"violates the API"

slate swan
vocal snow
#

Does not follow the guild schema? Is there a missing field in discord.Guild?

silk fulcrum
#

discord.Guild.schema :lmao:

vocal snow
#

bruh

#

Bad joke !!!

silk fulcrum
slate swan
#

No one asked what you think about that

shrewd apex
slate swan
#

They did KEKW

silk fulcrum
shrewd apex
#

how u know u were sitting next to him

slate swan
#

Check this discord api server

slate swan
shrewd apex
#

learn some english 🗿

#

or atleast explain how it violates don't just quote someone and tell what they told

slate swan
#

Says the dude who doesn't know what a QUOTE IS

shrewd apex
#

are u going to explain how it violates or u just simply trolling

slate swan
#

There is an API Guide by discord

#

i have a discord i had made but the dev is rude as hell but i have an error i need help with``` Traceback (most recent call last):
File "/home/container/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 195, in wrapped
ret = await coro(args, *kwargs)
File "ragebot.py", line 109, in stock
return await ctx.send(embed=discord.Embed(description=b, colour=0x00ff80).set_footer(icon_url=ctx.author.avatar_url,text=f"{ctx.author} • {datetime.datetime.now().strftime('%H:%M')}").set_author(name="Product Stock"))
AttributeError: 'Member' object has no attribute 'avatar_url'

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

Traceback (most recent call last):
File "/home/container/.local/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 1330, in invoke
await ctx.command.invoke(ctx)
File "/home/container/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 991, in invoke
await injected(ctx.args, ctx.kwargs) # type: ignore
File "/home/container/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 204, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Member' object has no attribute 'avatar_url'
2022-08-16 08:47:57 ERROR discord.ext.commands.bot Ignoring exception in command stock
Traceback (most recent call last):
File "/home/container/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 195, in wrapped
ret = await coro(args, kwargs)
File "ragebot.py", line 109, in stock
return await ctx.send(embed=discord.Embed(description=b, colour=0x00ff80).set_footer(icon_url=ctx.author.avatar_url,text=f"{ctx.author} • {datetime.datetime.now().strftime('%H:%M')}").set_author(name="Product Stock"))
AttributeError: 'Member' object has no attribute 'avatar_url'

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

silk fulcrum
slate swan
silk fulcrum
#

what did i just say

slate swan
silk fulcrum
shrewd apex
# slate swan There is an API Guide by discord

so just cause PPL like u will pop out randomly and say that this library dosent follow we have to go and read api guide so if tomorrow i question Newton's laws u will go calculate them again for me

mossy jacinth
#

Hey i want to add category buttons to my help command but i dont know how to edit the message after it got pressed

shrewd apex
#

ur making a claim or quoting and quote u should backup ur sentence 🗿

silk fulcrum
shrewd apex
humble trout
#

I have a lot of util functions that need to access my postgres database using a pool connection, but I dont want to pass the pool or my bot through every function I plan to query my database in. Am I thinking about this the wrong way or is there a better method of statically referencing my pool than putting a single connection in the bot's attributes?

silk fulcrum
shrewd apex
shrewd apex
mossy jacinth
#

I never clicked a button before this

shrewd apex
#

u responded once already

mossy jacinth
#

But i just restarted the bot, typed the command and then pressed the button

humble trout
shrewd apex
#

ok actually just defer it at start then do as master32 said

humble trout
shrewd apex
#

nope

#

wait a sec

humble trout
#

alright yeah cause otherwise I have no idea what you are saying

shrewd apex
#

those contain all the db parts

#

hopefully u'll get a rough idea

humble trout
#

looks like just create a new class with a static classreference to the pool?

slate swan
#

Hey, are you capable of passing json file info into an embed?

slate swan
unkempt canyonBOT
#

classmethod from_dict(data)```
Converts a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.10)") to a [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") provided it is in the format that Discord expects it to be in.

You can find out about this format in the [official Discord documentation](https://discord.com/developers/docs/resources/channel#embed-object).
slate swan
#

iirc load automatically converts json data to dict

#

So, you're not able to put json files into it by default?

silk fulcrum
#

what's the problem with doing json.load lmao

slate swan
#

Can someone tell me what the issue is?

#

The api isn't the issue

#

The embed isn't actually sending once I run the command.

potent spear
slate swan
#

OH LOL

#

it disappeared

#

I had it b4 tho

potent spear
#

anyways, you can refactor some indentation

#

your if: ... else: ...

#

can basically become

if steamid is None:
  return await ctx.send("...")

ts = int(...)
...```
#

this eliminates/removes a whole else block

slate swan
#

Oh, that's not a bad idea.

#

fuck I'm too sleep deprived to think of that

potent spear
#

you should also consider using aiohttp
but you probably knew that already

spring flax
#

If you want a command to be able to be used like py def something(ctx, one, two, three, four)
Or ```py
def something(ctx, mode)

How would you do it?
brazen raft
brazen raft
#

Which is exactly the reason I've recommended using it

slate swan
#

httpx fLOOsh

silk fulcrum
vocal snow
#

httpx is faster but you'll need another dependency

spring flax
silk fulcrum
slate swan
#

Okay. I'll look into it. Thanks!

brazen raft
#

You can use a group

#

This way you can have both versions

potent spear
#

but that would take an extra subcommand

brazen raft
#

Is that a problem

potent spear
#

depends for him

brazen raft
#

It makes sense to

spring flax
#

ah. i can check the len()

#

thanks

vocal snow
#

Right

#

You could also have custom converter or whatever but i feel like it's overkill

potent spear
#

not really that good, since if some args are multiple words, you wouldn't know which word is for which arg

#

example

brazen raft
#

You can use quotes

potent spear
#

yeah, but that's not really user-friendly, right?

brazen raft
#

That's why I suggested using a group

potent spear
#

I've done it for private guilds, but I don't think regular members would like it

slate swan
potent spear
#

can't you choose which arg you're passing a value to through autocomplete or whatever in the newer versions?

agile spade
#

so this ban command is not working for some reason

@client.command()
@commands.has_permissions(ban_members = True)
async def ban(ctx, member : discord.Member, *, reason = None):
    await member.ban(reason = reason)

potent spear
slate swan
agile spade
agile spade
# silk fulcrum error?

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

potent spear
# slate swan huh?

how would he know if the member's argument is a mode he passed, or the value of one?
it might also be that he meant to fill in the ctx, one, two ,three command, but accidentally ended up with ctx, mode
hard to explain, but not failproof I think

agile spade
#

yeah it does

#

stil not working

potent spear
#

you can't ban yourself, or someone with a higher/equal role than your bot I think

#

I'm not developing moderation bots, so idk

slate swan
agile spade
#

yeah i am trying to ban my alt so

potent spear
potent spear
slate swan
potent spear
#

I have something similar

#

city_or_postal_code

desert badger
#
Traceback (most recent call last):
  File "/home/container/main.py", line 32, in <module>
    client = commands.Bot(
TypeError: __init__() got an unexpected keyword argument 'test_guild'```
#

never got this wtf -

vocal snow
#

Which dapi wrapper are you using?

glad cradle
desert badger
desert badger
#

and in all my other bots, test_guild work

glad cradle
#

test_guild or test_guilds is not an attribute of nextcord.ext.commands.Bot

desert badger
#

it works in all my other bots tho

silk fulcrum
#

those use disnake

desert badger
#

i switched from disnake to nextcord a few months ago and i think i just still have test_guild in my code

i didnt get any errors yet, so i just kept it lol

slate swan
glad cradle
#

First it's test_guilds in disnake, not test_guild

slate swan
#

😳

desert badger
#

and it worked

glad cradle
#

as you can see nextcord doesn't have that attribute for commands.Bot

slate swan
#

why don't people just use d.py

silk fulcrum
glad cradle
silk fulcrum
#

the most confusing is pycord for me

silk fulcrum
#

discord.Bot

slate swan
desert badger
glad cradle
silk fulcrum
glad cradle
slate swan
silk fulcrum
slate swan
#

🥺

slate swan
#

Possible to use id in
@commands.has_role(Id)?

silk fulcrum
#

yes

slate swan
#

mhm?

#

Just do @fresh banemands.has_role(123)?

#

...

silk fulcrum
#

yes

slate swan
silk fulcrum
#

yes....

slate swan
glad cradle
#

fix your second if indentation

#

yes

#

😐

#
if argument == "...":
    ...
elif argument == "...":
    ...

basics of python

slate swan
#

Is it
commands.MissingPermissions
Or
commands.MissingRequiredPermissions?

slate swan
#

k

glad cradle
#

!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/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
hot prawn
#

Something named elif in python exist

junior verge
#

whats the thing called again to use a command if you have x ID

honest shoal
#

in english reference, it should be else if, right? In python that thing is elif(else+if)

limber bison
#

whAT 400MB one contain ?

vocal snow
limber bison
#

is anything like async and await while useing mysql ?

silk fulcrum
unkempt canyonBOT
limber bison
vocal snow
#

Yes use aiomysql for discord.bot

limber bison
#

got it , let me read doc thanks btw

silk fulcrum
#

maybe their dashboard is working with mysql

vocal snow
#

Wdym.for a discord bot

silk fulcrum
#

what's with your keyboard

vocal snow
#

Mobile

silk fulcrum
#

ohkay

vocal snow
#

It's scalable

junior verge
#
@commands.command()
    async def test(ctx):

        id1 = 813824599522541628
        id2 = 574217755692236803
        if ctx.message.author.id == id1 or ctx.message.author.id == id2:
            ctx.send("a")
        else:
            None

``` Should this just work?
vocal snow
#

why the else: None

silk fulcrum
#

who as... well, must agree... mysql is overkill

vocal snow
#

It's better in the long run

glad cradle
junior verge
vocal snow
junior verge
vocal snow
#

How so?

junior verge
vocal snow
#

It's not like using MySQL is causing any performance hits

#

However if data size and read/writes increase then sqlite won't be enough

#

That's going to mean refactoring, copying old data etc

silk fulcrum
#

btw, how do I copy data from postgres to async postgres

#

wait nvm nononono dont asnwer that

#

im stiupid

vocal snow
#

It's not like discord bots store only some specific data

#

Depends on what the bot does

#

A music bot could be storing lots and lots of track metadata

silk fulcrum
vocal snow
#

APIs don't let you collect data and statistics

#

Of course it is. But for large amounts of data MySQL is better

#

Why are you assuming that discord bots are always small and private

silk fulcrum
#

i also like it

vocal snow
#

And using MySQL hardly increases development time

#

Except for the initial setup everything is the same

#

It even has support for more types

#

You're saying that they have less knowledge now, so they will never be able to make a popular bot?

vale wing
#

Argument

#

.txt files are best for database no cap

vocal snow
#

So you agree that their bot can be in many servers? There is a chance?

#

In which case it's better to build a scalable solution in the first place

#

Depending on the data being stored it absolutely does

silk fulcrum
#

databases were always behind them

vale wing
silk fulcrum
vocal snow
#

It's 30 mph now but it can speed up anytime 🤷

#

Unless of course it's a private bot and OP is going to intentionally restrict it

vale wing
#

Migrating between databases is pain

#

That's why txt files are better

vocal snow
#

Why not

#

Can requirements never change

vocal snow
hushed galleon
potent spear
#

also, initializing that db in on_ready is... debatable...

vale wing
#

Where source

hushed galleon
#

well it seems new() is merely creating the channel if it doesnt exist in cache, so its not that big of a deal

#

compared to its existence

vocal snow
#

!d discord.Guild.bans

unkempt canyonBOT
#

async for ... in bans(*, limit=1000, before=..., after=...)```
Retrieves an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.10)") of the users that are banned from the guild as a [`BanEntry`](https://discordpy.readthedocs.io/en/latest/api.html#discord.BanEntry "discord.BanEntry").

You must have the [`ban_members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to get this information.

Changed in version 2.0: Due to a breaking change in Discord’s API, this now returns a paginated iterator instead of a list.

Examples

Usage...
vocal snow
#

ctx.guilds.bans

#

it doesn't return a list

#

what

#

why did you make it ctx.guilds

#

i was just telling you that ctx.guild.bans() is an AsyncIterator

#

not a list

vocal snow
shrewd apex
vocal snow
shrewd apex
#

what we here for if PPL read docs😔

vocal snow
#

to show them how to read doc so they dont need someone to hold their hand everytime they run into a problem ☺️

shrewd apex
#

life be easier if PPL read docs and extra bonus if they read a bit of python basics before reading docs

vocal snow
#

yes !!

shrewd apex
#

gl achieving

#

for now spork feed them if not spoon

vocal snow
#

spork is demon spawn

#

did you see the examples in the doc

shrewd apex
vocal snow
#

ill wait

vocal snow
#

which example do you not understand

shrewd apex
#

ur coding skill idk but u are very good at designing embeds that's a very important talent for making discord bots

vocal snow
#

true very good UX

shrewd apex
#

now that await checkinput() gives me a feeling that co pilot was suggesting and u pressed tab to complete pithink

#

ur wait_for lacks checks

vocal snow
#

your variable naming is insanely creative

shrewd apex
#

and a timeout

vocal snow
#

"susy_baka_check" so beautiful

shrewd apex
sick birch
#

Also this code could be leaned up a lot

#

Too much nesting, hard to follow

shrewd apex
#

yeah define a checkinput

#

idk what it does tho what does it do

#

or whats it supposed to do

#

so why did check_input become checkinput

cerulean shale
#

but i did install the package

shrewd apex
cerulean shale
shrewd apex
#

2.0 has slash commandspithink

cerulean shale
#

hmmm

shrewd apex
cerulean shale
#

then i installed discord-py-slash-command

#

and it said successfully installed

sick birch
#

All the discordpy slash command extension modules should be take off pip, they’re garbage lol

#

My humble opinion

shrewd apex
shrewd apex
#

it like writing on label i-am-not-fake-get-me

cerulean shale
#

;-;

shrewd apex
#

show check_dic

shrewd apex
#

the check_dic function def

#

not u calling it

desert badger
#
Traceback (most recent call last):
  File "/home/container/main.py", line 41, in <module>
    client.load_extension(f"cogs.{filename[:-3]}")
  File "/home/container/nextcord/ext/commands/bot.py", line 851, in load_extension
    self._load_from_module_spec(spec, name, extras=extras)
  File "/home/container/nextcord/ext/commands/bot.py", line 732, in _load_from_module_spec
    raise errors.ExtensionFailed(key, e) from e
nextcord.ext.commands.errors.ExtensionFailed: Extension 'cogs.status' raised an error: UnsupportedOperation: not readable```
#

why am i getting this 💀

cerulean shale
shrewd apex
shrewd apex
desert badger
#

at the beginning

shrewd apex
#

what's bomb here

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.

vocal snow
shrewd apex
#

214

desert badger
#

ohhh

#

its "r" not w

#

sry thank

shrewd apex
#

what's bombs now

#

hmm ic

#

so are u sure the guessed word is in the json file

#

and it's all lower case

#

like ball should be there in key as ball and not Ball

desert badger
#
Traceback (most recent call last):
  File "/home/container/main.py", line 41, in <module>
    client.load_extension(f"cogs.{filename[:-3]}")
  File "/home/container/nextcord/ext/commands/bot.py", line 851, in load_extension
    self._load_from_module_spec(spec, name, extras=extras)
  File "/home/container/nextcord/ext/commands/bot.py", line 732, in _load_from_module_spec
    raise errors.ExtensionFailed(key, e) from e
nextcord.ext.commands.errors.ExtensionFailed: Extension 'cogs.status' raised an error: JSONDecodeError: Expecting value: line 1 column 1 (char 0)```
#

now im getting this

desert badger
#

does the json have to be inside my cogs folder ?

shrewd apex
#

what's inside the json

shrewd apex
desert badger
shrewd apex
#

u are passing wrong bomb

#

param

desert badger
shrewd apex
#

it looks fine

#

add a few print statements and check

#

like print the word in checkdic print wort and other all that stuff

#

and print other also

#

print it before the of statement

#

even before the for

#

just after loading the json add those prints

whole sparrow
#

possible to send ephemeral = True on ctx.send?

#

or send an ephemeral message with ctx

shrewd apex
#

yes

#

add print(other)

#

also

coral flame
#

i'm trying to define some application commands inside of my commands.Bot subclass, yet am running into an issue. If i don't call tree.add_command for the commands and go to run the commands, I get CommandNotFound, yet when I add it and then sync, I get CommandSignatureMismatch. What exactly am i doing wrong?

cerulean shale
shrewd apex
#

remove print(word) sorry didn't see was helping out a friend

shrewd apex
cerulean shale
shrewd apex
coral flame
# shrewd apex code

on_ready looks like this

    async def on_ready(self):
        self.log.info(f"Ready! Logged in as {str(self.user)}")
        
        await self.__load_cogs()
        self.tree.add_command(self.reload_cogs)
        self.tree.add_command(self.sync_commands)
        
        c = self.load_config()
        
        if c.get("sync_commands_on_start", False):
            
            self.log.info("Syncing global commands...")
            await self.tree.sync()
            
...

both commands follow a similar sorta structure:

    @discord.app_commands.command(
        name = "reload_cogs",
        description = "Reloads all cogs that are currently loaded, loading them if necessary."
    )
    @discord.app_commands.guilds(816348537800753182)
    async def reload_cogs(self, interaction: discord.Interaction):
        cogs: dict = self.cogs
        
        for cog_name, cog in cogs.items():
            self.log.info(f"Reloading cog `{cog_name}`")
    
...
cerulean shale
shrewd apex
shrewd apex
cerulean shale
coral flame
shrewd apex
#

what it printed

#

thats it what about all the other stuff

shrewd apex
#

thats so strange we had like 2 print statements

#

did u remove print wort?

cerulean shale
#

@shrewd apex IT DOESN'T WORK 🥲

slate swan
#

poor ashy

cerulean shale
shrewd apex
#

it worked no ;-;

cerulean shale
#

wait i will show you

#

🥲

shrewd apex
#

there was word and wort just remove word why remove wort as well

slate swan
coral flame
shrewd apex
cerulean shale
#

k

shrewd apex
#

now run

cerulean shale
ionic edge
#

?

#

wow

#

@slate swan which discord version are you using?

shrewd apex
ionic edge
#

no

#

then?

coral flame
#

there's a pycord server y'know?

ionic edge
#

which one is better

coral flame
#

might find better help there

slate swan
#

at least other forks dont have the discord namespace

ionic edge
slate swan
ionic edge
#

is it truew?

#

heyy can you invite me to your dc server , i wanna see your bot once

sick birch
glad cradle
#

I think that you can't use app_commands without d.py 2.0 lmao

ionic edge
#

still i cant same error

brazen raft
#

You have to update it by installing it from GitHub

cerulean shale
#

i just installed dpy2.0 and am getting this error even after modifying my code, i dont understand it even a bit ;-;

ionic edge
#

what is discord2 module then??

glad cradle
# ionic edge i updated

run pip list or print in your code discord.__version__ and send the output, as Roie said you need to install d.py 2.0 from git

cerulean shale
#

i only have 2 cogs tho and the other one aint giving any error

#

pls help ;-;

ionic edge
glad cradle
unkempt canyonBOT
#

Hey @cerulean shale!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.