#discord-bots

1 messages ยท Page 453 of 1

reef trail
#

so yeah more or less

wary ravine
#

you could say InvalidArgument is thrown when the command can't be completed

reef trail
#

yes

wary ravine
#

saying "can't be completed" is vague

reef trail
#

I mean it cant really get more descriptive than that

#

Cant be completed cause of an error

wary ravine
#

what's more descriptive out of these two:
Forbidden โ€“ You do not have permissions to edit the channel.

Forbidden โ€“ The command cannot be completed.

reef trail
#

Forbidden is thrown when something cant be done, like regardless of an error

#

afaik

wary ravine
#

no, it's thrown when the user hasn't got permissions

reef trail
#

no? MissingPermissions is

wary ravine
#

which is entirely different to "the command can't be done"

wary ravine
reef trail
#

No

wary ravine
#

bot != user

reef trail
#

BotMissingPermissions

#

is when the bot doesnt have the perms

wary ravine
#

Forbidden โ€“ You do not have permissions to edit the channel.

reef trail
wary ravine
#

explain this

reef trail
#

I guess forbidden is an umbrella exception

cloud dawn
#

The command does not have a permission check so it cannot be the user, it has to be the bot.

wary ravine
#

Forbidden โ€“ You do not have permissions to edit the channel.

reef trail
#

show us your decorators

cloud dawn
#

I don't think you understand.

wary ravine
#
    @commands.command(name = "refresh", description = "refreshes the member and boost counts")
    @commands.is_owner()
    async def refresh(self, ctx):
        guild = ctx.guild
        members = guild.get_channel(884459371046768660)
        boosts = guild.get_channel(749371688822767666)
        
        await members.edit(name = f"Members: {guild.member_count}")
        await boosts.edit(name = f"Boosts: {guild.premium_subscription_count}")
        
        await ctx.send("updated stats")
reef trail
#

Yeah it is the bot

wary ravine
#

what about the bot is it

cloud dawn
reef trail
#

I assumed they are

wary ravine
#

obviously i'm the owner

reef trail
#

welp

cloud dawn
#

You'd be surprised how many people fork codes.

wary ravine
#

either way yes i am the owner

reef trail
#

Does your bots integreation role have the perms it needs

wary ravine
#

integration role

cloud dawn
#

Remove the ctx.send() and if the error still occurs it's the channel edit permission.

reef trail
wary ravine
reef trail
#

give it admin and see what happens

wary ravine
reef trail
#

Most of the time the permissions it has dont seem to work in my experience

cloud dawn
wary ravine
#

then it's edit

reef trail
#

Consider try excepting the edit then

#

then return the error

cloud dawn
#

try/except won't really fix his issue since it will just throw forbidden again.

reef trail
#

hmm

#

true, god i hate dpy sometimes

#

Forbidden is so vague

wary ravine
#

"something can't be done"

cloud dawn
#

Not dpy's fault error code from discord is just an 404 code.

reef trail
#

Well yeah, but theres obviously something else happening and its not being shown

slate swan
#

๐Ÿ‘€

#

Can you give the whole tb?

cloud dawn
#

I'm assuming members and boosts are getting defined correctly..

wary ravine
#

yes

reef trail
#

you 100% sure?

wary ravine
slate swan
wary ravine
#

.

#

@reef trail @cloud dawn yes it is an issue with the bot's permissions

#

i've just compared it to a role with admin

slate swan
#

Oh okay, it's the bot that doesn't have permissions it seems.

reef trail
#

Who would have guessed

slate swan
#

Buddy, you said you are using his code on your editor

cloud dawn
#

You don't get the full traceback because you catch the error inside on_command_error then it leaves out the full tb

slate swan
#

Those channel ID's must be ID's on his server

#

Where the bot can't manage

wary ravine
slate swan
#

Bruh

reef trail
wary ravine
slate swan
#

does the bot have permissions to edit the channel you passed in for the ID? because that error seems to say the bot doesn't have permission

cloud dawn
#

Best to take everything here with a grain or 10 million of saltshipit

slate swan
#

but we can't be sure even because you aren't getting the whole tb

cloud dawn
#

Let's focus on the full traceback first imo pithink

wary ravine
#

ok ill remove the error thingy

#

for a sec

#

bot has these perms

slate swan
#

and also, by the way

#

that's how you get full tb

cloud dawn
#

Or just comment out the catch in the on_command_error

#

Or raise it in the command

slate swan
#

yeah. but he probably did was on command error await send error

cloud dawn
#

He only got the error type.

slate swan
#

yeah, because he probably just printed error

slate swan
wary ravine
#

ok i got it working

slate swan
#

anyone uses lavalink?
lol no one is using in python general....

#

ah okay nice nice

slate swan
#

or i may be wrong

#

idk lol

wary ravine
#

we just gave up and gave the bot perms :troll:

robust wren
#

what alternative libraries are people using for discord.py

slate swan
wary ravine
slate swan
#

and probably more

slate swan
#

sad

slate swan
valid niche
#

!rule 5

unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

slate swan
#

generally any music library that has YT integration usually breaks ToS

cloud dawn
#

Youtube official bot

wary ravine
#

thats cause youtube

#

and youtube

slate swan
#

generally, usually

valid niche
#

and there's some decent logic behind it

slate swan
#

lol

cloud dawn
#

If youtube be making a discord bot be prepared to have an audio ad every 10 songs.

slate swan
blazing beacon
wary ravine
#

wasnt it like 3 ads every 4 seconds

cloud dawn
#

Honestly though if youtube would add a discord bot with youtube premium to allow premium users to use it in the VC that would be a better reason to buy it.

wary ravine
#

or did youtube change the ways

wary ravine
cloud dawn
wary ravine
#
    @commands.command(name = "refresh", description = "refreshes the member and boost counts")
    @commands.has_permissions(manage_channels = True)
    @commands.is_owner()

ok like i made a has permissions decorator but now i cant invoke the command even tho i have is_owner

#

help

cloud dawn
#

Still gonna need the full Tb

wary ravine
#

it just says im missing manage channels

past ermine
#

Any way to log errors in a .log file?

cloud dawn
past ermine
#

and i do that how?

cloud dawn
#

I dunno

past ermine
#

wow

wary ravine
# cloud dawn Still gonna need the full Tb

if you really want, here it is

Ignoring exception in command refresh:
Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.7/site-packages/discord/ext/commands/bot.py"                                               , line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/home/pi/.local/lib/python3.7/site-packages/discord/ext/commands/core.py                                               ", line 855, in invoke
    await self.prepare(ctx)
  File "/home/pi/.local/lib/python3.7/site-packages/discord/ext/commands/core.py                                               ", line 777, in prepare
    if not await self.can_run(ctx):
  File "/home/pi/.local/lib/python3.7/site-packages/discord/ext/commands/core.py                                               ", line 1087, in can_run
    return await discord.utils.async_all(predicate(ctx) for predicate in predica                                               tes)
  File "/home/pi/.local/lib/python3.7/site-packages/discord/utils.py", line 348,                                                in async_all
    for elem in gen:
  File "/home/pi/.local/lib/python3.7/site-packages/discord/ext/commands/core.py                                               ", line 1087, in <genexpr>
    return await discord.utils.async_all(predicate(ctx) for predicate in predica                                               tes)
  File "/home/pi/.local/lib/python3.7/site-packages/discord/ext/commands/core.py                                               ", line 1790, in predicate
    raise MissingPermissions(missing)
discord.ext.commands.errors.MissingPermissions: You are missing Manage Channels 
spring flax
#

!d discord.ext.commands.check_any

unkempt canyonBOT
#

discord.ext.commands.check_any(*checks)```
A [`check()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if any of the checks passed will pass, i.e. using logical OR.

If all checks fail then [`CheckAnyFailure`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.CheckAnyFailure "discord.ext.commands.CheckAnyFailure") is raised to signal the failure. It inherits from [`CheckFailure`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").

Note

The `predicate` attribute for this function **is** a coroutine.

New in version 1.3.
spring flax
#

use this for the check

wary ravine
#

or how can i add certain permissions

#

oh define my own function to assign perms i got it

slate swan
#
        em = discord.Embed(title='Hi there!', description='To setup the configuration, say start', color=color)
        await ctx.send(embed=em)
        await self.bot.wait_for('message', check=check, timeout=60)
        embed = discord.Embed(title='Great!',description='What would you like to set the logging channel too, this will log all actions! Specify a channel!')
        await ctx.send(embed=embed)
        msg = await self.bot.wait_for('message',check=check2,timeout=60)
        print(msg)
        embed = discord.Embed(title=f'The logging channel was set to {msg}')
        await ctx.send(embed=embed)

there is no error i just want it to print the id of the channel and its not

vocal shoal
#

my bot was running on a linux server and everything was normal. then the bot suddenly shut down, i logged in to the server and try running the bot but i get this error, and i am confused, like why did it decide to not work now, and also i can't see anything wrong in this line.

#

any ideas why this happens?

wary ravine
#

send them here

vocal shoal
cloud dawn
#

What python version is this?

vocal shoal
cloud dawn
#

3 what?

vocal shoal
#

3.9.5

vocal shoal
#

what do you need help with.

cloud dawn
vocal shoal
slate swan
#

Look at what I said

cloud dawn
#

This is his full traceback

wary ravine
#
...
def has_manage_channels():
    def predicate(ctx):
        return ctx.guild is not None and True if manage_channels in ctx.author.guild_permissions
    return commands.check(predicate)
...

    @commands.command(name = "refresh", description = "refreshes the member and boost counts")
    @commands.has_permissions(manage_channels = True)
    @commands.check_any(commands.is_owner(), is_guild_owner(), has_manage_channels())
    async def refresh(self, ctx):
...

Returns a SyntaxError for the has_manage_channels check function, I'm aware I haven't written it properly but i'm not sure how i should write it

cloud dawn
#

Why don't you use @has_permission

wary ravine
cloud dawn
#

Then use @commands.has_guild_permissions(**perms)

wary ravine
#

if i use has_guild_permissions i can't use is_owner or it'll pass that i don't have permissions

spring flax
wary ravine
wary ravine
#

yes

cloud dawn
#

Then they'd both be true

wary ravine
#

but im making the command so only i or someone with the manage channel permissions can use it

#

or the guild owner

cloud dawn
#

Then just pass in the manage_channels permission pithink

wary ravine
#

where do i pass it

cloud dawn
#

inside the guild has permission decorator. And for the guild owner make a custom check

wary ravine
#

i' don't understand what you can't see here.

i can't use has_permissions because it conflicts with is_owner so i can't operate that command unless i have a permission given in has_permissions

cloud dawn
#

?????????????????????????????????????

vocal shoal
#

how do i pip install discord buttons?

patent lark
#

pip install buttons

wary ravine
#

discord_components

#

@vocal shoal ^

vocal shoal
#

ok thx pepethumbsup

cloud dawn
#

it's just buttons

patent lark
patent lark
cloud dawn
#

there are too many buttons pydis_nope_py

cloud dawn
#

is_onwer is meant for the bot owner not the guild owner.

wary ravine
wary ravine
cloud dawn
#

Then why can't you use has_permissions

wary ravine
# cloud dawn Then why can't you use has_permissions
@commands.command()
@commands.has_permissions(**perms)
async def command():
    #will work if anyone has permissions set in has_permissions

@commands.command()
@commands.has_permissions(**perms)
@commands.is_owner()
async def command():
    #has_permissions overrides is_owner, 
    #so even if i am the bot's owner,
    #the has_permissions check will come into function  

i don't see why you aren't understanding

stable delta
#

I tried doing stuff like

emoji = bot.get_emoji(id)
emoji.roles.append(role_id)
#

but uhhh I don't think that works lmao

cloud dawn
wary ravine
#

oh so you're telling me if i run the command and i'm missing a permission in has_permissions but i have is_owner then it will work

cloud dawn
#

So why didn't you just tell me you want them to be optional.

wary ravine
#

i never said optional

#

so will this work then

    @commands.command(name = "refresh", description = "refreshes the member and boost counts")
    @commands.has_permissions(manage_channels = True)
    @commands.check_any(commands.is_owner(), is_guild_owner())
cloud dawn
#

Yes

hasty iron
#

i mean, if you're the bot owner that doesn't necessarily mean you have permissions

wary ravine
#

I'm not aware that i was trying to present that idea

cloud dawn
#

I also don't get why you are checking for the permission because the owner would have admin perms anyways

wary ravine
#

checking for the bot owner.

cloud dawn
wary ravine
#

confusion

cloud dawn
#

Yeah i still don't really know what you want

#

Aside from the fact you want to screw with settings in other guilds py_guido

slate swan
#
        em = discord.Embed(title='Hi there!', description='To setup the configuration, say start', color=color)
        await ctx.send(embed=em)
        await self.bot.wait_for('message', check=check, timeout=60)
        embed = discord.Embed(title='Great!',description='What would you like to set the logging channel too, this will log all actions! Specify a channel!')
        await ctx.send(embed=embed)
        msg = await self.bot.wait_for('message',check=check2,timeout=60)
        print(msg)
        embed = discord.Embed(title=f'The logging channel was set to {msg}')
        await ctx.send(embed=embed)

there is no error i just want it to print the id of the channel and its not

cloud dawn
slate swan
#

do print msg.content

pliant gulch
#

msg is a discord.Message object, you need to access content attribute of msg either via dotnotation or getattr. Then you have to the use TextChannelConverter to get the corresponding channel object

slate swan
#

yeah

#

Ok thx guys

pliant gulch
#

!d discord.ext.commands.TextChannelConverter

unkempt canyonBOT
#

class discord.ext.commands.TextChannelConverter```
Converts to a [`TextChannel`](https://discordpy.readthedocs.io/en/stable/api.html#discord.TextChannel "discord.TextChannel").

All lookups are via the local guild. If in a DM context, then the lookup is done by the global cache.

The lookup strategy is as follows (in order)...
pliant gulch
#

Pass message content the convert method of an instance of this

hoary gust
#
Traceback (most recent call last):
  File "C:\Users\USER\Desktop\ZENESIS DEVELOPEMENT\PYTHON\ZENESIS\CHAT FILTER\main.py", line 43, in <module>
    bot.run(token)
  File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 719, in run
    _cleanup_loop(loop)
  File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 95, in _cleanup_loop
    loop.close()
  File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\asyncio\selector_events.py", line 89, in close
    raise RuntimeError("Cannot close a running event loop")
RuntimeError: Cannot close a running event loop```
hasty iron
#

windows issue

#

oh wait

#

selector events hmm

#

ur on windows?

hoary gust
hoary gust
hasty iron
#

yeah then windows could be the issue here

hoary gust
hasty iron
#

it happens when you stop the bot right?

hoary gust
hasty iron
#

maybe?

cloud dawn
#

Or bot is already running

hoary gust
#

it is not running

cloud dawn
#

I had a bot running in the background once ducky_dave

hasty iron
#

is it happening when you stop the bot?

#

if so then blame windows

pliant gulch
#

windows bad moment

hoary gust
hasty iron
#

another error occured

pliant gulch
#

If you run the bot and it does this error you didn't actually login correctly

hasty iron
#

send the full traceback

pliant gulch
#

Seems like invalid tokens are passed I'm assuming?

hoary gust
#

!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.pydis.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.

grim epoch
#

what's the best way to get a user's reply after sending a message?

hasty iron
#

!d discord.Client.wait_for

unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

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

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

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

This function returns the **first event that meets the requirements**...
hasty iron
#

thats the whole thing?

hoary gust
hasty iron
#

so you run the bot then that happens?

hoary gust
#

@hasty iron

stone palm
#

how do i check if a role is below a role

#

_ _

cloud dawn
unkempt canyonBOT
#

The position of the role. This number is usually positive. The bottom role has a position of 0.

covert igloo
#

why is this coming back as theres no attribute get_channel

cloud dawn
#

I can't see how bot is defined here

stone palm
covert igloo
#

client

cloud dawn
covert igloo
#

yes

cloud dawn
covert igloo
#

idk it was client then someone told me to rename it to bot to make it easier

#

i dont think the name is the problem here anyways

#

@cloud dawn this is what im getting

cloud dawn
#

Can i see your client/bot definition?

pliant gulch
#

How is telling someone to name things correctly horrible advice?

cloud dawn
pliant gulch
#

Uh... seems like someone just told him to rename it to bot

covert igloo
#

its bot = commands.Bot() @cloud dawn

cloud dawn
#

Now i'm confused

covert igloo
#

everything else works, dont think my bot definition is the probllem

#

what im trying to do here is when the command is used, to get the log channel id and send an embed there

pliant gulch
#

Are you sure its commands.Bot not commands.bot?

covert igloo
#

yes lol

#

let me send u a ss

pliant gulch
#

Can you show your imports real quick

covert igloo
#

main file

#

the cog im having the error in

cloud dawn
odd pendant
#

why import stuff from commands when you have ext.commands imported

high flame
#

what's different of loop.create_task and loop.run_until_complete

pliant gulch
#

You should really clean up your imports

covert igloo
#

I see

pliant gulch
#

Half of these are useless

#

most*

covert igloo
#

yea ๐Ÿ’€

cloud dawn
# high flame .

This is by far not buried yet you are 1/3th of the way lol

covert igloo
#

i just moved everything into cog thats why my main file has unused inmports

cloud dawn
#

They can also be combined.

covert igloo
#

the id is in there

#

@cloud dawn

wicked atlas
#

at least the single line where get_channel is called

covert igloo
wicked atlas
#

get_channel should be called on a bot or guild instance

covert igloo
wicked atlas
#

Did you perhaps me to do ```py
bot.get_channel(<id>)

covert igloo
#

ill try that

odd pendant
#

lowercase bot

#

Bot is the class, bot is your instance

wicked atlas
#

And without the <>

covert igloo
#

says undefined if i do lowercase

wicked atlas
#

Did you define your bot instance?

odd pendant
#

where is your bot = commands.Bot()

lilac bramble
#

where is a good website to start learning how to code discord bots with python

covert igloo
#

in my main file

covert igloo
odd pendant
#

i assume not

covert igloo
#

yes it is

odd pendant
#

you need to use self then

covert igloo
#

self.get_channel?

wicked atlas
#
self.bot.get_channel(id)
#

As long as you have taken bot as a parameter in __init__, like most cogs do

covert igloo
#

its self.client = client

#

should i change that to bot

wicked atlas
#

It's better to use bot when using commands.Bot

covert igloo
#

so do change it to self.bot = bot

narrow spruce
#

is it possible to do .info megaman(or whatever character u want) and the bot will send an embed with the pic of the character I want

hasty iron
#

use an api or something

narrow spruce
#

is there a video or website I can see to learn how to

agile goblet
#

Find an api that does that

narrow spruce
#

alright I'll start searching ty

high flame
drifting swift
#

fetch_guild always garunteed to work (unless not found)

#

as opposed to get_guild

slate swan
#

!d discord.Member.create_dm

unkempt canyonBOT
#

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

Creates a [`DMChannel`](https://discordpy.readthedocs.io/en/stable/api.html#discord.DMChannel "discord.DMChannel") with this user.

This should be rarely called, as this is done transparently for most people.
slate swan
#

!d discord.User.create_dm

unkempt canyonBOT
#

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

Creates a [`DMChannel`](https://discordpy.readthedocs.io/en/stable/api.html#discord.DMChannel "discord.DMChannel") with this user.

This should be rarely called, as this is done transparently for most people.
pearl inlet
#

Hello i'd like support

#

I'm making a discord bot and have an error and have no idea how to fix it

pale turtle
#

Send the code and error

pearl inlet
#

It's a simple code but if I send the whole thing i'd be sending the token

pale turtle
#

So rrmove the the token from what you are sending?

pearl inlet
#

below the client.run is the token

pale turtle
#

You need to unindent the client.run

#

And everything after the return

pearl inlet
compact field
#

guys how can i return something from on_ready ?

pearl inlet
#

And wdym by unindent

#

I'm very new to python so..

compact field
pearl inlet
#

Wait what

#

that's it

pale turtle
pale turtle
#

!resources can be a help for that.

unkempt canyonBOT
#
Resources

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

slate swan
#

@pearl inlet ur code makes no sense

#

just do 'We have logged in as {}.user'.format(client)

pearl inlet
#

New problem

slate swan
#

show code

full lily
#

not that i'm gatekeeping or anything

#

you're just going to struggle

pearl inlet
compact field
#

guyyyyyyyyyyyyyys how can i return something from on_ready

vocal plover
#

youre missing a closing )

#

on the line with .format(client)

compact field
#

how can i return something from on_ready

pearl inlet
compact field
#

somebody can help me ? :|

silver wolf
compact field
#

i need guild name from on_ready what can i do ?

#

or something like that

silver wolf
#

!d discord.Client.get_guild

unkempt canyonBOT
silver wolf
unkempt canyonBOT
slate swan
#
Traceback (most recent call last):
  File "main.py", line 5, in <module>
    import discord
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/__init__.py", line 23, in <module>
    from .client import *
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 27, in <module>
    import asyncio
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/asyncio/__init__.py", line 21, in <module>
    from .base_events import *
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/asyncio/base_events.py", line 296
    future = tasks.async(future, loop=self)
                   ^
SyntaxError: invalid syntax
``` why?
compact field
#

no i need this out of event

#

how can i get channel name out of command or event ?

full lily
dapper cobalt
brittle ingot
#

!d discord.Webhook.channel

slate swan
#

Command raised an exception: NotImplementedError: Derived classes need to implement this.

#

problem with rpl = await client.wait_for("message", timeout = 60.0), if it doesn't get an expected valid command, the prompt will just cancel completely

#

I could do it in a while loop but then the timer will reset any time you put in a new invalid feedback

#

example, I have it rn to where it will send a message then you react to the message with whatever reactions and then you type "done"

#

but if you type anything else, it'll just break itself

slate swan
#

hold up gimme a sec

#
try:
    rpl = await client.wait_for("message", timeout = 60.0)
    if rpl.content.lower() == "done":
        for i in list(client.cached_messages):
            if i.id == rm:
                print(i.reactions)
                break
except asyncio.TimeoutError():
    await cl.send("Prompt has been cancelled.")

#

but if the awaited reply is not "done", it will just break

pliant gulch
#

Depending on cache size this could take ages to finish

slate swan
#

trying to get it to wait for you to say done over multiple messages

slate swan
#

I'm gonna use the find command

#

@pliant gulch im having an i ssue now'

#

find(client.cached_messages, id = rm) I believe it would be

pliant gulch
#

Looks better but it still iterates over

#

I don't think is a way to get past that tbh

slate swan
#

Okay so better idea:

#

How can I better manage my bot's cache to where it'll only store like, the last 200 messages

#
class SetupCommand(commands.Cog):
  def __init__(self,bot):
    self.bot = bot

  async def convert(self, ctx, argument):
    raise NotImplementedError('Derived classes need to implement this.')

        
  @commands.command()
  @commands.has_permissions(administrator=True)
  async def setup(self, ctx):

    def check(message):
      return message.author == ctx.author and message.content.lower() == "start"
    
    def check2(message):
      return message.author == ctx.message.author

    try:
        em = discord.Embed(title='Hi there!', description='To setup the configuration, say start', color=color)
        await ctx.send(embed=em)
        await self.bot.wait_for('message', check=check, timeout=60)
        embed = discord.Embed(title='Great!',description='What would you like to set the logging channel too, this will log all actions! Specify a channel!')
        await ctx.send(embed=embed)
        msg = await self.bot.wait_for('message',check=check2,timeout=60)
        msg2 = await self.convert(ctx,msg.content)
        embed = discord.Embed(title=f'The logging channel was set to {msg2}')
        await ctx.send(embed=embed)

    except asyncio.TimeoutError:
      await ctx.channel.send('Timeout, try again!')

Command raised an exception: NotImplementedError: Derived classes need to implement this.

pliant gulch
#

Why are you adding a convert method to your cog?????

#

I told you earlier to just make an instance of TextChannelConverter and use the convert method of that

#

!d discord.ext.commands.TextChannelConverter.convert

unkempt canyonBOT
#

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

The method to override to do conversion logic.

If an error is found while converting, it is recommended to raise a [`CommandError`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError") derived exception as it will properly propagate to the error handlers.
lofty heron
#

hi can somebody check why console returns client is not defined? i'm pretty sure i've defined it with

  def __init__(self, client):
    self.client = client
#

is it because client.latency needs to be commands.latency?

#

hmm not that

jaunty dagger
#

how long does this take to fix

lofty heron
#

10 minutes - 30 minutes - an hour

#

could be a minute tho

waxen granite
jaunty dagger
#

and got the msg

#

so im just using a vpn

#

so I can bypass lol

lofty heron
viscid fractal
#

Maybe making a class? With some tables?

vocal fog
#

Hi!

stone talon
vocal fog
#

I want to make a function for easy embed building

#
    embed = EmbedBuilder (
    color = discord.Color.dark_gold(),
    title = title,
    description = description
    ).build()
    return embed

await ctx.send(embedbuilder('',f'You can use this command again in {round(error.retry_after, 2)}s'))
#

but i get this result

#

<discord.embeds.Embed object at 0x000001DACC6244C0>

slate swan
#

embed=embedbuilder(...)

#

In ctx.send

stone talon
#

or something like that

vocal fog
slate swan
#

Yw

slate swan
stone talon
stark hearth
normal halo
slate swan
#

It's the master version of dpy

#

It's dpy with a bit more features which should've been released somewhere in the near future if the development wouldn't have ceased

normal halo
#

Ok

boreal ravine
final iron
#

I basically replicated the dank memer hack command for fun but for some reason its sending channel information

#

I can send the code but essentially its sending the message then editing it then using asyncio.sleep and looping it

boreal ravine
#

show

final iron
#
    @commands.command()
    async def hack(self, ctx, member: discord.Member):
        msg = await ctx.send(f"Hacking {member.name} now...")
        await ctx.send(msg)

        await asyncio.sleep(1)
        await msg.edit(content="[โ––] Finding discord login... (2fa bypassed)")
        await asyncio.sleep(1)
        await msg.edit(content=f"[โ–˜] Found:\n**Email**: `{random.choice(email_choices)}`\n**Password**: `{random.choice(password_choices)}`")
        await asyncio.sleep(1)
        await msg.edit(content="[โ–] Fetching dms with closest friends (if there are any friends at all)")
        await asyncio.sleep(1)
        await msg.edit(content=f'[โ–—] Last DM: "{random.choice(dm_choices)}"')
        await asyncio.sleep(1)
        await msg.edit(content="[โ––] Finding most common word...")
        await asyncio.sleep(1)
        await msg.edit(content=f'[โ–˜] const mostCommon = "{random.choice(mostcommonword_choices)}"')
        await asyncio.sleep(1)
        await msg.edit(content=f'[โ–] Injecting trojan virus into discriminator #{member.discriminator}')
        await asyncio.sleep(1)
        await msg.edit(content=f'[โ–—] Virus injected, emotes stolen')
        await asyncio.sleep(1)
        await msg.edit(content=f'[โ––] Setting up Epic Store account...')
        await asyncio.sleep(1)
        await msg.edit(content=f'[โ–˜] Hacking Epic Store account....')
        await asyncio.sleep(1)
        await msg.edit(content=f'[โ–] Finding IP address')
        await asyncio.sleep(1)
        await msg.edit(content=f'[โ–—] IP address: 127.0.0.1:2994')
        await asyncio.sleep(1)
        await msg.edit(content=f'[โ––] Selling data to the Government...')
        await asyncio.sleep(1)
        await msg.edit(content=f'[โ–˜] Reporting account to discord for breaking TOS..')
        await asyncio.sleep(1)
        await msg.edit(content=f'[โ–] Hacking medical records')
        await asyncio.sleep(1)
        await msg.edit(content=f"[โ–—] **IMPORTANT HEALTH UPDATE**: Subject's brain is {random.choice(healthupdate_choices)}")
        await asyncio.sleep(1)
        await msg.edit(content=f'Finished hacking {member.name}')
        await ctx.send(f"The *totally* real and dangerous hack is complete")
#

It sends the first message then sends this <Message id=884578946367258675 channel=<TextChannel id=851801920695435277 name='general' position=1 nsfw=False news=False category_id=851801920695435275> type=<MessageType.default: 0> author=<Member id=868156490022789130 name='Epic bot' discriminator='8161' bot=True nick=None guild=<Guild id=851801920695435274 name='Test server' shard_id=None chunked=True member_count=4>> flags=<MessageFlags value=0>>

normal halo
#

In Discord v.2.0, how do I get the users banner and send it as a link?

hasty iron
#

iirc its banner.url

#

and banner can be None, so check that first

normal halo
#
bannerURL = avamember.banner,url
await ctx.send(userAvatarUrl)
normal halo
hasty iron
#

actually, banner is only returned with fetch_user

crisp pine
#

How can i make the bot change the server icon

normal halo
#

I saw something about that but I don't know how to ctx.send with fetch_user

hasty iron
#

!d discord.Client.fetch_user

unkempt canyonBOT
#

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

Retrieves a [`User`](https://discordpy.readthedocs.io/en/stable/api.html#discord.User "discord.User") based on their ID. This can only be used by bot accounts. You do not have to share any guilds with the user to get this information, however many operations do require that you do.

Note

This method is an API call. If you have [`Intents.members`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Intents.members "discord.Intents.members") and member cache enabled, consider [`get_user()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Client.get_user "discord.Client.get_user") instead.
crisp pine
#

How can i make the bot change the server icon

hasty iron
#

and then User.banner.url

hasty iron
unkempt canyonBOT
#

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

Edits the guild.

You must have the [`manage_guild`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.manage_guild "discord.Permissions.manage_guild") permission to edit the guild.

Changed in version 1.4: The rules\_channel and public\_updates\_channel keyword-only parameters were added.
crisp pine
#

Is it possible for user banner command too?

hasty iron
normal halo
hasty iron
#

fetch_user is a method of Client/Bot

#

and you need an instance of User, fetch_user returns one

hardy yoke
#

(also needs to be indented inside the command)

hasty iron
#

and user_id is not defined

normal halo
#

Ok

hasty iron
#

yes

normal halo
#

wait

hasty iron
#

also put a cooldown on the command to prevent people from spamming it, fetch_user is an api call that could get you ratelimited if spammed or even banned

normal halo
#

how do I make a cooldown?

hasty iron
#

!d discord.ext.commands.cooldown

unkempt canyonBOT
#

discord.ext.commands.cooldown(rate, per, type=<BucketType.default: 0>)```
A decorator that adds a cooldown to a [`Command`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")

A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").

If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.on_command_error "discord.on_command_error") and the local error handler.

A command can only have a single cooldown.
normal halo
#

ok

#

im getting errors

#

OH wait

normal halo
#

ok now it says int has no attribution to banner

#

indenting was fixed

#

@hasty iron

hasty iron
#

as i said banner is an attribute of User

#

you have to save the return value of fetch_user and use that

#

you clearly are a python beginner so i suggest you go back to learning basics

normal halo
#

im a beginner at discord python

hasty iron
#

no, youโ€™re a beginner at python as a whole

bold oxide
#

lmfao

stark bobcat
#

Hoi

slate swan
#

so with print(ctx.guild.members) how can I just print their ids?

vale pendant
hasty iron
#

you can do ids = [member.id for member in Guild.members]

sweet pilot
#

role always return none when fetched

#

any reason?

pliant gulch
sweet pilot
#
role = member.guild.get_role(853983786236377266)
await member.add_roles(role)
#

the role returns none altho I copied the id of the correct role from the server

normal halo
#

@hasty iron Thanks for the help with the banner command lol. I will go and study the basics of python again. It now sends the banner and says if someone doesn't have a banner.

slate swan
slate swan
sweet pilot
#

guild has no issue

#

guild object seems fine

slate swan
#

@vale pendant discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'discord.member' has no attribute 'id'

brisk fiber
#

(@slate swan ^)

slate swan
#

oh.. no lmao

#

I added it. still the same thing

brisk fiber
#

no thatโ€™s good that you donโ€™t

#

yeah donโ€™t add it haha sorry poor phrasing

#

thatโ€™s just what the error message read as to me

slate swan
#
ids = []
        for _ids in ctx.guild.members:
            ids.append(member.id)```
brisk fiber
#

oh actually i think i see the problem

slate swan
#

oh?

brisk fiber
#

oh okay

#

you havenโ€™t defined member

slate swan
#

um... is member member = ctx.guild.members?

brisk fiber
#

no itโ€™d be ids.append(_ids.id)

#

because _ids is a Member object

#

probably better to name it something like each_member

#

donโ€™t name it just member because youโ€™d override dpy

slate swan
#

ohh that makes sense

vale pendant
#

Sorry for not answering but yes, member is not defined.

#

So you would put _ids.id

brisk fiber
#

actually i think dpy uses Member, not member, but probably still good to avoid just in case

tight obsidian
#

your local variable member will not override anything in discord.py

#

naming a variable the same way as a class is pretty common if there isn't more context than the type

brisk fiber
#

fair

slate swan
#

how do i make a discord bot in colab?

heavy folio
slate swan
#

google colab

heavy folio
#

idt u can

slate swan
#

what can you use to make discord bots

#

the discord api?

#

which is probably a language i cant understand?

normal halo
#

What is the documentation for a user's accent color in discord.py v2.0

slate swan
#

discovered the module called multiprocessing, can anyone tell me why this isn't printing anything:

#
from multiprocessing import Process

def func1():
    while True:
        print(1)
        
p1 = Process(target = func1)
p1.start()```
round quarry
#

How can I make that, when a user has been kicked from the server, the bot send them md?

heavy folio
round quarry
#

what

heavy folio
#

what do u mean by md

#

whats a md

drifting swift
#

Direct message probably

heavy folio
#

uhhh

round quarry
#

yes, dm, md, private message, that's how it is said in Spanish

heavy folio
#

u should prolly send them a message before they get kicked

boreal ravine
#

What's an accent color?

#

Is it the random banner color?

heavy folio
slate swan
boreal ravine
#

O

slate swan
boreal ravine
#

Ok thanks

round quarry
#

I know, but I thought that in English it was also said like this

vale pendant
#

que?

round quarry
#

so it is not possible for the bot to do it automatically?

drifting swift
#

Not everyone can type perfectly Curious

round quarry
#

o :(

drifting swift
# round quarry o :(

Well it could do it โ€œautomaticallyโ€ you just canโ€™t dm anyone who isnโ€™t the same server as you

round quarry
#

how is it done? shipit

drifting swift
#

Cant*

round quarry
#

thank you anyway

slate swan
urban river
#

does anyone know anything about the API update? there are many things missing

slate swan
#

#bot-commands

lofty heron
maiden fable
#

@boreal ravine what's that?

heavy folio
#

is it possible to put timestamp in the footer?

maiden fable
unkempt canyonBOT
heavy folio
#

want the text to be small but also want the unix timestamp to be there

heavy folio
maiden fable
#

Ah

#

Nope, not in footer

heavy folio
#

aw okay ty

slate swan
slate swan
#

what should i import for buttons

silver wolf
#

buttons are for discord.py 2.0a. unless ur using a different library

maiden fable
#

Use disnake instead. It has buttons inside the library. Discord Components is messing with the discord.py lib

slate swan
#

does anyone know where to find a cookiecutter template for python discord bots?

maiden fable
#

What's the error?

slate swan
maiden fable
#

I mean

#

There could be 316167618404 errors, I don't know which one you got

slate swan
#

It looks like they ended the discord.py project. Are there serious attempts to fork it and continue it?

unkempt canyonBOT
brisk fiber
slate swan
brisk fiber
#

no worries! and dpy should keep functioning fine as-is for a fair number of months at least, although we never know

#

and yeah itโ€™s kinda too bad but i understand where dpyโ€™s maintainer is coming from

boreal ravine
slate swan
boreal ravine
#

kk

slate swan
boreal ravine
#

no

slate swan
#

pls sis

boreal ravine
#

no

slate swan
#

why sis

boreal ravine
#

no

slate swan
#

ok

#

please

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied mute to @slate swan until <t:1630988468:f> (9 minutes and 59 seconds) (reason: mentions rule: sent 6 mentions in 10s).

maiden fable
#

I just got pinged

dapper cobalt
#

Read.

maiden fable
#

Yea just saw

rich valve
#

interactions_endpoint_url: The specified interactions endpoint url could not be verified

I have problem when i try to configure the endpoint for interactions event in discord. Does anyone face it , how can i fix this problem?

slate swan
#

hikari

unkempt canyonBOT
#

You are not allowed to use that command here. Please use the #bot-commands channel instead.

slate swan
#

1000493ns

#

How can i set custom activity status ( like listening, streaming etc ) in my discord bot?

maiden fable
unkempt canyonBOT
#

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

Changes the clientโ€™s presence.

Example

```py
game = discord.Game("with the API")
await client.change_presence(status=discord.Status.idle, activity=game)
slate swan
#

!time

#

!d time

unkempt canyonBOT
#

This module provides various time-related functions. For related functionality, see also the datetime and calendar modules.

Although this module is always available, not all functions are available on all platforms. Most of the functions defined in this module call platform C library functions with the same name. It may sometimes be helpful to consult the platform documentation, because the semantics of these functions varies among platforms.

An explanation of some terminology and conventions is in order.

โ€ข The epoch is the point where the time starts, and is platform dependent. For Unix, the epoch is January 1, 1970, 00:00:00 (UTC). To find out what the epoch is on a given platform, look at time.gmtime(0).

maiden fable
#

!botvar this is how u make a botvar

unkempt canyonBOT
#

Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:

bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"

@bot.command()
async def get(ctx: commands.Context):
    """A command to get the current value of `test`."""
    # Send what the test attribute is currently set to
    await ctx.send(ctx.bot.test)

@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
    """A command to set a new value of `test`."""
    # Here we change the attribute to what was specified in new_text
    bot.test = new_text

This all applies to cogs as well! You can set attributes to self as you wish.

Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!

slate swan
#

let me read just a sec

slate swan
#

sorry i am noob

maiden fable
#

U can name or anything

supple wing
#

guys

maiden fable
#

Hm?

supple wing
#

i need help

#

i want to make a discord AI chatbot

#

like i cant do it myself

maiden fable
#

Bro.... I have made one, but lemme tell you something.... It's not as easy as it seems. You gotta find an AI Module, then gotta find out how to train it and then add profanity filter and then add it to yr bot keeping in mind it doesn't block your bot. Then you gotta make a basic bot for the same

visual island
maiden fable
maiden fable
slate swan
#
time_to_return = datetime.utcnow()
#

is this syntax ok?

maiden fable
#

No

visual island
#

!docstring this is mine pepe_epiklaugh

unkempt canyonBOT
#

A docstring is a string - always using triple quotes - that's placed at the top of files, classes and functions. A docstring should contain a clear explanation of what it's describing. You can also include descriptions of the subject's parameter(s) and what it returns, as shown below:

def greet(name: str, age: int) -> str:
    """
    Return a string that greets the given person, using their name and age.

    :param name: The name of the person to greet.
    :param age: The age of the person to greet.

    :return: The greeting.
    """
    return f"Hello {name}, you are {age} years old!"

You can get the docstring by using the inspect.getdoc function, from the built-in inspect module, or by accessing the .__doc__ attribute. inspect.getdoc is often preferred, as it clears indents from the docstring.

For the last example, you can print it by doing this: print(inspect.getdoc(greet)).

For more details about what a docstring is and its usage, check out this guide by Real Python, or the official docstring specification.

supple wing
slate swan
#

then

maiden fable
#

bot.time_to_return....

maiden fable
#

There goes my net, it was expected cat_headbang

steel flower
#

what is the difference between from discord.ext import commands and discord.ext.commands.Bot()

maiden fable
#

If yes, then no difference

steel flower
#

Yes that works @maiden fable

maiden fable
#

Then no difference. Matter of chouce

#

Choice**

steel flower
#

Another question when using commands how do i run the bot? I was using client.run()

#

however someone suggested i use bot commands

#

since i was checking message content

visual island
pliant gulch
#

commands.Bot inherits discord.Client

maiden fable
pliant gulch
#

Thus you run it the same way

maiden fable
#

Ah, that thing. Yea

steel flower
#

I see @maiden fable so i just run client.run()

#

correct?

maiden fable
steel flower
#

Alright thanks @maiden fable

maiden fable
#

Instead of commands.Bot

pliant gulch
visual island
#

i thought he was trying to see the difference between

from discord.ext import command
bot = commands.Bot()

and

import discord
bot = discord.ext.commands.Bot()
visual island
#

so i dont really want to load all of it

maiden fable
maiden fable
pliant gulch
steel flower
#

Alright so i am trying to figure out how to view the current channel name do y'all have a API reference i can checkout so i don't keep bothering you all i checked the discord.py docs and was confused when it came to the bot commands

#

i understand client() just not bot commands

visual island
#

oh the __init__.py

pliant gulch
#

So it doesn't load the __init__.py and other files I want not to be loaded

#

For an example if I needed something like _help to stay unloaded

#

cool trick in that snippet is the async classmethod

#

makes the class in an async func so I don't need to do stupid asyncio stuff

waxen granite
#

How can i get a list of loaded and unloaded cogs?

maiden fable
unkempt canyonBOT
steel flower
unkempt canyonBOT
steel flower
#

alright let me try that thanks @maiden fable

maiden fable
valid patio
#

why is this comming ?

maiden fable
#

Ah

#

It's not yr bot, is it?

valid patio
#

its mine

maiden fable
#

Hmm, well u gotta uncheck the code grant check from discord dev portal. Open the portal, I will guide u

valid patio
#

ok

#

i opened the dev portal

maiden fable
#

Go to the Bot section

valid patio
#

ok

maiden fable
#

And there should be a check with the name code grant or something

valid patio
#

i will look for it

#

ok yea thanku

maiden fable
#

(:

keen talon
#

what happened XD

maiden fable
#

Nothing

keen talon
#

one message got deleted

maiden fable
#

Idk

vast juniper
steel flower
#

hey is there any more easy to read docs for bot commands than the discord.py documentation

keen talon
#

help()

unique nexus
#

docs is most ez but sometime it also confuse me

#

the payload and all that

steel flower
#

I am trying to figure out how to access the message that called the bot command however i can't seem to find a answer i understand and @keen talon if you aren't going to help then shut up and don't answer a message i did not ask for your opinion i am here to get help not have someone try and act like they know everything

#

yeah i am used to client run event however i am trying to figure out bot commands @unique nexus

keen talon
#

ctx.message

#

rip @client

unique nexus
#

ok

steel flower
#

oh crap

#

i meant to say @ client.run

keen talon
#

u should use commands.Bot

steel flower
#

I am now

keen talon
steel flower
#

again if you aren't going to bother reading the message don't respond

keen talon
#
async def damn(self ,ctx):
  ctx.message
#

@steel flower you there ?

steel flower
#

yeah @keen talon

#

i figured it out

#

thanks for the help

keen talon
steel flower
#

what? @boreal ravine

boreal ravine
#

-.-

steel flower
#

what do you want

drifting arrow
#

Hey guys. Whats the benefits to using the discord.py (or its successors) vs just coding it myself?

pliant gulch
#

Well, you have about 6 years of work already made for you

boreal ravine
#

Why is it undefined?

reef shell
#

I would say using a good fork of d.py would be good as it will save your time

#

BucketType

#

"T"

#

in line 5

boreal ravine
#

Huh

#

I just copied it from my other files and the letters changed

#

thats weird

#

well thanks sherlock

reef shell
#

lol

#

np

wispy sequoia
#

!charinfo ๐Ÿ“

unkempt canyonBOT
drifting arrow
reef shell
#

yes that's the best out there

wispy sequoia
#

you want yt tutorial?

reef shell
#

don't

wispy sequoia
#

sad

drifting arrow
#

Send me one and if I get around to it I'll watch it ๐Ÿ˜„

steel flower
#

Hey everyone i am back i am using cfx.message and before with message.content i could use split() however now i can not even when converting to a str does anyone have a suggestion how i can access a certain part of a bot command

unique nexus
reef shell
wispy sequoia
# steel flower Hey everyone i am back i am using cfx.message and before with message.content i ...
elif(msg.content.lower().startswith('ban')):
        if(not msg.author.id in devs and not msg.author.guild_permissions.view_audit_log):
            return await noPerm(msg)

        args = msg.content.split(' ')[1:]

        if(len(args) < 1):
            return await msg.channel.send(f'Usage: {prefix}ban <user> <reason>|none')

        if(not args[0].startswith('<@') or not args[0].endswith('>')):
            return await msg.channel.send(f'Usage: {prefix}ban <user> <reason>|none')
        
        args[0] = args[0][2:-1]
        if(args[0].startswith('!')):
            args[0] = args[0][1:]

        if(len(args) == 2 and args[1] == 'none'):
            args[1] = '' 

        try:
            memberToBan = await msg.guild.fetch_member(args[0])
            await memberToBan.ban(reason=' '.join(args[1:]))
            await msg.reply(embed=discord.Embed(title=f":white_check_mark: Banned {memberToBan.name}#{memberToBan.discriminator}!", color=0x00ff00), mention_author=False)
        except discord.errors.HTTPException:
            await msg.reply(embed=discord.Embed(title=":x: An error occurred.", color=0xff0000), mention_author=False)```
#

smth me and a friend made

#

maybe it can help

reef shell
#

why not use a cmd deco.

wispy sequoia
#

ยฏ_(ใƒ„)_/ยฏ

#

I'm still learning man I'm not a pro

wispy sequoia
#

there's just 1 event

#

with multiple if options

reef shell
unkempt canyonBOT
#
Naw.

No documentation found for the requested symbol.

reef shell
#

oh nvm

boreal ravine
wispy sequoia
#

yess

boreal ravine
#

thats bad

wispy sequoia
#

Ik

#

but it's just testing

boreal ravine
#

o

#

ok

wispy sequoia
#

I'm making this now

boreal ravine
#

ok

wispy sequoia
#

does anyone know a vscode extension with help in discord python?

#

like suggesting things

reef shell
#

idk but vs code by default suggest/shows docstrings when you hover over any method or attr.

wispy sequoia
#

you see channel and purge are not even reached by vscode

boreal ravine
#

await

wispy sequoia
#

yes

boreal ravine
#

u didnt await it

wispy sequoia
boreal ravine
wispy sequoia
#

not even reached

boreal ravine
#

not reached?

#

wym

reef shell
#

^

wispy sequoia
#

.channel.purge are white

reef shell
#

wdyw

wispy sequoia
#

vscode says

reef shell
#

so?

wispy sequoia
#

channel: Any

#

purge: Any

boreal ravine
#

colors (pyflakes) dont matter except green and red

wispy sequoia
#

Ik

boreal ravine
#

try it on your bot to see if it works ig

wispy sequoia
#

but I want something to suggest me things

boreal ravine
wispy sequoia
#

Ik

#

is there smth better than vscode I can use for python?

boreal ravine
#

uh

wispy sequoia
#

also

#

the purge command works with 5 messages, how to make it purge much messages as I want?

steel flower
#

@wispy sequoia yeah i had that working in my own version however someone suggested i move to bot commands

wispy sequoia
#

like #purge 50

steel flower
#

and now with bot commands split does not work even when converting to a str

reef shell
#

use the cmd deco.

#

not a on_message event

boreal ravine
steel flower
#

what do you mean @boreal ravine

#

i was using message.content however it was not clearing the text at the end and instead was just using the bot response as the message text

boreal ravine
#

I mean that on message commands are messy and if you make normal commands you can set the command permissions like ```py
@commands.has_permissions(administrator=True)

steel flower
#

Do you know how i could remove the content of the message on next run

boreal ravine
#

the content?

steel flower
#

I have the bot always running so restart is not a option

#

yes message.content

reef shell
#

can you share the code snippet

steel flower
#

The bot always uses it's message as the message.content

#

and yes one second

reef shell
#

again , don't make commands using on_message event, lol

slate swan
#

Yeah

#

Use decorators to make the commands

unkempt canyonBOT
reef shell
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

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

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

steel flower
boreal ravine
#

o

steel flower
#

I was not using commands for this one i was doing it almost like yours @reef shell lol

#

what @boreal ravine

reef shell
#

what?

steel flower
#

you said not to use commands using on_message

#

Unless you were not talking to me

wispy sequoia
#

if I do #purge 50 this returns ['50'] (list), how to make it just 50

steel flower
#

oh wrong person sorry @reef shell

reef shell
boreal ravine
steel flower
#

i got you confused with someone else and i would like to be able to check a Discord message at a specific part in the string and check it's length

boreal ravine
#

those u dont have to change

boreal ravine
wispy sequoia
#

like, isn't the amount set on 2?

steel flower
#

@boreal ravine You going to answer the question you keep saying o

boreal ravine
wispy sequoia
#

oh wow

reef shell
wispy sequoia
#

I didn't know that

reef shell
#

when you don't pass the amount

boreal ravine
#

A filter is what your doing right? like dyno for example

steel flower
#

alright do you know what could be wrong with my code and yeah @boreal ravine

boreal ravine
#

ooo

reef shell
#

@wispy sequoia

@bot.command(aliases = ['del', 'delete', 'clear'])


async def purge(ctx, amount : int = 5):
    await ctx.channel.purge(limit = amount + 1)
    await ctx.channel.send(f"Deleted {amount} messages!!", delete_after = 2)```
wispy sequoia
#

ok now

#

this is a music bot

#

so it's not meant for moderation

boreal ravine
#

o

wispy sequoia
#

how to set the purge only on the bot

reef shell
#

i just copied my code nvm

wispy sequoia
#

so if I do #purge it purges only itself messages?

boreal ravine
#

no

reef shell
#

no

boreal ravine
#

it'll purge every1s message

reef shell
#

latest messages in channel

wispy sequoia
boreal ravine
#

o

#

brb

wispy sequoia
#

like rythm does

steel flower
#

does anyone know how to help me or point me in the right way

wispy sequoia
steel flower
#

@wispy sequoia if you scroll up you will see i sent a piece of my bot that always returns the bots last message the next bot command and screws up the length check

wispy sequoia
#

ye that's a problem

wispy sequoia
#

Idfk how to unlist

#

but u can try

steel flower
#

anyone else

wispy sequoia
steel flower
#

i already tried that

wispy sequoia
#

hm k

#

finally smth that works :yay:

lone aurora
#
@client.command(pass_context=True)
async def play(ctx, url):
    guild = ctx.message.guild
    voice_client = guild.voice_client
    player = await voice_client.create_ytdl_player(url)
    players = [guild.id] = player
    player.start()

@client.command(pass_context=True)
async def join(ctx):
    if ctx.message.author.voice:
        channel = ctx.message.author.voice.channel
        await client.channel.connect()``` whats my dumb butt doing wrong now
steel flower
#

Can someone help me with my problem

#

I canโ€™t figure it out

wispy sequoia
#
@client.command()
async def ping(ctx):
    await ctx.reply(f"\U0001f3d3 Pong! **{round(client.latency * 1000)}ms**", mention_author=False)


@client.command()
async def purge(ctx, amount=5):
    await ctx.channel.purge(limit=amount)```

excuse me WHAT
#

what's that thing

lone aurora
#

yea this happened to my bot too

#

apparently an auto help cmd is made

wispy sequoia
#

bruh

lone aurora
#

also u seem to be the guy who knows how music bots work

brave ravine
#

u have to get rid of it

lone aurora
wispy sequoia
lone aurora
#

well frick

brave ravine
#

if u want to make a custom embed help command

wispy sequoia
brave ravine
#

look through the docs

#

if u cant find it ill tell u

brave ravine
lone aurora
#

potato potaato

wispy sequoia
wispy sequoia
lone aurora
#

meh id say its good to start with yt since its a bit hard togo through docs, once u get some basic knowledge u can start with docs

brave ravine
wispy sequoia
#

well I do

maiden fable
brave ravine
steel flower
#

Could someone help me with my bot

brave ravine
steel flower
#

I have no idea whatโ€™s wrong

maiden fable
brave ravine
#

we cant help if u dont tell us what u need help with

steel flower
#

If you arenโ€™t going to help shut up @brave ravine

maiden fable
#

Please be polite @brave ravine

brave ravine
#

lmao

maiden fable
#

@steel flower what do u need help with?

steel flower
#

Nobody wants to hear a lowlife basement dwelling mamas boy talk

brave ravine
#

ok

#

but i have a working music bit

#

bot

maiden fable
brave ravine
#

its not gonna get banned since its not popular

valid niche
brave ravine
#

lots of things scrape youtube and arent banned

#

only reason why groovy and other popular bots are getting banned is because they made money of scraping youtube

wispy sequoia
#

finally

steel flower
#

Please i have multiple monitors a OpenSea query generator you ainโ€™t nothing little boy this is just my first time with Discord bots @brave ravine also @maiden fable i am trying to check a bot command and check the length of a specific index of the code using splits however when the bot is ran again it gets the last bot comment not the users new command

slate swan
wispy sequoia
#

ye

maiden fable
steel flower
#

Donโ€™t tag me again thanks @brave ravine

wispy sequoia
brave ravine
maiden fable
#

Dude