#discord-bots

1 messages Β· Page 834 of 1

vocal snow
#

But wasn't ytdl reinstated

glossy ocean
#

im extremeley sorry and will not request more assistance

sick birch
#

And it's still the same error?

slate swan
sick birch
#

Can we see the new check?

#

I'm assuming you removed the ids in devList?

#

else return false by the way

#

and you can send a message along with that

#

Checks need to return a boolean

keen talon
sick birch
#

Not sure about that

#

@slate swan and devList is a list of integer ids correct?

glossy ocean
sick birch
#

alright for a test, try this:

async def dev_check(ctx):
    if ctx.message.author.id == YOUR_ID_HERE:
        return True
    else:
        return False
#

see if that passes

slate swan
sick birch
#

Helps us narrow down the issue

vocal snow
final iron
#

CTX should be lower case

vocal snow
#

My phone makes it uppercase

final iron
#

Yeah autocorrect

#

Gotta be careful with it

rose hazel
#

im trying to print client.guilds and i keep getting an empty list

#
intents = discord.Intents(messages=True, guilds=True)
intents.members = True
client = discord.Client()
bot_prefix = "."
client = commands.Bot(command_prefix=bot_prefix, intents=intents)
client.remove_command("help") #removes default help command```
fervent shoal
#

when i do import chalk, it says its not accsessed

#

so do i need to install an external package or

slate swan
#

Plus, see the channel name

rose hazel
fervent shoal
slate swan
# rose hazel ?

discord.Client is the old method of creating bot constructors, use the Bot class from discord extension

#

You can make commands and stuff

#

!d discord.ext.commands.Bot

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.

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

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

print("DONE LOADING!\n")

num1 = 0

num2 = 0

num3 = 0

num4 = 0

while True:
num1 = num1+1
if num1 == 60:
num1 = 0
num2 = num2+1
if num2 == 60:
num2 = 0
num3 = num3+1
if num3 == 24:
num3 = 0
num4 = num4+1
time.sleep(1)

@bot.command(pass_context=True)
async def runtime(ctx):
    await bot.say("Running for {}d {}h {}m {}s".format(num4, num3, num2, num1))

this is what google tells me after a long time searching

#

oh wow thas a lot bigger than i was expecting

slate swan
#

Rip

rose hazel
#

use py formatting

bold surge
#

code block moment:

fervent shoal
#

num1 = 0

num2 = 0

num3 = 0

num4 = 0

while True:
    num1 = num1+1
    if num1 == 60:
        num1 = 0
        num2 = num2+1
    if num2 == 60:
        num2 = 0
        num3 = num3+1
    if num3 == 24:
        num3 = 0
        num4 = num4+1
    time.sleep(1)

    @bot.command(pass_context=True)
    async def runtime(ctx):
        await bot.say("Running for {}d {}h {}m {}s".format(num4, num3, num2, num1))```
fervent shoal
#

rip google search

bold surge
#

not only will it rate limit the shit outta your bot

#

but it will also be inaccurate asf

slate swan
#

time.sleep

#

while loop

#

format

fervent shoal
#
    def __init__(bot):
        @commands.command(name="uptime")
        async def uptime (self,ctx):
            current_time = time.time()
            difference = int(round(current_time - start_time))
            text = str(datetime.timedelta(seconds=difference))
            await ctx.send("Current uptime: " + text)```
bold surge
#

use something like that

fervent shoal
#

i also have this but it doesnt recognize the command uptime

bold surge
#

then remove it from a cog

slate swan
#

Do you even know where you are making the command

#

In the init function

fervent shoal
#

sooooooooo change it

slate swan
bold surge
#

well i thought

bold surge
fervent shoal
#
async def runtime(ctx):
    now = datetime.utcnow()
    elapsed = now - starttime
    seconds = elapsed.seconds
    minutes, seconds = divmod(seconds, 60)
    hours, minutes = divmod(minutes, 60)
    await bot.say("Running for {}d {}h {}m {}s".format(elapsed.days, hours, minutes, seconds))

starttime = datetime.utcnow()```
#

would this one be better or no

rose hazel
#

client.guilds still gives me an empty list

bold surge
#

gotta fix some of the indentation...

fervent shoal
#

ive been browsing google for an answer tbh

rose hazel
#

anyone know why?

bold surge
slate swan
fervent shoal
#

Traceback (most recent call last):
File "/home/pi/Downloads/riot bot 5, no way this works.py", line 124, in <module>
starttime = datetime.utcnow()
AttributeError: module 'datetime' has no attribute 'utcnow'

the code its talking about is starttime = datetime.utcnow()

somber brook
#

this is not working

slate swan
#

!d datetime.datetime.utcnow

unkempt canyonBOT
#

classmethod datetime.utcnow()```
Return the current UTC date and time, with [`tzinfo`](https://docs.python.org/3/library/datetime.html#datetime.datetime.tzinfo "datetime.datetime.tzinfo") `None`.

This is like [`now()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.now "datetime.datetime.now"), but returns the current UTC date and time, as a naive [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") object. An aware current UTC datetime can be obtained by calling `datetime.now(timezone.utc)`. See also [`now()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.now "datetime.datetime.now").

Warning

Because naive `datetime` objects are treated by many `datetime` methods as local times, it is preferred to use aware datetimes to represent times in UTC. As such, the recommended way to create an object representing the current time in UTC is by calling `datetime.now(timezone.utc)`.
fervent shoal
#

Oh isn’t utc a time zone

slate swan
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**.
fervent shoal
#

or am I just thinking of something else

bold surge
# unkempt canyon

and put this in a try and except statement to prevent errors from being invoked incase the users dms are turned off

slate swan
#

Yeah

fervent shoal
slate swan
#
try: member.send("Hunter uwu")
except discord.Forbidden: pass```
timid wagon
rose hazel
#

πŸ˜‚

slate swan
timid wagon
fervent shoal
#

alr

slate swan
slate swan
bold surge
unkempt canyonBOT
fervent shoal
#
  File "/usr/local/lib/python3.7/dist-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/usr/local/lib/python3.7/dist-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/usr/local/lib/python3.7/dist-packages/discord/ext/commands/core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'datetime' has no attribute 'utcnow'```
#
async def runtime(ctx):
    now = datetime.utcnow()
    elapsed = now - datetime
    seconds = elapsed.seconds
    minutes, seconds = divmod(seconds, 60)
    hours, minutes = divmod(minutes, 60)
    await bot.say("Running for {}d {}h {}m {}s".format(elapsed.days, hours, minutes, seconds))

datetime.datetime.utcnow()```
timid wagon
fervent shoal
#

did i put it in the wrong place

timid wagon
#

Yes, read the error

fervent shoal
#

i need stronger glasses holy shit

timid wagon
#

You have to replace the method in the line the error mentions

fervent shoal
#
  File "/usr/local/lib/python3.7/dist-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/usr/local/lib/python3.7/dist-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/usr/local/lib/python3.7/dist-packages/discord/ext/commands/core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'module'```
timid wagon
sick birch
timid wagon
#

What are you trying to do with this code, exactly?

fervent shoal
#

runtime >.<

sick birch
#

the easiest way would be to store the UNIX seconds at startup, and get the UNIX seconds when the command is run, and subtract those 2 (they will be regular integers)

timid wagon
#

^

fervent shoal
#

how uh, how would i do that

timid wagon
#

You can save the start time in the bot's cache, like bot.start_time = datetime.datetime.now.to_timestamp() <- this is an example

sick birch
#

Wasn't it just .timestamp()

timid wagon
#

That's why I said it's an example - don't really remember all mehtods

sick birch
#

then when you run the command, datetime.datetime.now().timestamp() - start_time

fervent shoal
#

so would I swap the code im using right now for that or

bold surge
sick birch
#

yes, you would

sick birch
bold surge
#

ah

sick birch
#

not to mention global variables are just ugh

timid wagon
#
  • saving it in the bot's cache means that you can access it in cogs
fervent shoal
sick birch
#

No, that was psuedocode

#

You'll have to change it and adapt it to work with your own code

fervent shoal
#

So what would be start time

sick birch
#

The timestamp at startup

#

datetime.datetime.now().timestamp() when the bot starts would return that time

fervent shoal
#

yes

#

and then what do I do

sick birch
#

When someone runs the command subtract the startup timestamp from the current timestamp

#

Since the startup time happened in the past, it will be a smaller number

fervent shoal
#

so the command would just be

async def runtime(ctx):
    now = datetime.utcnow()
    elapsed = now - datetime
    seconds = elapsed.seconds
    minutes, seconds = divmod(seconds, 60)
    hours, minutes = divmod(minutes, 60)
    await bot.say("Running for {}d {}h {}m {}s".format(elapsed.days, hours, minutes, seconds))

datetime.datetime.utcnow()```
#

oop

sick birch
#

uh

#

are you following a youtube tutorial

hollow urchin
fervent shoal
#

website

sick birch
#

yeah don't do that

patent lark
sick birch
#

that code is heavily oudated

fervent shoal
#

damn

timid wagon
#

Where even did you get bot.say()?

fervent shoal
#

what would you recoment

hollow urchin
# hollow urchin

is this against tos if not can someone help me code a bot like this

fervent shoal
#

recommend

sick birch
sick birch
timid wagon
sick birch
#

and that

#

unfortunately most if not all of discord.py tutorials these days are not ideal

timid wagon
#

That's probably the most reliable source for beginners to work with

fervent shoal
#

theres nothing on runtime or uptime pithink

sick birch
hollow urchin
#

its tiktok.

sick birch
sick birch
patent lark
#

you should be familiar with how a bot actually works, first.

hollow urchin
sick birch
#

Then you'd need to use that

#

Should be a relatively simple

hollow urchin
#

i’m not sure doing this is against their tos though. Im going to have to read

sick birch
#

No, why would it be

#

You're just getting a user's info from their public API

final iron
sick birch
#

Or relative time

echo wasp
#

I don't use end

#

So idk

sick birch
#

That's not python I don't think

vocal snow
#

this is not python

timid wagon
#

^

hollow urchin
#

I don’t know if they used official api because does anyone know if tiktok api allows you to view when someone created their account?

fervent shoal
echo wasp
sick birch
hollow urchin
#

okay.

timid wagon
sick birch
sick birch
#

Perhaps

fervent shoal
#

doesnt dyno have a runtime command

ornate meteor
#

this is lua

sick birch
#

oops :p

ornate meteor
#

specifically lua with the roblox API

sick birch
#

Should only be 2 or 3 lines of code in total

echo wasp
fervent shoal
#

does dyno have something on github

final iron
#

No

sick birch
#

No

fervent shoal
#

alr

#

guessed lol

sick birch
#

Said again it's pretty easy and you can do it if you put some thought and documentation-searching into it

final iron
#

All of the big bots aren't open source

slate swan
#

Even if its open source it uses javascript

final iron
#

Tbh using discord formatting is just easier

slate swan
#

The Eris library.

final iron
#

You don't have to deal with formatting at all

#

You just throw in the timestamp

#

<t:81828282>
Becomes:
<t:81828282>

sick birch
#

<t:81828282:R> relative

final iron
#

Can you send the discord docs for them?

#

Im on mobile

slate swan
final iron
fervent shoal
#

so ive installed youtube_dl but it says its not resolved, does that have anything to do with the music bot cease and desist

slate swan
#

!ytdl

unkempt canyonBOT
#

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
fervent shoal
#

Oh so it is something to do with that

#

Alr thanks so much fr

hollow urchin
spring flax
#

what are the cons of having several bot.listen()?

flat solstice
#

I've been thinking about making a dashboard for my bot and have hard about flask, dijango and quart, which of these do ppl recommend. I'm making the bot itself in hikari which includes a rest API so should I just use that instead?

timid wagon
timid wagon
#

Just one server, you mean?

spring flax
#

yeah

timid wagon
#

It would ideally just increase the memory usage

#

having more listeners, that is

slate swan
#

"ideally"?

spring flax
#

it's basically one bot with many stuff included like it's a utility bot, suggestion bot, modmail

timid wagon
slate swan
timid wagon
#

For example, if it's a server with 10k members and you're checking for each member updating their profile - that's a lot of information for the bot to process

slate swan
#

performance issues? don't worry about it, any performance hit is negligible

spring flax
#

yeah i'll just combine two listeners into one then

timid wagon
#

So I wouldn't just tell them to not worry about it /shrug

pliant gulch
#

😳 Got components back into my wrapper

slate swan
#

combining event listeners is a pretty unsubstantial optimization. the main reason for binding several listeners to a single event is just to organize code better, combining them makes little to no sense

spring flax
#

also I was talking about 3 of them; I assume it doesn't have a considerable impact right?

pliant gulch
#

Yea, using listeners would barely impact any resources, if anything it would only just use a bit of memory since it stores in-memory

spring flax
#

3 @bot.listen for on_message ( i have other listeners too)

slate swan
#

unless you have a shit ton of listeners (like a shit ton) or you power your deployed app with a potato, you are fine

timid wagon
slate swan
slate swan
#

just don't worry about these minor things.

pliant gulch
spring flax
#

yeah, just 5 listeners so with the one I want to make for on_message, 6

slate swan
#

real optimization happens when you start reducing time wasted on io or something

pliant gulch
#

Why do you even have the need for so many listeners for MESSAGE_CREATE?

slate swan
#

in my bot i have like 5

pliant gulch
#

Is it to split up the code into chunks or

slate swan
#

each for a different module

#

yeah

pliant gulch
#

Yea that makes sense, readability is good to keep

slate swan
#

besides, each handler performs its own thing, i don't need to jumble everything into one function

spring flax
#

and I want to make one more for if a role x is pinged in a message, the bot invokes a command

slate swan
#

just don't waste your time worrying about it, go build some stuff πŸ’ͺ

spring flax
#

haha thanks for the responses

pliant gulch
#

I haven't made a mod mail in a while

#

Probably tedious, but easy ig

slate swan
#

i mean it should be pretty simple

pliant gulch
#

Yea, just need a persistent storage, do some flow control, listen to message create

spring flax
#

also, what's logger for exactly?

pliant gulch
#

It's a logging module, logs messages, etc. You'd use for debug or whatever

spring flax
#

like error messages?

pliant gulch
#

Sure, it could be error messages

spring flax
#

ah so it's essentially print(error) in that context?

round yarrow
#

Im trying to make a warn command in txt files (ik i should use a database, but im just doing it for fun)

I have done warn command, warnings command (which shows number of warns)

But I need help in making a clrwarns (clears the number of warns) command

Code: https://pastebin.com/ZJ4CdDe3

neat tartan
#

@pliant gulch im looking through the discord api itself rn and i've got a few questions about it and slash commands and registering commands and your solution for dealing with them

pliant gulch
pliant gulch
hollow urchin
#

is it against tos here to pay people to code things for you, because I may not know how to code, but I got money.

flat solstice
pliant gulch
hollow urchin
#

!rule 9

unkempt canyonBOT
#

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

hollow urchin
#

oh ight

vast gale
#

@timid wagon hey do i know you from somewhere?

neat tartan
# pliant gulch What are the questions exactly
  1. you would have to register the commands through the HTTP POST request first right?
  2. what you register is essentially just they keyword trigger for the command and descriptions of the command right?
  3. the interaction the application/bot receives when someone uses a slash command would be the new thing you would have to pull all the information from? such as instead of pulling a message context(ctx) and using that in the command code it would be from the interaction it receives?
timid wagon
vast gale
timid wagon
#

Not really

vast gale
#

:(

timid wagon
#

Though if you did contribute, ty for your help

vast gale
pliant gulch
neat tartan
# slate swan yes, yes, yes

doooooppppeee. i think i get how you might have done yours then. kinda. how often do you do your post? every time you launch the bot or do you do it through a different file/system

slate swan
#

i've only fiddled around with interaction commands, but the time i did, i had a script set up that i could run

#

basically i would load all commands, filter the ones that supported interactions, and then send post requests with a payload containing the command's data.

pliant gulch
#

In the POC slash commands I had in my wrapper, I would register them before connecting to the gateway

slate swan
#

the commands stay once you create them, you don't need to keep creating them

slate swan
round yarrow
#

Im trying to make a warn command in txt files (ik i should use a database, but im just doing it for fun)

I have done warn command, warnings command (which shows number of warns)

But I need help in making a clrwarns (clears the number of warns) command

Code: https://pastebin.com/ZJ4CdDe3

pliant gulch
#

Basically requesting those first, then getting the gateway URL then sending IDENTIFY

flat solstice
pliant gulch
#

You should claim a help channel, I’m gonna go to sleep soon

fervent shard
#

so this is my code, the bold part is the main focus.

async def on_message_delete(message):
  embed=discord.Embed(description=f"")```**embed.set_author(name=message.author, icon_url=message.author.avatar_url)**```channel=bot.get_channel(943385924052602880)
  await channel.send(embed=embed)```
how can i make it so that it also shows the member's id like this?
slate swan
#
embed.set_author(name=f'{message.author} ({message.author.id})', ...)
#

use author.id

flat solstice
slate swan
#

that would cause syntax errors

#

besides, f string is just better in every way

#

at least in this scenario

flat solstice
flat solstice
neat tartan
#

so i got a 201 response when sending a post for registering commands. should the commands at least be registered and visible in the "/" list now?

slate swan
#

i mean just check for yourself?

neat tartan
#

i tried and they arent listed but idk if its cause i had something set wrong

#

i think this is enough information for it to exist and doesnt have any optional features

#

like it works i just dont know if there is more feedback after registering a command

slate swan
#

wdym "more feedback"?

#

a 201 status is plenty of info

#

you can just send a GET to that same url if you want to view your application commands

vocal snow
steel void
#

can anyone help me I get the application did not respond sometimes using pycord slash commands I have defer in my code

#

await ctx.defer()

neat tartan
# slate swan a 201 status is plenty of info

the 201 is enough to know its registered but its more for the developing of the command itself. i usually like to test the command in discord itself partway through developing it to make sure its doing or pulling what it needs but its hard when the slash doesnt actually show up

neat tartan
slate swan
steel void
#

god i hate slash commands

slate swan
neat tartan
# slate swan don't make it a global command then

fair enough, ill wait the hour while reading up a bit more and if that doesnt work i will. it would still have the issue of not picking up if its not in the list though... ill do some more reading about it

slate swan
#

no, it shouldn't take an hour

#

it's just slow to update

#

just have it bound to your testing guilds

steel void
# slate swan can you show the traceback?
Ignoring exception in command <discord.commands.SlashCommand name=currentstocks>:
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 110, in wrapped
    ret = await coro(arg)
  File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 766, in _invoke
    await self.callback(ctx, **kwargs)
  File "/home/container/247-casino-bot.py", line 325, in currentstocks
    await ctx.defer()
  File "/home/container/.local/lib/python3.10/site-packages/discord/interactions.py", line 471, in defer
    await adapter.create_interaction_response(
  File "/home/container/.local/lib/python3.10/site-packages/discord/webhook/async_.py", line 192, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction

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

Traceback (most recent call last):
  File "/home/container/.local/lib/python3.10/site-packages/discord/bot.py", line 520, in process_application_commands
    await ctx.command.invoke(ctx)
  File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 306, in invoke
    await injected(ctx)
  File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 116, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.commands.errors.ApplicationCommandInvokeError: Application Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction```
slate swan
#

can anyone help me I get the application did not respond sometimes using pycord slash commands I have defer in my code
"application did not respond"?

steel void
#

it shows application did not respond on discord

#

but thats the traceback on the host

slate swan
steel void
#

well I mean idk what else im supposed to do

#

literally what it told me

slate swan
#

did you already respond to the interaction before calling defer()?

spring flax
#

how would I duplicate a role?

slate swan
#

!d discord.Guild.create_role

unkempt canyonBOT
#

await create_role(*, name=..., permissions=..., color=..., colour=..., hoist=..., mentionable=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

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

All fields are optional.

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

Changed in version 1.6: Can now pass `int` to `colour` keyword-only parameter.
slate swan
#

you would want to acquire the Role object using guild.get_role(id) and then pass name=role.name, permissions=role.permissions, colour=role.colour, ... and so on

spring flax
#

ah okay cool that work

#

oh wow, bots with admin can give other roles the admin perm

neat tartan
#

its actually quite scary what a bot can do

steel void
#

wdym tim

spring flax
#

discord should've made it raise Forbidden

vocal snow
spring flax
slate swan
#

no

spring flax
#

how would I get that?

spring flax
#

or at least that's what i think

vocal snow
spring flax
#

only the owner should be able to do that

slate swan
#

ig i didn't account for that, mb. you would want to iterate through guild.channels and use channel.edit(permissions=channel.permissions_for(role))

vocal snow
#

you can't give a bot administrator privileges and then say that it shouldn't be an administrator

spring flax
slate swan
spring flax
slate swan
#

?

#

oh right uh i made a typo and got distracted before i was able to fix it

#

mb

spring flax
#

did you mean set_permissions?

slate swan
#

hold on

#

yeah

spring flax
#

!d discord.TextChannel.set_permissions

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...
spring flax
#

(this is for me)

slate swan
#

fuck im too sleepy for this shit

#

!d discord.abc.GuildChannel.set_permissions

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...
slate swan
#

Tim, get rest

#

try to comply by this if you're targeting all channels in a guild

#

i think all the children are the same tho

slate swan
#

Good

flat solstice
spring flax
#

but why

flat solstice
#

I got distracted doing other things

#

Anyway went off topic

neat tartan
#

@slate swan figured out my issue, bot didnt have perms to add commands

flat solstice
#

Ooof lol

neat tartan
#

yeah...

slate swan
unkempt canyonBOT
flat solstice
slate swan
#

this channel has a wonderful reputation of hardly ever being on topic

#

Yep

neat tartan
#

true

heavy folio
#

πŸ’€

slate swan
#
import pycord as uwu
from pycord.ext import commands as uwu_c

no_uwu_prefix="!"
uwu_prefix=uwu_c.when_mentioned_or(no_uwu_prefix)
uwu_intents = uwu.Intents.all()
uwu_bot_r = uwu_c.Bot
uwu_help_cmd = True

uwu_bot = uwu_bot_r(command_prefix=uwu_prefix, intents=uwu_intents, help_command=uwu_help_cmd)

uwu_command = uwu_bot.command
uwu_event = uwu_bot.event
uwu_on_ready_message = "uwu"
@uwu_command(name="uwu")
async def uwu_cmd_one(uwuness):
      await uwuness.send("Hunter uwu")

@uwu_event
async def on_ready()
      print(uwu_on_ready_message)```
#

@maiden fable

#

How is my naming convention?

#

Tf is line 7

#

and line 8

slate swan
slate swan
#

help_command takes a HelpCommand instance, or None
Won't be a bool

slate swan
#

But it looks so uwu

#

Sure

#

wasted

#

And why is it pycord

#

😫

slate swan
slate swan
slate swan
cedar stream
#

@slate swan to fix the error in your code press Ctr + A and then press backspace

steel void
#

anyone got any idea why on pycord even if you have await ctx.defer() sometimes it just like to say application did not respond, run same command again boom it works just fine

slate swan
shadow wraith
#

does anyone know how'd id add like a command disabler

steel void
#

wdym

slate swan
slate swan
unkempt canyonBOT
#

remove_command(name)```
Remove a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") from the internal list of commands.

This could also be used as a way to remove aliases.
slate swan
shadow wraith
cedar stream
steel void
#

idk it's just this await ctx.defer()

shadow wraith
slate swan
#

what , if you don't know what is it why you use it

cedar stream
steel void
#

because its supposed to fix the issue with the application

#

not responding

#

but it doesnt

slate swan
cedar stream
slate swan
slate swan
steel void
slate swan
steel void
#

isnt defer supposed to give the bot extra time to send the message instead of failing to send?

slate swan
cedar stream
slate swan
steel void
# slate swan Any errors? And follow Pep8
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.10/site-packages/discord/bot.py", line 520, in process_application_commands
    await ctx.command.invoke(ctx)
  File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 306, in invoke
    await injected(ctx)
  File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 116, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.commands.errors.ApplicationCommandInvokeError: Application Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction```
slate swan
steel void
#

im using pycord

slate swan
#

Nvm

slate swan
#

😳that's why it's the best fork.

slate swan
steel void
#

so if I remove the defer it'll work correctly?

slate swan
steel void
#

what if the bot takes longer than 3 seconds

#

to send the message?

cedar stream
slate swan
#

never used that library so no idea, send the link to pycord docs I'll check it

cedar stream
steel void
steel void
#

its on a host, n ot hosting it locally

cedar stream
#

Okay

slate swan
slate swan
steel void
#

yeah see that's supposed to fix my issue, but it doesnt

slate swan
#

i mean i thought that's what defer is for

steel void
#

cause as soon as like 3 seconds hit, application did not respond sometimes

slate swan
shadow wraith
slate swan
#

then just respond with a message and edit it later

cedar stream
#

Like to load it on my screen

steel void
#

yeah I heard that solution too, :/ hopefully I dont have to do that, that would be so obnoxious

slate swan
#

Lmao

slate swan
cedar stream
shadow wraith
slate swan
#

json best db

keen talon
cedar stream
slate swan
#

indeed

keen talon
shadow wraith
cedar stream
slate swan
shadow wraith
#

πŸ₯Ά

keen talon
slate swan
#

i will internally combust the second i even consider using json as a means of storing non configuration stuff

slate swan
#

json is so easy and easier syntax than sql or mongo, local json file dbs are cute

shadow wraith
#

i alr got this:


def ifdisabled(ctx: commands.Context):
    if data.get(ctx.command.name) is False:
        return True
    else:
        return False
keen talon
cedar stream
shadow wraith
cedar stream
#

Hb u use csv for db

cedar stream
#

Or a .txt file

slate swan
keen talon
slate swan
#

pickle best

slate swan
#

i use html for db 😎

#

!ot

keen talon
unkempt canyonBOT
shadow wraith
#

guys stop talking about dbs else just go to #databases

keen talon
shadow wraith
slate swan
slate swan
shadow wraith
slate swan
#

Should raise an CheckFailure if it's disabled

shadow wraith
cedar stream
slate swan
shadow wraith
cedar stream
shadow wraith
#
{"wyr": true, "modnick": false, "latency": false}
#

@cedar stream

cedar stream
shadow wraith
cedar stream
#

Ohhhh

shadow wraith
#

wait

cedar stream
#

It’ s a decorator??

shadow wraith
#

!d disnake.ext.commands.check

unkempt canyonBOT
#

@disnake.ext.commands.check(predicate)```
A decorator that adds a check to the [`Command`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Command "disnake.ext.commands.Command") or its subclasses. These checks could be accessed via [`Command.checks`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Command.checks "disnake.ext.commands.Command.checks").

These checks should be predicates that take in a single parameter taking a [`Context`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Context "disnake.ext.commands.Context"). If the check returns a `False`-like value then during invocation a [`CheckFailure`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.CheckFailure "disnake.ext.commands.CheckFailure") exception is raised and sent to the [`on_command_error()`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.disnake.ext.commands.on_command_error "disnake.disnake.ext.commands.on_command_error") event.

If an exception should be thrown in the predicate then it should be a subclass of [`CommandError`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.CommandError "disnake.ext.commands.CommandError"). Any exception not subclassed from it will be propagated while those subclassed will be sent to [`on_command_error()`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.disnake.ext.commands.on_command_error "disnake.disnake.ext.commands.on_command_error").
shadow wraith
#

yup

slate swan
#

you decorate a command function declaration with it

shadow wraith
#

it should be an asynchronous function too ig

drowsy thunder
#

How can I get the website with tutorial on how to create a python bot

slate swan
#

no, it's not required.

slate swan
cedar stream
#

It has to be done like this ```py
def is_me():
def predicate(ctx):
return ctx.message.author.id == 85309593344815104
return commands.check(predicate)

@bot.command()
@is_me()
async def only_me(ctx):
await ctx.send('Only you!')

drowsy thunder
drowsy thunder
#

Ok thanks

slate swan
cedar stream
slate swan
#

?

cedar stream
#

Nicer

drowsy thunder
cedar stream
#

It becomes It’ s own decorator

drowsy thunder
#

Ok thx

slate swan
shadow wraith
slate swan
cedar stream
shadow wraith
#

nvm

cedar stream
#

I took the example from there

maiden fable
slate swan
shadow wraith
#

File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/disnake/ext/commands/common_bot_base.py", line 418, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
disnake.ext.commands.errors.ExtensionFailed: Extension 'utility' raised an error: TypeError: ifdisabled() takes 0 positional arguments but 1 was given

maiden fable
#

Code

shadow wraith
#
def ifdisabled():
    def predicate(ctx: commands.Context):
        return data.get(ctx.command.name) is False

    return commands.check(predicate)

and

@commands.command(aliases=["ping"])
    @commands.has_role("staff")
    @commands.guild_only()
    @ifdisabled
    async def latency(self, ctx):
        await ctx.send(
            f"Pong! (Heartbeat: {self.bot.latency * 1000 / 4:0.0f}ms Ping: {self.bot.latency * 1000:.0f}ms)"
        )
#

oh yes and this is a cog btw

slate swan
#

you have to call it

shadow wraith
slate swan
#

not sure why, kinda dumb

slate swan
heavy harbor
#

Does anyone teach python basics here

#

The basics

slate swan
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
#

i wanted to propose a pr to make decorators more fool proof (i'm not calling you a fool, you know what i mean (: ) but i was advised to not

heavy harbor
#

Ok thanks

slate swan
#

also Client class needed .listen() (not sure why commands extension has it, doesn't make any sense)

heavy harbor
#

Uh I'm actually new to python

slate swan
heavy harbor
#

Idk

#

I found it interesting

maiden fable
slate swan
unkempt canyonBOT
maiden fable
maiden fable
#

Just told u the difference between event and listen deco

slate swan
#

no like it would actually be handy to be able to register multiple handlers for a single event

#

without using Bot

maiden fable
#

Ah that way

slate swan
#

did you try setting bot.help_command = None before loading the Cog?

shadow wraith
#

ok so i have my json in data/disabled.json but i kept getting Command raised an exception: FileNotFoundError: [Errno 2] No such file or directory: 'data'

so i just put it in where my cogs (and main file) is and i still get the same error

slate swan
#

using bot.load_extension() isn't representative of the actual file path, don't try to replicate it with open().

slate swan
#

yes

#

try ./data/disabled.json

#

yes

shadow wraith
# slate swan try `./data/disabled.json`

no i literally didnt do that this is what i did to load the cogs

def loadShit():
    extensions = ["utility", "fun"]
    for i in extensions:
        bot.load_extension(i)


loadShit()
slate swan
#

are you sure the cog is being loaded?

#

just pass help_command=None to the Bot constructor

#

it should work

#

what?

#

how is it an issue with your terminal

#

that's not the full traceback

#

ok

heavy folio
#

subclass HelpCommand

#

dont hardcode

slate swan
#

not everybody wants to

#

so don't force it

heavy folio
#

thats legit a bad way to do it

slate swan
#

according to you

heavy folio
#

dont tell people to write bad code

#

πŸ’€

slate swan
#

it's just a help command, there's no strict convention

heavy folio
#

ask hunter he'll say subclassing is better

#

alr then

slate swan
#

why ya'll arguing

nimble plume
#
        overwrites = {
            ctx.guild.default_role: discord.PermissionOverwrite(connect=False),
            ctx.author: discord.PermissionOverwrite(manage_channels=True, connect=True),
        }

fine?

nimble plume
#

ok..

fervent shard
#

how do i mention a text channel?

dense swallow
unkempt canyonBOT
nimble plume
#

how to stop my for loops

limber spire
fervent shard
#

how can i do this? i imported datetime but please dont send any links, just help me out through here.

limber spire
#

embed.footer.text is what you're looking for

slow fog
unkempt canyonBOT
#

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

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

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

New in version 2.0.

Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").

For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
heavy folio
#

pass a datetime object into the timestamp kwarg

steady berry
#

im trying to mkae a simple bot what responds but it dowesnt

#

'''import discord
import os
my_secret = os.environ['token']
client = discord.Client()

@client.event
async def on_ready():
print("We have logged in as {0.user}".format(client))

@client.event
async def on_messages(message):

if message.content.startswith("$hello"):
await message.channel.send("hello")
print(12)

client.run(my_secret)'''

limber spire
steady berry
#

no

steady berry
#

it says as i want we logged as

#

ok but how

heavy folio
unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.

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

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

instead of discord.Client() since on_message handling for commands is bad

steady berry
#

wait i found and error

fervent shard
heavy folio
#

and also os.getenv()

steady berry
#

thanks

heavy folio
#

and name it bot since it's a bot not client (good practices)

steady berry
#

ok

#

thx

#

its works now

fervent shard
# steady berry its works now

and instead of

    await message.channel.send("hello")```do ```@client.command()
async def hello (ctx):
  await ctx.send("hello")```
steady berry
#

ok

fervent shard
#

yes?

limber spire
#

Go ahead

fervent shard
steady berry
fervent shard
steady berry
limber spire
#

@client.command(name='name')

fervent shard
steady berry
#

ok

#

but what is ctx

limber spire
steady berry
#

thanks

fervent shard
#

btw just asking what colour code is the embed?

#

whats ur question?

kindred drum
#

Hey does anyone know how to make something like this elif isinstance(error, commands.MissingRequiredArgument): specific to a command? e.g. it detects the command and sends a message based on that

limber spire
steady berry
limber spire
limber spire
#

Also send the full code

fervent shard
limber spire
#

bruh

#

you just gave everyone access to ur bot congrats

fervent shard
#

sus bot? seriously?

limber spire
#

LMAO

limber spire
steady berry
kindred drum
limber spire
fervent shard
steady berry
fervent shard
#

hello, u dont have to spam, if someone doesnt answer you, then they don't know.

limber spire
limber spire
#

i messed up

#

But i can't realy help without code and a clear question

kindred drum
limber spire
#

i messed up

kindred drum
#

I dont think that will work

steady berry
#

how to make command with input like *boo @ loke

limber spire
#

Thats more a API bug then ig

limber spire
steady berry
#

how to mkae command with imput like bot has *ban {user} how to get {user}

kindred drum
#

except commands.MissingRequiredArgument:

#

that doesn't catch the error 😦

limber spire
limber spire
steady berry
kindred drum
#
@commands.Cog.listener()
    async def on_command_error (self, ctx, error):
        if isinstance(error, commands.MissingPermissions):
            await ctx.channel.purge(limit=1)
            em = discord.Embed(title="Cosmic Overground", description="Sorry, you don't have permission to run that command.", color=0x00a8ff)
            await ctx.send(embed=em)
        elif isinstance(error, commands.MissingRequiredArgument):
            await ctx.channel.purge(limit=1)
            em = discord.Embed(title="Cosmic Overground", description="You need to enter all the required arguments!", color=0x00a8ff)
            await ctx.send(embed=em)
        else:
            raise error```
#

that catches it but like not what i want

#
try:
            for i in range (0, len(Json_Items)):
                
                for x in Json_Items[i]:
                    
                    if int(x) == int(member.id):
                        
                   
                        id = member.id
                        name = member.name
                        staff = Json_Items[i][x]['Staff']
                        
                        await ctx.channel.purge(limit=1)
                        
                     
                        scammer = getJSON("./Cosmic overground/scammer.json")
                        scammer_dict2 ={
                        id: {
                            "Discord_Name": name,
                            "User IGN": ign,
                            "Payment Method": payment_methods,
                            "Payment Address": payment_address,
                            "Proof": args,
                            "Reason": reason,
                            "Staff": staff,
                            "Scammer": True,
                        }}
                        
                        
                        scammer.append(scammer_dict2)
                        json.dump(scammer, open("./Cosmic overground/scammer.json", "w"), indent=1)  
                        break
                    
        except commands.MissingRequiredArgument:
            await ctx.channel.purge(limit=1)
            em = discord.Embed(title="Cosmic Overground Secruity", description="You need to enter all the required arguments! ``!cban <user id> <reason> <proof>``", color=0x00a8ff)
            await ctx.send(embed=em)```
#

that doesn't catch it

nimble plume
kindred drum
#

embed.set_footer(text="")

kindred drum
fervent shard
kindred drum
#

you forgot a braket

#

bracket*

fervent shard
tacit storm
kindred drum
#

File "main.py", line 34, in on_message_delete
embed=discord.Embed(description=f"message deleted in: <#{943385924052602880}>\ncontent: {message.content}", colour=0x2F3136, timestamp = datetime.datetime.utcnow**)**
AttributeError: type object 'datetime.datetime' has no attribute 'datetime'

quick gust
#

but it's utcnow(), you need to call it

tacit storm
#

wait

tacit storm
#

im confused, who am i@helping

steady berry
#

SyntaxError: 'await' outside function what does this mean

kindred drum
kindred drum
#

lmao

quick gust
#

you must be awaiting outside an async function

tacit storm
#

^

#

it explains the whole error

kindred drum
quick gust
#

@steady berry i dont help in dms, also

#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

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

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

quick gust
#

indents

#

!indents

unkempt canyonBOT
#

Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

limber spire
#

try to learn basic python before digging into apis

fervent shard
dusk dock
#

Do any of you know how to do slash commands with disnake? If so, do you know how to make it so only the user who issued the slash command see the response from the bot? Could you send me a documentation link or give me an example? Thanks so much! (Feel free to ping me if you decide to reply by the way)

vocal snow
dusk dock
#

aah thank you

dusk dock
#

I didn't know what the word was called πŸ˜…

boreal ravine
#

you defined bio somewhere else in the global scope

hallow tangle
#

So last time I made this command py deletion_list = [] @bot.command() async def deleteadd(ctx, user: discord.User): deletion_list.append(user.id) await ctx.send("Done.") @bot.listen() async def on_message(msg): if msg.author.id in deletion_list: await msg.delete() How can I make it so that the deletes only happens in the server where the command is executed?

vocal snow
visual island
#

cause bio is inside the if-statement, if the if-statement isn't executed, then bio is undefined

hallow tangle
vocal snow
hallow tangle
vocal snow
#

If that's intended design, then ok. You can use a dictionary and store a list per guild to solve your issue

#

I'd use a set instead of a list though

grim oar
#

Html

tidal hawk
#

Which listener gets triggered when somebody boosts the server?

hallow tangle
brisk helm
#

use regex to match all numbers

#

+\d

hallow tangle
grim oar
loud goblet
#

Hello guys .How can I get notified when my bot joins a new server ? Like : Everytime the bot joins a new server, it should send a message to my personal server that it has joined a server

@client.event
async def on_guild_join(id):
  channelid = client.get_channel(942304159674282034)
  await channelid.send("hello")```

I already tried the above code but I'm getting the following error :
```File "main.py", line 20, in on_guild_join
    await channelID.send("Joined a server")
AttributeError: 'NoneType' object has no attribute 'send'```
hallow tangle
#

o

grim oar
#

np

hoary cargo
tidal hawk
#

Can bot see how many times user has boosted the serveR?

hallow tangle
unkempt canyonBOT
#

discord.on_guild_join(guild)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild") is either created by the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") or when the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") joins a guild.

This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
hallow tangle
#

wait they edited

vocal snow
maiden fable
hoary cargo
tidal hawk
#

Hey wise Hun....ter? Can a bot see how many times has a user boosted the server?

loud goblet
#

I want to send the msg into my personal server... not the server which the bot has joined

loud goblet
vocal snow
#

what intents do you have?

maiden fable
fervent shard
#
    embed.set_author(name=f'{message.author} ({message.author.id})', icon_url=message.author.avatar_url)
    ^
SyntaxError: invalid syntax``````py
@bot.listen()
async def on_message_delete(message):
  embed=discord.Embed(description=f"message deleted in: <#{943385924052602880}>\ncontent: {message.content}", colour=0x2F3136, timestamp = datetime.datetime.utcnow()
  embed.set_author(name=f'{message.author} ({message.author.id})', icon_url=message.author.avatar_url)
  channel=bot.get_channel(943385924052602880)
  await channel.send(embed=embed)```
slate swan
#

wth is this now :/

fervent shard
maiden fable
slate swan
grim oar
maiden fable
slate swan
timid wagon
slate swan
hoary cargo
maiden fable
fervent shard
# grim oar Yes
    embed=discord.Embed(description=f"message deleted in: <#{943385924052602880}>\ncontent: {message.content}", colour=0x2F3136, timestamp = datetime.datetime.utcnow())
AttributeError: type object 'datetime.datetime' has no attribute 'datetime'```
vocal snow
#

since when are option descriptions mandatory πŸ€”

timid wagon
slate swan
timid wagon
#

Either way you'd need an update

visual island
slate swan
#

the version is 2.3.0 btw @maiden fable

grim oar
maiden fable
grim oar
#

just do datetime.utcnow()

fervent shard
grim oar
slate swan
fervent shard
grim oar
slate swan
#

tysm

maiden fable
#

Works now?

hoary cargo
maiden fable
#

"What options smh"
- Ashley, 2022

grim oar
#

shiki birthday today @hoary cargo

hoary cargo
grim oar
#

😼

hoary cargo
vocal snow
#

happy birthday Ares πŸ₯³

fervent shard
# grim oar just do `datetime.utcnow()`
    embed=discord.Embed(description=f"message deleted in: <#{943385924052602880}>\ncontent: {message.content}", colour=0x2F3136, timestamp = datetime.datetime.utcnow())
AttributeError: type object 'datetime.datetime' has no attribute 'datetime'```
grim oar
#

just do datetime.utcnow()

timid wagon
hoary cargo
vocal snow
#

oh

maiden fable
#

Happy. Birthday. Ares.

grim oar
#

I am homo for shiki.

fervent shard
# grim oar just do `datetime.utcnow()`
@bot.listen()
async def on_message_delete(message):
  datetime.utcnow()
  embed=discord.Embed(description=f"message deleted in: <#{943385924052602880}>\ncontent: {message.content}", colour=0x2F3136, timestamp = datetime.datetime.utcnow())
  embed.set_author(name=f'{message.author} ({message.author.id})', icon_url=message.author.avatar_url)
  channel=bot.get_channel(943385924052602880)
  await channel.send(embed=embed)``````  File "main.py", line 35, in on_message_delete
    embed=discord.Embed(description=f"message deleted in: <#{943385924052602880}>\ncontent: {message.content}", colour=0x2F3136, timestamp = datetime.datetime.utcnow())
AttributeError: type object 'datetime.datetime' has no attribute 'datetime'```
pliant gulch
#

You seem to have imported from datetime import datetime instead of import datetime

grim oar
#
@bot.listen()
async def on_message_delete(message):
  embed=discord.Embed(description=f"message deleted in: <#{943385924052602880}>\ncontent: {message.content}", colour=0x2F3136, timestamp = datetime.utcnow())
  embed.set_author(name=f'{message.author} ({message.author.id})', icon_url=message.author.avatar_url)
  channel=bot.get_channel(943385924052602880)
  await channel.send(embed=embed)
maiden fable
#

andy

spring flax
#

can i not convert a datetime.datetime object to a specific timezone without another module?

maiden fable
#

The due date is nearing πŸ‘€

spring flax
#

hunter

pliant gulch
maiden fable
pliant gulch
#

I did add buttons, interactions and action rows yesterday though

grim oar
#

do you have taxes due andy

maiden fable
#

I prefer working with epoch time tbh

pliant gulch
#

Never heard someone actually say that

maiden fable
#

Wym

pliant gulch
#

Oh, yea I totally prefer calculating the date & time using epoch milis

maiden fable
#

Indeed

pliant gulch
#

That was sarcasm

maiden fable
#

;-; why bully

pliant gulch
#

Because why would you use epoch milis over datetime when trying to get the date & time

maiden fable
#

Okay lemme rephrase my statement: "I don't work with dates and times much"

vocal snow
# maiden fable Okay lemme rephrase my statement: "I don't work with dates and times much"

well, that is because andy is very smart in the aspect of developing. so when andy explains something to someone who doesnt have the same knowledge, it may be looked at as confusing because andy is explaining something with the assumption it can be understood as simply as he/she understands the topic. so yeah it creates confusion. thats why you ask more and more. the more you ask the more you know. dont walk away misunderstanding the topic because one explanation didnt give you the knowledge needed. im sure andy would have been willing to break down the explanation.

grim oar
#

OMG hi Andy!

maiden fable
vocal snow
#

you won't regret it

maiden fable
#

Oh yea I totally didn't

grim oar
#

im sure Andy would have been willing to break down the explanation tho.

modest plover
#
import disnake
from disnake.ext import commands

class Timeout(commands.Cog):
  """Mutes/timeouts a user."""
  
  def __init__(self, bot: commands.Bot):
    self.bot = bot
  
  @commands.slash_command()
  async def timeout(self, inter, user: disnake.Member, until = int, reason = None):
    """Mutes/timeouts a member for up to 28 days in the future."""
    await timeout(duration=until, member=user, reason=reason)
  
def setup(bot):
    bot.add_cog(Timeout(bot))

Slash doesn't register, any idea why?

maiden fable
#

It takes an hour

#

Discord issue Β―_(ツ)_/Β―

vocal snow
#

Discord *feature

modest plover
#
import disnake
from disnake.ext import commands
import os
from dotenv import load_dotenv

load_dotenv()

token = os.environ["token"]
bot = commands.Bot(test_guilds=[938194100639895713])

bot.load_extensions("commands")

@bot.event
async def on_ready():
    print(f"{bot.user} is loading into developer mode...")

bot.run(token)
grim oar
#

have you invited the bozo with application command set

hoary cargo
maiden fable
#

Uhhh?

#

!d disnake.Member.timeout

#

Nvm

hoary cargo
maiden fable
slate swan
#

halo frenz

#

nvm

maiden fable
#

Add another overwrite for ctx.author

modest plover
#

Still isn't registering the command in the test guild

hoary cargo
#

are you sure the cog is loaded

modest plover
#

I used bot.load_extensions("commands") to load the whole commands foldee

#

And it's loading my ping command

#

From the same folder

slate swan
#

inter.author

maiden fable
#

The member that created the channel?

#

ctx.author?

hoary cargo
maiden fable
#

Lmao

modest plover
#

yes I do because organisation :)

slate swan
maiden fable
#

I don't really develop bots anymore, so no comments. Everyone got their own opinions

maiden fable
#

inter.author, if u want the member object of the person who invoked the command

modest plover
#

Haven't used pycord, but I heard Disnake is good

slate swan
#

lol

maiden fable
#

U do know that this isn't the correct channel for memes, right?

slate swan
#

this is the visual explanation of pycord's uwuness

maiden fable
#

Β―_(ツ)_/Β―

modest plover
#

dpy is worse.

maiden fable
#

inter isn't defined

slate swan
maiden fable
#

Use ctx.author

final iron
#

Pycord is so bad

#

I looked at their repo

#

They have basically no examples for new things

maiden fable
#

Okay I smell a controversy starting, so I will just keep shut

modest plover
#

What about Nextcord?

slate swan
slate swan
maiden fable
slate swan
#

lol ikr

timid wagon
#

Nextcord has done well, they're a stable fork

maiden fable
#

.....?

#

Ah

#

Well then u gotta store the ticket channel ID somewhere, mapped to the ID of the person who opened it

slate swan
maiden fable
maiden fable
#

In short, u need a db

slate swan
#

..

maiden fable
#

?

timid wagon
#

every bot needs a db at some point mmlol

maiden fable
#

Not my bot hehe. I use txt files πŸ‘€

hoary cargo
#

artistic_hmm not really, depends if your bot store data

maiden fable
#

Indeed

timid wagon
#

once you want to implement anything specific, having a place to store your stuff is very useful

final iron
#

@maiden fable why is there a lowercase true and camelCase in your pfp smh

timid wagon
#

because it's js

maiden fable
#

Smh LEAVE it

final iron
#

It's like a mixture of python and js

hoary cargo
#

j* r_catpuke

maiden fable
#

It's been discussed like a thousand times already

timid wagon
#

yeah half js*

timid wagon
slate swan
unkempt canyonBOT
timid wagon
#

Wow

slate swan
#

lol

hoary cargo
#

!ot

slate swan
#

lol

hoary cargo
maiden fable
hoary cargo
#

i want to commit stop living for the fail

slate swan
maiden fable
#

Smh this isn't the correct channel Ash

timid wagon
#

Alright, this is getting a little out of hand

lapis lintel
slate swan
#

lol

maiden fable
hoary cargo
#

this is quite normal atm, still no serious fights

maiden fable
#

Good thing tbh. I'm either involved in those arguments, or I'm the one who starts them

hoary cargo
#

same

#

i wish the badges for devs would be back sad at least idk like if your bot > x servers you get the badge

maiden fable
#

They ain't coming back

hoary cargo
#

i got my bot verified few days after it got removed, the pain was immeasurable

hoary cargo
#

pog who's gonna start

maiden fable
#

My bot got verified last year haha

#

Just a day or two before their Christmas Holidays started

hoary cargo
#

artistic_hmm great Christmas present

quick gust
#

mine still is in the same amount of servers it was in 2 months ago lmao

maiden fable
final iron
maiden fable
quick gust
quick gust
maiden fable
#

Nope

#

Haha

quick gust
#

o

maiden fable
#

Well, u can use that, but i meant a proper SQL db

slim ibex
#

πŸ—Ώ

maiden fable
# quick gust πŸ˜”

It's still in only 123 servers even when my friend's bot which got verified like 2 weeks before mine is in like 400 or smth servers already

hoary cargo
#

if you ever apply for intents, uh, expect an answer after few months dedbruh

quick gust
maiden fable
hoary cargo
#

i applied for member intents on February and got an answer in fucking September mike

maiden fable
#

Damn tf

quick gust
#

dang

hoary cargo
#

i just needed it to set up an easy welcome message stuff for my server, but imagine over half year, in that time i just made a custom bot just for my server and solved the problemKEK but at least they enabled the intent after over half year

maiden fable
#

Lmao

hoary cargo
#

dyno and mee6 supremacy is over, their moderation stuff are pretty easy to replicate

maiden fable
#

Mhm

final iron
sage otter
#

Dashboard is just ux

#

It’s all about functionality

maiden fable
#

Indeed

hoary cargo
surreal sierra
#

hi, I know that discord.py is not the best library and dpy is not getting updated anymore but what is new to disnake. like is there some major features that Im missing by staying with dpy?

slim ibex
#

ye you could say so

#

like application commands, interactions

#

i would just use a fork or something like hikari/pincer

steady berry
#

im trying to make command like boo {user} but i get to have id how can i get id by usernam

quick gust
#

You dont need ID, just do user.mention

slim ibex
#

!d discord.Member.mention