#discord-bots

1 messages · Page 843 of 1

slate swan
#

Thx👍

boreal ravine
#

Can you please go learn python before making a discord bot? And the error clearly says what you need to do..

'await' outside function

slate swan
#

Yes

#

await xyz

#

discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embed: Embed size exceeds maximum size of 6000 any help?

honest vessel
#

@slate swan too much text in ur embed

slate swan
#

len(data) > 5000:
send as txc

#

but it doesnt work ig

#

@honest vessel

drowsy thunder
#

Yay finally its working

slate swan
#

Maximum size is only 6000

slate swan
drowsy thunder
#

Also is it possible to connect a python bot to a web dashboard?

honest vessel
#

str("test").title()

slate swan
#

i just said i alr know that

#

Liar

#

🤬

#

@novel apex

boreal ravine
slate swan
tulip frigate
#

How can it happen that an event and its code parts only happen to work in some servers. I have an if statement which prevents stuff to happen, but that just doesn't work in some servers..?

fresh smelt
#

I have this weird unexpected indent , that I can't seem to fix can anyone help? | if yes dm.

slate swan
#

how can i use on_member_join to change somebody’s nickname instantly

#

You get the member object in the event, use member.edit

#

!d discord.Member.edit

unkempt canyonBOT
#

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

Edits the member’s data.

Depending on the parameter passed, this requires different permissions listed below...
maiden fable
#

Iirc it edits in-place

fiery imp
#

Hi, I saw this video where we can send messages using python requests in discord
how to interact with interaction (bot buttons) ???

#

using requests and python

maiden fable
slate swan
#

Correct me if I'm wrong

fiery imp
#

hmm idk . . . ;-;

maiden fable
#

Uhhh, actually u can use raw requests, but too much work

tacit token
#
    @commands.command(alieases=["Repli","Replpy"])
    async def reply(self,ctx):
        pipa=client.get_emoji(944579032828227646)
        embed=discord.Embed(color = ( discord.Color.random()), title="", description="**i replied**")
        await ctx.reply(embed=embed)
        await ctx.message.add_reaction(pipa)

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: InvalidArgument: emoji argument must be str, Emoji, or Reaction not NoneType.

maiden fable
#

So yea, u r correct

slate swan
maiden fable
#

Nope, u need to connect to the gateway

buoyant quail
#

!e
language = "hello world xd"
words = language.split(" ")
for word in words: word.capitalize()
print(" ".join(words))

unkempt canyonBOT
#

@buoyant quail :white_check_mark: Your eval job has completed with return code 0.

hello world xd
buoyant quail
#

it changes nothing @maiden fable

tacit token
slate swan
unkempt canyonBOT
#

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

This Changes Into Title
buoyant quail
slate swan
slate swan
#

👌

fiery imp
#

this ?

maiden fable
slate swan
#

@bot.command()
async def start(ctx):
  overwrites = {
   ctx.guild.default_role: discord.PermissionOverwrite(view_channel=False),
   ctx.author: discord.PermissionOverwrite(view_channel=True, send_messages=True )
}
  category = ctx.guild.get_channel(944748748117012560)
  await category.create_text_channel(f'{ctx.message.author.name}', overwrites=overwrites)
  await ctx.reply("channel is created")```
Command doesn’t seem to work
slate swan
fiery imp
slate swan
fresh smelt
#

I'm having this weird unexpected indent I can't seem to fix can anyone help me | if yes dm me.

drowsy thunder
#

Anyone has a keep_alive.py code?

spring flax
#

Anyone uses oracle host?

maiden fable
#

You got the VPS?

drowsy thunder
spring flax
maiden fable
#

Oh cool!

spring flax
#

but

fresh smelt
#

dm me

spring flax
#

would it be considered a good free host?

spring flax
#

like, on levels of paid ones

drowsy thunder
#

help me bruhhhh

fresh smelt
#

ignore "sexmaker" LOL

drowsy thunder
#

Any keep_alive.py codes?

fresh smelt
visual yarrow
#

@fresh smelt I suggest not disparaging people with disabilities in your rules ¯_(ツ)_/¯ Doesn't set a great tone tbh.

fresh smelt
drowsy thunder
#

@visual yarrow can you help

visual yarrow
spring flax
#

hello LX

drowsy thunder
fresh smelt
#

I did.

slate swan
visual yarrow
slate swan
fresh smelt
drowsy thunder
slate swan
fresh smelt
#

how do i make an embed without fields.

drowsy thunder
#

@visual yarrow

maiden fable
spring flax
drowsy thunder
#

@visual yarrow @visual yarrow

maiden fable
#

Haha indeed it is

spring flax
#

and what's the uptime of your bot?

drowsy thunder
spring flax
#

that was to Hunter

fresh smelt
novel bolt
#
from flask import Flask
from threading import Thread

app = Flask('')

@app.route('/')
def main():
  return "Your bot is alive!"

def run():
    app.run(host="0.0.0.0", port=8080)

def keep_alive():
    server = Thread(target=run)
    server.start()
drowsy thunder
#

Ok thx

novel bolt
#

for keep_alive

spring flax
drowsy thunder
#

So it needs any code modifications?

maiden fable
novel bolt
fresh smelt
drowsy thunder
novel bolt
#

🙂

buoyant quail
spring flax
#
embed = disnake.Embed(description='something')

This is the least you can do with an embed

visual yarrow
#

Sorry @drowsy thunder, can you not spam-ping me please.

drowsy thunder
spring flax
#

just a description

novel bolt
fresh smelt
#

like that

buoyant quail
#

description =

fresh smelt
#

I don't add "await ctx.send" ??

buoyant quail
#

if you want send - add, if you don't want - don't add

slate swan
#

How do I make a command only work for certain user ids

maiden fable
#

!d discord.ext.commands.check

unkempt canyonBOT
#

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

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

If an exception should be thrown in the predicate then it should be a subclass of [`CommandError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError"). Any exception not subclassed from it will be propagated while those subclassed will be sent to [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error").
slate swan
maiden fable
#

Sure

slate swan
#

Ok

#

@maiden fable ```py

@bot.command()
@commands.has_role('RoleName')
async def command_name():```?

maiden fable
#

Sure

slate swan
maiden fable
#

There ain't anything like that

potent spear
#

custom checks be like

slate swan
#

LOL

potent spear
slate swan
#

User id

#

Then plan is to :
Have user ids in txt
Command will only work for txt ids

potent spear
#

a txt isn't a db, I don't encourage bad implementations

slate swan
slim ibex
#

then learn it lmaop

potent spear
slate swan
#

How can i slipt args
example
async def help(ctx, arg1, arg2, arg3):
!help arg1 arg2 arg3
To
async def help(ctx, arg1, arg2, arg3):
!help arg1:arg2 arg3

buoyant quail
potent spear
#
      #burp

!shit now please I have to go```
this will result in 
`arg = "now"`
`other_args = "please I have to go"`
slate swan
dusky cloak
#

how can I make a function in bot that creates an invite with the specified guild id (example usage: .get_invite {guild id})

potent spear
dusky cloak
#

I tried making but it throws error
async def get_invite(ctx,gid):
guild = bot.get_guild(gid)
invite = await guild.channels[0].create_invite()
await ctx.send(f"{invite}")

Command raised an exception: NotFound: 404 Not Found (error code: 10003): Unknown Channel

potent spear
#

make it an int

#

gid: int

#

also, get_invite creates an invite for another guild than the current one, I hope?

dusky cloak
#

still the same

#

Command raised an exception: NotFound: 404 Not Found (error code: 10003): Unknown Channel

potent spear
#

first you get guild, via converted gid to int
then you check if guild is not None, THEN you execute the rest of the code

dusky cloak
#

can you help me writing that

slim ibex
unkempt canyonBOT
desert badger
#
@client.command()
async def google(ctx, *, search : str = None):
    if not search:
        await ctx.send("https://google.com")
        return
    await ctx.send(f"https://www.google.com/search?q={'+'.join(search)}")

input

.google i am mentally stupid```
output
```https://www.google.com/search?q=i+ +a+m+ +m+e+n+t+a+l+l+y+ +s+t+u+p+i+d```

hlep
slate swan
#

use replace instead

#

search.replace(" ", "+")

desert badger
slate swan
#

Wrong quotes

#

You would not use the double quotes inside a f-string with double quotes

desert badger
boreal ravine
slate swan
#

you know what a quote means right?

boreal ravine
#

solution: use single quotes

desert badger
#

it works

desert badger
boreal ravine
#

lol

desert badger
#

lol

#

is there any way to make a discord bot show the results of the google search? like the top 5 results or something

#

lol

drowsy condor
#
@bot.event
async def on_message(message):
    if {i.lower().translate(str.maketrans('','', string.punctuation)) for i in message.content.split(' ')}\
    .intersection(set(json.load(open('cenz.json')))) != set():
        await message.channel.send(f'{message.author.mention} по губам отшлепать??')
        await message.delete() ```
potent spear
#

your json file might be empty, double check

drowsy condor
desert badger
potent spear
potent spear
slate swan
#

Is there a way to create an embed which updates itself and tells if a bot is online?

#

something like a bot status command

desert badger
potent spear
slim ibex
#

!pip aiohttp

unkempt canyonBOT
slate swan
potent spear
# unkempt canyon

^^ this is one of the async versions of requests, which you can use

slim ibex
#

!pip httpx

unkempt canyonBOT
slate swan
#

i didn't understand

drowsy condor
#
 .intersection(set(json.load(open('cenz.json')))) != set():
File "/app/.heroku/python/lib/python3.9/json/__init__.py", line 293, in load
return loads(fp.read(),
File "/app/.heroku/python/lib/python3.9/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/app/.heroku/python/lib/python3.9/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/app/.heroku/python/lib/python3.9/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 2 column 1 (char 1)  ```
#

This json

slate swan
#

?

drowsy condor
#

Sorry

#
import json

ar = []

with open('cenz.txt', encoding='utf-8') as r:
  for i in r:
    n = i.lower().split('\n')[0]
    if n != '':
      ar.append(n)
      
with open('cenz.json', 'w', encoding='utf-8') as e:
    json.dump(ar, e) ```
#

This json

drowsy condor
#

Yes

desert badger
weary sierra
#

How to fix?

#

This my code

naive spoke
#

when sombody clicks the reaction on the bots message how does it reconize who did it

honest vessel
#

@weary sierra its a list

weary sierra
#

well how do i make it not a list

#

i dont use python much

unkempt canyonBOT
#
Not in a million years.

No documentation found for the requested symbol.

maiden fable
#

Ah wait my bad

#

!d discord.Reaction.users

unkempt canyonBOT
#

async for ... in users(*, limit=None, after=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") representing the users that have reacted to the message.

The `after` parameter must represent a member and meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.

Examples

Usage

```py
# I do not actually recommend doing this.
async for user in reaction.users():
    await channel.send(f'{user} has reacted with {reaction.emoji}!')
```...
naive spoke
#

ok

vale wing
#

Blindly copying code is not a good practice

naive spoke
weary sierra
#

its just one error 💀

vale wing
#

The root of this error is in your python knowledge lack

#

This would be pretty easy to fix if you knew what a list is and what a dict is

weary sierra
#

can u just telll me ;/

vale wing
#

You would need to change a lot of things that I am not going to explain to you

#

However I can recommend resources

hoary cargo
#

!resources

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.

hoary cargo
tidal hawk
#

Can you inittiale a Task loop from a command?

#

self.task.start()

hushed galleon
#

sure, just check is_running() beforehand so the command doesnt try starting it twice

boreal ravine
naive spoke
maiden fable
#

message.reactions

naive spoke
#

!message.reactions

slate swan
#

@bot.command()
async def start(ctx):
  overwrites = {
   ctx.guild.default_role: discord.PermissionOverwrite(view_channel=False),
   ctx.author: discord.PermissionOverwrite(view_channel=True, send_messages=True )
}
  category = ctx.guild.get_channel(944748748117012560)
  await category.create_text_channel(f'{ctx.message.author.name}', overwrites=overwrites)
  await ctx.reply("channel created")```

How do I limit 1 channel
hushed galleon
#

probably the most preferred method would be to store the newly created channel's id in a database then add a command check to make sure it doesnt exist

slate swan
potent spear
#

Db isn’t really needed since you can just check the username, BUT the username can change so a db is indeed the best method

hushed galleon
#

if you trust that they wont change their name sure

slate swan
potent spear
#

Don’t assume things 😂, there will always be exceptions

slate swan
#

True

#

But no one is gonna change name for just an extra channel

hushed galleon
#

someone will

potent spear
#

No, it can be unintentionally…

hushed galleon
#

but if you're fine with it then you can skip the database part and just have the custom check

slate swan
slate swan
#

Is there docs related to that?

slate swan
#

hey, please i'm working on a discord.py project, and i was wondering how to make a command usable on the bot dms, like for example i have a simple ?ping command that works perfectly on the server, but i cant use it on his dms

slim ibex
#

!d discord.ext.commands.guild_only

unkempt canyonBOT
#

@discord.ext.commands.guild_only()```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that indicates this command must only be used in a guild context only. Basically, no private messages are allowed when using the command.

This check raises a special exception, [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
hushed galleon
#

commands should trigger in dms by default

slim ibex
slate swan
# slate swan Use ctx.send?

ctx.send allows the bot to send a dm to a user, but i need the opposite, i need to be able to execute a command directly on the bot dms

slate swan
hoary cargo
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.

hoary cargo
slate swan
#

!resources @hoary cargo

hoary cargo
slate swan
#

!resources

#

Wtf

hoary cargo
#

it doesn't work for noobs

hushed galleon
slate swan
#

!resources

slim ibex
slate swan
#

WTF

#

!resources

#

It’s actually trolling

hoary cargo
#

go to #bot-commands not here WeirdChamping

hoary cargo
unkempt canyonBOT
hoary cargo
slate swan
#

for example if i make the ?help command on server it works fine

#

but if i make ?help on his dms it doesnt

#

thats what i need 🙏

slim ibex
#

!d discord.ext.commands.guild_only

unkempt canyonBOT
#

@discord.ext.commands.guild_only()```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that indicates this command must only be used in a guild context only. Basically, no private messages are allowed when using the command.

This check raises a special exception, [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
hushed galleon
#

moai i think you have a misunderstanding

i need to be able to execute a command directly on the bot dms

slim ibex
#

oh so the command is only usable in dms?

hushed galleon
#

they're saying it doesnt work in dms, and they want it to

hoary cargo
slim ibex
#

^

#

!d discord.Member.send

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**.
hushed galleon
#

then its not really a dm command

#

commands should work in dms normally

slim ibex
#

idk never tried it

#

oh yes, it indeed does

hushed galleon
#

i do it all the time

daring olive
#

don't be rude to users

slate swan
#

@hoary cargo for the help command that was just to get you in situation, actually i'll need the user to send infos that arent supposed to be seen by other, like email or whatever

#

thats why it would be better to make command in dms

slate swan
#

I forgot the h tho

hushed galleon
#

vertex you'll need to share your code since there shouldnt normally be a problem using commands in dm

boreal ravine
slim ibex
hoary cargo
slate swan
#

ight ty

daring olive
hoary cargo
#

right

manic wing
#

Am I supposed to make the accept and decline a command?
?

fresh orchid
#

How can I disable a select menu after I used it. I tried like this but it wont work. So how to disable the menu after I used it

class DroppDownMenu(discord.ui.View):


        options.append(discord.SelectOption(label=case_name, description="descrption"))
    @discord.ui.select(placeholder="Choose one option", min_values=1, max_values=1, options=options)
    async def callback(self, select, interaction : discord.Interaction):
       DroppDownMenu.disabled = True
hoary cargo
#

!d disnake.Interaction.edit_original_message

unkempt canyonBOT
#

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

Edits the original, previously sent interaction response message.

This is a lower level interface to [`InteractionMessage.edit()`](https://docs.disnake.dev/en/latest/api.html#disnake.InteractionMessage.edit "disnake.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.

Note

If the original message has embeds with images that were created from local files (using the `file` parameter with [`Embed.set_image()`](https://docs.disnake.dev/en/latest/api.html#disnake.Embed.set_image "disnake.Embed.set_image") or [`Embed.set_thumbnail()`](https://docs.disnake.dev/en/latest/api.html#disnake.Embed.set_thumbnail "disnake.Embed.set_thumbnail")), those images will be removed if the message’s attachments are edited in any way (i.e. by setting `file`/`files`/`attachments`, or adding an embed with local files).
modern egret
#

hello
who can help me with discord.py
i will to command has datetime
with send message in channel in 7:00 am
i searching many internet but not finding

#

if you can send me friend invite

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied mute to @modern egret until <t:1645373753:f> (9 minutes and 59 seconds) (reason: discord_emojis rule: sent 30 emojis in 10s).

outer parcel
#

hi everyone im making a discord bot currency does anyone have any unique features i can add to it

#

it will be really helpful

slate swan
outer parcel
#

Hmm that is not bad idea ill actually work on that

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied mute to @cyan rover until <t:1645374353:f> (9 minutes and 59 seconds) (reason: discord_emojis rule: sent 100 emojis in 10s).

uncut comet
#

has anyone here got a good method for reloading cogs they can share?

slate swan
#

!d discord.ext.commands.Bot.reload_extension

unkempt canyonBOT
#

reload_extension(name, *, package=None)```
Atomically reloads an extension.

This replaces the extension with the same extension, only refreshed. This is equivalent to a [`unload_extension()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.unload_extension "discord.ext.commands.Bot.unload_extension") followed by a [`load_extension()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.load_extension "discord.ext.commands.Bot.load_extension") except done in an atomic way. That is, if an operation fails mid-reload then the bot will roll-back to the prior working state.
subtle dirge
final iron
unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

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

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

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

This function returns the **first event that meets the requirements**...
subtle dirge
#

I don't like this if message.content.startswith('$greet'). I want it to occur after after a command has been initiated.

final iron
#

Okay?

tidal hawk
#

Why has it been giving me the same rate limiter error for 5 times in a row?

#

it's been like 30 minutes

final iron
#

Stop spamming the api

#

¯\_(ツ)_/¯

tidal hawk
#

not spamming

#

or wdym, how could the bot be spamming it self

uncut comet
#

thanks ill try that

final iron
#

How is your bot the discord api

tidal hawk
#

it ain't, stop picking words

#

just asked how to solve it, ok obv answer do not spam

#

but I'm not

final iron
#

You asked how the bot was spamming itself

tidal hawk
final iron
#

That implies the bot is the discord api

tidal hawk
#

If i'm not spamming, who else is

slate swan
final iron
tidal hawk
#

Oh Wow! Thanks man!!

#

Thought it was the bot :))

slate swan
#

finally someone saying thanks after taking help is nice

slate swan
tidal hawk
#

Haha

final iron
#

Could be done with a list comp

#

But it would make readability really bad

slate swan
#
from roblox import Client```
says roblox isnt defined but i have installed ro.py
slate swan
final iron
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

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

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

final iron
#

Use this so it doesn't clog chat

final iron
#

It's not relevant to this channel

subtle dirge
vale wing
#

Oh yeah sorry

#

I thought you were loading commands one by one

hoary cargo
#

cogs are loaded automatically when you start the bot, and yes, there's other way rather than hardcoding them to double load apparently

vale wing
#

You could create double loop

hoary cargo
#

why

vale wing
#
for cmd_folder in os.listdir('cogs'):
    for ext in os.listdir(f'cogs/{cmd_folder}'):
        if ext.endswith('.py'):
            bot.load_extension(f'cogs.{cmd_folder}.{ext[:-3]}')```
hoary cargo
#

mike yeah but they are cogs

#

literally you don't have to create cogs/cog_name/cog_name.py for each

vale wing
#

Or you could use the power of recursion but that's a bit more complicated

#

You know what recursion is right?

hoary cargo
#

it's just unpractical pepeannoyed you use what you want to use but still

vale wing
#

You could do a logic like if the file is extension then load it, if folder then call function on that folder

#

The good thing about it is it would work at any depth if you program it well

#

Unlike double loop

hoary cargo
#

MR_uncanny_1 yes, i am sure, y'all just like to make your stuff way more annoying and complex than it should be

vale wing
#

There are only 2 proper ways to implement the thing you want and I told them both

modern egret
#

embed.add_field(name = f"Стоимость {row[1]} PumCoins", value = f"Вы приобретёте роль {row[0]}", inline=False)
await ctx.send(embed=embed)

#
                await ctx.send(embed=embed)```
vale wing
#

Hello russian comrade nice to meet you

modern egret
#

i too

vale wing
#

Could you describe your issue

desert badger
#
@client.command()
async def find(ctx,*, query = None):
    if not query:
        return
    embed = disnake.Embed(
        title = "Here is your Google Search",
        color = disnake.Color.orange()
    )
    embed.set_thumbnail(url = "https://niclas.wants-to.party/google.png")
    num = 0
    for j in search(query, tld="co.in", num=5, stop=5, pause=5):
        embed.add_field(name = f"Number {num}", value = j)
        num = num+1
    await ctx.send(embed = embed)

what exactly did i do wrong? -

modern egret
#

i need help a datetime
i will to discord bot send message in channel in 7:00 am

#

i searching in google and nothing find

modern egret
vale wing
#

You should use loops

#

!d discord.ext.tasks.loop

unkempt canyonBOT
#

discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True, loop=...)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
vale wing
desert badger
#

ye

vale wing
modern egret
#

but use datetime is nothing?

desert badger
vale wing
#

For

desert badger
#

th other thing smh works

vale wing
#

Try replacing it with tab or four spaces and vice versa

desert badger
#

it somehow worked

#

thank lol

modern egret
#

sorry
can told me what is my error
@commands.command() async def shoprole(self, ctx): await ctx.message.delete() embed = discord.Embed(title ="**Магазин ролей**", color=emcolor) for row in cur.execute(f"SELECT role_id, cost, name FROM shoprole WHERE id={ctx.guild.id}"): if ctx.guild.get_role(row[0]) != None: embed.add_field(name = f"Стоимость {row[1]} PumCoins", value = f"Вы приобретёте роль **{row[2]}**", inline=False) await ctx.send(embed=embed)

#

shop dont shows
but shop work
and i can buy role

hoary cargo
#

That's how i have them, and I have more than you, this doesn't affect me at all when I edit them, it's more handy, I don't need to open 20 folders just for a file.
Are you those kind of people with just 20-30 lines per cog and also puts them on different folders? Lmao, irrational

dull terrace
#

how tf do i format this so it looks nice

pliant gulch
#

Unpack j

native wedge
#

how do i make another argument for a command?

async def profile(self, ctx: commands.Context, *, profile=None):```
pliant gulch
#

!e ```py
something = ["foo", "bar", "baz"]
foo, bar, baz = something

print(foo, bar, baz)

unkempt canyonBOT
#

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

foo bar baz
dull terrace
native wedge
pliant gulch
#

Is it not better than seeing indexes

#

With unpacking I actually know whats going on

#

Otherwise I'd only know j is a sequence, and you're indexing it

elfin walrus
#

Hi

dull terrace
#

speaking of unpacking...

elfin walrus
#

Someone can help me with a discord bot

dull terrace
#

gotta be a better way

elfin walrus
#

Pls

slate swan
dull terrace
#

in the process, got all of the tables set up

elfin walrus
slate swan
slate swan
dull terrace
#

do you guys usually pull out the whole table at once or just one value at a time, gotta be better to grab the whole table rather than searching many times

#

need most of the table in the function and connected ones

elfin walrus
slate swan
slate swan
dull terrace
#

throw it in a dictionary or like i have?

elfin walrus
dull terrace
#

hmm could do a for loop and use the row name to declare local variables

solid summit
slate swan
dull terrace
#

i guess it's more of a how do i grab the whole table neatly

solid summit
#

Is that sqlite3?

dull terrace
native wedge
#

hey im trying to fix an issue.
i am trying to make api request with an argument named profile

https://paste.pythondiscord.com/ucogolekig

error gives this:

disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'int' object is not subscriptable```
iron agate
#

Hi all, is there a Tableau expert in this room?

native wedge
#

expected is this (if it was .profile michigun)

solid summit
#

Michigun :c

solid summit
#

And dont do so many ctx.send make it all a single message

#

There is also no need to use the .json method everytime

native wedge
# solid summit Can u provide a full traceback?
  File "C:\Users\no\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\bot_base.py", line 561, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\no\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\core.py", line 930, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\no\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\core.py", line 185, in wrapped
    raise CommandInvokeError(exc) from exc
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'int' object is not subscriptable```
native wedge
# solid summit And dont do so many ctx.send make it all a single message
 await ctx.send(f"""{username})
        Rank: {rank}
        Stars: {stars}
        Diamonds: {diamonds}
        Coins: {coins}
        User Coins: {user_coins}
        Demons: {demons}
        Creator Points: {creator_points}
        Icon ID: {icon_id}
        Friend Requests Enabled: {friend_requests}
        Messages Enbaled: {messages}
        Comment History Enabled: {comment_history}
        Moderator Status: {moderator}
        Youtube: {youtube}
        Twitter: {twitter}
        Twitch: {twitch}""")
#

fixed it

slate swan
#

how to check if after.activity is None ? (CustomActivity)

#

aka status

unkempt canyonBOT
#
Bad argument

Unable to convert '@hoary cargo check out some other open source projects and you will understand that you need it to be organized. Seems like you have never done such thing, neither released any legit package.' to valid command, tag, or Cog.

#
Command: source

Display information and a GitHub link to the source code of a command, tag, or cog.

Source Code
solid summit
native wedge
hoary cargo
#

MR_canny_meh_stage imagine assuming things about me when you don't even know me, seems like I hurt your pride or something yllaer
And no, my cogs are organised, each cog does have a suggestive name of what type of commands you will find in there, the classes are documented each of them MR_uncanny_10 but you don't have to know this because it's not your business how I organise my stuff

slate swan
#

how to check if the member status is empty

quick gust
#

chill guys

solid summit
#

Smt like response = req.json()

dull terrace
#

is there a way to unpack a tuple in a segmented way like merging head and body into one variable that has both

slate swan
#

whats happening here....

unkempt yacht
#

hey could someone guide me on how to use a mongodb database for a warn command?

hoary cargo
#

Listen here mf, you come here and ask "How I do X" and people telling you how you do X and get mad about it, fucking grow up

slate swan
#

well, thats completely fine, its up to you

hoary cargo
#

I try to be polite and you start assuming shit about me

slate swan
#

can u guys stop beefing in this channel :l there is DMs for a reason and thank yall ^^

quick gust
#

I hate to be the guy but please stop, I'll have to ping the mods

hoary cargo
#

MR_uncanny_10 Don't compare that
Have you ever opened those folders to see how many files are in each? They don't have 1 file per folder

slate swan
#

I'm out

unkempt yacht
#

i just need a guide on how to store the warns on a db as I haven't used mongodb before

#

ok

slate swan
hoary cargo
slate swan
slate swan
slate swan
#

Acitvity returns the status of a member right but if the member doesnt have a status it returns the member's presence(playing, streaming etc)

#

Idk tbhsadge

slate swan
#

i've tried```py
if after.activity.type is discord.ActivityType.custom:
if after.activity is None:
print("empty")

hoary cargo
pliant gulch
#

You're checking if the after.activity is None inside of an if-statement that only is true if activity is a type of custom??

#

How you layed this out basically means everytime you check if activity is None is always gonna be false

slate swan
#

basically after.activity returns the CustomActivity and the presence

slate swan
hoary cargo
slate swan
tacit storm
slate swan
maiden fable
tacit storm
#

use aiohttp

slate swan
maiden fable
#

Isn't even 12 tho

hoary cargo
#

tracking custom activity type is quite useless ngl MR_uncanny_1

slate swan
hoary cargo
maiden fable
slate swan
hoary cargo
#

artistic_hmm European mfs

maiden fable
#

Uhhh

slate swan
alpine storm
#

Hey everyone! I'm just tryung to build a simple bot on Replit that infinitely sends a specific message each second, I watched some youtube tutorials but nobody talks about what I need, can anyone help me?

slate swan
hoary cargo
#

MR_uncanny_1 you don't want your bot to send a message each second

maiden fable
#

Indeed

slate swan
tacit storm
#

look at that

maiden fable
tacit storm
#

plus replit is just shit overall

hoary cargo
#

and you have to deal with keep alive shit tf pepeannoyed

alpine storm
#

ok

#

i can find another better host

#

but can anyone help me with the code?

tacit storm
#

we cant help unless you give us the code

alpine storm
#

i don't have code...

hoary cargo
slate swan
tacit storm
maiden fable
#

!d discord.Guild.get_channel

unkempt canyonBOT
#

get_channel(channel_id, /)```
Returns a channel with the given ID.

Note

This does *not* search for threads.
tacit storm
#

im sure you can use a task loop for it though

hoary cargo
#
  • it will basically get you ratelimited if you want to send 1 message per second kek
maiden fable
#

!d discord.TextChannel.send

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

please dont do that

hoary cargo
alpine storm
slate swan
maiden fable
tacit storm
#

learn python first

hoary cargo
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.

tacit storm
hoary cargo
#

i think when beginners come here expect some people will give a ready to use bot with their requirements or something MR_uncanny_1 eventually free hosted

slate swan
maiden fable
#

Actually I learnt Python doing dpy, sooooo

slate swan
#

xD

maiden fable
#

Uhh, I was using cogs when I didn't know what was a class in programming pithink

tacit storm
#

@alpine storm Learn OOP in python and learn how to utilize async shit before starting discord.py

slate swan
maiden fable
#

I do know OOP now

hoary cargo
maiden fable
#

That happened about 2 years ago

#

2020 haha

maiden fable
slate swan
hoary cargo
#

it all started at 3 am with a freecodecamp python video sad

maiden fable
#

Mine in the.... day

tacit storm
#

i honestly

#

started python with dpy

maiden fable
#

Same

tacit storm
#

and it was horrible.

maiden fable
#

!ot anyways

unkempt canyonBOT
hoary cargo
#

we all know the inspiration is during the night

hoary cargo
maiden fable
#

Hmm, that time I used to shut down my laptop at 8 cz I didn't have a separate room

hoary cargo
#

we still talk about discord bots

slate swan
#

Hunter always hates being the bad guy, but she's always the bad guy

hoary cargo
#

MR_uncanny_1 she?

maiden fable
#

Lmao I was also seeing that

slate swan
silent portal
#

I know this isn't about python but how can I run 2 different tasks with different versions of discord.py? I have a bot for discord.py 2.0 and one for discord.py 1.7
I want to run both on one server. Can any1 help?

slate swan
#

Oh typo nvm

maiden fable
maiden fable
hoary cargo
slate swan
maiden fable
hoary cargo
#

MR_uncanny_10 well, you are and you are not in the same time

median spoke
#

how do i learn discord module

silent portal
maiden fable
#

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

maiden fable
#

Docs are a great way to start

median spoke
#

docs

#

???

maiden fable
#

Yea

slate swan
unkempt canyonBOT
hoary cargo
#

What are docs MR_uncanny_17

maiden fable
#

documentation

slate swan
hoary cargo
maiden fable
slate swan
#

Since discord.py will stop working soon what should i use to code in python still?

slate swan
hoary cargo
tacit storm
#

but discord.py isn;t dead yet and it has support for slash_commands via the slash_utils

slate swan
tacit storm
unkempt canyonBOT
hoary cargo
slate swan
tacit storm
#

a fork.

slate swan
#

Im new to all this bs so

tacit storm
#

there are many dpy forks such as pycord, nextcord, etc

slate swan
#

Slash commands are ugly i refuse to use them lmaooo

hoary cargo
slate swan
#

Im starting to kinda try hikari but idk it seems confusing because its new and not much documentation

#

Slash commands are ugly

hoary cargo
#

that was me months ago

slash commands are shit
i will never use those
eventually starts working to migrate to slash

tacit storm
tacit storm
slim ibex
#

wrong command

hoary cargo
pliant gulch
#

😔

maiden fable
slate swan
unkempt canyonBOT
maiden fable
#

I mean... pithink

pliant gulch
#

this version is so out of date

#

I'll push master to pypi rn

maiden fable
#

At least he got a link

slate swan
#

Naw but i mean that with a passion never making SLASH commands

#

Nvm i cant be too strong on that

neat tartan
slate swan
#

Idk… what do y’all suggest me using for making discord bots?

slate swan
#

Like pycord, hikari etc

#

Disnake?

neat tartan
#

Disnake i think is the main suggested one

tacit storm
#

yeah

neat tartan
#

Hikari i think is also pretty good but isnt as beginner/user friendly from what ive seen/heard

slate swan
#

Does it have good documentation?? And tutorials

hoary cargo
#

!pypi disnake

unkempt canyonBOT
slate swan
slim ibex
#

!pip pincer 🗿

unkempt canyonBOT
slate swan
#

"rebuild"

slate swan
pliant gulch
#

Now pypi isn't so out of date

maiden fable
#

w o w

slate swan
maiden fable
pliant gulch
#

I gave an ETA to v1.0.0 by the end of this month

#

But I don't think I will be able to follow through on that

maiden fable
#

Imagine 88 MB RAM used by a bot in 125 servers pithink

pliant gulch
#

I never acknowledged your deadline 😼

tidal hawk
#

Why can't my alt account see non admin slash commands 🤔

pliant gulch
#

I decided yesterday I was gonna attempt that

maiden fable
#

0% cpu 👀

maiden fable
#

Why u do this to me

tidal hawk
#

Yoo

#

How can I make admin slash commands private to normal users

#

They can't use these, but can see these

slate swan
tidal hawk
#

Still the alt can see it

vivid marsh
#

So I might be stupid but what is hikari like what does it do?

slow fog
slate swan
tidal hawk
#

Can you Unlist the goddamn admin slash commands from everybody D:

slate swan
slate swan
vivid marsh
#

Is it worth downloading and trying to use

maiden fable
#

just set the timeout to None

quick gust
#

timeout=None

maiden fable
#

Ash do be drunk 👀

slate swan
maiden fable
#

Why tho

quick gust
#

No, why?

slate swan
slate swan
maiden fable
#

Smh just get some sleep and don't u dare use the ot command

quick gust
#

yw

unkempt canyonBOT
maiden fable
#

INFERNUMMMMMMMMMMMMMMMMMMMMMMMMMMMM

#

Whyyyyyyy

slate swan
cold sonnet
#

!source ot

unkempt canyonBOT
#

Sorry, an unexpected error occurred. Please let us know!

AttributeError: 'TagIdentifier' object has no attribute 'qualified_name'

cold sonnet
#

bro broken bot

maiden fable
slate swan
unkempt canyonBOT
maiden fable
#

👀 I did go in the ot tho

maiden fable
#

!src ot

unkempt canyonBOT
#

Sorry, an unexpected error occurred. Please let us know!

AttributeError: 'TagIdentifier' object has no attribute 'qualified_name'

maiden fable
#

Oh, thought it was a random error

cold sonnet
#

I'm gonna look at it in github

#

imagine if I could solve it

#

which I won't

maiden fable
#

Facts (same)

cold sonnet
#

where could it hide thonk

#

you don't import bot

#

you make a cog which is gonna get passed bot by the setup function

#

your setup function will pass your bot to your cog

#

it will make an instance of it

#

now I don't understand

#

are you making this in multiple files?

#

maybe self.connection is defined after loading the cogs?

#

should be before it

#

access (self.)bot.connection?

slim ibex
#

do you not understand how to subclass

#

and pls use os.listdir for checking the cogs directory

#

!d os.listdir

#

you can do for filename in os.listdir("path")

#

no you use two for loops./ you can do it in 1

#

but whats the issue anyways

#

oh ok my fault

vivid marsh
#

I can’t figure out how to install 3.8 it’s only letting me install 3.7 anyone able to help I’m on Linux btw

slim ibex
#

wiat im not being rude

#

i meant that as a question

#

ik becuase i forgot the question mark

#

so what are you having trouble with?

#

for your db?

vivid marsh
#

Can you still run python successfully on 3.7?

slim ibex
#

ahh ook ye ye. i have dealt with this before

vivid marsh
#

I can’t figure out how to install 3.8 lmfao 🤣 I’m only getting 3.7

tacit token
#

Hi, how can I do a command that shows how many people/channels/servers the bot sees?

unkempt canyonBOT
#

property guilds: List[discord.guild.Guild]```
The guilds that the connected client is a member of.
pliant gulch
#

@slate swan You were the one asking earlier for a way to shorten cog loading right?

#

I'll write a quick example of what you cold do, holdon

scenic swan
#

guys can someone try making a bot like rhythm

#

but like you know youtube does not ban it

rough finch
#

helppy @bot.event async def on_command_error(ctx, cmd_error): embed = discord.Embed(title = "Ошибка", description = "Команда не найдена", color = 0xe74c3c)

slim ibex
#

wait i fucked up

pliant gulch
#
for root, _, files in os.walk("Cogs/"):
    if root.endswith("__"):
        continue

    for file in files:

        if file.startswith("_"):
            continue

        print(f"{root.replace('/', '.')}.{file}")
``` Would load all cogs for each sub-directory in `Cogs`
slate swan
#
@bot.event
async def on_message(message):
    if {i.lower().translate(str.maketrans('','', string.punctuation)) for i in message.content.split(' ')}\
    .intersection(set(json.load(open('cenz.json')))) != set():
        await message.channel.send(f'{message.author.mention} по губам отшлепать??')
        await message.delete() 
import json

ar = []

with open('cenz.txt', encoding='utf-8') as r:
  for i in r:
    n = i.lower().split('\n')[0]
    if n != '':
      ar.append(n)
      
with open('cenz.json', 'w', encoding='utf-8') as e:
    json.dump(ar, e) 

error

 .intersection(set(json.load(open('cenz.json')))) != set():
File "/app/.heroku/python/lib/python3.9/json/__init__.py", line 293, in load
return loads(fp.read(),
File "/app/.heroku/python/lib/python3.9/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/app/.heroku/python/lib/python3.9/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/app/.heroku/python/lib/python3.9/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 2 column 1 (char 1) 
rough finch
#

A, thx

pliant gulch
rough finch
#

i'm idiot

slim ibex
#

!d os.walk

unkempt canyonBOT
#

os.walk(top, topdown=True, onerror=None, followlinks=False)```
Generate the file names in a directory tree by walking the tree either top-down or bottom-up. For each directory in the tree rooted at directory *top* (including *top* itself), it yields a 3-tuple `(dirpath, dirnames, filenames)`.
pliant gulch
#

Heres the format it outputs in

gentle lion
#

how do I solve this problem (I need to take the value "system")
code:

import platform

@bot.command
async def server(ctx):
    osps = platform.uname()

  await ctx.reply(embed=nextcord.Embed(title="Information for bot", description=f"System: {osps}"))

what he writes:

pliant gulch
#

Actually looking at it, might need a fix but eh

slim ibex
#

shit i forgot how i fixed this the last time

pliant gulch
#

You can still make this connection clearner, and get rid of asyncio.run entirely

#

Which I would do, as asyncio.run creates a whole new event loop

#

Could cause issues later on, since your bot depends on an event loop

#

You can just overwrite your bot's connect method, which is a coroutine function

#
class Foo(Bot):

    async def connect(self, ...) -> None:
        self.connection = ...

        await super().connect(...)
#

connect is called internally by the wrapper after you call bot.run()

#

Also I'm assuming your IDE Is telling you it does not exist because you didn't add a placeholder for it

#

To get rid of that error you may add it before hand to the constructor method

#
class Foo:
    def __init__(self) -> None:
        self.connection: Database
``` etc
#

This doesn't actually initialise the bound attribute though

#

It just let's your IDE know it exists, and is expected

#

If you were to access this before the connection is created you'd get an attribute error

#

Yea, it goes in your subclass

#

Database would be the type of whatever connection is

slate swan
#

Idk how but I made it work! (fixed manually)

pliant gulch
#

Can you show the subclass after adding it?

#

And what linter are you using

cloud dawn
slate swan
cloud dawn
slate swan
#

xD

gentle lion
#

help solve this problem, I need the system value

what he writes:
uname_result(system='Linux', node='e4ecd0a42409', release='5.11.0-1029-gcp', version='#33~20.04.3-Ubuntu SMP Tue Jan 18 12:03:29 UTC 2022', machine='x86_64', processor='')

code:

import platform

osps = platform.uname()

@bot.command()
async def server(ctx):
await ctx.reply(f"{osps}")
lyric tusk
#

how can i make that in a embed message

cloud dawn
pliant gulch
#

You need to callawait super().connect(reconnect) otherwise it won't keep the super classes implementation, also you type-checker is going crazy because self.bot is expected to be of commands.Bot not Application

#

For an example, if you were in a cog you'd typehint it like so ```py
class Cog(...):
def init(self, bot: Application):
self.bot = bot

#

Now the linter knows bot has connection

maiden fable
#

connection with whom 👀

pliant gulch
cloud dawn
maiden fable
#

Hahaha

pliant gulch
#

In your connect method

#

It calls the super classes connect method

#

You overwritten it, so obviously it stops working as expected

#

You just pass whatever reconnect is

lyric tusk
maiden fable
#

👀

tacit token
#

dot work

pliant gulch
#

You should call the super class under, usually good practice to do so when overwriting methods

pliant gulch
#

But other than that, looks fine to me, and after you typehint the bot properly your type checker won't cry

slim ibex
#

andy so smart

pliant gulch
#

When loading a cog? Yea, look at the setup method usually at the bottom of your Cog file

#

You didn't typehint like I did in my example

slim ibex
#

do you have a __init__.py in the src directory

rough finch
#

Help pls```py
@bot.event
async def on_command_error(ctx, cmd_error, arg):
if arg == help:
embed = discord.Embed(title = "Error", description = "Command not detective", color = 0xe74c3c)
else:
embed = discord.Embed(title = "Error", description = "Command not found", color = 0xe74c3c)

    await ctx.send(embed=embed)```

error:
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event await coro(*args, **kwargs) TypeError: on_command_error() missing 1 required positional argument: 'arg'

pliant gulch
#

The bottom setup isn't typehinted

#

Also you will probably get a type error from how your connection is typehinted

#

I'm almost quite sure that your await asyncpg.connect(...) does not return a coroutine

#

What is the type error exactly?

#

Right, ok so inside of test access bot through self.bot

#

Yea, if you want to access interaction without type error you'd need to subclass the context

#

Pain, so just don't do it for now unless you are adding more too it

#

Other than that I'd fix your self.connection typehint in Application as it's wrong

#

I don't think connect returns a Coroutine

#

You can just do reveal_type

slim ibex
#

it returns a Connection object

pliant gulch
#

Since your using pyright

rough finch
#

I don’t know how, but it seems that because of the tabulation I had an error in sending the first embed and after your words, I myself don’t know how to insert the embed sending without an error ... No, I’m really an idiot

pliant gulch
#

The one with connect?

#

Ok, try moving the connection stuff into into start, and overwrite it the same way you did with connect

fresh orchid
#

I have this code

class DroppDownMenu(discord.ui.View):
    with open("cases.json", "r") as f:
            cases = json.load(f)
    options = []
    for case_name in cases:

        options.append(discord.SelectOption(label=case_name, description="descrption"))
    @discord.ui.select(placeholder="Choose one option", min_values=1, max_values=1, options=options)
    async def callback(self, select, interaction : discord.Interaction):
        with open("cases.json", "r") as f:
            cases = json.load(f)

        case_name = select.values[0]
        
        case_picture = cases[case_name]["url"]
        await interaction.delete_original_message()
        await interaction.response.send_message(case_picture)

@commands.slash_command(name='own_pc', description='Shows charts with benchmark of CPUs, GPUs or RAM', guild_ids=[708218806928932896])
    async def own_pc_slash(self, ctx):
        view = DroppDownMenu()
        await ctx.respond("Choose the case", view=view)

So it sends a message with a select menu
But how can I disable the menu after I used it
I tried to delete the message with the interaction.delete.original_message but it returns unkown webhook error

pliant gulch
#

start is a method bound to commands.Bot

#

Just overwrite it like you did for connect and add your database connection there

#

then remove connect, it might fix it?

#

connect does more important stuff compared to start anyhow iirc

#

Yea, under it call the super again

#

run calls start internally with the token

#

Just pass token to the start method's arguments

pliant gulch
#

then call super().start with it

fresh orchid
slate swan
#

Oh right it's just dpy

fresh orchid
pliant gulch
#

What is it

slate swan
#

token? I thought it was TOKEN

rough finch
#

Me send error
on_command_error() missing 1 required positional argument: 'arg' Ignoring exception in on_command_error

pliant gulch
#

👍

jade tartan
#

How do you have the bot ask questions in an embed message?

#
async def start(ctx):
    embed=discord.Embed(title="Profile", description="Desc", color=0x00ff00)
    embed.add_field(name= f"User: {ctx.author.mention}", value="✅Verified 18+✅", inline=False)
    await ctx.send(embed=embed)```
median spoke
#

does anyone want to build an ai in a discord bot????

pliant gulch
#

That's a windows issue, it's fixed in 3.7+ iirc,

#

You could also set the event loop policy or something like that, but I forgot what it was exactly

#

Is the error saying some sort of Proactor error

jade tartan
#
async def start(ctx):
    embed=discord.Embed(title="Profile", description="Desc", color=0x00ff00)
    embed.add_field(name= f"User: {ctx.author.mention}", value=":white_check_mark:Verified 18+:white_check_mark:", inline=False)
    await ctx.send(embed=embed)```
How do you have the bot ask questions in an embed message?
oblique adder
#

Is it possible to send 2 embeds in one message ? plz ping

pliant gulch
#

I'm pretty sure asyncpg should be handling that, not sure though

slate swan
slate swan
pliant gulch
#

You could try setting the event loop policy to WindowsSelectorEventLoopPolicy

#

asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) iirc?

oblique adder
#

like this right ?

slate swan
#

yep, try it out

slate swan
#

you can send up to 10 in a single message

rough finch
#

Help plspy @bot.event async def on_command_error(ctx, cmd_error, arg): if arg == help: embed = discord.Embed(title = "Error", description = "Command not detective", color = 0xe74c3c) await ctx.send(embed=embed) else: embed = discord.Embed(title = "Error", description = "Command not found", color = 0xe74c3c) await ctx.send(embed=embed)
error:
await coro(*args, **kwargs) TypeError: on_command_error() missing 1 required positional argument: 'arg' Ignoring exception in on_command_error

pliant gulch
#

👍

slate swan
#

!d discord.ext.commands.Bot.on_command_error

unkempt canyonBOT
#

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

The default command error handler provided by the bot.

By default this prints to [`sys.stderr`](https://docs.python.org/3/library/sys.html#sys.stderr "(in Python v3.9)") however it could be overridden to have a different implementation.

This only fires if you do not specify any listeners for command error.
slate swan
#

arg is not part of the signature

pliant gulch
#

Yes but I will probably never finish it 😔

#

I've made two of them now

slate swan
rough finch
pliant gulch
#

It's tedious and time consuming

slim ibex
#

i have come to the conclusion that the current bot I am making will be the last 🗿 . (unless the api wrapper is Rin)

pliant gulch
#

😔 Maybe I'll finish it just for you binds

#

😼

rough finch
slate swan
fresh orchid
#

yes

#

wait

slim ibex
#

if you finish Rin, and I make a bot with it, that will be it for my bot development "career"

outer parcel
#

hey everyone,
does anyone have an idea i can add for my currency bot it will be extremely helpful
nitroWumpus

pliant gulch
slim ibex
slate swan
rough finch
slate swan
#

Triggers?

outer parcel
#

anyone got any ideas for a currency bot

rough finch
rough finch
slate swan
#

I have no clue what you're talking about.

rough finch
#

Like I write help or pleh and the same command works

slim ibex
#

yes

#

aliases

#

!d disnake.ext.commands.Command.aliases

unkempt canyonBOT
slim ibex
#

very helpful sentence

slate swan
#

pass aliases=... to the @command decorator

slim ibex
#

Aliases's type is: Union[List[str], Tuple[str]]

rough finch
#

Ooh, can you type how ~roughly use this?

#

@bot.command(aliases = help, pleh)?

slim ibex
#

it has to be a list or tuple

#

aliases=["...", "..."] or aliases=("...", "...")

slate swan
#

Why are you so determined to use help object as a string

rough finch
#

@bot.command(aliases = ["help", "pleh"]) yea?

slim ibex
#

as the type says, a list or tuple of strings

slate swan
slim ibex
#

hurts me to see so many extreme beginners getting into dpy too early

rough finch
slate swan
#

You see it all the time unfortunately, discord.py is just one of those libraries that attracts newbies like a moth to a light

slim ibex
rough finch
#

aaa

#

Okay

#

sory

hoary cargo
slate swan
#

how i separate arguments in command
edonate 560 adv | 1w | greentea 35 pts
like that

#

with |

#

or comma

slim ibex
#

!args-kwargs ?

unkempt canyonBOT
#

*args and **kwargs

These special parameters allow functions to take arbitrary amounts of positional and keyword arguments. The names args and kwargs are purely convention, and could be named any other valid variable name. The special functionality comes from the single and double asterisks (*). If both are used in a function signature, *args must appear before **kwargs.

Single asterisk
*args will ingest an arbitrary amount of positional arguments, and store it in a tuple. If there are parameters after *args in the parameter list with no default value, they will become required keyword arguments by default.

Double asterisk
**kwargs will ingest an arbitrary amount of keyword arguments, and store it in a dictionary. There can be no additional parameters after **kwargs in the parameter list.

Use cases
Decorators (see !tags decorators)
Inheritance (overriding methods)
Future proofing (in the case of the first two bullet points, if the parameters change, your code won't break)
Flexibility (writing functions that behave like dict() or print())

See !tags positional-keyword for information about positional and keyword arguments

hoary cargo
slim ibex
#

!e

def func(x, y):
  return x + y

print(func(10, 10))
unkempt canyonBOT
#

@slim ibex :white_check_mark: Your eval job has completed with return code 0.

20
rough finch
#

BUT before I started learning d.py, I somehow taught python, all the same, with zero knowledge, it’s impossible to do something

hoary cargo
#

FeelsAmericanMan nah, impossible, just if you blindly copy paste what you see in tutorials and have no idea what are you doing

slim ibex
#

^

slate swan
#

not like that

#

like this

slim ibex
#

thats just command invocation

rough finch
slate swan
#

separate args with |

slim ibex
#

str.split?

hoary cargo
# slate swan

in this case probably you need to have 9-10 args kekw

#

MR_canny_1 pros of using slash commands, you don't have to struggle with this kind of stuff

slim ibex
#

yessir

slate swan
#

yes

wraith pendant
#

are you able to find the server that a command was run in?
does something like ctx.guild.name exist?

slim ibex
unkempt canyonBOT
slim ibex
#

yes

slate swan
#

args ?

slate swan
wraith pendant
#

ok

#

thanks

kindred epoch
#

if you want to do that kind of stuff you have to only use 1 arg

#

and then split it between |

slate swan
kindred epoch
#

wdym like?

slate swan
vivid marsh
#

How do I get the bot to ping the person I ping like .hey @the
Then the bot would say hey @the

kindred epoch
#

it depends on what your commands are gonna do

slate swan
slate swan
vivid marsh
#

So like

@client.command()
Async def fuck(ctx,discord.member):

slate swan
#

What are you doing

kindred epoch
vivid marsh
#

I’m just tryna make it respond with the message set and who I ping

slate swan
slate swan
#

🥄

#

Indeed

vivid marsh
slate swan
#

I'm not going to waste my 7 and a 3 quarters braincells for nothing, tim

vivid marsh
#

Got more brain cells then me

slate swan
vivid marsh
#

Way less lol

dull terrace
#

pithink why we bein mean to people

slate swan
dull terrace
#

don't you remember when you first started coding

calm vortex
#

Lol

kindred epoch
#

read the error again