#discord-bots

1 messages ยท Page 158 of 1

loud junco
#

what does thing got to do with my case

flat pier
#

using .format() is bad in sql like that

drifting arrow
#

No it's not.

loud junco
#

!formatter

unkempt canyonBOT
#

String Formatting Mini-Language
The String Formatting Language in Python is a powerful way to tailor the display of strings and other data structures. This string formatting mini language works for f-strings and .format().

Take a look at some of these examples!

>>> my_num = 2134234523
>>> print(f"{my_num:,}")
2,134,234,523

>>> my_smaller_num = -30.0532234
>>> print(f"{my_smaller_num:=09.2f}")
-00030.05

>>> my_str = "Center me!"
>>> print(f"{my_str:-^20}")
-----Center me!-----

>>> repr_str = "Spam \t Ham"
>>> print(f"{repr_str!r}")
'Spam \t Ham'

Full Specification & Resources
String Formatting Mini Language Specification
pyformat.info

flat pier
#

it goes directly against sql sanitization of asyncpg (which this looks like)

loud junco
#

this doesnt work in sql forget it

#

just use placeholder it saves ur time, ur sanity and also ur life but not my spelling

flat pier
flat pier
#

L that removed my image sad

loud junco
#

LOL who remove the embed

flat pier
#

i did on accident

loud junco
#

kekw

flat pier
#

btw you didn't pass self to your function here

loud junco
#

oops

#

hydrorico as shit as ever

fickle sky
#

can anyone say me if im doing something wrong
when i run the cmd it just says "bot is thinking"

slate swan
# drifting arrow No it's not.

!sql-fstrings you shouldn't. that's what the python developers suggest and im quite sure they're more experienced with their own products

unkempt canyonBOT
#

SQL & f-strings
Don't use f-strings (f"") or other forms of "string interpolation" (%, +, .format) to inject data into a SQL query. It is an endless source of bugs and syntax errors. Additionally, in user-facing applications, it presents a major security risk via SQL injection.

Your database library should support "query parameters". A query parameter is a placeholder that you put in the SQL query. When the query is executed, you provide data to the database library, and the library inserts the data into the query for you, safely.

For example, the sqlite3 package supports using ? as a placeholder:

query = "SELECT * FROM stocks WHERE symbol = ?;"
params = ("RHAT",)
db.execute(query, params)

Note: Different database libraries support different placeholder styles, e.g. %s and $1. Consult your library's documentation for details.

See Also
โ€ข Python sqlite3 docs - How to use placeholders to bind values in SQL queries
โ€ข PEP-249 - A specification of how database libraries in Python should work

slate swan
fickle sky
#

bot dont even responds ;-;

slate swan
#

do you get any errors in your console?

slate swan
ember nest
#

How can I make a json file as a database to make it save a channel id with the guild id of channel and set a name for the channel id?

naive briar
#

Yes it is

#

But JSON isn't a database

ember nest
#

I used json as a database for my level system that's why

naive briar
# slate swan

!d discord.InteractionResponse.send_message - the method doesn't return the message

unkempt canyonBOT
#

await send_message(content=None, *, embed=..., embeds=..., file=..., files=..., view=..., tts=False, ephemeral=False, allowed_mentions=..., suppress_embeds=False, delete_after=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Responds to this interaction by sending a message.
naive briar
ember nest
#

Hmm

slate swan
#

how to disable a button if clicked?

cold sonnet
#

it's sql queries

#

you can't just use formatting

naive briar
#

W

cold sonnet
#

here look at this

shrewd fjord
unkempt canyonBOT
slate swan
#

in the callback ?

naive briar
#

Where else

slate swan
#

@naive briar like this ?

cold sonnet
#

what

#

oh

slate swan
#

or , inside the button definiton

#

i mean this

naive briar
#

Whatever

cold sonnet
#

that's not how you make buttons

naive briar
#

See what happens

slate swan
slate swan
cold sonnet
#

where do you think a callback is called

slate swan
#

that's my command full code

cold sonnet
#

yeah this seems right

slate swan
#

any help about disabling buttons ?

cold sonnet
#

you still have to edit the message with the view the buttons are in

shrewd fjord
slate swan
naive briar
#

Show the actual error from the terminal

slate swan
cold sonnet
#

defer

shrewd fjord
slate swan
shrewd fjord
slate swan
cold sonnet
#

add await interaction.response.defer()

#

at the start of the callbacks

slate swan
#

okay

#

done i'll try

shrewd fjord
slate swan
#

no error, but it isn't disabled

naive briar
#

Edit the message with the edited view the button is int

slate swan
#

or , how can i definie a new view

naive briar
slate swan
#

ok

slate swan
naive briar
#

No

slate swan
#

bruh ok

cold sonnet
#

deleted the message with the code

#

to enstrengthen catgal's will

slate swan
#

can i delete a message which is sent by response ?

shrewd apex
#

!d discord.Interaction.original_response

unkempt canyonBOT
#

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

Fetches the original interaction response message associated with the interaction.

If the interaction response was a newly created message (i.e. through [`InteractionResponse.send_message()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionResponse.send_message "discord.InteractionResponse.send_message") or [`InteractionResponse.defer()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionResponse.defer "discord.InteractionResponse.defer"), where `thinking` is `True`) then this returns the message that was sent using that response. Otherwise, this returns the message that triggered the interaction (i.e. through a component).

Repeated calls to this will return a cached value.
shrewd apex
#

use this and delete

slate swan
#

ok

gusty mango
#

error:
main.py:13: RuntimeWarning: coroutine 'BotBase.load_extension' was never awaited
bot.load_extension('cogs.crash')
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
main.py:14: RuntimeWarning: coroutine 'BotBase.load_extension' was never awaited
bot.load_extension('cogs.mines')
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
code: https://paste.pythondiscord.com/ajibecohav

shrewd fjord
#

?

shrewd fjord
#

like dat

slate swan
#
async def onegai(ctx: commands.Context, channel_id):
    await ctx.respond("Please pound me more with you ")
    channel_id = int(channel_id)
    voice_channel = bot.get_channel(channel_id)
    vc = voice_channel
    await vc.connect()
    while ctx.voice_client.play(discord.FFmpegPCMAudio("./sounds/onegai.mp3")):
        while ctx.voice_client.is_playing():
            await asyncio.sleep(.1)
            await ctx.voice_client.disconnect()```
bot not getting disconnected after the sound file has been finished playing, no error nothing language- pycord
fickle sky
#

can you guys find the error please im not able to fix it ;-;

leaden solar
#

yo im trying to read the message history of a thread after detecting it getting deleted, but i get this error:

discord.errors.NotFound: 404 Not Found (error code: 10003): Unknown Channel
@bot.event
async def on_thread_delete(thread):
    if thread.category_id == 983745432192688138:
        messages = await thread.history(limit=200).flatten()
        for message in messages:
            print(message)
        # messages is now a list of Message...
#

is it something wrong with my code?

#

because i just get errors from this code

naive briar
#

You can't get the history of a deleted channel

leaden solar
#

oh okay

#

but is there any way to detect on_message

#

or something

#

for threads

naive briar
#

Detect what

leaden solar
#

im trying to log all messages in a specific threads under a specific category

naive briar
#

Then check the channel ID from the message

#

!d discord.Message.channel

unkempt canyonBOT
leaden solar
#

alright

slate swan
#

Help!

shrewd fjord
#

hm

slate swan
#

How do I make my bot think?

rare echo
#

like defer?

#

or like sentience

slate swan
#

Like some bots have the thinking... thing on the slash command.

rare echo
#

defer

slate swan
#

While they are loading something long.

rare echo
#

yes its called defer

shrewd fjord
#

!d discord.InteractionResponse.defer

unkempt canyonBOT
#

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

Defers the interaction response.

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

This is only supported with the following interaction types...
shrewd fjord
#

thinking=True u have to do

rare echo
#

ty didnt know it off the top of my head

slate swan
#

Let me try.

shrewd fjord
#

or poem or whatever

rare echo
#

channeled inner yoda

shrewd fjord
slate swan
#

I still can't figure it out.

shrewd fjord
slate swan
#

Ooh.

#
TypeError: InteractionResponse.defer() got an unexpected keyword argument 'thinking'
#

@shrewd fjord

shrewd fjord
#

which library you are using?

slate swan
#

disnake

shrewd fjord
#

๐Ÿ™‚

#

need to check docs

polar dawn
#

How do I make a specific hybrid commands that are only available for specific servers?
I used to do this:

@bot.command()
async def test(ctx):
  allowed_guild = [123, 321]
  if ctx.guild.id in allowed_guild:
      async with ctx.typing():
        await ctx.reply("Pass")
  else:
      return

but how do i do it with hybrid commands? maybe if the guild id is not in the list it would just not respond or just not appear in the slash command list for the guild

slate swan
shrewd fjord
#

um this channel is for discord bots

slate swan
drifting arrow
#

Is it possible embed a youtube video inside of a discord embed?

#

So instead of that I want the entire video to be playable.

polar dawn
polar dawn
shrewd fjord
#

u cant have a embed in a embed

polar dawn
drifting arrow
#

lol

slate swan
shrewd fjord
ivory vortex
#

this is my code, i want to make the slash command paramater have a description on discord ```py
async def a(interaction: discord.Interaction, string: str):

shrewd fjord
rare echo
shrewd fjord
#

ugh awkward

#

!d discord.app_commands.describe

unkempt canyonBOT
#

@discord.app_commands.describe(**parameters)```
Describes the given parameters by their name using the key of the keyword argument as the name.

Example:

```py
@app_commands.command(description='Bans a member')
@app_commands.describe(member='the member to ban')
async def ban(interaction: discord.Interaction, member: discord.Member):
    await interaction.response.send_message(f'Banned {member}')
```  Alternatively, you can describe parameters using Google, Sphinx, or Numpy style docstrings...
shrewd fjord
#

oh makes sense

#

@ivory vortex

naive briar
#

Can you send them as message for once

rare echo
#

payloud?

slate swan
#

payload it is, but who cares about var names

#

get_channel(channelid), not get_channel(id=channelid)

rare echo
#

you dont need id= for bot.get_channel, just pass the int

shrewd fjord
#

same as channel

#

hmm

#

ohh u r using guiold

#

nvm

slate swan
#

!d discord.Guild.get_role

unkempt canyonBOT
#

get_role(role_id, /)```
Returns a role with the given ID.

Changed in version 2.0: `role_id` parameter is now positional-only.
slate swan
#

/ means a positional arg

#

remove role_id=?

rare meadow
#

Hello everyone. I'm quite new. Can i ask question about using BeautifulSoup?

slate swan
rare meadow
drifting arrow
#

How do I output an apps_command error?

naive briar
#

Huh

drifting arrow
#

I'm using @app_commands.checks.has_permissions(administrator=True), but when a regular person without those permissions uses it, the error is sent to console and not to the user

naive briar
#

!d discord.app_commands.Command.error

unkempt canyonBOT
#

@error(coro)```
A decorator that registers a coroutine as a local error handler.

The local error handler is called whenever an exception is raised in the body of the command or during handling of the command. The error handler must take 2 parameters, the interaction and the error.

The error passed will be derived from [`AppCommandError`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.AppCommandError "discord.app_commands.AppCommandError").
slate swan
#

Hey guys, i heard that discord-components is gonna get deleted, is that real?

naive briar
#

What is that

slate swan
#

A python library

#

For buttons and generally ui

bright wedge
#

update your version

naive briar
#

Idk about that, but discord.py have a good enough UI support

bright wedge
shrewd fjord
#

cul

bright wedge
slate swan
naive briar
#

Months ago

bright wedge
#

Discord components are cool, but discord.py will support it on version 2.0. It is hard to wait, so we made a third-party library for using components such as buttons or selects!

Source: discord-components github.

slate swan
bright wedge
#

Welcome back then

slate swan
#

discord.py had buttons soon after when discord announced the feature, you just didnt know how to install it

feral frost
#

CODE:

class create_account(discord.ui.Modal, title="ACCOUNT SETUP!"):
    age = discord.ui.TextInput(label='Age:', style=discord.TextStyle.short, min_length=2, max_length=32, required=True)
    region = discord.ui.TextInput(label='Region:', style=discord.TextStyle.short, min_length=3, max_length=56, required=True)

    ready = Button(label="Account ready", style=discord.ButtonStyle.green)
    remove = Button(label="Remove account", style=discord.ButtonStyle.red)

    async def on_submit(self, interaction: discord.Interaction):
        await interaction.response.edit_message(view=None, content=f"Succesfully created account!{self.age}{self.region}")

    view = View(timeout=None)
    view.add_item()

...
async def setup_callback(interaction: discord.Interaction):
      await interaction.response.send_modal(create_account())
...

QUESTION:
How can i make a modal but without the class ?

naive briar
#

Discord buttons were added a year ago!? ๐Ÿฅน

naive briar
feral frost
slate swan
#

!d discord.ui.Modal

unkempt canyonBOT
#

class discord.ui.Modal(*, title=..., timeout=None, custom_id=...)```
Represents a UI modal.

This object must be inherited to create a modal popup window within discord.

New in version 2.0.

Examples...
shrewd fjord
#

keyboard goes brrrrrrrr

slate swan
#
modal = discord.ui.Modal(title="your title")
``` and then add placeholders using add_item
#

!d discord.ui.Modal.add_item

unkempt canyonBOT
#

add_item(item)```
Adds an item to the view.

This function returns the class instance to allow for fluent-style chaining.
feral frost
#

hm ok ill try thanks ๐Ÿ™‚

upbeat otter
shrewd fjord
slate swan
#

sarth who\

proud apex
#
  async def custom_cooldown(ctx):
    time = await self.db.fetchval("SELECT time FROM users WHERE user_id = $1", ctx.author.id)
    if time == 0:
      print("one")
      return commands.Cooldown(1, 200)
    elif time == 1:
      print("two")
      return commands.Cooldown(1, 120)

  @commands.command()
  @commands.dynamic_cooldown(custom_cooldown, commands.BucketType.user)
  async def test(self, ctx):
    await ctx.send("ok")

the bot is not responding, there are no errors, what could be the problem?

upbeat otter
slate swan
#

ikr

upbeat otter
#

good boy

fading marlin
#

your bot doesn't have permissions to have slash commands, probably because you didn't enable the application.commands scope in the dev portal

feral frost
#

CODE:

class create_account(discord.ui.Modal, title="ACCOUNT SETUP!"):
    age = discord.ui.TextInput(label='Age:', style=discord.TextStyle.short, min_length=2, max_length=32, required=True)
    region = discord.ui.TextInput(label='Region:', style=discord.TextStyle.short, min_length=3, max_length=56, required=True)

    ready = Button(label="Account ready", style=discord.ButtonStyle.green)
    remove = Button(label="Remove account", style=discord.ButtonStyle.red)

    async def on_submit(self, interaction: discord.Interaction):
        await interaction.response.edit_message(view=None, content=f"Succesfully created account!{self.age}{self.region}")

    view = View(timeout=None)
    view.add_item()

...
async def setup_callback(interaction: discord.Interaction):
      await interaction.response.send_modal(create_account())
...```

**QUESTION:**
How can i make a modal but without the class ?
fading marlin
#

modals don't need views

feral frost
#

i tried a lit but nothing works

#

no no dont mind that

#

just the "age" "region" and on_submit

fading marlin
#

well, what you're doing is the proper way to create a modal...

feral frost
#

the view thing is just something that i added

feral frost
fading marlin
#

wdym?

feral frost
slate swan
#

from discord.ext import commands

ember nest
#

Well I have a question

#

I used to be good on JavaScript and now I started learning Python too and even learned how to make discord bot on python

#

But I have a question would it be better to make a bot on JavaScript?

#

Because mostly when I search on YouTube for features I want to add to my bot mostly I see discord.js videos

slate swan
#

i see no reason to use javascript unless you're significantly better at javascript than python

naive briar
#

Depends on what you're comfortable with

ember nest
#

I am comfortable with both of them actually

feral frost
#

guys ? please just answer this very simple question

ember nest
#

I am actually comfortable with both but I want to know which would be better to use @slate swan @naive briar

feral frost
#

how can i make a modal ( the thing that can be used to make a survey or smth ) but WITHOUT class ????

fading marlin
feral frost
slate swan
#

What are you trying to do?

feral frost
slate swan
naive briar
#

Cool

ember nest
slate swan
#

thats one way to say it yeah

ember nest
#

Because like when I searched for a minigames bots etc with python couldn't find any

high sun
#

How can I get/fetch a guild in a cog with the Bot? It always returns None

async def setup(bot):
    server = bot.get_guild(int(guildID))
    print(server)
    await bot.add_cog(RaffleMonitor(bot))
slate swan
naive briar
ember nest
feral frost
# slate swan What are you trying to do?

dont mind the things i scratched so this makes a modal wow very nice but now when i want to get the "age" thing in the command where the modal gets printed it wont let me get the "age" is there a way to get it or ?

fading marlin
ember nest
high sun
fading marlin
feral frost
#

no guys you dont understand

slate swan
ember nest
#

Oh really

high sun
slate swan
#

there's a cool python Library for that as well

feral frost
#

the COMMAND thing not the CLASS like this

fading marlin
feral frost
ember nest
high sun
slate swan
#

its not about the language maybe people just didn't care about making those with python

ember nest
#

Because I am working on a bot too actually

slate swan
naive briar
fading marlin
ember nest
feral frost
naive briar
#

Look at the example

high sun
slate swan
#

if you're talking about wyvern its totally different from dpy

#

its just written in python

ember nest
#

Oh you are using wyvern to make your discord bot?

fading marlin
slate swan
#

i might do that in future but currently im just making it to learn about discord api

high sun
ember nest
#

But what is the best to use though discord.py or nextcord etc

naive briar
#

Wait until they say hikari

feral frost
slate swan
#

discord.py has most support and nice codebase
disnake is nice too
hikari is the best choice if you don't wanna stay mainstream

my preference order:
hikari, disnake, dpy, nextcord, pycord, hata, pincer, naff, other shitty forks

slate swan
ember nest
feral frost
slate swan
naive briar
#

What are you trying to do is my question

slate swan
#

it will seem like djs at some point due to its low level implementations

feral frost
slate swan
naive briar
ember nest
#

But if I want to make a really professional bot with all features like games / moderation / design / music / level, credit system etc what would you suggest to use ? @slate swan

slate swan
feral frost
ember nest
#

Alright good I am already using that

#

I already made 350+ lines for my bot till now

#

Level system / warn system / welcome message (on image) / ban/kick/mute / and some other commands

#

That's what I have for now

slate swan
ember nest
#

I have poll system too

naive briar
ember nest
#

Planning to add ticket/giveaway and some other

#

But really ticket and giveaway seems hard lol

feral frost
# naive briar And?

ok so i want to make it WITHOUT the class like not inside of a class but immediately inserted inside the @bot.command thing

high sun
#

hmm, im getting an error saying Client has not been properly initialised. Please use the login method or async context manager. The docs don't give me a clear instruction about what to do now. How can I fix this

ember nest
#

I've been searching much and I see people do it at 1 hour long video etc

#

For ticket

#

Or 3 parts video

#

Feels hard to learn

slate swan
#

It depends on how well you want it to function really.

naive briar
ember nest
#

Giveaway or ticket?

naive briar
#

This is just like subclassing but less readable

ember nest
ember nest
#

Can you help me to do mine as well?

#

It's private but I will make it public

#

So I want to make it as a public bot ticket system

#

Yes

#

Oh shoot

#

Give me the file and I will tell you if the end result is good ๐Ÿ˜Š

#

Nah jk I want to learn

#

So you learned from a video or document?

#

Hmmm

slate swan
#

I wouldn't rely on YouTube videos for bot tutorials to be honest

ember nest
#

Yeah I see

ember nest
#

I mostly made everything from learning by YouTube

#

Because I can't find any good documents that are easy to learn from

slate swan
# ember nest Why

Most videos are out-dated and/or skip over important details in my opinion

ember nest
#

What's fun about this is that you are literally learning nothing xD

ember nest
#

So you suggest me to use docs?

slate swan
#

thats what a normal user would do

ember nest
#

So there are only 1 popular docs or much?

slate swan
#

usually I check docs > search StackOverflow > ask/search on Discord in that order if there's something I don't know

fading marlin
#

!d discord

unkempt canyonBOT
#

In order to work with the library and the Discord API in general, we must first create a Discord Bot account.

Creating a Bot account is a pretty straightforward process.

slate swan
ember nest
#

Alright

#

But how do I use docs though

#

Like for the ticket system

slate swan
#

ill be honest ticket systems are wack now

#

just use private Threads

#

that does all that a ticket system would do

fading marlin
#

forum channels ducky_dave

slate swan
#

yeah modmail is a different case

slate swan
# ember nest Like for the ticket system

Split the problem into smaller steps. Say you want to have a button that opens a new ticket, start by asking how do you create a button? Then think about how you can create your text channel/thread/whatever type of ticket system you want. Etc

ember nest
#

Hmm

#

I don't know that views thing actually

#

Well I know a bit actually

#

Like how to make a button and after clicking it sends a message

#

That's what I know how to do

feral frost
#

my code

ember nest
#

But idk how to make it create new channel etc

feral frost
#

pls help ๐Ÿ™‚

naive briar
unkempt canyonBOT
ember nest
#

Yes

naive briar
#

You need to get the value from it

feral frost
ember nest
#

Uh it's alright

#

Actually I am kinda busy now maybe later

#

I'll also try to know more about docs and StackOverFlow

naive briar
unkempt canyonBOT
naive briar
#

.value

feral frost
#

where

naive briar
#

FROM the textinput

#

age.value

fading marlin
#

Does your bot have the application.commands scope enabled?

feral frost
# naive briar **age.value**

ah ok ok i did it and it works but a big but in the database it now just smacks an empty thing instead of the values you gave in the MODAL

high sun
#

When I try to use:

await self.bot.wait_until_ready()

it gives me the following error: RuntimeError: Client has not been properly initialised. Please use the login method or asynchronous context manager before calling this method

#

But I'm kinda stuck about what to do cause? Either way I'm using bot.login wrong or im stupid

#

probably both

naive briar
#

Why are you using the login method anyway

feral frost
high sun
feral frost
naive briar
feral frost
naive briar
#

Also you should subclass the modal

naive briar
feral frost
feral frost
high sun
slate swan
#
@commands.has_permissions(manage_messages=True)
async def mute(ctx, member: discord.Member=None, unit = None, reason=None):
    if member == None or member == ctx.message.author:
        await ctx.channel.send("You cannot mute yourself")
        return
    if reason == None:
        reason = "Not specified!"
    guild = ctx.guild
    mutedRole = discord.utils.get(guild.roles, name="Muted")  
    embed = discord.Embed(description=f"**Muted** {member.mention}\n๐Ÿ‘‹ ใƒปUser {member.mention} is muted!\nโ› ใƒปReason of mute is {reason}\n:boom: ใƒปTime of mute is {unit} seconds\n๐Ÿ”ง ใƒปMuted by {ctx.author.mention}")
    embed.set_footer(text="ยฉ 2022 Pirates Developments.  All rights reserved") 
    await member.add_roles(mutedRole, reason=reason)
    await ctx.send(embed=embed)
    if unit == None:
        unit = "3600"
    await asyncio.sleep(unit)
    await member.remove_roles(mutedRole)```
#

any who can help me idk why my mute command dont work

fading marlin
#

asyncio.sleep should be an integer/float, not a string

#

you're welcome

high sun
#

i'm still stuck at the cogs problem

#

could you help me further, Lee?

fading marlin
fading marlin
high sun
# fading marlin what exactly do you need help with?

I'm trying to either get or fetch a channel in a cog, now I'm using self.bot.wait_until_ready() on the @tasks.before_loop but it gives me this RuntimeError: Client has not been properly initialised. Please use the login method or asynchronous context manager before calling this method

fading marlin
#

!paste send you full code please

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

slate swan
#

start the task after the bot is running @high sun

high sun
slate swan
fading marlin
#

wot?

high sun
slate swan
# fading marlin wot?
@commands.has_permissions(manage_messages=True)
async def mute(ctx, member: discord.Member=None, testing=None, reason=None):
    if member == None or member == ctx.message.author:
        await ctx.channel.send("You cannot mute yourself")
        return
    if reason == None:
        reason = "Not specified!"
    if testing == None:
        testing = 3600
    guild = ctx.guild
    mutedRole = discord.utils.get(guild.roles, name="Muted")  
    embed = discord.Embed(description=f"**Muted** {member.mention}\n๐Ÿ‘‹ ใƒปUser {member.mention} is muted!\nโ› ใƒปReason of mute is {reason}\n:boom: ใƒปTime of mute is {testing} seconds\n๐Ÿ”ง ใƒปMuted by {ctx.author.mention}")
    embed.set_footer(text="ยฉ 2022 Pirates Developments.  All rights reserved")  
    await member.add_roles(mutedRole, reason=reason)
    await ctx.send(embed=embed)
    await asyncio.sleep(testing)
    await member.remove_roles(mutedRole, reason=reason)```
#

i tried this but dont work

fading marlin
#

you have to type hint testing with int too, otherwise its still a string

fading marlin
high sun
#
async def on_ready():
    await bot.load_extension(name='cogs.repeater')
    print("Bot is online!")

client.run(os.getenv("BOT_TOKEN"))
fading marlin
#

use setup_hook instead

high sun
#

instead of?

fading marlin
#

on_ready

high sun
#

with a wait_until_ready in the setup_hook?

#

cause i'm using a get_channel inside the on_ready aswell

feral frost
fading marlin
high sun
#

in the on_ready

feral frost
#

@naive briar i think i need to do like the submit button in the modal i nee that to do something else but idk how

fading marlin
high sun
#

correct

fading marlin
#

and you're loading your extensions in setup_hook?

high sun
#

correct

feral frost
#

anyone knows how the on_submit button works in a modal ?

fading marlin
#

what happens if you place the wait_until_ready inside the actual task instead?

feral frost
#

cuz this doesnt work

fading marlin
#

it's missing an interaction parameter

feral frost
#

oo ok

high sun
#

still gives me this:
RuntimeError: Client has not been properly initialised. Please use the login method or asynchronous context manager before calling this method

feral frost
fading marlin
#

you have to override Modal's on_submit with that

feral frost
#

how ?

fading marlin
#
class A:
    def method(self):
        print("A")

def other_method():
    print("B")

>>> a = A()
>>> a.method()
A
>>> a.method = other_method
>>> a.method()
B
#

that's what you have to do

feral frost
#

is this for me ?

fading marlin
#

yes

feral frost
#

ok

#

is it in the terminal

high sun
#

do i need to use bot.login, Lee?

fading marlin
#

no, bot.run should be fine. It calls login anyway

high sun
#

th, it's so weird

fading marlin
feral frost
#

ah ok

high sun
#

without the wait_until_ready it gives just a NoneType

feral frost
#

and how do i use it with the on_submit ?

#

what this is it ?

fading marlin
high sun
#

so you want me to use fetch_channel?

#

cause thats an API call

fading marlin
feral frost
#

aah ok

fading marlin
high sun
#

yeah that gives me AttributeError: 'coroutine' object has no attribute 'fetch_channel'\

slate swan
#

how can i get a role by id using utils?

fading marlin
#

!d discord.Guild.get_role - you don't need to use utils

unkempt canyonBOT
#

get_role(role_id, /)```
Returns a role with the given ID.

Changed in version 2.0: `role_id` parameter is now positional-only.
slate swan
#

thx

fading marlin
#

kinda, you don't have to call your modal a, nor call on_submit

feral frost
#

ah ok

fading marlin
high sun
#

ah i fixed that and that gives me AttributeError: '_MissingSentinel' object has no attribute 'is_set'

fading marlin
#

because you're not connected

high sun
#

i know

#

it just won't work with get and wait_until_ready

eternal delta
#

Whats async before def?

quick gust
#

asynchronous function

fading marlin
# feral frost so like this ?

no, you don't override Modal's on_submit, you override the instance's on_submit. You shouldn't call on_submit either

fading marlin
eternal delta
#

I never understood that...

quick gust
#

u can google a video to learn async python

fading marlin
eternal delta
#

Can u give me an example, maybe?

fading marlin
# feral frost huh ?

you previously had an instance of Modal called a, a's on_submit should've been overridden, not Modal (fwiw it's a lot simpler if you just subclass)

feral frost
high sun
#

but with wait_until_ready it doesnt even print Bot is online!

fading marlin
# eternal delta Can u give me an example, maybe?
async def foo(): print("'a'")
def bar(): print("'b'")

>>> foo()  # coroutine, is also an awaitable
<coroutine object foo at 0x0>
>>> x = foo()
>>> await x
'a'
>>> await foo()
'a'
>>> bar()
'b'
>>> x = bar  # basically the same as doing 'foo()'
>>> x()  # basically the same as doing 'await x' where x is an awaitable/coroutine
'b'

this is pretty much the basics of asyncio, I'd suggest reading up on it

fading marlin
feral frost
fading marlin
#

the both times that you're doing it

feral frost
#

the a.on

fading marlin
fading marlin
feral frost
feral frost
fading marlin
#

send your entire code please

feral frost
fading marlin
#

you're sending the modal before adding a callback

feral frost
#

hm

#

where ?

fading marlin
#

here you sent the modal

await interaction.response.send_modal(create_account)

and 11 lines below you're adding a callback to a completely different modal

feral frost
#

ah i have to put on_submit above it

fading marlin
#

sure

feral frost
quartz valley
#

Hi

fading marlin
high sun
ivory vortex
feral frost
high sun
fading marlin
#

before you use get_channel, call wait_until_ready

high sun
fading marlin
#

Missing Permissions
your bot doesn't have the permissions to do what you want it to do

fading marlin
high sun
fading marlin
fading marlin
feral frost
high sun
#

ok, thanks Lee. Appreciate ur time

fading marlin
#

you're very welcome

ivory vortex
#

Is it possible to make a slash command parameter have a maximum character length

high sun
fading marlin
fading marlin
unkempt canyonBOT
#

class discord.app_commands.Range```
A type annotation that can be applied to a parameter to require a numeric or string type to fit within the range provided.

During type checking time this is equivalent to [`typing.Annotated`](https://docs.python.org/3/library/typing.html#typing.Annotated "(in Python v3.11)") so type checkers understand the intent of the code.

Some example ranges...
feral frost
fading marlin
#

in your callback (on_submit)

feral frost
#

what do i have to put there ?

fading marlin
#

await interaction.response.something

#

!d discord.InteractionResponse

unkempt canyonBOT
#

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

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

New in version 2.0.
feral frost
#

ah ok

#

after the send_modal ?

fading marlin
#

no, inside your on_submit

#

that's your callback

feral frost
#

aah

#

ok ok

#

YESS IT WORKS thanku very much lee

fading marlin
#

you're very welcome

feral frost
#

๐Ÿ™‚

slate swan
#

hey guys, can someone please give me a good website that will teach me how to do ui multiple choice using only discord.py?

alpine cove
#

Just watch one of those bad yt tutorials lol

#

Or read the docs like a masterdev

slate swan
#

cant find one tho

alpine cove
#

Why dont you start out by looking at the github examples

#

try to understand them

#

then modify them

#

at least that worked for me

slate swan
#

i tried to, but i only saw people that use pycord

alpine cove
#

you want to

fading marlin
unkempt canyonBOT
#

class discord.ui.Modal(*, title=..., timeout=None, custom_id=...)```
Represents a UI modal.

This object must be inherited to create a modal popup window within discord.

New in version 2.0.

Examples...
alpine cove
#

but pycord sucks anyways

fading marlin
#

๐Ÿ˜Ž hehe

slate swan
#

thx

versed root
#

"no module named discord" how do i solve this

#

?

fading marlin
#

install dpy

eternal delta
#

Hey! i have a question, whats an intent?

eternal delta
#

on cmd

indigo valley
#

hi i need help

unkempt canyonBOT
#

Hey @indigo valley!

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

fading marlin
eternal delta
#

Like, i need to know how to use it or its smth normal

fading marlin
#

generally speaking no, it's just something that gets sent whenever your bot connects to the gateway

eternal delta
#

Okay!

#

Thanks!

fading marlin
# indigo valley hi i need help
import nextcord as discord
from nextcord.ext import commands
from nextcord.ext.commands import has_permissions, MissingPermissions, has_role
from nextcord import Interaction
from discord.utils import get
import asyncio
import Protocol  # <- this is causing issues
import datetime
from datetime import datetime
import json

don't use bot and client either, stick to one

eternal delta
#

What should be next for me?

#

the tutorial i was following was outdated

alpine cove
#

use commands.Bot

eternal delta
#

I think i should create smth like a class before...

#

Idk what to do lol

high sun
#

how can i add emojis in the create_text_channel function?

#

either unicode, shortname and copy-pasting the emojis dont work

eternal delta
fading marlin
#

unicode should've worked

high sun
#

i'll try again

high sun
dense merlin
eternal delta
#

ยฟ?

#

should i add uppercase?

fading marlin
#

ban_members

eternal delta
#

uhh...

fading marlin
#

discord.Member (type hint)

unreal iron
#

hello, I wanted to send DM to someone with my bot. but I got error: @client.command()
AttributeError: 'Client' object has no attribute 'command'

fading marlin
#

you need to use commands.Bot

#

Client doesn't have a command framework

dense merlin
cloud dawn
#

You are syncing them globally so it take up to an hour to see them. Also use either Client or Bot, not both.

dense merlin
#

ohhhhhh

fading marlin
#

you're not decorating your callback

fading marlin
dense merlin
#

where do I decorate my callback

#

oh right client.event nvm

fading marlin
#

no, you don't have any events

@tree.command(...)
dense merlin
fading marlin
#

I showed you how....

#

you're missing an @

dense merlin
#

OMG IM AN IDIOT

#

tysm

unreal iron
cloud dawn
#

Also global, json, hard coded author id and duplicate code on elif. ducky_dave

fading marlin
#

asking for bot token each time to start ahhhhhhh

dense merlin
#

await tree.sync(1043711872723070976)
TypeError: sync() takes 1 positional argument but 2 were given

fading marlin
#

!d discord.app_commands.CommandTree.sync

unkempt canyonBOT
#

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

Syncs the application commands to Discord.

This also runs the translator to get the translated strings necessary for feeding back into Discord.

This must be called for the application commands to show up.
fading marlin
#

it only takes kw arguments

cloud dawn
dense merlin
dense merlin
#

'int' object has no attribute 'id'

cloud dawn
dense merlin
fading marlin
#

full traceback please

cloud dawn
#

You are giving like 5% of the the traceback

dense merlin
#

Traceback (most recent call last):
File "/home/runner/uNomics/venv/lib/python3.8/site-packages/discord/client.py", line 409, in _run_event
await coro(*args, **kwargs)
File "main.py", line 96, in on_ready
await tree.sync(guild=1043711872723070976)
File "/home/runner/uNomics/venv/lib/python3.8/site-packages/discord/app_commands/tree.py", line 1059, in sync
commands = self._get_all_commands(guild=guild)
File "/home/runner/uNomics/venv/lib/python3.8/site-packages/discord/app_commands/tree.py", line 740, in _get_all_commands
commands = self._guild_commands[guild.id]
AttributeError: 'int' object has no attribute 'id'

slate swan
#

lol

fading marlin
#

you're forgetting to surround the ID in a discord.Object

dense merlin
#

oh yeah

#

Traceback (most recent call last):
File "/home/runner/uNomics/venv/lib/python3.8/site-packages/discord/app_commands/commands.py", line 862, in _do_call
return await self._callback(interaction, **params) # type: ignore
File "main.py", line 51, in balance
await open_account(str(author))
File "main.py", line 68, in open_account
users[author]['Wallet'] = 0
KeyError: '928109349140824125'

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

Traceback (most recent call last):
File "/home/runner/uNomics/venv/lib/python3.8/site-packages/discord/app_commands/tree.py", line 1242, in _call
await command._invoke_with_namespace(interaction, namespace)
File "/home/runner/uNomics/venv/lib/python3.8/site-packages/discord/app_commands/commands.py", line 887, in _invoke_with_namespace
return await self._do_call(interaction, transformed_values)
File "/home/runner/uNomics/venv/lib/python3.8/site-packages/discord/app_commands/commands.py", line 880, in _do_call
raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'bal' raised an exception: KeyError: '928109349140824125'

cloud dawn
#

As much as we love to help solving issues, I know this code is from an old youtube video please don't use it.

dense merlin
#

oh...

#

it was the only economy bot vide w/ json and python i could find

#

and it had good review

cloud dawn
#

It has a lot of issues and using a database is more ethical.

slate swan
#

try learning the basics of python before jumping into making a discord bot

dense merlin
dense merlin
#

so can help?

slate swan
#

ExtensionFailed: Extension 'cogs.admin' raised an error: ModuleNotFoundError: No module named 'discord_slash'

class Commands(commands.Cog):

    def __init__(self, bot):
        self.bot = bot
        self.admin_id = [985170190121730120, 826854630751076414]

    @bot.slash_command(name="test")
    async def _test(self):
        embed = Embed(title="Embed Test")
        await ctx.send(embed=embed)

async def setup(bot):
    await bot.add_cog(Commands(bot))
slate swan
#

How to make slash command in disocrd.py in cogs pls help

cloud dawn
#

You make groups not cogs

#

Atleast that's how I do it.

rare echo
slate swan
rare echo
#

whats the full error

slate swan
#

i dont know how to write slash, this is error

eternal delta
fading marlin
#

the class should subclass commands.Cog

eternal delta
#

ye so?

cloud dawn
#

Well you aren't

eternal delta
#

thats the thing idk how to do

#

i still need some py classes i think ;(

fading marlin
#
class A: ...
class B(A): ...

B subclasses A

cloud dawn
#

class Ping(Cog)

eternal delta
#

oh

#

So it would be smth like:
class commands.cog:
class ping(commands.cog):

#

??

fading marlin
#

no...

#

commands.Cog is already defined

rare echo
#

he was just giving example

eternal delta
#

ye so

rare echo
#

so just second one but .Cog

fading marlin
#

you just have to subclass it

eternal delta
#

HOW

rare echo
#

but do .Cog not .cog

cloud dawn
eternal delta
#

Now?

fading marlin
#

correct

eternal delta
#

love u brothers

fading marlin
#

your setup isn't right though

cloud dawn
rare echo
#

remove commands.cog from the add_cog

eternal delta
#

oh ye

#

forgot about it

#

Its normal that debugging takes more than 10 seconds?

fading marlin
#

are you using a debugger other than print()?

cloud dawn
#

Debugging takes me hours ๐Ÿ˜ข

eternal delta
#

What do you refer?

#

this my code:

cloud dawn
#

You are using asyncio.run and calling an async function but you don't run it in a context manager so this isn't utilized very good.

fading marlin
# cloud dawn Debugging takes me hours ๐Ÿ˜ข

lmao the other day I was messing around with pagination, strings of 2k characters, and an echo command and for the life of me I couldn't figure out why I was getting a repeated value when in fact it what just the output + input ๐Ÿ˜ญ
I spent at least 2 days scratching my head

pliant gulch
#

!e ```py
def foo(x, y: list[int] = []) -> None:
y.append(x)
print(y)

foo(1)
foo(10)
foo(12)

unkempt canyonBOT
#

@pliant gulch :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | [1]
002 | [1, 10]
003 | [1, 10, 12]
pliant gulch
#

Yea stuck on that one forever

#

Until toxickidz told me about it

#

Very early on during my concurrency journey race conditions was also another one

#

But I figured out those easily after a few tries

fading marlin
pliant gulch
#

Which linter?

fading marlin
#

the worst of them all: whatever PyCharm uses

pliant gulch
#

I cannot LSP install that to nvim I think

#

๐Ÿ˜” , I got nvim on pyright and pyright alone

#

Typehinting is king

fading marlin
#

strict type hinting ducky_sphere

slate swan
#
ftp = FTP()
ftp.connect(HOST, PORT)
ftp.login()
ftp.cwd('user/home/')

with open(save_file, 'wb') as f:
  ftp.retrbinary('RETR ' + save_file, f.write)
ftp.quit()

I want to change the location of where the file is downloaded. Does any1 know how I can change the path. I was told to just open the py file where I want it to be saved but this will be a command and I want to change the download location path with each download depending on who its for

sick birch
eternal delta
#

@fading marlin, sorry for ping, u there?

fading marlin
#

hey

eternal delta
#

I need some help :(

fading marlin
#

shoot away

eternal delta
#

Look, i got a main.py and another file with a cog but its not ok...

#

There's no error, just not working.

fading marlin
#

you should use bot.load_extension and a setup function instead of importing it

slate swan
#

pretty sure you HAVE to use setup function inside of the cog lol otherwise it will not work

fading marlin
#

not really

#

you need the setup for load_extension to work

eternal delta
#

and this on the cog one.
async def setup(bot):
await bot.add_cog(Ping(bot=bot))

fading marlin
#

you should pass the name of the module to load_extension

eternal delta
#

The file name?

#

Or the Class name?

fading marlin
#

the filename (without the file extension)

eternal delta
#

thats the name

slate swan
#

its not async

#

sync

fading marlin
#

setup is async...

slate swan
#

no its not.

eternal delta
#

setup is always async because of the await thing

#

no async no functioning await

fading marlin
eternal delta
#

So what's the error on my code

fading marlin
#

there are no errors

#

you've got a warning telling you that you don't have message content intents enabled

eternal delta
#

in the devs panel?

fading marlin
#

idk, at least in the code you don't

eternal delta
fading marlin
#

yup

#

default doesn't include message content

eternal delta
#

Thanks!

fading marlin
#

you're welcome

eternal delta
# fading marlin you're welcome

Ok, i got at least no warning but now this is showing up: discord.ext.commands.errors.CommandNotFound: Command "ping" is not found

fading marlin
#

can you show your updated code?

eternal delta
#

ofcourse

rare echo
#

bot=bot? not saying thats it but ive never seen someone do that

eternal delta
#

i actually dont know what that does

rare echo
#

you also have

eternal delta
#

i understand the class needs the bot thing to work

rare echo
eternal delta
#

Thats previous

#

look at the ps new session

rare echo
#

gotcha

fading marlin
#

why are you importing the ping on your main file? also rename your cog, you might be having some scoping issues

fading marlin
fading marlin
#

what is supposedly necessary?

rare echo
#

just "bot" is necessary, you are just defining bot as "bot"

eternal delta
#

well actually the import isnt necessary

#

just knew it

eternal delta
rare echo
#

i mean kinda right, but you use it and define it in your init

eternal delta
#

Btw, still having the same problem: discord.ext.commands.errors.CommandNotFound: Command "ping" is not found

fading marlin
#

send new code!

eternal delta
fading marlin
#

rename you cog class (probably use proper class naming convention), see if that fixes it

eternal delta
#

Okay...

#

Same error, code:

fading marlin
#

oh

#

I'm actually blind

#

setup_hook isn't decorated as an event, nor should you pass self as its parameters. You're not subclassing

eternal delta
#

AAAA

#

im gonna kill my self

sick birch
shrewd fjord
slate swan
#
import discord
from discord.ext import commands

class Moderation(commands.Cog):
    def __init__(self, client):
        self.client = client

    @commands.Cog.listener()
    async def on__ready(self):
        print("Moderation.py is online")

    @commands.command()
    @commands.has_permissions(manage_messages=True)
    async def clear(self, ctx, count: int):
        await ctx.channel.purge(limit=count)
        await ctx.send(f"{count} messages have been deleted")

    @commands.command()
    @commands.has_permissions(kick_members=True)
    async def kick(self, ctx, member: discord.Member, reason=None):
        if reason is None:
            reason = "No reason provided"
        await ctx.guild.kick(member)

        conf_embed = discord.Embed(title="Success", color=discord.Color.Random())
        conf_embed.add_field(name="Kicked", value=f"{member.mention} has been kicked by {ctx.author.mention}", inline=False)
        conf_embed.add_field(name="Reason", value=reason, inline=False)

        await ctx.send(embed=conf_embed)

    @commands.command()
    @commands.has_permissions(ban_members=True)
    async def ban(self, ctx, member: discord.Member, reason=None):
        if reason is None:
            reason = "No reason provided"
        await ctx.guild.ban(member)

        conf_embed = discord.Embed(title="Success", color=discord.Color.Random())
        conf_embed.add_field(name="Banned", value=f"{member.mention} has been banned by {ctx.author.mention}", inline=False)
        conf_embed.add_field(name="Reason", value=reason, inline=False)

        await ctx.send(embed=conf_embed)

    @commands.command(name="Unban")
    @commands.guild_only()
    @commands.has_permissions(ban_members=True)
    async def unban(self, ctx, userId):
        try:
            user_id = int(userId)
        except ValueError:
            return await ctx.guild.unban(user_id)
 
async def setup(client):
    await client.add_cog(Moderation(client))
#

for some reason my code doesn't give embeds after ban or kick

fading marlin
#

any errors?

slate swan
fading marlin
#

well you've got an error handler that's eating them or you haven't enabled debug

#

!d discord.Colour.random - random is lower cased, not upper

unkempt canyonBOT
#

classmethod random(*, seed=None)```
A factory method that returns a [`Colour`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Colour "discord.Colour") with a random hue.

Note

The random algorithm works by choosing a colour with a random hue but with maxed out saturation and value.

New in version 1.6.
severe mural
#

Problem "outdating is this wrong command? but that update that new command. but that's not kick , etc (but removed)

#

already remove codes , kick , etc only have 3 commands

#

problem no solution?

polar dawn
#

How do I make a specific hybrid commands that are only available for specific servers?
I used to do this with bot.command():

@bot.command()
async def test(ctx):
  allowed_guild = [123, 321]
  if ctx.guild.id in allowed_guild:
      async with ctx.typing():
        await ctx.reply("Pass")
  else:
      return

but how do i do it with hybrid commands? maybe if the guild id is not in the list it would just not respond or just not appear in the slash command list for the guild. or is this not even possible

shrewd fjord
#

edit_message()

#

!d discord.Interaction.edit_original_response

unkempt canyonBOT
#

await edit_original_response(*, content=..., embeds=..., embed=..., attachments=..., view=..., allowed_mentions=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the original interaction response message.

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

This method is also the only way to edit the original message if the message sent was ephemeral.
shrewd fjord
#

hmmmmmmm

#

what's the output

drifting arrow
#

with these, do they have to be in a specific order or does it not matter?

@app_commands.checks.has_permissions(administrator=True)
@app_commands.guild_only()

Or can I only use 1?

shrewd fjord
drifting arrow
#

I know. I was just making sure that I could use both.

#

and there wasn't an order it needed to be in

shrewd fjord
#

np

drifting arrow
#

and just a quick reminder, to @ someone using an id its: <@id>?

rare echo
#

yes

drifting arrow
#

Ty ty

shrewd fjord
#

and for channels <#channel_id>

#

xd

drifting arrow
#

awesome

#

Saves me from having to fetch the individual users

shrewd fjord
#

and for slash command </:name:id>

drifting arrow
#

wot

#

how does that work?

shrewd fjord
#

y can mention slash commands

drifting arrow
#

does it run the command or just post it in chat?

shrewd fjord
drifting arrow
#

๐Ÿ˜ฑ

#

starts updating code

rare echo
#

lmao

drifting arrow
#

Atm I got a bunch of "Did you mean to use /command?"

#

I can replace /command (text form) with a link to the command >:D

drifting arrow
#

How do I get the command ID? ๐Ÿค”

rare echo
#

before you hit send you can right click the actual little popup above the text box

drifting arrow
#

But I need to get it through my code

rare echo
#

yeah then just copy it and paste it

drifting arrow
#

Because I intend on selling this bot I am making lol

rare echo
#

oh i see what you mean, im not sure

drifting arrow
#

oh well

#

it's not that important I guess

shrewd fjord
#

</name:id> btw i made a mistake

#

xd

drifting arrow
#

My favorite part about making a new bot is when you finally make it, 1500 lines later, "Can you add this?"

#

like mother fucker -.-

drifting arrow
#

Alright it's probably shouldnt be 1500 lines..

#

But that's what refactoring is for ๐Ÿ˜‰

severe mural
#

explain, this is my command and update code and but it does not seem missing commands 3

#

This problem cannot be solved. Discord bot is useless. Do you know how to solve it?

#

times expel and invite and no command appears are 3

upbeat otter
severe mural
#

that already add ready script "hello" this does not appear /hello.

severe mural
#

@upbeat otter hello?

#

are you busy lol?

#

there and nothing /bothost see not appearing

upbeat otter
#

!d discord.Client.setup_hook

unkempt canyonBOT
#

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

A coroutine to be called to setup the bot, by default this is blank.

To perform asynchronous setup after the bot is logged in but before it has connected to the Websocket, overwrite this coroutine.

This is only called once, in [`login()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.login "discord.Client.login"), and will be called before any events are dispatched, making it a better solution than doing such setup in the [`on_ready()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_ready "discord.on_ready") event.

Warning

Since this is called *before* the websocket connection is made therefore anything that waits for the websocket will deadlock, this includes things like [`wait_for()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.wait_for "discord.Client.wait_for") and [`wait_until_ready()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.wait_until_ready "discord.Client.wait_until_ready")...
severe mural
#

@upbeat otter ohh

upbeat otter
#

?

severe mural
#

@upbeat otter how is explain example

#

Ah

#

Think there is on_ready change setup_hook

#

Correct?

upbeat otter
#

right

#

you could do that

severe mural
#

Ok, check

upbeat otter
#

or you can manually do that

async def setup_hook() -> None:
  await client.tree.sync()
  print(f"Synced Slash Commands")

client.setup_hook = setup_hook
severe mural
#

Ok

#

@upbeat otter ahh

#

I see thanks you help

upbeat otter
#

welcome

severe mural
#

On ready is bad?

#

Is old think?

#

Differents on ready and setuphook?

upbeat otter
#

no it's not good for performing other tasks except printing stuff

severe mural
#

Hmm i see okay thx

upbeat otter
# severe mural Differents on ready and setuphook?

setup_hook is triggered before any event in your bot is triggered, on_ready is triggered when your bot is fully loaded along with the cache and this may be triggered multiple times when you start your bot or at random times when your bot is running so it's not good to perform other tasks

severe mural
#

Ah i see

#

Ok thx

upbeat otter
#

kill

#

me

#

pls

shrewd fjord
#

shoots the bullet

#

@upbeat otter u alive dawg

upbeat otter
#

no

shrewd fjord
upbeat otter
#

How am I supposed to know, am ded

shrewd fjord
#

...

#

makes sense

#

read error ๐Ÿ’€

#

what library u r using

naive briar
alpine cove
#

^

shrewd fjord
#

from discord import app_commands [for dpy]

naive briar
#

Good lord

shrewd fjord
alpine cove
shrewd fjord
#

well my brain is dying rn

shrewd fjord
#

YESSSSSSS]

upbeat otter
shrewd fjord
slate swan
#

always remember to unimport stuff after using them

upbeat otter
#

^

shrewd fjord
#

^^

upbeat otter
#
import sys
sys.modules.pop("sys")

uwu

shrewd fjord
#

:3

slate swan
#

SkillIssueException: no ๐Ÿ”‘ named "sys"

upbeat otter
#

๐Ÿ”‘

#

nah you can't write key

shrewd fjord
slate swan
#

i can ๐Ÿ˜ˆ

upbeat otter
#

๐Ÿ—๏ธ

#

tf...

shrewd fjord
#

i can barely see the tail of the key xd

upbeat otter
#

,

shrewd fjord
#

ayo i saw that

upbeat otter
#

it was meant to be seen

shrewd fjord
#

then why did u hide

#

hmm

upbeat otter
shrewd fjord
#

:3

slate swan
#

hi im.back

#

bye am going again wtf is this chat

upbeat otter
#

๐Ÿ’€

#

,

shrewd fjord
#

LMAO

#

ok

upbeat otter
#

yes

shrewd fjord
#

i didnt saw anything np ๐Ÿ’€

upbeat otter
#

see*

shrewd fjord
upbeat otter
shrewd fjord
#

gave up

upbeat otter
#

๐Ÿซ‚

slate swan
#

.topic

lament depotBOT
#
**What commands/features are you proud of making?**

Suggest more topics here!

slate swan
#

none

#

if monkeypatching discord.py for low levelled component counts, that

wintry raft
#

const Discord = require('discord.js')
const client = new Discord.Client()
const db = require('quick.db')
const covid = require('novelcovid')
var prefix = "co!"

client.on('ready', () => console.log("thicc NUB is online like a proffesional NUB"))

client.on('message', async message => {
if (message.content.startsWith(${prefix}covid)) {
const covidStats = await covid.all()

 return message.channel.send(new Discord.MessageEmbed()
  .setTitle('covid19 stats')
  .setColor("BLUE")
  .addFields(
    { name: `Cases`, value: covidStats.cases.toLocaleString(), inline: true},
    { name: `Cases Today`, value: covidStats.todayCases.toLocaleString(), inline: true},
    { name: `Deaths`, value: covidStats.deaths.toLocaleString(), inline: true},
    { name: `Deaths today`, value:covidStats.deaths.toLocaleString(), inline: true},
    { name: `Recovered`, value: covidStats.recovered.toLocaleString(), inline: true},
    { name: `Recovered today`, value: covidStats.todayRecovered.toLocaleString(), inline: true},
    { name: `Infected right now`, value: covidStats.active.toLocaleString(), inline: true},
    { name: `Critical condition`, value: covidStats.critical.toLocaleString(), inline: true},
    { name: `Tested`,  value: covidStats.tests.toLocaleString(), inline: true },
  ) 
)

}
})

light violet
#

@client.event
async def on_member_update(before, after):
  print(before.activities[0].name)```
#

why it is not loggin anything

slate swan
#

you're missing presence intents most probably

light violet
#

nah

slate swan
light violet
slate swan
#

*more

#

!intents in your code, not the portal

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.

There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.

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

from discord import Intents
from discord.ext import commands

# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True

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

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

light violet
#

this is only the code

slate swan
#

enable intents.presences

light violet
#

intents=discord.Intents.all()

client = commands.Bot(command_prefix =[">", "."],intents=intents)

slate swan
#

do you have multiple on_member_update s?

light violet
#

nah

#

only 1

slate swan
#

is it placed after bot.run()?

light violet
#

is it rate limited

#

no

slate swan
#

you'll get an error msg if its ratelimited

light violet
#

no error msg

slate swan
#

!paste show full code

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

light violet
#

ok np