#discord-bots

1 messages · Page 617 of 1

tiny ibex
#

No

#

It will return the ID of the message's author

velvet tinsel
#

Legit ctx author id wait no

#

Do you want a bot to send you their ID when you reply?

tiny ibex
#

@urban shell would you mind showing your code

velvet tinsel
urban shell
#

like, I wat to have a hug command -
to trigger it, I type - >hug while replying to a person's message
and then I want an embed to be sent saying that "@urban shell is hugging <@idOfThePersonIamReplyingto>" followed by a hugging GIF ofc

slate swan
velvet tinsel
#

That’s message id

slate swan
#

oh

slate swan
#

after running the code, you need to force the bot to log in to the discord account and after that the bot requests a link to the server and then the following code starts working

velvet tinsel
#

Here

slate swan
velvet tinsel
#

What?

tiny ibex
vale wing
#

message.reference.resolved so basically

velvet tinsel
#

Here is your answer

vale wing
#

Leads to a message that you replied to

urban shell
#

I've tried going thru SO beforehand

velvet tinsel
#

How is that not helpful

urban shell
#

breh

velvet tinsel
#

!d await ctx.channel.fetch_message(ctx.message.reference.message_id)

unkempt canyonBOT
vale wing
#

@urban shell so you need to get id of the replied message author?

slate swan
urban shell
#

is it possible?

velvet tinsel
#

That’s probably what you want

vale wing
urban shell
tiny ibex
vale wing
velvet tinsel
#

Oh

#

That’s how I usually do it

slate swan
#

does anyone know how i can add slash commands in a cog?

vale wing
#

Better do like that unless you care about cache

#

If you do it's better to fetch it ofc

velvet tinsel
#

That doesn’t work?

tiny ibex
#

Slash commands are not a thing in dpy

#

They don't exist

velvet tinsel
#

They are, you’ll have to import them

sage otter
#

No

#

They are not

tiny ibex
vale wing
slate swan
vale wing
#

We are talking about stable version

velvet tinsel
#

Like buttons 😫

tiny ibex
#

You need to use extensions

velvet tinsel
#

Why did they have to do this

sage otter
# vale wing In 2.0

Slash commands doesn’t even exist in 2.0. Danny literally said he was never gonna add them.

vale wing
#

Which is 1.7.1 or something

velvet tinsel
#

Now I have to migrate all my bots to nextcord

sage otter
#

On the master branch of the head repo. There’s no implementation of slash commands anywhere.

slate swan
cobalt jacinth
#

should i recode my bot in js

velvet tinsel
velvet tinsel
slate swan
#

already installed that and i cant figure out how to use them in cogs

vale wing
#

Are there libraries for java btw

brisk latch
velvet tinsel
#

Read it

velvet tinsel
sage otter
slate swan
#

what happens if I run the code with a user token?

brisk latch
sage otter
urban shell
velvet tinsel
sage otter
velvet tinsel
#

Returns with an error

slate swan
#

Does anyone know of a simple way to retrieve a channel id from a user/members id?

brisk latch
slate swan
#

how can i delete the message with the command?

cobalt jacinth
velvet tinsel
#

That doesn’t work but it is ctx channel

sage otter
#

Literally the most insufferable help conversation I’ve ever seen in my life.

slate swan
velvet tinsel
#

No

sage otter
slate swan
#

await ctx.message.delete() ?

velvet tinsel
#

Doesn’t work

velvet tinsel
brisk latch
# slate swan So its work?

You can't just put a user token, there are multiple things you would have to do to make it work, for example bot = False and self_bot = True, which I don't recommend as it's against TOS

sage otter
sage otter
slate swan
sage otter
brisk latch
velvet tinsel
#

Oh

#

Really? Sweet

sage otter
#

It’s not user

#

Users don’t have voice channels

velvet tinsel
#

Yay at least we have a expert around here

sage otter
#

I’m not really an expert. I just know more than most. And most of the time if you come in here with a big problem and like 200 lines of code I’m not gonna even bother and help. Id just let some other person help.

slate swan
#

how to nuke a channel each 3 hours?

sage otter
#

By cloning and deleting the old one.

slate swan
unkempt canyonBOT
#

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

sage otter
#

Tragic.

slate swan
#

Ikr

velvet tinsel
#

Hi

velvet tinsel
slate swan
slate swan
#

Cant assume maliciousness just because he wants channel cleaned

#

He said he wants to nuke it every 3h

#

Yeah, thats a common phrase for deleting and recreating the channel

#

Oh

#

Mb then 💀

#

Most ppl do that to bypass client mods with messageloggers

#

Since they wont have the stored messages anymore

#

Didn't know that 🤔

glass rock
#

what does nuke mean

#

like clear it?

surreal sierra
#

what is the best database to use for a large amount of users?

sage otter
#

Postgres

sage otter
#

In a sense yes

sage otter
#

People do it clear messages

surreal sierra
glass rock
sage otter
quick gust
#

¯_(ツ)_/¯

#

maybe cause I pinged

sage otter
#

I literally sent that a second right after they sent their initial message. It’s baffling that they didn’t see it.

quick gust
#

lol maybe they did

#

but just wanted to respond to one

#

you never know

#

please dont go OT

slate swan
#

oops

surreal sierra
full valley
#

How can I wait for a voice channel and see when x amount of members join, even if it is a temporary channel

sage otter
#

!d discord.VoiceChannel.members

unkempt canyonBOT
sage otter
#

Consider using length on this for checking the amount of members.

slate swan
#

i don't think so.......

sage otter
#

You don’t need to unnecessarily ping him. He was already told that.

slate swan
quick gust
#

Atleast that's what I infer the word as

slate swan
#

It usually means something malicious to me

sage otter
# slate swan thats not called nuke fyi

It’s basically the same concept. When someone says they're "gonna nuke a text channel" they are gonna re-create/clone(so all the permissions transfer over) and delete the old one.

slate swan
velvet tinsel
#

Self botting?

sage otter
#

Huh?

velvet tinsel
#

Nuking servers

#

Self bot yourself, clone and spam?

sage otter
#

The mentioning part is new to me. 🤷‍♂️

#

Personally when I see people make nuke commands, they do what I described above. Since nuking is a term for just clearing out a text channel.

haughty pelican
#

does this sever make bots idk i am new plz help me

sage otter
# velvet tinsel Nuking servers

See this tho. I can see. These are two different things. Nuking a server I can see role and member mentions, banning, consecutively deleting channel and what not.

boreal ravine
#

😕

haughty pelican
#

hmmmm

#

@boreal ravine so they make for us idk i dont understant

boreal ravine
haughty pelican
#

how @boreal ravine

#

@boreal ravine teach me to make one

boreal ravine
#

by coding it

boreal ravine
haughty pelican
#

i saw

boreal ravine
haughty pelican
#

kk

#

@boreal ravine are you kidding me i have to read all of that

quick gust
#

If you don't wish to make effort then you won't be able to properly learn

haughty pelican
#

ooof

slate swan
haughty pelican
#

bruh you have to pay @boreal ravine .....

quick gust
#

dude

slate swan
#

You don't

slate swan
#

how should i call the command then... ?

#

and how can i see the user id who sent the message or user name

#

you could have just said delete and clone it... As you said later

#

yeah i know how to delete one and clone one

#

but i want that action to be ran each 3 hours

quick gust
#

tasks

slate swan
#

I'm using discord buttons and everything working it just that before it work it says " interaction failed " then it shows this error

Task exception was never retrieved
future: <Task finished name='Task-59' coro=<Command.__call__() done, defined at C:\Users\gcpla\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py:358> exception=NotFound('404 Not Found (error code: 0): Interaction is unknown (you have already responded to the interaction or responding took too long)')>
Traceback (most recent call last):
  File "C:\Users\gcpla\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 374, in __call__
    return await self.callback(*args, **kwargs)
  File "E:\Codes\ticketBot\ticketBot.py", line 159, in new
    await controller.respond(embed=embed)
  File "C:\Users\gcpla\AppData\Local\Programs\Python\Python39\lib\site-packages\discord_components\interaction.py", line 117, in respond
    raise NotFound(
discord.errors.NotFound: 404 Not Found (error code: 0): Interaction is unknown (you have already responded to the interaction or responding took too long)

may i know what is wrong?

#

use a task loop

#

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

sorry i misread it

#

The error says that the bot got no response (ie button was not clicked) within the timeframe

slate swan
slate swan
boreal ravine
slate swan
slate swan
#

that's the new hastebin xd

dusk dust
#

how can i get message regardless of whether it is in uppercase or lowercase

slate swan
#

I'm using discord buttons and everything working it just that before it work it says " interaction failed " then it shows this error

Task exception was never retrieved
future: <Task finished name='Task-59' coro=<Command.__call__() done, defined at C:\Users\gcpla\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py:358> exception=NotFound('404 Not Found (error code: 0): Interaction is unknown (you have already responded to the interaction or responding took too long)')>
Traceback (most recent call last):
  File "C:\Users\gcpla\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 374, in __call__
    return await self.callback(*args, **kwargs)
  File "E:\Codes\ticketBot\ticketBot.py", line 159, in new
    await controller.respond(embed=embed)
  File "C:\Users\gcpla\AppData\Local\Programs\Python\Python39\lib\site-packages\discord_components\interaction.py", line 117, in respond
    raise NotFound(
discord.errors.NotFound: 404 Not Found (error code: 0): Interaction is unknown (you have already responded to the interaction or responding took too long)

may i know what is wrong?

maiden fable
#

Either u look too long or u r replying twice

shy schooner
velvet tinsel
boreal ravine
tawdry perch
#

I have this command, but when I try to send a emoji from another server using this it wont work as I don't have nitro and it tried to make it emoji before sending it. So how could I send a emoji using <:name:id> or smth else? ```py
@commands.command()
@commands.cooldown(1, 10)
async def echo(self, ctx, channel: Optional[discord.TextChannel] = None, *, message: str):
'''Will be sending message to specific channel NOTE: should only be used in moderation channels'''
await ctx.message.delete()
if channel is None:
channel = ctx.channel
await channel.send(f"{message}")

boreal ravine
#

simple

tawdry perch
#

right... but what is emoji instance

boreal ravine
tawdry perch
#

get_emoji?

boreal ravine
tawdry perch
#

that's fine I can get it

boreal ravine
#

oh, use that then

velvet tinsel
#

I can’t tell the difference between you two

boreal ravine
#

!d discord.ext.commands.Bot.get_emoji <=

unkempt canyonBOT
tawdry perch
#

oh

#

so it's a self.bot.get_emoji?

boreal ravine
#

yes

#

idk how'd you get the emoji id though 🤔

tawdry perch
#

how could I get a emoji ID from the whole message

#

I just copy paste it from my server (id of emoji)

#

if I do smth like ```py
!echo <channel> Hello <id> what's up?

boreal ravine
#

Hm, that I have no idea, but my way worked if you wanted to send a message and the only argument was the emoji

tawdry perch
#

so I need to use some sort of black magic

boreal ravine
#

Maybe

tawdry perch
#

or actually I know a way maybe

#

no actually I don't

velvet tinsel
boreal ravine
tawdry perch
#

I'll ask in pygen and see if someone can let some black magic out

tawdry perch
tawdry perch
#

Hmm

#

this will be harder than I expected

slate swan
tawdry perch
#

I have never used regex

slate swan
#

then to get the Emoji object you just need to do bot.get_emoji(id)

slate swan
#

here's the regex just in case <(?P<animated>a?):(?P<name>[a-zA-Z0-9_]{2,32}):(?P<id>[0-9]{18,22})>

tawdry perch
#

what is that?

slate swan
#

regex

tawdry perch
#

I can't understand that

slate swan
#

!d regex

unkempt canyonBOT
#

regex

Case-sensitive regular expression match.

The regular expression syntax is that of the database backend in use. In the case of SQLite, which has no built in regular expression support, this feature is provided by a (Python) user-defined REGEXP function, and the regular expression syntax is therefore that of Python’s re module.

Example:

Entry.objects.get(title__regex=r'^(An?|The) +')
```  SQL equivalents...
maiden fable
unkempt canyonBOT
#
re

Source code: Lib/re.py

This module provides regular expression matching operations similar to those found in Perl.

Both patterns and strings to be searched can be Unicode strings (str) as well as 8-bit strings (bytes). However, Unicode strings and 8-bit strings cannot be mixed: that is, you cannot match a Unicode string with a byte pattern or vice-versa; similarly, when asking for a substitution, the replacement string must be of the same type as both the pattern and the search string.

maiden fable
#

This is the correct one

brisk helm
slate swan
#

that yes

brisk helm
tawdry perch
#

regex is not to go for me

#

it's too confusing

#

The emoji ID is in this format so far```py
['9', '1', '2', '3', '9', '2', '8', '2', '7', '9', '6', '1', '4', '8', '3', '2', '7', '4']

slate swan
#

it's the only thing i can think of to do what you wanna do

tawdry perch
#

oh.. well rip

tawdry perch
#

I mean what for

slate swan
#

for emojis i just said that 🤦‍♂️

boreal ravine
slate swan
#

maybe

boreal ravine
#

🚶‍♂️

tawdry perch
#

how would I even use that?

slate swan
tawdry perch
#

.rp 1 regex

slate swan
#

Hey guys

#

is there a way i can make my Bot read embedded messages and depending on what they say, react to them?

tawdry perch
#

;-;

slate swan
# slate swan here's an example

it basically returns a list of tuples, and inside the tuples there's 3 elements, the a or '', depends whether it's animated or not, then the name of the emoji, and lastly the id

slate swan
slate swan
#

yes

#

!d discord.Message.embeds

unkempt canyonBOT
tropic briar
#
@bot.listen()
async def on_message(message):
  message_split = message.content.split(".")
  for message_word in message_split:
    for bad_word in Filter:
      if(bad_word == message_word.lower()):
        await message.delete()
        await message.channel.send("I have deleted that message :angry:")
``` I have this function which checks if there is a bad word or not and if there is one then the bot deletes the message 
but I want to add another list from which it will check the words How can I do it
slate swan
tropic briar
#

with the same values?

#

like bad_word, message_word.lower()

slate swan
#

yes

#

basic python 🤦‍♂️

slate swan
# slate swan yes

alright ive read a bit into it but i dont get how i would make the bot send a message if a particular embed got sent

boreal ravine
tropic briar
#
@bot.listen()
async def on_message(message):
  message_split = message.content.split(".")
  for message_word in message_split:
    for bad_word in Filter:
      if(bad_word == message_word.lower()):
        await message.delete()
        await message.channel.send("I have deleted that message :angry:")

  for message_wor in message_split:
    for bad_wor in invite:
      if(bad_wor == message_wor.lower()):
        await message.delete()
        await message.channel.send("A invite was posted ")
#

@slate swan See this

slate swan
slate swan
boreal ravine
#

i think you can do

if message.embeds:
  embed = message.embeds[0]
  if embed.title == "title":
    print(...)
``` but im not sure
slate swan
#

i know if statements but i just got into making discord bots

#
bot = commands.Bot("c#", self_bot=True)

@bot.event

async def on_ready():
    print(f"All contected, Script is work.")
    
@bot.command()
async def start(ctx):
    await ctx.send("oof")
bot.run("my token", bot=False)

Why is the code not working?

slate swan
# slate swan could you do an example of how a command would look like maybe?

it's really just this easy 😟 🤦‍♂️ ```py
embeds = message.embeds
for embed in message.embeds:
if embed.title == 'some title that you wanna check':
... # The title matches so do something about it
elif embed.description == 'some description you wanna check':
... # The description matches so do something, idk

#

==

slate swan
slate swan
#

Lol

#

Guys, how do I run the code to on behalf of the account discord. after the "c#start" command, I wrote the word "hello"

slate swan
slate swan
slate swan
#

someone maybe can help?

#

no one will help you with this

#

!rule 5

unkempt canyonBOT
#

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

slate swan
#

why

#

m

tawdry perch
#

and I cant send it there

tawdry perch
#

in your example the emoji was in the chat alrd, but I can not do that

#

the emoji is on another server and I don't have nitro

slate swan
#

It doesn't matter whether you can't use the emoji, your bot can, and as long as the bot can see a message it'll be fine, even if the bot can't see the emoji because it doesn't have a mutual server the regex will still work on the message

tawdry perch
#

hm

slate swan
#

Anyways I'm gonna go take my daily nap 🚶‍♂️

lethal moat
#

for some reason i am unable to have a bot.command with the name "help" as its somehow already a command
is there a way i can override this with my own help command? when i enter said help command in chat it shows this -

​No Category:
  class 
  help  Shows this message
  info  
  test  

Type rpg help command for more info on a command.
You can also type rpg help category for more info on a category.
tawdry perch
slate swan
#

!d discord.ext.commands.HelpCommand

unkempt canyonBOT
#

class discord.ext.commands.HelpCommand(*args, **kwargs)```
The base implementation for help command formatting.

Note

Internally instances of this class are deep copied every time the command itself is invoked to prevent a race condition mentioned in [GH-2123](https://github.com/Rapptz/discord.py/issues/2123).

This means that relying on the state of this class to be the same between command invocations would not work as expected.
slate swan
#

Subclass it

tawdry perch
# slate swan here's an example

seems like this happened ```
re.compile('<(?P<animated>a?):(?P<name>[a-zA-Z0-9_]{2,32}):(?P<id>[0-9]{18,22})>')
're.Pattern' object is not subscriptable

fair axle
#

anyone got examples for a verification command like one that uses a command and gives role

velvet tinsel
#

A verification bot?

#

Try just prompting user for input and then have a photo of a blurred out image with text and ask the user to input it

slate swan
#

code:```py
user_id_list = (int[639551337989931008])

error:```
Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 301, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\User\Desktop\папка для заказа бота\main.py", line 25, in on_message
    user_id_list = (int[639551337989931008])
TypeError: 'type' object is not subscriptable

why its not work?

zealous dagger
#

How to add like this

slate swan
#
# Setting `Listening ` status
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name="a song"))
slate swan
# zealous dagger

just so you know```py

Setting Playing status

await bot.change_presence(activity=discord.Game(name="a game"))

Setting Streaming status

await bot.change_presence(activity=discord.Streaming(name="My Stream", url=my_twitch_url))

Setting Listening status

await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name="a song"))

Setting Watching status

await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="a movie"))

zealous dagger
#

Ok

#

thanks

#

@slate swan

glass rock
#

how can i write the tiny text at the bottom of an embed

final iron
#

!d discord.Embed.set_footer

unkempt canyonBOT
#

set_footer(*, text=Embed.Empty, icon_url=Embed.Empty)```
Sets the footer for the embed content.

This function returns the class instance to allow for fluent-style chaining.
final iron
#

This iirc

glass rock
#

ooo thx

final iron
dusk dust
#

how can i check if command is being executed in dm?

slate nymph
#

how to use @commands.check() for allowing only specific people to use ur command?

dusk dust
slate swan
dusk dust
slate swan
#

@slate nymph your trying to check members with the @commands.check decorator?

slate nymph
#

yeah maybe?

slate swan
dusk dust
#

yess

slate swan
slate nymph
#

how?

#

I dont know xd

#

return?

slate swan
#

Don't add "" since their int

slate nymph
#

ok

slate swan
#

@slate nymph nvm what i said

slate nymph
#

what

#

if ctx.author in listid[] ig

dusk dust
#

!=, no?

slate nymph
#

nvm i ll do it

slate swan
slate nymph
#

yeah

slate swan
dusk dust
slate swan
#

But add the id attr

slate swan
slate swan
slate swan
slate nymph
#

we cant use commands.check inside a function :/

dusk dust
#

will cancel the command

slate swan
slate nymph
slate swan
#

It will return bool

slate swan
slate nymph
#

ye

dusk dust
#

but u can help me...?

slate swan
brittle ingot
#

good morning

slate swan
brittle ingot
#

use an isinstance in an on_message to check if the message.channel is a DMchannel ?

#

wait are you wanting it for inside the command itself to switch between uses in DM or server channel?

slate swan
#

@brittle ingot bro you know my brain is crazy when i try to compare a int to a list😭

brittle ingot
#

bruhh 😂

slate swan
#

I wokeup from a 7 hour nap ok😭

#

Gosh what was i thinking😭

brittle ingot
#

lmao

slate swan
#

@dusk dust are you going to use this to restrict certain commands from running in DM's?

slate swan
slate swan
#

right

boreal ravine
#

help pls 🙏

quick gust
#

with?

boreal ravine
#
        author = await self.thank.find_one({"_id": ctx.author.id})
        receiver = await self.thank.find_one({"_id": member.id})

        if not author:
            await self.thank.insert_one(
                {
                    "_id": ctx.author.id,
                    "sent": 0,
                    "received": 0,
                }
            )
            new_receiver = await self.thank.find_one({
                "_id": ctx.author.id
                })

            new_sent = new_receiver["sent"] + 1
            await self.thank.update_one(new_receiver, {"$set": {"sent": new_sent}})

        if not receiver:
            await self.thank.insert_one(
                {
                    "_id": member.id,
                    "sent": 0,
                    "received": 1,
                }
            )
            new_find = await self.thank.find_one({
                "_id": member.id
            })

            new_received = new_find["received"] + 1
            await self.thank.update_one(new_find, {"$set": {"received": new_received}})


        sent = author["sent"] + 1
        received = receiver["received"] + 1

        await self.thank.update_one(author, {"$set": {"sent": sent}})
        await self.thank.update_one(receiver, {"$set": {"received": received}})
``` this is my code, so basically the bot tries to find the ppl, if they werent in the database it'd create something for them, but my bot isn't creating them and giving me a `NoneType` error which I thought I avoided using my if statements at the beginning
visual island
#

error line?

boreal ravine
#

idk why its None though

visual island
#

which is probably None

boreal ravine
#

hm

visual island
#

what does "hm" mean?

boreal ravine
slate swan
#

But idk about that one lemonpeek

unkempt jewel
#

help me

#

im working on a card game/commands but im stuck at the sell commands ( sell buttons in embed )

visual island
#

explain where are you stuck on

slate swan
slate swan
unkempt jewel
maiden fable
slate swan
#

code: ```py
class MyClient(discord.Client):
async def on_ready(self):
print('Logged on as', self.user)

async def on_message(self, message):
    # don't respond to ourselves
    if message.author == self.user:
        return

    if message.content == 'ping':
        user_id_list = (int[639551337989931008])
        for user_id in user_id_list:
            user = await client.get_user_info(user_id)
            await message.user.send('hello')

client = MyClient()
client.run("")

error:

Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 301, in _run_event
await coro(*args, **kwargs)
File "C:\Users\User\Desktop\папка для заказа бота\main.py", line 25, in on_message
user_id_list = (int[639551337989931008])
TypeError: 'type' object is not subscriptable

help?
unkempt jewel
#

i can send the code here?

maiden fable
#

Yea..

visual island
#

not with int[]

unkempt jewel
#

oh

maiden fable
unkempt canyonBOT
unkempt jewel
#

._.

maiden fable
#

Read the embed

visual island
maiden fable
visual island
#

guessed

velvet kindle
#

Code

maiden fable
unkempt jewel
#
from random import randint
import discord
from discord.ext import commands
from discord_components import Button, ButtonStyle, Interaction

from classes.Time import Time

import hdb3

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

   @commands.Cog.listener("on_button_click")
   async def on_button_click(self, interaction: Interaction):
     if interaction.custom_id.startswith("dc"):
       card_id = int(interaction.custom_id.split(" ")[1])
       card = await hdb3.get_card(card_id)
       if card['owner'] != interaction.author.id:
         await interaction.respond(
           content="You Dont own this card"
         )
       else:
         cost, card, vtuber = await hdb3.get_card_cost(card_id)
         res = await hdb3.inc_bal(interaction.author.id, cost)
         await interaction.respond(
           embed = discord.Embed(
             title="Balance",
             description=f"Sold Card For: {cost}\n New Balance: {res['bal']}",
             color=self.bot.color
           )
         )
#

here is my code

slate swan
velvet kindle
#

Oke

fair axle
#

how do you get a role for a command

maiden fable
unkempt canyonBOT
fair axle
#

thanks

fair axle
#

discord.Guild.get_role(role_id=12345)

maiden fable
#

No

unkempt jewel
maiden fable
#

ctx.guild.get_role(1234)

fair axle
#

oh

maiden fable
slate swan
#

code:```py
class MyClient(discord.Client):
async def on_ready(self):
print('Logged on as', self.user)

async def on_message(self, message):
    # don't respond to ourselves
    if message.author == self.user:
        return

    if message.content == 'ping':
        user_id_list = [639551337989931008]
        for user_id in user_id_list:
            user = await self.get_user_info(user_id)
            await message.user.send('hello')

client = MyClient()
client.run("")


error:```py
Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 301, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\User\Desktop\main.py", line 27, in on_message
    user = await self.get_user_info(user_id)
AttributeError: 'MyClient' object has no attribute 'get_user_info'

help?

maiden fable
#

get_user*

#

And remove that await

visual island
#

and message.user doesn't exists

maiden fable
#

Ye

visual island
#

@maiden fable helper when

maiden fable
unkempt jewel
visual island
maiden fable
#

Tell the error

unkempt jewel
#

i send you the error!

maiden fable
maiden fable
#

!traceback

unkempt canyonBOT
#

Please provide the full traceback for your exception in order to help us identify your issue.

A full traceback could look like:

Traceback (most recent call last):
    File "tiny", line 3, in
        do_something()
    File "tiny", line 2, in do_something
        a = 6 / b
ZeroDivisionError: division by zero

The best way to read your traceback is bottom to top.

• Identify the exception raised (in this case ZeroDivisionError)
• Make note of the line number (in this case 2), and navigate there in your program.
• Try to understand why the error occurred (in this case because b is 0).

To read more about exceptions and errors, please refer to the PyDis Wiki or the official Python tutorial.

maiden fable
#

See the last line

visual island
unkempt jewel
#

what isthat

maiden fable
#

Oh nvm

#

Didn't see that. Smh I am still in sleep

maiden fable
visual island
unkempt canyonBOT
#

exception KeyError```
Raised when a mapping (dictionary) key is not found in the set of existing keys.
unkempt jewel
#

Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\Administrator\Desktop\bot\cogs\Card2.py", line 183, in sell
description=f"Sold Card For: {cost} vyen\nNew Balance: {res['bal']}",
KeyError: 'bal'

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

Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: KeyError: 'bal'

maiden fable
#

Happens when the key isn't in the dict

visual island
maiden fable
maiden fable
boreal ravine
slate swan
unkempt jewel
boreal ravine
#

whatever your JSON file is called

unkempt jewel
visual island
maiden fable
slate swan
#

Very inspirationaljam_cavedude

visual island
#

yeah

unkempt jewel
# visual island show us the `hdb3.inc_bal()` function
else:
        cost, card, vtuber = await hdb3.get_card_cost(card_id)
        res = await hdb3.inc_bal(interaction.author.id, cost)
        await interaction.respond(
          embed = discord.Embed(
            title="Balance",
            description=f"Sold Card For: {cost}\n New Balance: {res['bal']}",
            color=self.bot.color
          )
        )
tender charm
#

Hi, I am making ticket system and when I start a discord bot, it will write into TERMINAL this error: async with aiofiles.open("ticket_configs.txt", mode="a") as temp: NameError: name 'aiofiles' is not defined How can I fixed that?

visual island
maiden fable
#

Tf anyways leave it. If my parents saw these messages... They be like, u r seeing the MOST WRONG IMAGE OF MINE

visual island
maiden fable
#

Hehe facts. Anyways leave it

tender charm
unkempt jewel
visual island
unkempt jewel
unkempt jewel
maiden fable
visual island
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
maiden fable
visual island
slate swan
maiden fable
unkempt jewel
slate swan
maiden fable
#

DM your files to Moros, he's gonna help you there

unkempt jewel
slate swan
#

Moros helps me all day in dms 😎 jam_cavedude

brittle ingot
#

The biggest issue with DM help is that there isn't anyone that might be able to check the validity of your help / code. In the server here, a helper or other dev that has more experience, may be able to interject and propose a different solution that is more efficient and easier to read. Making it a learning process for everyone 😄

unkempt jewel
#

holy molly

#

i just checked the logs file

slate swan
unkempt jewel
#

80.000 lines

maiden fable
fair axle
#

how do i generate a 6 digit number using string lib and store it in a variable

slate swan
visual island
#

yeah not a package either

slate swan
#

Share that function then

maiden fable
#

W H E 4 E

unkempt jewel
slate swan
maiden fable
#

Imagine class going on

unkempt jewel
maiden fable
unkempt canyonBOT
#

Source code: Lib/random.py

This module implements pseudo-random number generators for various distributions.

For integers, there is uniform selection from a range. For sequences, there is uniform selection of a random element, a function to generate a random permutation of a list in-place, and a function for random sampling without replacement.

On the real line, there are functions to compute uniform, normal (Gaussian), lognormal, negative exponential, gamma, and beta distributions. For generating distributions of angles, the von Mises distribution is available.

slate swan
fair axle
slate swan
unkempt jewel
#

lemme find it

slate swan
#

Say what now

slate swan
fair axle
#

random.randint(6, 6)??

quick gust
fair axle
maiden fable
#

BTW Misa, try using VSCode instead of sublime if u code often in Python

slate swan
maiden fable
#

Uhhhhhhhhhhh

unkempt jewel
unkempt jewel
#

now i need to fix his problem

maiden fable
#

U need a list of alphabets

slate swan
maiden fable
fair axle
slate swan
visual island
#

too ironic

sick talon
#

hey, i am trying to make a discord bot command which uses the github api, to lists all the repos of a user
but i really don't know how can i make something which gives the user ability to control how many repos they want to see, sort them by stars/forks
rn it looks something like this (check the image below)
also i don't want to break the embed description limit will giving the user the ability to choose how many repos they want to see at a time
ping me on reply, thanks

slate swan
maiden fable
unkempt jewel
#

i used it before

maiden fable
slate swan
maiden fable
slate swan
# unkempt jewel

Lol you coding during ur online classes..? Anyways this function return a dict which has no bal key

kind wind
#

why the vsc gives me an error when i try to run the code?

slate swan
#

Check those internals

maiden fable
kind wind
#

I get an error with the last line which is the bot.run

maiden fable
slate swan
maiden fable
slate swan
quick gust
#

hopefully I don't regret

slate swan
visual island
fair axle
#

someone give me a easy way to generate 6 digit number and save it in a variable?

slate swan
slate swan
slate swan
maiden fable
#

random.randint(100000, 999999)

fair axle
velvet tinsel
#

Lol

slate swan
#
file = open(r"./main/message.txt", "rt")```
file path:```py
C:\Users\User\Desktop\bot\main

why does the code not find the desired text document?

velvet tinsel
#

That’s something I would do

maiden fable
unkempt jewel
sick talon
slate swan
# unkempt jewel yo

No ur users3 func's attr raw_result return something else, tbh ur code is too messy, try to check those functions instead

slate swan
maiden fable
#

This channel is a chaos now 😐

visual island
maiden fable
#

I'mma go get something to eat, cya

fair axle
kind wind
#

I hid the token and the small thing because I used my name to recognize my folder

unkempt jewel
slate swan
fair axle
#

yeah

slate swan
slate swan
visual island
slate swan
slate swan
slate swan
kind wind
visual island
unkempt jewel
visual island
slate swan
slate swan
#

@unkempt jewel i tried to compare a int to a list earlier so im dumber😭

maiden fable
slate swan
visual island
#

so fast

maiden fable
unkempt jewel
#

i think only me come from asian in this channel :/

maiden fable
slate swan
# unkempt jewel

Your db don't return a bal key... Do one thing, just print your res in first file u shared

sick talon
unkempt jewel
maiden fable
#

print(res)

visual island
slate swan
unkempt jewel
#

vietnam here

slate swan
maiden fable
unkempt jewel
slate swan
slate swan
kind wind
#

anyone can help

#

pls?

unkempt jewel
#

yo i know a lots people from indo and know py

slate swan
sick talon
visual island
slate swan
maiden fable
unkempt canyonBOT
#

os.environ```
A [mapping](https://docs.python.org/3/glossary.html#term-mapping) object where keys and values are strings that represent the process environment. For example, `environ['HOME']` is the pathname of your home directory (on some platforms), and is equivalent to `getenv("HOME")` in C.

This mapping is captured the first time the [`os`](https://docs.python.org/3/library/os.html#module-os "os: Miscellaneous operating system interfaces.") module is imported, typically during Python startup as part of processing `site.py`. Changes to the environment made after this time are not reflected in `os.environ`, except for changes made by modifying `os.environ` directly.

This mapping may be used to modify the environment as well as query the environment. [`putenv()`](https://docs.python.org/3/library/os.html#os.putenv "os.putenv") will be called automatically when the mapping is modified.
kind wind
visual island
maiden fable
unkempt jewel
maiden fable
#

Just add the token there

visual island
maiden fable
#

run("token")

visual island
#

using ()

maiden fable
visual island
slate swan
#

Isnt he using vsc why is he hiding his token?

maiden fable
unkempt jewel
#

im almost done the MATH CLASS

maiden fable
slate swan
visual island
kind wind
slate swan
maiden fable
maiden fable
unkempt jewel
#

yo help me aman

slate swan
maiden fable
slate swan
slate swan
brittle ingot
#

wait what? how does VSC hide the token for you?

fair axle
#

i changed my mind i need a random 3 digit code

quick gust
#

@slate swan no offense but what vsc are you on

visual island
maiden fable
brittle ingot
slate swan
#

Yall cant fool me lemonpeek

#

Im dumb but not that dumblemonpeek

maiden fable
#

Can we please..... stop this talk?

visual island
#

I stopped angelAWrun

slate swan
brittle ingot
#

oh i gotcha i thought you mean it literally stores it hidden for you somewhere

slate swan
brittle ingot
#

they apparently only wanted strings

fair axle
#

no i can do str()

#

hehe

brittle ingot
#

oh you wanted the output as a string 😂

unkempt jewel
#

aman it still show the same error

#

ok so too manu asian here, now i think im the youngest :)

slate swan
#

Lol just use random.randint then, first param should be from where u need to start, like 100 for three-digit no, and second should be till where, like 999 for three-digits

unkempt jewel
visual island
#

yeah

slate swan
#

Most people here are probably 14yert

#

Or 14+

brittle ingot
#

wow im tired, i completely misunderstood every part of that question. Thank you for the catch Aman

unkempt jewel
slate swan
visual island
sick talon
slate swan
slate swan
visual island
slate swan
unkempt jewel
#

yo my code still error

#

keyerror "bal"

slate swan
#

Did it print something?

unkempt jewel
#

nah

#

oh yes

kind wind
#

why it says that the command is not found?

unkempt jewel
kind wind
#

I did the same thing with the command above but only put a reply for test

slate swan
#

That's not where u need to use print(), use it in the func which is giving errors

#

use it in on_button_click

sick talon
slate swan
kind wind
#

isnt it

@bot.command():
async def commandname(ctx):
  await ctx.reply("Test")
unkempt jewel
unkempt jewel
#

can u just tell me how to fix it :)

kind wind
#

then why doesnt it work

unkempt jewel
#

english is not my first lang so...

visual island
unkempt jewel
slate swan
slate swan
visual island
kind wind
#

i have the

bot = commands.Bot(command_prefix="v!", intents=discord.Intents.all())
slate swan
kind wind
#

yes

sick talon
slate swan
slate swan
slate swan
slate swan
unkempt jewel
slate swan
#

yes

sick talon
slate swan
# sick talon yeah :)

That route returns 100 per page as default, if you need to limit them, pass per_page field in the body

sick talon
kind wind
#

I had a verify command that i used
Command:

@bot.command()
async def verify(ctx):
    verified = ctx.guild.get_role(roleid)
    notverified = ctx.guild.get_role(roleid)
    await ctx.author.remove_roles(notverified)
    await ctx.author.add_roles(verified)
    await ctx.reply("You have been verified!", delete_after=10)
    await ctx.message.delete(delay=10)

I have put the ids on the place where i say roleid so dont say anything about that. also this command is working fine. My problem is, i copied the async def verify(ctx): and put the other command name but nop

slate swan
#

pass the value whatever user wants to inside the body of the request

slate swan
quick gust
#

It's a decorator

kind wind
#

oof i put that by accident

sick talon
#

you didn't put the other channels id

kind wind
#

but i dont have it in the other command

slate swan
#

The bot doesn't see the command as the decorator isnt correct

sick talon
slate swan
safe fulcrum
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

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

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

slate swan
#

A decorator doesnt have a colon

slate swan
kind wind
#

on both commands

slate nymph
#

when i use bot.fetch its alright

slate swan
#

user isn't in ur cache

safe fulcrum
#
@client.command()
async def send(ctx, user: discord.Member):
  await user.send(files=.\"file.txt")
slate nymph
slate swan
#

did u modify MemberCacheFlags or something else?

slate nymph
#

lol

slate nymph
visual island
slate swan
#

Ummm... enabled intents?

slate nymph
#

no

slate swan
#

enable them

slate nymph
#

fine i ll enable then

slate swan
#

socket isn't sending u any data to prepare any cache

safe fulcrum
#

How to send a .txt file with my bot

slate swan
#

!d discord.File

unkempt canyonBOT
#

class discord.File(fp, filename=None, *, spoiler=False)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for sending file objects.

Note

File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")s.
kind wind
#

It still not works

slate swan
slate swan
slate swan
safe fulcrum
#

oh yes

kind wind
slate swan
#

code:```py
async def on_message(self, message):
# don't respond to ourselves
if message.author == self.user:
return

    if message.content == 'ping':

        file = open(r"id_users.txt", "rt")
        content = file.read()
        file.close()

        user_id_list = [file]
        for user_id in user_id_list:
            user = self.get_user(user_id)

            file2 = open(r"message.txt", "rt")
            content2 = file2.read()
            file2.close()

            await user.send(content2)

error:```py
Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 301, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\User\Desktop\discord\main.py", line 38, in on_message
    await user.send(content2)
AttributeError: 'NoneType' object has no attribute 'send'

help?

#

user is none

kind wind
#

I have 2 commands in the same file but the one works and the second one says that doesn't exist

slate nymph
#

actually how to enable member intent?

slate swan
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot 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

intents = Intents.default()
intents.members = True

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

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

slate nymph
#

i ll do discord.flag.Intents.all()?

slate swan
#

Not discord.flag...? Just discord.Intents.all(), yes

slate nymph
#

oh ok

slate swan
#

all will enable all the intents especially the presences one, which takes a considerable amt of memory

#

If u don't need presences, I prefer enabling only member one

slate nymph
#

inside commands.Bot(intent=Intents.all())

visual island
#

it's intents

#

not intent

slate nymph
#

ok ty

slate swan
slate nymph
#

ok

sick talon
kind wind
slate swan
#

code:```py
class MyClient(discord.Client):
async def on_ready(self):
print('Logged on as', self.user)

async def on_message(self, message):
    # don't respond to ourselves
    if message.author == self.user:
        return

    if message.content == 'ping':

        file = open(r"id_users.txt", "r")
        content = file.read()
        file.close()

        user_id_list = [content]
        for user_id in user_id_list:
            user = self.get_user(user_id)

            file2 = open(r"message.txt", "rt")
            content2     = file2.read()
            file2.close()

            await user.send(content2)
error:
```py
Logged on as Jocks#0932
Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 301, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\User\Desktop\discord\main.py", line 38, in on_message
    await user.send(content2)
AttributeError: 'NoneType' object has no attribute 'send'

why can't I connect the text file id_users.t?

sullen shoal
#

you cant use it there

#

also

#

!ytdl

unkempt canyonBOT
#

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

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

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

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

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

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

well youtube doesnt care about that so we cant either

slate swan
sullen shoal
#

whats fax?

#

good to see you too

slate swan
quick gust
#

a slang for "facts"

sullen shoal
#

oh

slate swan
#

Yeah

kind wind
#

I want to make a submit bot command how can i check if the id given is a real bot?

slate swan
sullen shoal
#

!d discord.User.bot

unkempt canyonBOT
slate swan
#

That^

sick talon
#

where can i paste my long code ?

slate swan
#

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

sick talon
#

thanks

slate swan
#

Yw

#

@sullen shoal pastediscord 😭

slate nymph
#

@slate swan getting the same error after enabling member intents....

slate swan
#

😭

kind wind
#

oof

sullen shoal
#

discord.User.mention

#

will return the str that can be used in a message to mention them

sullen shoal
slate swan
#

@sullen shoal are you a time traveler lemonpeek

sullen shoal
#

i mean it looks like theyre making their ping command using the event

#

when commands extension exists

slate swan
#

😭

#

Bruu

sick talon
#

https://paste.pythondiscord.com/haseqafodu.py @slate swan
||sorry for the really poor code 🥲 ||

i am trying to do this:

First the user types %repo <repo-name>, the user sees a list of repos of total number 10
The user wants a list of total 20, if uses the command %repo <repo-name> 20 then the bot should post an new embed with 20 repo search list
If it exceeds the embed description limit then the bot should send an embed saying that it exceeds the embed description limit ¯_(ツ)_/¯

slate swan
#

Aman is getting pinged so much poor guy😭

glass rock
#

iscord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embed.fields.2.name: This field is required
how can fix this error?

sullen shoal
#

add field name

glass rock
#

i did

sullen shoal
#

show code

glass rock
#

embedVar=discord.Embed(title='To-Do:',color=0x00ff00) for i in json_read(str(message.author),'work.json').split('\n'): embedVar.add_field(name=str(i)+' ',value='\u200b',inline=False) await message.channel.send(embed=embedVar)

#

if i put await inside the loop it works

sullen shoal
#

check value of i

glass rock
#

no it works if i put await inside the loop

sullen shoal
#

then show the code tjat doesnt work

glass rock
#

but it embeds and sends each element as they get added

glass rock
sullen shoal
#

you said it works tho

slate swan
sullen shoal
#

just put the message send method outside

glass rock
#

embedVar=discord.Embed(title='To-Do:',color=0x00ff00)
for i in json_read(str(message.author),'work.json').split('\n'):
embedVar.add_field(name=str(i)+' ',value='\u200b',inline=False)
await message.channel.send(embed=embedVar)

#

this works but if the await is outside the loop it doesnt

slate swan
#

!e

a = "hello world"
for b in a:
    print(b)
unkempt canyonBOT
#

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

001 | h
002 | e
003 | l
004 | l
005 | o
006 |  
007 | w
008 | o
009 | r
010 | l
011 | d
glass rock
sullen shoal
#

ugh fuck it

slate swan
glass rock
kind wind
#

is this code right?

@bot.command()
async def submitbot(ctx):
  if discord.User.mention == userNotFound:
    ctx.reply("User not found")
  elif discord.User.mention != userNotFound:
    ctx.reply("Success!")
  else:
    ctx.reply("An error occured...")
sullen shoal
#

no

#

and im not helping with it. go learn about python classes

slate swan
sullen shoal
#

and OOP

glass rock
kind wind
#

actually

slate swan
kind wind
#

wait

#

i wan the user to put the bot id to check if it exists

#

dont eat me i dont know much python

boreal ravine
#

eat me 😳

kind wind
#

...

#

i give up

slate swan
#

Cough cough

kind wind
#

dont help me

#

thanks but i am leaving

sullen shoal
#

k

slate swan
#

My finger slipt

tawdry perch
#

how do I check if message.author is any bot?

slate swan
slate swan
sullen shoal
tawdry perch
#

oh

slate swan
unkempt canyonBOT
#

property bot```
Equivalent to [`User.bot`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.bot "discord.User.bot")
slate swan
#

is a bool

sullen shoal
#

author can be User so keep that in mind

boreal ravine
#

Yes

sullen shoal
#

User also has this attribute

#

it will be User when Guild is None

#

meaning dms basically

slate swan
#

What that error

sullen shoal
#

ModuleNotFoundError

slate swan
#
import subprocess
from typing import List

import discord
from discord.ext import commands


from disbot.myToken import SECRET_TOKEN

client = discord.Client()
bot = commands.Bot(command_prefix='$')

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


@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith("$hello"):
        await message.channel.send("Hello!")

@bot.command()
async def test(ctx, arg):
    await ctx.send(arg)

client.run(SECRET_TOKEN)

i cant get my test command to work, no response from $test hi. $hello works fine though

slate swan
sullen shoal
#

yes

maiden fable
slate swan
# sullen shoal yes

I think you didnt get it i ment like replit with its errors not asking if it is replit😭

sullen shoal
#

oh yeah replit suck

slate swan
glass rock
slate swan
# maiden fable `await bot.process_commands(message)` in the last line of on_message

like this? i get an error when i run $hello now

@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith("$hello"):
        await message.channel.send("Hello!")
    
    await bot.process_commands(message)
# if self._skip_check(message.author.id, self.user.id):
# AttributeError: 'NoneType' object has no attribute 'id'
sullen shoal
#

those are giving me pain in the ass

maiden fable
boreal ravine
sullen shoal
boreal ravine
unkempt canyonBOT
boreal ravine
#

hm replit error it is then

maiden fable
sullen shoal
#

yeah please

slate swan
#

Most times

boreal ravine
maiden fable
#

So I have something like

self.listeners = {"event-name": []}

for msg in self.ws:
    for function in self.listeners[msg]:
        await function() 
sullen shoal
slate swan
maiden fable
sullen shoal
#

yup

maiden fable
#

!d aiohttp.ClientWebSocketResponse

unkempt canyonBOT
maiden fable
#

This is what u should use

#

There is an example here

sullen shoal
#

im using something called websockets that came first when i searched websockets python lol

maiden fable
boreal ravine
sullen shoal
#

also it was popular so i thought it would be better

maiden fable
#

There's an example

sullen shoal
#

alright looks like i have tp rewrite

#

thanks for the help

maiden fable
#

But the only problem is, your dispatch method would become async

#

But that's fine, since u can always do loop.run_until_complete()

sullen shoal
#

yeah

maiden fable
#

But preferred is to keep it async

slate swan
sullen shoal
#

thanks

slate swan
#

Later guys have a good day or nightyert

sullen shoal
#

gn