#discord-bots

1 messages · Page 618 of 1

slate swan
#

maybe you help?

sullen shoal
#

file content is string but get_user accepts int thats it

slate swan
#

the user is not in bot's cache

#

oh yea , you need to convert the id in int form as myxi said

#

It's there

#

.read() returns str type only iirc

glass rock
#

if i make the bot send a message, how can i make it react to it?

sullen shoal
#

send method returns the discord.Message you sent

#

you may assign it to a variable

glass rock
#

wait do you mean:
message=await message.channel.send('<@'+i+'>')?

sullen shoal
#

yeah, you assigned the instance of discord.Message to the variable message because channel.send returns it

glass rock
#

thank you

velvet tinsel
#

Hi myxi

sullen shoal
#

hello

normal folio
#

@slate swan tell. the problem

modern fiber
#

Looking for one more Python Bot Developer to be a part of our team that is working on a public discord multipurpose bot!

fallen mica
slate swan
#

Yeah so it didnt work

#

i turned every variable into a attribute and used self.variable but it doesnt work

sullen shoal
#

how it doesn't work

#

like how did u check

glass rock
#

can i define a client event inside a client event?

sullen shoal
#

why

#

you can use bot.wait_for

glass rock
#

hmm

#

what does it do?

sullen shoal
#

waits for an event

glass rock
#

Does it have a client alternative?

sullen shoal
#

bot is a subclass of client

glass rock
#

oh ye

#

thx @sullen shoal

sullen shoal
#

the docs of it are very well explained you can check them if you get stuck

#

!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/master/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
steep estuary
#

how to get roles of my discord bot ?

#

bot.user.roles not working

#

should i fetch the user?

twilit dragon
#

!invite

unkempt canyonBOT
#

property me: discord.member.Member```
Similar to [`Client.user`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.user "discord.Client.user") except an instance of [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member"). This is essentially used to get the member version of yourself.
slate swan
#

you can do guild.me.roles

steep estuary
#

guild.me.roles ?

#

this will target the bot ?

slate swan
#

yea , basically Guild.me returns the bot member for a guild

twilit dragon
steep estuary
#

cuz i want to check roles of my bot

#

i thought that will work

#

it is giving exception

#

client user don't have attribute roles

twilit dragon
#

why putting user

steep estuary
#

ohk

twilit dragon
steep estuary
#

trying

twilit dragon
#

ok

rose shale
#

i cant find the link to invite my bot in developer portal

#

can anyone help

steep estuary
#

i think i should fetch the bot

slate swan
#

mrinalsparks , did you try what i told you just a minute ago?

twilit dragon
#

wait what did you define the bot

#

like what is the line you wrote after imports

steep estuary
slate swan
twilit dragon
steep estuary
#

it is showing underline on it

slate swan
#

like ctx.guild or message.guild

steep estuary
slate swan
#

ye

steep estuary
#

ohk

twilit dragon
#

see i need to see the code

slate swan
#

um?

steep estuary
rose shale
slate swan
#

@snow kiln can you stop

#

or we need to ping some moderator

snow kiln
slate swan
twilit dragon
slate swan
#

pls dont spam here

twilit dragon
#

ok listen wha is the line you wrote after all the imports

steep estuary
#

see i used for loop

#

and then tried to split the role into list

#

oops wait

slate swan
twilit dragon
#

dude it looks like you wrote Role not roles

steep estuary
#

i knew it

slate swan
#

xd

steep estuary
#

i should do it to role.name.split

slate swan
slate swan
twilit dragon
steep estuary
#

my idea is strange i just want to save the money for database

#

my bot have so many minigames

slate swan
# steep estuary yes

so you're trying to break a role's name ?
like if you have a role named 'Buggy BOt' , you want to split it into a list of strings?

steep estuary
#

and users complain that do u have any command to disallow members from playing games in some channels

rose shale
steep estuary
#

my plan successful xD

#

ty

#

so much

twilit dragon
#

make a command prefix(disallow 'member')
then give him role disallow using give.roles ig
then use check roles and if function like if roles disallow
ctx.send("you arent allowed to play")
else:(the game code)

steep estuary
#

i am disallowing channels

velvet tinsel
steep estuary
#

here

velvet tinsel
#

Here

twilit dragon
steep estuary
velvet tinsel
steep estuary
#

and if it don't have

#

then in all channels

velvet tinsel
#

Commands.has_role()

tall dust
#

!uvban 755669942224814140

velvet tinsel
#

I don’t think python has it tho

unkempt canyonBOT
#

:ok_hand: pardoned infraction voice ban for @snow kiln.

velvet tinsel
#

But it is in the discord py docs

sullen shoal
#

!d discord.ext.commands.has_role

unkempt canyonBOT
#

@discord.ext.commands.has_role(item)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member invoking the command has the role specified via the name or ID specified.

If a string is specified, you must give the exact name of the role, including caps and spelling.

If an integer is specified, you must give the exact snowflake ID of the role.

If the message is invoked in a private message context then the check will return `False`.

This check raises one of two special exceptions, [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") if the user is missing a role, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").

Changed in version 1.1: Raise [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
velvet tinsel
#

Thank you myxi

twilit dragon
# steep estuary and if it don't have

dude i think its hard to do it its not impossible you need to get client roles and if client has role you want then check guilds if guild = minigames then start its too complicated

#

are you using replit

velvet tinsel
#

Here’s your answer

#

Oh wait

#

I don’t think you’re asking

#

Nvm

twilit dragon
velvet tinsel
#

My bad 😞

twilit dragon
sullen shoal
steep estuary
#

that is done

#

i use heroku

#

and heroku provide free db with less rows

#

also data is not safe

#

i loss data in heroku every month

slate swan
#

Is there a way I can detect the channel permissions for everyone who are added there specifically? Not by the role. Just like Devo in the picture

#

I want to check if there are any and if yes, delete them all. Or edit their perms

velvet tinsel
#

Wrong answer

#

Oh

slate swan
#

Yea

velvet tinsel
#

Please elaborate I don’t quite understand

slate swan
#

So it's a Ticketsystem. And for ppl to get support they create a channel and they get added like this to the channel perms section to get some help from staff.
When the ticket gets closed I want to remove him from there. So that only staff can see that channel and not the person that created the ticket

velvet tinsel
#

Oh so allowing someone to view a channel?

#

Wouldn’t roles work?

slate swan
#

u don't understand

#

all good man :) thx anyways

sullen shoal
unkempt canyonBOT
#

await set_permissions(target, *, overwrite=see - below, reason=None, **permissions)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sets the channel specific permission overwrites for a target in the channel.

The `target` parameter should either be a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that belongs to guild.

The `overwrite` parameter, if given, must either be `None` or [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/master/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite"). For convenience, you can pass in keyword arguments denoting [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions") attributes. If this is done, then you cannot mix the keyword arguments with the `overwrite` parameter.

If the `overwrite` parameter is `None`, then the permission overwrites are deleted.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this...
velvet tinsel
#

Damn

slate swan
sullen shoal
slate swan
#

I don't want to use roles here tbh

sullen shoal
#

then go with the poor method

slate swan
#

can u give me an example?

#

On how it works

sullen shoal
#

never saw a ticket system with multiple user allocation idk how your system works

slate swan
#

And there can be multiple users in the channel permissions. That's why I want to delete them all when the ticket is closed

sullen shoal
#

the thing is, the system you want (setting channel perm for every user) will take more api calls than using roles, like you added them but when removing them, you just gotta remove the role but with your system, you have to send multiple api calls to remove all the set perms of users

slate swan
#

I don't want any temp-roles on my server

#

That's my goal

sullen shoal
#

then go with the poor method

slate swan
#

And for other ticket system bots it works good.

sullen shoal
#

when they do add user, set the perm for them in the channel, and remove them when needed

#

the docs of that method are well made click the blue title

outer violet
#

so i have a poll command, that looks like this whenever someone makes a poll (this is just my example of it). But the problem is, it’s not sending this message The results are in and option {most_voted.emoji} was the the most popular with {most_voted.count-1:,} votes! when the specified time is up when it’s supposed to and idk what to do, can someone help? https://mystb.in/TiesMadagascarMaximum.python

slate swan
#

is this where you ask for help ?

sullen shoal
#

yes with stuff related to discord bots

#

also thats not how you use the or statement

slate swan
#

this code

#
@commands.has_any_role(864458060911083562, 864808826171949066,
                       899271391872966656, 898544682978656310,)
async def mute(ctx, member: discord.Member, time: int, zeit, *, reason=None):
    author = ctx.message.author
    role = discord.utils.get(ctx.guild.roles, name="Muted")
    channel = client.get_channel(898544683406491701)
    embed = discord.Embed(title="mute:", color=0xf40000)
    
if role in ctx.guild.roles:
        if 'm' or 'minutes' or 'minute' in ctx.message.content:
            await member.add_roles(role)
            await ctx.message.delete()

            embed2.add_field(name="Mute", value=f"admin has muted {member.mention} for {time} {zeit}\n**Reason**: {reason}", inline=False)

            await asyncio.sleep(time * 60)
            await member.remove_roles(role)

        elif 'h' or 'hours' or 'hour' in ctx.message.content:
            await member.add_roles(role)
            
         embed.add_field(name="Mute", value=f"{author} muted {member.mention} for {time} {zeit}\n**Reason**: {reason}", inline=False)

            await asyncio.sleep(time * 3600)
            await member.remove_roles(role)

    else:
        embed = discord.Embed(
            title='Dude',
            description=
            "Are you mentally challenged or why haven't you created a Muted role?",
            color=0xfffffd)

        await ctx.send(embed=embed)
    await channel.send(embed=embed2)``` i got this mute that i tried to embed but it seems to not be working idk how to fix it any help ?
sullen shoal
#

looks like the main problem is with the or statement

slate swan
#

what do you mean ?

#

i get this error embed = discord.Embed(title="mute:", color=0xf40000)
^
IndentationError: unindent does not match any outer indentation level

sullen shoal
#

or checks if the first object is truthy or not if not, it will set the second object as the value of the expression

slate swan
#

if 'm' or 'minutes' or 'minute' in ctx.message.content:

if 'm' in ctx.message.content or 'minute' in ctx.message.content:
sullen shoal
#

!e

print(None or "hello")```
unkempt canyonBOT
#

@sullen shoal :white_check_mark: Your eval job has completed with return code 0.

hello
slate swan
#

Can I store all the members in 1 global variable and then delete the perms all by using the global variable?

sullen shoal
#

!e

print("hello" or "world")```
unkempt canyonBOT
#

@sullen shoal :white_check_mark: Your eval job has completed with return code 0.

hello
sullen shoal
#

a string which is not empty is truthy.

#

what you want is

slate swan
#

and I find this system dumb

sullen shoal
#

!e

print(("e", "h", "l") in "hello"))```
slate swan
#

if m is in the message, that statement will trigger

unkempt canyonBOT
#

@sullen shoal :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     print(("e", "h", "l") in "hello"))
003 |                                      ^
004 | SyntaxError: unmatched ')'
slate swan
#

the command's name is mute

sullen shoal
#

huh

slate swan
#

imagine m not being in mute

slate swan
sullen shoal
#

i gotta go afk for now

slate swan
#
@client.command()
async def mute(ctx):
    if 'm' in ctx.message.content:
        await ctx.send("Hi")
#

do you think it will send hi or not

#

i would say no , tbh im kind of new to python so i barely know what i am doing

#

bruh

#

so let's say the message you sent is !mute

#

yuh

#

since the m is in mute, the if statement will always be true

#

so what's the point of the statement

#

and there's no point of checking if minute is in the string

#

so what do i do with the m ?

#

if minute is in the string, m's gonna be in it too

slate swan
#

but this would need higher handling on a higher level

#

!resources I recommend these at first

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
#

also indentation is bad there

#

let me have a look

shadow wraith
#

whenever i load a cog and run a command which only exists in a cog (and not the main file itself), and if a false error of the command not existing even though it did the command is there, how do i get rid of it:
i mean this discord.ext.commands: bro that command doesnt exist because im running an exclusive command in a cog

#

basically im gonna sum this up:
fix the discord.ext.commands: command not found issue appearing in the terminal even tho the command works 💀

slate swan
#

so it does the command

#

then says it doesn't exist?

shadow wraith
#

the command is in a cog.

#

ye the command is in a cog.

#

so it confuses the main file and says the command doesn't exist

#

main file = main bot.py file (not the cog)

slate swan
#

don't you have two instances of the main file running?

shadow wraith
#

..

slate swan
#

the only thing I can think of

shadow wraith
#

well sorta? they're not the same

#

the cog is a spanish version of the bot

slate swan
#

...?

quick gust
#

wha...

slate swan
#

how did you write that cog

shadow wraith
slate swan
#

yes, I'm no

#

no I'm yes

shadow wraith
#

💀

slate swan
#

we yes no

shadow wraith
#

it's the yes but no

slate swan
#

I kinda wanna see what you did there

shadow wraith
#

no so basically

slate swan
#

no yes

shadow wraith
#

i have this def setup(): function which set ups the bot

slate swan
#

I can't help you without it

shadow wraith
#

and this class Spanish which literally holds all the commands

broken igloo
#

What is the best way to store references messages in the database? (MongoDB) I need to simply fetch messages

slate swan
#

the only thing you're gonna run is the main file

shadow wraith
slate swan
#

yes, the main file loads the cog

shadow wraith
#

wait no im stupid asf

#

hm

#

if used os module to make the bot start the cog first

#

then how tf do i unload the cog

slate swan
#

you do not use os for it

quick gust
#

close the bot

shadow wraith
quick gust
#

extension

slate swan
#

!d discord.ext.commands.Bot.load_extension

unkempt canyonBOT
#

load_extension(name, *, package=None)```
Loads an extension.

An extension is a python module that contains commands, cogs, or listeners.

An extension must have a global function, `setup` defined as the entry point on what to do when the extension is loaded. This entry point must have a single argument, the `bot`.
shadow wraith
#

bru

#

wait so that also works inside a cog?

slate swan
#

no

quick gust
#

no

slate swan
#

this is in the main file

quick gust
#

add that in your main file, and load the cog

shadow wraith
#

yes load_extension is in the main file

#

its in a load cmd

slate swan
#

I recommend reading some docs to understand cogs

shadow wraith
#

see i have a load command which loads the command,
and an unload command

#

unload is like

#

shoot.

slate swan
#

!d discord.ext.commands.Bot.unload_extension

unkempt canyonBOT
#

unload_extension(name, *, package=None)```
Unloads an extension.

When the extension is unloaded, all commands, listeners, and cogs are removed from the bot and the module is un-imported.

The extension can provide an optional global function, `teardown`, to do miscellaneous clean-up if necessary. This function takes a single parameter, the `bot`, similar to `setup` from [`load_extension()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.load_extension "discord.ext.commands.Bot.load_extension").
quick gust
#

do you even load the cogs when the bot connects?

shadow wraith
#

no

slate swan
#

looks like with a command

shadow wraith
#

when the bot is started, it doesn't load the cog instantly

quick gust
#

so you manually load the cogs

shadow wraith
#

yes.

quick gust
#

ok...

shadow wraith
#

only do that because im confused how tf do you unload the cog then

slate swan
#

weird way of loading them but alr

slate swan
slate swan
unkempt canyonBOT
#
Fat chance.

No documentation found for the requested symbol.

slate swan
quick gust
slate swan
#

mb

#

it just doesnt print out the board when the player marks it

#

client's bad

#

ik

shadow wraith
#

the cogs don't load instantly

slate swan
#

i just tried to get a quick shortcut to it so i don't have to type all of that

shadow wraith
#

still dunno how to make it do that

spiral stratus
#

Hello everyone. I am a beginner, so please dont blame me 🙂 I want to code a "lastsales" command. My problem is, when i do (ctx,a:str, b:str, c:str): like below, the user has to input 3 arguments but they should also input only 1 or how many they want. How can i solve my problem?

@client.command()
async def lastsales(ctx,a:str, b:str, c:str):
    embed_lastsales = discord.Embed(title="Last sales on ebay.de", color=color, description='['f"Click here too see last sales of {a} {b} {c}]("f"https://www.ebay.de/sch/i.html?_from=R40&_nkw={a}+{b}+{c}&_sacat=0&LH_Sold=1&LH_Complete=1&rt=nc&_fsrp=1)")
    embed_lastsales.set_footer(text=footer, icon_url=footer_url)
    embed_lastsales.set_thumbnail(url="https://ir.ebaystatic.com/cr/v/c1/ebay-logo-1-1200x630-margin.png")
    await ctx.send(embed=embed_lastsales)
slate swan
#

new into coding

#

using .replace() im replacing multiple objects that are outputs from a list of outputs, such as print("1 2").replace("1", "a").replace("2", "b"), is there any way where i can replace 2 things in 1 argument? something like .replace(["ActivityType.custom", "", ":rich_presence:", ""])

sullen shoal
shadow wraith
slate swan
#

loop over the cog's folder

#

!d os.listdir

unkempt canyonBOT
#

os.listdir(path='.')```
Return a list containing the names of the entries in the directory given by *path*. The list is in arbitrary order, and does not include the special entries `'.'` and `'..'` even if they are present in the directory. If a file is removed from or added to the directory during the call of this function, whether a name for that file be included is unspecified.

*path* may be a [path-like object](https://docs.python.org/3/glossary.html#term-path-like-object). If *path* is of type `bytes` (directly or indirectly through the [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike "os.PathLike") interface), the filenames returned will also be of type `bytes`; in all other circumstances, they will be of type `str`.

This function can also support [specifying a file descriptor](https://docs.python.org/3/library/os.html#path-fd); the file descriptor must refer to a directory.

Raises an [auditing event](https://docs.python.org/3/library/sys.html#auditing) `os.listdir` with argument `path`.
shadow wraith
#

so you do have to use the os module to do stuff

slate swan
#

no

sullen shoal
#

or use pkgutils

slate swan
#

you do not have to

#

pkgutil?

#

you can do fancy stuff with it

slate swan
unkempt canyonBOT
#
Fat chance.

No documentation found for the requested symbol.

slate swan
shadow wraith
sullen shoal
#

!d pkgutil.iter_modules

unkempt canyonBOT
#

pkgutil.iter_modules(path=None, prefix='')```
Yields [`ModuleInfo`](https://docs.python.org/3/library/pkgutil.html#pkgutil.ModuleInfo "pkgutil.ModuleInfo") for all submodules on *path*, or, if *path* is `None`, all top-level modules on `sys.path`.

*path* should be either `None` or a list of paths to look for modules in.

*prefix* is a string to output on the front of every module name on output.

Note

Only works for a [finder](https://docs.python.org/3/glossary.html#term-finder) which defines an `iter_modules()` method. This interface is non-standard, so the module also provides implementations for [`importlib.machinery.FileFinder`](https://docs.python.org/3/library/importlib.html#importlib.machinery.FileFinder "importlib.machinery.FileFinder") and [`zipimport.zipimporter`](https://docs.python.org/3/library/zipimport.html#zipimport.zipimporter "zipimport.zipimporter").

Changed in version 3.3: Updated to be based directly on [`importlib`](https://docs.python.org/3/library/importlib.html#module-importlib "importlib: The implementation of the import machinery.") rather than relying on the package internal [**PEP 302**](https://www.python.org/dev/peps/pep-0302) import emulation.
slate swan
#

some people like to make a list with the path to their cogs and loop over that and load them

sullen shoal
sullen shoal
#

tbh i would have subclassed Bot and changed the entire way cogs work and let it first check if the cog has an attribute called disabled and if its set to True, it wouldn't load it

quick gust
#

I just check if a file in my cogs folder ends with .py, if it does then I load the said extensions

sullen shoal
slate swan
unkempt canyonBOT
#

bot.py lines 26 to 28

for cog in pkgutil.iter_modules(["cogs"]):
    bot.load_extension(f"cogs.{cog.name}")
    print("Loaded cog: {}".format(cog.name.title()))```
quick gust
#

yeah I saw your repo, you were using that

slate swan
shadow wraith
#

i got the issue fixed

sullen shoal
#

:/

shadow wraith
slate swan
#

UH

quick gust
#

lmfao, "that cool tutorial"

#

very descriptive yes.

slate swan
#

that's how i've loaded my cogs since last year when i was "new" to python but yeah 😂 😂

#

so all the cool kiddos started with dpy

shadow wraith
slate swan
#

lucas

quick gust
#

true

slate swan
sullen shoal
#

freecodecamp

slate swan
#

YES

slate swan
quick gust
#

n o

slate swan
quick gust
#

I did

slate swan
#

don't even know who that is

#

oh so just me and some others 🥲

sullen shoal
#

good thing i didn't

slate swan
#

(:

#

that guy's unban command was complete 🤮

shadow wraith
#

he was a virtual but great temporary frien.d

shadow wraith
sullen shoal
#

i can also make my bot look good from outside

#

but with piece of crap code

shadow wraith
#

i never format my code

slate swan
shadow wraith
#

and that is a very not-temporary fact

shadow wraith
slate swan
#

😂

shadow wraith
#

the inside is literally just 462 lines of code

sullen shoal
slate swan
#

mine has almost 18k

shadow wraith
#

not formatted, no checks

slate swan
#

Can I overwrite all the permissions in one channel?
Example:

  • Role "Moderator" has access to the channel
  • Role "Everyone" has NO access to the channel
  • Member "xyz" has access to the channel

Overwrite = overwrite everything so that only Role "Moderator" has access to the channel

shadow wraith
shadow wraith
#

that's kinda interesting

unkempt canyonBOT
#

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

Edits the channel.

You must have the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to use this.

Changed in version 1.3: The `overwrites` keyword-only parameter was added.

Changed in version 1.4: The `type` keyword-only parameter was added.

Changed in version 2.0: Edits are no longer in-place, the newly edited channel is returned instead.
slate swan
#

ty

sullen shoal
shadow wraith
#

bro what was that called

slate swan
#

!d discord.Member.add_roles

unkempt canyonBOT
#

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

Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
shadow wraith
#

ok but if i want to add a role but it has a spaced name

#

how tf do i do that then

slate swan
shadow wraith
#

that's already in the param's tho

slate swan
sullen shoal
#

¯\_(ツ)_/¯

slate swan
shadow wraith
#

of the cmd function

#

because im a dumb

slate swan
#

??

#

Then you need nothing more

#

Simply add the role

shadow wraith
#

h'

slate swan
#

It converts what you give when executing the command, pretty sure it also converts role names with spaces

#

Just need to add the *

shadow wraith
#

i think last time i added the * it confused the bot

#

i dont remember now

#

oh wait i remember now

#

there was a member: discord.Member which confused the bot

slate swan
distant warren
#

I have a discord.py bot and I realized it has a custom help command which isn't that good so I want to change it

slate swan
#

It removes the help command

distant warren
#

then can I ad my own?

slate swan
#

and you can create ur own help command

slate swan
distant warren
#

thx

slate swan
#

Yw

distant warren
#

I have a discord.py bot and all of the code is in one file so can I put them into other files and it'd run the same?

jaunty terrace
#

cogs

plucky shoal
jaunty terrace
#

i have no clue how to find the documentation

#

how do i make a listener outside of cogs

distant warren
#

I want my bot to DM someone with some text when they use a command

#

how do I do it

jagged root
#

Hey! is it posible to make the bot say in what position the channel in wich the user typed is witha number?

jaunty terrace
unkempt canyonBOT
#

await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=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/master/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.9)") of [`File`](https://discordpy.readthedocs.io/en/master/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/master/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.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
dusk dust
#

messages are duplicated... What can I do about it?

full lily
#

Find the source of the issue and fix it

full lily
dusk dust
# full lily Do you have two bot instances running?

after I put this, it started to cause problems


with open('scam.txt', 'r') as f:
    global scam
    words = f.read()
    scam = words.split()

@bot.event
async def on_message(message):
    msg = message.content
    for word in scam:
        if word in msg:
            await message.delete()
            delete = await message.channel.send(f"**DIVULGAÇÃO** | Divulgação de gift's scam não está em nossa lista de `coisas-permitidas`, {message.author.mention}!")
            await asyncio.sleep(20)
            await delete.delete()

    await bot.process_commands(message)
#

t put this "on_message" and two others to give an error when the user sends an invite, nitro scam and bad words

full lily
#

How come you're iterating through your scam.txt list

#

wouldn't it be easier to iterate through the person's message? That's bound to be shorter, no?

#
if any(word in scam for word in message):
dusk dust
full lily
#

mm

#

What message did you type?

dusk dust
dusk dust
full lily
#

that's what you typed or the bot?

jagged root
#

Hey! is it posible to make the bot say in what position the channel in wich the user typed is witha number?

lofty mulch
#

are there any known alternatives for bot.load_extension?

#

I can't seem to load my extensions for shit and it's really getting into my nerves

lofty mulch
#

the os method

#

for filename in os.listdir()...

#

I'm honestly done with it and I just want a viable alternative for it

quick gust
lofty mulch
#

Yeah, pretty much

lofty mulch
#

Interesting

#

Is there any documentation about it?

#

That github link is where it comes from?

quick gust
quick gust
lofty mulch
#

Interesting

#

I'll check it out, i'll lyk if anything pops up

#

Thanks

zinc reef
#

I have a aiosqlite db that I want to create a table in a cog's init. Since it has to be done async, what's the proper way to call that coroutine inside the (sync) init?

dusk dust
slate swan
#

How can I check the Channel topic with an "if" statement?

Something like this:

   if ctx.channel.topic("admin-only"):
      ctx.send("This is an admin-only channel.")
   else:
      pass```
sullen shoal
#

make use of in statement?

#

also else: pass is same as not having it at all

slate swan
#

yes I know just wanted to demonstrate

warm mirage
#

i need help sorta

slate swan
#

how can i make a ton of global error handlers for every error that i can possibly get? im tired of my screen getting clusterfucked with directory's being printed to module files ill never need to access, i just want the straight up error

warm mirage
#

im making a discord bot that if the users types in a secret message they get mod on my server i can do the rest of the code but it needs to send a verification code to the person who wrote the message

my issue is that idk how to get it to dm the person who wrote the message the code is bellow i do not know how to get the id of a user and use it so send a private dm to them with the verification code

sullen shoal
lofty mulch
#

like, execution error or what

jaunty terrace
#

use jishaku i heard it has hidden errors

lofty mulch
#

because you can either make the bot report the traceback or just ignore it

slate swan
# sullen shoal > im tired of my screen getting clusterfucked with directory's being printed to ...

so instead of something like Ignoring exception in command ban: Traceback (most recent call last): File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 994, in invoke await ctx.command.invoke(ctx) File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 886, in invoke await self.prepare(ctx) File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 820, in prepare await self._parse_arguments(ctx) File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 735, in _parse_arguments kwargs[name] = await self.transform(ctx, param) File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 560, in transform raise MissingRequiredArgument(param) discord.ext.commands.errors.MissingRequiredArgument: member is a required argument that is missing. i just want to get this Ignoring exception in command ban: Traceback (most recent call last): discord.ext.commands.errors.MissingRequiredArgument: member is a required argument that is missing.

slate swan
sullen shoal
sullen shoal
slate swan
jaunty terrace
#

in the error handler

slate swan
#

i dont need to define it?

#

oh, in the handler

#

well how can i make a global handler for all errors pepeugh

sullen shoal
slate swan
sullen shoal
#

catching every error is dumb and useless

#

bad practice

slate swan
#

ty

zinc reef
#

either make a function in a Bot subclass, or create a listener for this event

#

scratch that, on_error doesn't get sent to listeners it would seem

lofty mulch
slate swan
sullen shoal
#

topic is None

#

!d discord.TextChannel.topic

unkempt canyonBOT
sullen shoal
#

otherwise that should work

slate swan
sullen shoal
#

use and

#

if topic is not None and topic in ...

jaunty terrace
#

elif ctx.channel.topic is None:
return

that should cancel if the topic is none

slate swan
#

kk

jaunty terrace
#

idk if that's what you meant but

sullen shoal
lofty mulch
#

Like, it didn't start from the root folder

sullen shoal
#

its relative path

lofty mulch
#

I see

#

I'll get back if I have any questions

sullen shoal
#

i gotta sleep now

lofty mulch
#

Well, have a nice rest

#

I hope your pillow is cold

sullen shoal
#

you may check my file structure and source code if you use the nicer way i suggested

#

thanks

lofty mulch
#

I'll do

sullen shoal
#

good, gn

tawdry perch
#

Can bots add emojis to server?

slate swan
unkempt canyonBOT
#

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

Creates a custom [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji") for the guild.

There is currently a limit of 50 static and animated emojis respectively per guild, unless the guild has the `MORE_EMOJI` feature which extends the limit to 200.

You must have the [`manage_emojis`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_emojis "discord.Permissions.manage_emojis") permission to do this.
tawdry perch
#

So I can yeet the image from gallery?

slate swan
#

?

dusk dust
#

how can i add role to some1?

slate swan
unkempt canyonBOT
#

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

Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
dusk dust
slate swan
#

read the docs and you'll understand

slate swan
#

Tbh

#

I don't have a clue 😂😂

#

I ain't that smart :kek:

slate swan
#

Probably fetch the role or sum idk

slate swan
#

The description of what "atomic" does is too high level for me :kek:

slate swan
slate swan
slate swan
slate swan
#

Great to see you

#

Hihi

#

How are you doing today

#

Good wbupithink

#

Glad to hear that, I'm doing awesome 107

wary ravine
#

"In embed.fields.1.value: This field is required"

#

field 1 in your embed is empty

slate swan
#

synonyms is an empty string

slate swan
wary ravine
#

void ghost ping i was incorrect

rotund nova
#

someone know why bot don't any reaction?

@client.event
async def on_message(message):
    guild = client.get_guild(855101953024983061)
    rola = message.guild.get_role(858383553090945074)
    if message.channel.id == 858317811151405087:
        if message.content == "Something":
            if rola in message.author.roles:
                await message.author.remove_roles(rola) 
                await message.channel.send(f"Pomyślnie usunięto role {rola} dla {message.author.mention}")
            else:
                await message.author.add_roles(rola)
                await message.channel.send(f"Pomyślnie dodano role {rola}.")
            await client.process_commands(message) 
tawdry mist
#

It is possible to do bio for discord bots?

carmine pilot
#

Yes

slate swan
#

The bot description in the developer portal will be shown as "About me"

#

Simply click on your bot in the developer portal and you will see the "Description" section

#

Which says

Your description will appear in the About Me section of your bot's profile.

#

Ah that's what he meant xD

tawdry mist
#

Thanks.

slate swan
vague grove
#

how can I run a command and it fetches all active invites?

summer flume
#

how do I manage the bot to send a message in every text channel?

slate swan
#

When there is multiple people in the channel that I am moving them from, all of them get disconnected but 1. Does anyone have an idea as to why they are getting disconnected?

async def bringAll(ctx,channel1: discord.VoiceChannel):
    channel = None
    for k,v in vcMembers.items():
        if ctx.message.author.id not in v:
            pass
        else:
            if channel == None:
                channel = k
                break
    for channels,members in vcMembers.items():
        if channel != None:
            if channels == channel1.id:
                for users in vcMembers[channel1.id]:
                    user = ctx.message.guild.get_member(users)
                    channel = bot.get_channel(channel)
                    await user.move_to(channel)
slate swan
#

anyone know what i should do?

summer flume
summer flume
patent lark
patent lark
sage otter
unkempt canyonBOT
#

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

Returns a list of all active instant invites from the guild.

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

Ooop wrong person

summer flume
#

hm

vague grove
sage otter
vague grove
#

o ok

patent lark
slate swan
#
def read_json(filename):
    cwd = get_path()
    with open(cwd + "/data/" + filename + ".json", "r") as file:
        data = json.load(file)
    return data```
```  File "D:\acrella\bot.py", line 76, in <module>
    secret_file = utilities.json_loader.read_json('secrets')
  File "D:\acrella\utilities\json_loader.py", in read_json
    data = json.load(file)```
#

¯_(ツ)_/¯

hot cobalt
#

What's the error?

slate swan
#

uh that is the error

hot cobalt
#

That's part of the traceback

#

Not the full error

slate swan
#

right, found it

#

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

hot cobalt
#

Your JSON file is empty

slate swan
#

is it cuz i didnt do

{
#stuff
{```
#

cuz rn its just the 'stuff' basically

hot cobalt
#

You can't json.load an empty file

slate swan
hot cobalt
#

Well you'll need some form of JSON in there for it to load, so yes you'll need something like {} or [] in your file

summer flume
#

I was using ctx..

unkempt jewel
#

good morning

unkempt jewel
slate swan
#

yeah i noticed

#

its weird though

#

cuz the json file isnt empty

#

its my mongodb connection but its saying its invalid

unkempt jewel
#

just change the
{
stuff
}

#

its actually is {stuff}

#

u wrote like {stuff{

slate swan
#
Traceback (most recent call last):
  File "D:\acrella\bot.py", line 76, in <module>
    secret_file = utilities.json_loader.read_json('secrets')
  File "D:\acrella\utilities\json_loader.py", line 27, in read_json
    data = json.load(file)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)```
the json file im trying to load:
```json
{mongodb+srv://terror(private info)}```
hot cobalt
#

You haven invalid json

#

Yeah that's not valid json

#

Are you trying to connect to a mongodb?

slate swan
#

OH

#

i see what i did wrong

#
{
    "mongo": "stuff"
}```
hot cobalt
#

Yes that's valid

#

Although what exactly are you using the json file for here?

hot cobalt
#

I don't see the need for a json file

#

Why not just connect to the db?

slate swan
#

i mean, it works now.. dont see reason to need to go back

hot cobalt
#

It loads the file sure

#

But where are you connecting to the db?

slate swan
#
secret_file = utilities.json_loader.read_json('secrets')
bot.connection_url = secret_file["mongo"]

    bot.mongo = motor.motor_asyncio.AsyncIOMotorClient(str(bot.connection_url))
    bot.db = bot.mongo["data"]
    bot.config = Document(bot.db, "secrets")
    print("Initialized Database\n-----")
    for document in await bot.config.get_all():
        print(document)```
hot cobalt
#

Oh are you using the JSON for configuration?

slate swan
summer flume
slate swan
#

Alr it was kinda obvious yert

summer flume
#

👍

slate swan
unkempt jewel
#

bruh i putted my uri database link to .env

boreal ravine
#

☹️

unkempt jewel
#

why sad

#

its working for me ://

distant warren
hollow agate
#
@client.command()
async def mute(ctx, member: discord.Member, time=None, *, reason=None):
    format = datetime.now(tz=pytz.timezone('America/Tijuana'))
    formatted = format.strftime("%I:%M %p")
    b = DT.datetime.now().timestamp()
    modlogs = client.get_channel(872909569196707870)
    db = await aiosqlite.connect('database.db')
    cursor = await db.execute('SELECT * FROM mutes')
    rows = await cursor.fetchall()
    muted = discord.utils.get(ctx.guild.roles, name="Muted")
    farmer = discord.utils.get(ctx.guild.roles, name="Farmers")
    apprentice = discord.utils.get(ctx.guild.roles, id=907127783849861120)
    if ctx.message.author.guild_permissions.administrator:
        if member is None:
            e = await ctx.reply('You must mention someone to mute!')
            await asyncio.sleep(5)
            await e.delete()
            await ctx.message.delete()
            return
        if time is None:
            a = await ctx.reply('Please state a time for a timed mute or a reason for a permanent mute!')
            await asyncio.sleep(5)
            await a.delete()
            await ctx.message.delete()
            return
        if reason is None:
            if time[-1] in ['s', 'm', 'h', 'd']:``` This is quite messy, but is there a way that I can somehow determine if the `s`, `m`, `h`, and `d` are touching another letter, if so it does something?

```py
            if time[-1] in ['s', 'm', 'h', 'd']:``` after this line of course.
obtuse rose
#

Why can I use asyncio.sleep() without having to import asyncio on my cog?

slate swan
slate swan
#

I have this close command code, and i wanna ask how can i add a time on it? like close 5m something like that and if time is not added it will close immediately

@bot.command()
async def close(ctx):
    with open('data.json') as f:
        data = json.load(f)

    if ctx.channel.id in data["ticket-channel-ids"]:

        channel_id = ctx.channel.id
        channel_name = ctx.channel.name

        def check(message):
            return message.author == ctx.author and message.channel == ctx.channel and message.content.lower() == "close"

        try:

            em = discord.Embed(title=embedTitle,
                               description="Are you sure you want to close this ticket? Reply with `close` if you are sure.",
                               color=0x00a8ff)

            await ctx.send(embed=em)
            transcript = await chat_exporter.export(ctx.channel)
            transcript_file = discord.File(io.BytesIO(transcript.encode()), filename=f"transcript-{ctx.channel.name}.html")
            channel = ctx.guild.get_channel(858027059153600512)
            await bot.wait_for('message', check=check, timeout=60)
            await channel.send(file=transcript_file)
            await ctx.channel.delete()

            indexID = data["ticket-channel-ids"].index(channel_id)
            del data["ticket-channel-ids"][indexID]

            index = data["ticket-channel"].index(channel_name)
            del data["ticket-channel"][index]

            with open('data.json', 'w') as f:
                json.dump(data, f)

        except asyncio.TimeoutError:
            em = discord.Embed(title=embedTitle,
                               description="You have run out of time to close this ticket. Please run the command "
                                           "again.",
                               color=0x00a8ff)
            await ctx.send(embed=em)
patent lark
#

the attribute in my example is get_guild which is one attr, getguild would still be one attr, the underscore is separation of words

#

this is called snake casing

#

a . is used to access methods and properties

#

aka, dot operator

slate swan
#

@patent lark makes sense thanks🤔

patent lark
#

yep

#

maybe take a look at this

#

!pep8

unkempt canyonBOT
#

PEP 8 is the official style guide for Python. It includes comprehensive guidelines for code formatting, variable naming, and making your code easy to read. Professional Python developers are usually required to follow the guidelines, and will often use code-linters like flake8 to verify that the code they're writing complies with the style guide.

More information:
PEP 8 document
Our PEP 8 song! :notes:

slate swan
#

@patent lark sounds stupid but what are those stuff like pep8 and others syntax updates?

slate swan
loud junco
#

oof

#

i get a long error

patent lark
#

pep8 is a convention that basically is the way you should write python code, it shows the most pythonic way to write python.

from the doc:
PEP 8 is the official style guide for Python. It includes comprehensive guidelines for code formatting, variable naming, and making your code easy to read. Professional Python developers are usually required to follow the guidelines, and will often use code-linters like flake8 to verify that the code they're writing complies with the style guide.

loud junco
slate swan
#

Replit does that sometimes

loud junco
#

so how do i fix it

patent lark
#

you dont

#

you wait, likely one hour.

loud junco
#

oo ok

slate swan
loud junco
#

oof

slate swan
#

Basically happens to avoid api abuse

patent lark
#

mhm

slate swan
#

Like a way you should write your code

patent lark
#

correct

slate swan
#

Never seen it

boreal ravine
loud junco
dark pawn
#

can someone tell me why this isnt working

slate swan
boreal ravine
#

🤔

loud junco
#

wdym by
x = User()

#

i dont think it works that way

dark pawn
#

its trying to create an instance of a class called User if one doesnt exist for that user

patent lark
# slate swan Like a way you **should** write your code

writing code that doesnt follow the pep8 convention isnt necessarily super wrong or a huge mistake. but by following the pep8 convention, you will write cleaner code, more understandable and cleaner code. things such as, when your variable names should be lower or upper case, snake casing, pascal casing. how many new-lines should be in between your functions, when you should use double or single quotes. importing things only at the top, or where a triple quoted doc string should go

boreal ravine
#

camel casing 😳

dark pawn
#

it keeps saying false no matter how many times it reads a message from me

slate swan
#

And thats lowkey cool

slate swan
sage otter
#

camelCase

#

PascalCase

boreal ravine
sage otter
#

snake_case

slate swan
#

Whats thatlemon_warpaint

sage otter
#

Look at the differences in how I wrote those.

boreal ravine
sage otter
#

Different naming conventions.

patent lark
unkempt canyonBOT
#

PEP 8 is the official style guide for Python. It includes comprehensive guidelines for code formatting, variable naming, and making your code easy to read. Professional Python developers are usually required to follow the guidelines, and will often use code-linters like flake8 to verify that the code they're writing complies with the style guide.

More information:
PEP 8 document
Our PEP 8 song! :notes:

slate swan
#

firstWordSecondWordThirdWord = camelCase
FirstWordSecondWordThirdWord = PascalCase
first_word_second_word_third_word = snake_case

boreal ravine
#

^

slate swan
#

Yeah i got it

boreal ravine
#

Idk what lang uses pascal but I know python uses snake casing and javascript uses camel casing

slate swan
spark osprey
#

Y'all Kno how to take Instagram accounts

boreal ravine
slate swan
sage otter
#

A programming language

spark osprey
#

LMAO

patent lark
boreal ravine
patent lark
#

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

Were not falling for "download my .exe"yert

slate swan
#

Doesnt the server state to read rules before you chat?

patent lark
#

channel descriptions and server rules are there no matter how long you've been in a server.

lament mesa
#

an if condition?

sage otter
#

No

#

He’s telling you to use logic

patent lark
#

😭

#

bruh.

slate swan
sage otter
#

You're actually insufferable

#

You know. if statements?

lament mesa
#

You can use an if statement and only wait if the condition is True

#

and not wait otherwise

slate swan
lament mesa
#

str.join

lament mesa
# slate swan

!e ```py
i = ['one', 'two', 'three', 'four']
print(i)
print(', '.join(i))

unkempt canyonBOT
#

@lament mesa :white_check_mark: Your eval job has completed with return code 0.

001 | ['one', 'two', 'three', 'four']
002 | one, two, three, four
slate swan
slate swan
#

Wym new line

#

I just wanna get rid of those brackets and quotations

sage otter
#

consider view.stop()

slate swan
#

!e

i = ['one', 'two', 'three', 'four']
print("\n".join(i)) 
sage otter
#

Like the docs say. wait finishes for the view to finish or timeout.

unkempt canyonBOT
#

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

001 | one
002 | two
003 | three
004 | four
lament mesa
#
class buttonstuff():
  def stuff:
    stuff
  
  @discord.ui.button()
    stuff
    
  @discord.ui.button()
    if counter == 10:
      view.wait == stop it

for x in x:
  if condition:  # This will only wait if the condition is True
      await view.wait()
``` this wont wait if the condition is `False`
slate swan
#

Oh

#

Yeah

unkempt jewel
#

yo help me

slate swan
#

Who?

unkempt jewel
#

i see no error

slate swan
#

Okay

unkempt jewel
#

help

slate swan
unkempt jewel
#

uwu tks

#

Extension 'cogs.General' raised an error: SyntaxError: invalid syntax (getcorona.py, line 22)

#
@commands.command(name = "hello", aliases= ["Hello", "hi", "Hewo uwu"])
  async def hello_command(self, ctx):
    msg = f"hello <@!{str(ctx.message.author.id)}>, Type `.help` to see more information"
    await ctx.channel.send(msg)
sage otter
slate swan
unkempt jewel
#

F

#

ME

#

I AM SO DUMB

sage otter
#

Replace the first in with an underscore

sudden basin
#

also you can just... combine that

unkempt jewel
#

Extension 'cogs.General' raised an error: NameError: name 'command' is not defined

loud junco
#

define command then

sudden basin
#

you don't need to do await ctx.channel.send(msg), you can just do await ctx.send(f"hello <@!{str(ctx.message.author.id)}>, Type .help to see more information")

loud junco
#

=.=

unkempt jewel
sage otter
#

you probably made a typo or something

unkempt jewel
sage otter
#

Probably meant commands

unkempt jewel
#

commands?

unkempt jewel
#

it didnt show lines

#

C:\Users\Administrator\Desktop\bot>py main.py
registering cog: cogs.Card2
registering cog: cogs.Data
registering cog: cogs.Dev
registering cog: cogs.General
Extension 'cogs.General' raised an error: NameError: name 'command' is not defined
registering cog: cogs.Guild
registering cog: cogs.Shop
Gura Bot#0215 has logged in!

lament depotBOT
sage otter
#

Print the full traceback

unkempt jewel
#

h o w?

slate swan
forest blade
#

From what I can see I’m guessing you have a for loop in your main file that loads each cog in a try/except, can we see that code to tell you how to print the full traceback

sage otter
#

Actually hold on.

forest blade
unkempt jewel
#
import discord
from discord.ext import commands, tasks
from dotenv import load_dotenv
import os
import logging
# from app import keep_alive
import asyncio
import random

from corona.getcorona import getcorona
from corona.embed import *
from classes.Bot import Bot


logging.basicConfig(
  filename="logs.log",
  filemode="a",
  format="[%(asctime)s::%(name)s::%(module)s]:\n\t(args: %(args)s)\n%(levelname)s - %(message)s",
  level="DEBUG"
)

load_dotenv()


# keep_alive(with_join=False)


token = os.getenv("TOKEN")

prefix = commands.when_mentioned_or(".")

bot = Bot(
  command_prefix=".",
  owner_ids={ 720991106048720916 }
)

@bot.event
async def on_ready():
  print(f"{bot.user} has logged in!")
  await bot.change_presence(activity = discord.Activity(type = discord.ActivityType.listening, name = ".help"))

def run():
  cogs = [f"cogs.{filename[:-3]}" for filename in os.listdir("./cogs/") if filename.endswith(".py")]

  for cog in cogs:
    try:
      print(f'registering cog: {cog}')
      bot.load_extension(cog)
    except Exception as err:
      print(err)

  bot.run(token)


if __name__ == "__main__":
  run()
sage otter
#

There’s two ways you can do this you can do this. Remove the try and except or use the traceback library.

unkempt jewel
#

how ;-;

sage otter
#

remove the try and except

unkempt jewel
forest blade
#
import traceback

try:
    bot.load_extension(…)
except Exception:
    print(traceback.format_exc())
unkempt jewel
#

oh btw, i have an error about SELL COMMAND yesterday, i posted it here, and i and the others guys fall in the freacink story and no one help me :)

slate swan
#

What are triple quotes for?

forest blade
# unkempt jewel

Looks like you meant to inherit from commands.Cog not command.Cog

unkempt jewel
#

ok i fixed it

#

and now it got more error

forest blade
#

What does it say?

unkempt jewel
shy schooner
unkempt jewel
#

@shy schooner vietnam?

shy schooner
#

what matters?

unkempt jewel
shy schooner
#

dont speak vietnamese here

unkempt jewel
#

ok

forest blade
shy schooner
unkempt jewel
#

i need to put the bot.remove_command('help') at the top of the file?

forest blade
#

bot has to be defined first

shy schooner
#

and then remove_command()

unkempt jewel
#

i got this

#

i defined it

unique raven
#

😂

shy schooner
#

bruh

unkempt jewel
#

bruh

unique raven
#

hello 🇻🇳

unkempt jewel
#

dude i dont understand too clearly in english

shy schooner
unkempt jewel
#

can we talk in vietnamese :))

shy schooner
#

ofc no

unkempt jewel
#

supbi cuu toi

forest blade
#

so now do either, ```py
bot = Bot(…, help_command = None)
#or
bot = Bot(…)
bot.remove_command('help')

ornate glade
#

Is there way to look at a user's DM settings?

#

Like to check if they're on or off?

unkempt jewel
#

:vv

unique raven
unkempt jewel
graceful sigil
#

🙂

shy schooner
#

he just gave the solution

graceful sigil
#

hello everybody

unkempt jewel
#

ok de chay thu nhe

graceful sigil
#

ye

shy schooner
unkempt jewel
#

done

#

à mà tôi còn lỗi ở sell command với sell button cơ, tôi dms ông dc không, vì ở đây ông minh miner có vẻ không thích tiếng việt cho lắm

shy schooner
#

please

#

speak english

#

🙂

graceful sigil
#

yes

unkempt jewel
#

why?

#

miner 3 /

unkempt jewel
#

bruh what

unkempt jewel
shy schooner
#

im hate being DMs for helping others

graceful sigil
#

please don't speak another language language

unique raven
#

😂 ok

slate swan
#

!rule 4

unkempt canyonBOT
#

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

slate swan
#

Guys ^

graceful sigil
#

I don't understand what you guys are chatting about

ornate glade
#

Is it possible to check if a users DMs is on?

slate swan
#

Keep the convo in english plsjam_cavedude

unkempt jewel
#

ok english

shy schooner
graceful sigil
#

yes

slate swan
#

Dont have nothing against it but its rules guys please follow themjam_cavedude

unkempt jewel
#

yo okimii i still not done the sell command that i told u yesterday

unkempt jewel
#

i putted the error here and no one help ._.

shy schooner
unkempt jewel
#

i tried

slate swan
unkempt jewel
#

i posted when i cant ://

shy schooner
slate swan
unkempt jewel
#

i dont know much about button, my friend made that and now i need to fix it for her

unkempt jewel
unique raven
shy schooner
#

idk much about disnake :/

graceful sigil
#

i'm 🇦🇺

slate swan
unkempt jewel
slate swan
unique raven
unkempt jewel
#

i cant sell it

slate swan
graceful sigil
shy schooner
spark widget
#

how to fix this, i can't install pygooglenews
and i have try all version

unkempt jewel
slate swan
shy schooner
graceful sigil
slate swan
#

Were monkeys like me live

graceful sigil
#

😂

unkempt jewel
slate swan
#

🦧

unkempt jewel
#

i can use the .sell command but not the sell button

slate swan
shy schooner
unkempt jewel
#

keyError ig

graceful sigil
#

I have a French father and an Australian mother 😂

unkempt jewel
#

cool

shy schooner
unkempt jewel
#

bonjour

slate swan
slate swan
unkempt jewel
shy schooner
graceful sigil
slate swan
#

@graceful sigil take notes

graceful sigil
#

ok

silk dawn
#

Привет

graceful sigil
#

😂

slate swan
silk dawn
#

я русский

graceful sigil
#

pls don't say 🇷🇺

silk dawn
#

Im russian

shy schooner
shy schooner
slate swan
#

Im from marsyert

graceful sigil
#

i am beginner

#

🙂

#

🙂

slate swan
#

🙂

silk dawn
unkempt jewel
ornate glade
shy schooner
graceful sigil
#

help so much 😂

silk dawn
ornate glade
#

No I want to know if the bot can message them via dms

slate swan
#

No he wants to check if his dms are on or not

ornate glade
#

I tried searching online, but I had no luck.

shy schooner
sage otter
#

you message them and if it returns an error their dms are off.

shy schooner
#

and see

ornate glade
#

ah ok

boreal ravine
slate swan
boreal ravine
ornate glade
#

got u

slate swan
boreal ravine
#

leave server yes turn that on

graceful sigil
#

i did already

slate swan
shy schooner
zealous dagger
#

Can anyone tell how to add dropdown

sage otter
boreal ravine
sage otter
#

Thank you Kayle for reposting the message that’s literally right above yours

boreal ravine
#

\😏

slate swan
#

They be hitting different

sage otter
zealous dagger
#

Cn

#

YOu give an example

#

@boreal ravine

boreal ravine
#

@sage otter 👀

unkempt jewel
#

yo guys i got a weird err

#

although my code have it

slate swan
sage otter
maiden fable
hollow hemlock
#

how to disable the default help command?

slate swan
hollow hemlock
#

no

slate swan
#

What exactly?

hollow hemlock
#

wait

#

this default help command. how to disable it so i can setup a custom help command?

#

nevermind

sick birch
sick birch
#

That's actually a fair question

slate swan
#

People say its a waste of time making a command for help

sick birch
#

People have always told me to do it that way, and it makes sense since i mean the whole point of it is to aid in making custom help commands

sick birch
slate swan
#

Idk i always make a command for help

sick birch
#

the approach i usually take is to add a triple quote docstring to each function, and let d.py handle the rest

#

And of course some basic styling with embeds and whatnot

slate swan
sick birch
#

Then the only thing I have to do is add docstrings to each new function I add, which you should do anyway

hollow hemlock
#

idk how to use commands.HelpCommand

sick birch
#

It's quite daunting at first

#

There was a really nice walkthrough link in the d.py server, sadly I can't find it atm

#

It was a full gist page that really helped me out a lot

hollow hemlock
#

ooh nice

#

thanks!

sick birch
#

I suggest take some time and read through it fully, and make sure you understand it as well. It'll help you a ton