#discord-bots

1 messages · Page 437 of 1

pure totem
#

It sucks I delete it then it comes back

upbeat otter
#

Anybody 😭

#

it must be pycache

pure totem
kindred epoch
#

Why in a json file?

wary ravine
pure totem
slate swan
#

Storing in json is bad if you open and close it on every message. Consider using a db

kindred epoch
#

Huh?

upbeat otter
upbeat otter
kindred epoch
upbeat otter
kindred epoch
#

For learning sql: https://sqlbolt.com/

General choices for SQL databases:
sqlite- a liteweight SQL variant, single file, no server. Lacks some features
postgresql - Standard-weight SQL server, very capable, good sql lib.

slate swan
pure totem
#

@slate swan can you help

#

I heard Danny retired rip

heavy belfry
#

ty, but where do i put the bots token for it to connect?

upbeat otter
slate swan
lament mesa
#

commands.bot is a module and its Bot_instance.command() not the class

heavy belfry
#

ty guys :D

unkempt canyonBOT
#

Hey @heavy belfry!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

heavy belfry
#

D:

#

this is the code```import discord
from discord.ext.commands import bot
from discord.ext import commands

bot = commands.Bot(command_prefix="!", help_command=None, intents=discord.Intents.all())

@bot.command('$ping')
async def ping(ctx):
await ctx.send(f"Pong! {round(bot.latency * 1000)}ms")

cunning fiber
#

what are some ways i could create a custom help command?

slate swan
#

I assume you mean pycache? If yes, it's the cache file where your compiled code is stored during the runtime.
You don't need to take care of that much. If you're uploading your code on git repo, make a .gitignore and add those files with correct syntax in the file, and it'll not be uploaded on git

heavy belfry
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.pydis.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.

heavy belfry
cloud escarp
#

I'm new to python

slate swan
# heavy belfry this is the code```import discord from discord.ext.commands import bot from disc...

Remove from discord.ext.commands import bot since it can interfere with your main bot instance, maybe... Also import discord isn't used, so you can remove that too.
You don't need help_command=None unless you need to disable your help command, which I don't think you want. I may be wrong.
You don't need to set prefix in @bot.command(...). You already set the prefix in the Bot constructor, no need to do that again and just write command name

heavy belfry
slate swan
#

In @bot.command(...), you always need to just name the main command, like ping without $, to set $ as the prefix, set the command_prefix equal to $

heavy belfry
slate swan
#

You added the token in it?

heavy belfry
slate swan
#

Try to paste the error, can't guess what's the issue without any traceback blobpain

heavy belfry
slate swan
#

Okay

#

@heavy belfry You enabled intents in the constructor but it's not enabled on your dev portal. Enable them from discord developer portal.
Also have a look at https://vcokltfre.dev/, a pretty good tutorial and guide on dpy

#

It has everything mentioned about basics of dpy, also about intents ^

heavy belfry
slate swan
#

or

heavy belfry
# slate swan or

what you sent, i had already done that, either im big dum and have missed something or.. well idk

slate swan
#

No idea then, error says you have not ¯_(ツ)_/¯

heavy belfry
#

O, i copied and pasted what was on the website and that didnt come with any errors!

bitter kite
#

I just saw that you can post a private message in a channel - visible for only one user. How to do that?

crisp sphinx
#

I am trying to make a server info command and i have one embed field with total members but i cant find a way to calculate the total bots and humans. I can only find the total members but I want to include total bots and humans

slate swan
#

What examples can I see that requires presence intents

toxic flint
#

Guys does anyone know any good alternatives to discord.py as a Python discord API wrapper?

unkempt canyonBOT
maiden fable
#

releasing soon, but the features are amazing 😄

toxic flint
#

@maiden fable will it have completely different functions to dpy?

maiden fable
#

no

#

same syntax 😄

boreal ravine
#

Do try excepts work with command cooldowns?

lament mesa
#

yes

#

But you can't use it inside the command itself

boreal ravine
#

okay

valid patio
#

how can i make my bot run even if my pc is off ?

lament mesa
#

Host it on a vps

valid patio
#

and is it possible to do that

valid patio
lament mesa
#

Use a vps

twin shadow
lament mesa
#

Why?

valid patio
#

any free vps's ?

lament mesa
#

heroku

wary ravine
#

can anyone help me use the bot token regex to make a piece of code to delete a message if it contains a token please

twin shadow
#

idk, im just complaining lol. trying to learn it but im a dumb fuck KEKW

valid patio
lament mesa
valid patio
#

ok

valid patio
valid patio
vale pendant
slate swan
#
@bot.command()
async def code908(ctx):
    embed = discord.Embed(
        description=f"""**Ranks**

            **#1 @Owner / Founder / CEO **
            **#2 @Co Owner / CFO **
            **#3 @Developer **
            **#4 @Admin **
            **#6 @Staff **
            **#7 @Helper **
            **#8 @[HR] Member **
            **#9 @[V] Elite **
            **#10 @[IV] Advanced **
            **#11 @[III] Intermediate **
            **#12 @[II] Novice **
            **#13 @[I] Member **


            **All ranks have different perks, Premium / Premium + / Premium ++ Are limited ranks, they are earned as rewards for events and staff spotting out active people, thank you.**"""
        colour=0x3D9AF2)

    await ctx.send(embed=embed)``` what's wrong with this?
cloud dawn
#

!source

unkempt canyonBOT
cloud dawn
#

although there is no regex that works 100%

slate swan
cloud dawn
#

levelling

slate swan
#
@bot.command()
async def code908(ctx):
    embed = discord.Embed(
        description=f"""**Ranks**

        **#1 @Owner / Founder / CEO **
        **#2 @Co Owner / CFO **
        **#3 @Developer **
        **#4 @Admin **
        **#6 @Staff **
        **#7 @Helper **
        **#8 @[HR] Member **
        **#9 @[V] Elite **
        **#10 @[IV] Advanced **
        **#11 @[III] Intermediate **
        **#12 @[II] Novice **
        **#13 @[I] Member **


        **All ranks have different perks, Premium / Premium + / Premium ++ Are limited ranks, they are earned as rewards for events and staff spotting out active people, thank you.**"""
        colour=0x3D9AF2)```What's wrong here?
cloud dawn
slate swan
#

oh thanks

cloud dawn
#

tak?

slate swan
cloud dawn
#

I don't understand

wary ravine
slate swan
#

without import leveling

#

@cloud dawn

cloud dawn
slate swan
slate swan
wary ravine
#

why is your font so large

slate swan
wary ravine
#

if serverstats['Antispam'] is True: get rid of is, why is it even there

elfin pewter
#

i want create py bot on danbot but i cant. help me please. what i should

wary ravine
#

get rid of is True as a matter of fact, you don't need them

elfin pewter
#

@wary ravine help me please

#

i want create bot

wary ravine
#

@slate swan don't invite me to your servers

cloud dawn
marsh depot
#

Hello, I was wondering how I could do the following:

If I have the bot on more than one server and I only want it to send welcome messages, goodbye to a specific server, how could I do it?

That is, it only sends those messages if someone joins a specific server that the bot sends a welcome message if it gets on that specific server, not on another that is the bot

I do not know if I explained well

elfin pewter
cloud dawn
elfin pewter
#

yes

wary ravine
elfin pewter
#

how to combine bot token and my process

marsh depot
cloud dawn
sly hamlet
#

i made a fork of discord.py and have i seet it up but do not how do i import it

slate swan
#

fghj

wary ravine
marsh depot
cloud dawn
hoary gust
#

Guys suggest me a cmd

#

I wanna make somthing new

wary ravine
hoary gust
#

Ah I see

wary ravine
#

have a go at making a morse code translator

marsh depot
minor totem
#

@elfin pewter what are you trying to do?

wary ravine
hoary gust
#

@marsh depot explain ur issue

marsh depot
# hoary gust <@720332640498221106> explain ur issue

Hello, I was wondering how I could do the following:

If I have the bot on more than one server and I only want it to send welcome messages, goodbye to a specific server, how could I do it?

That is, it only sends those messages if someone joins a specific server that the bot sends a welcome message if it gets on that specific server, not on another that is the bot

I do not know if I explained well

hoary gust
#

@marsh depot fetch the id and get the channel and send it

#

Fetch the guild

#

Then get the channel u want it to send msges in

cloud dawn
wary ravine
#

fetch is an api call, using get would be better

hoary gust
#

@cloud dawn ofc we need to fetch the guild first

marsh depot
hoary gust
#

@marsh depot just make a list and save ur guild id in it

ionic wadi
#

Ignoring exception in on_message
Traceback (most recent call last):
File "/home/container/.local/lib/python3.9/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "/home/container/bot.py", line 36, in on_message
users = json.load(f)
File "/usr/local/lib/python3.9/json/init.py", line 293, in load
return loads(fp.read(),
File "/usr/local/lib/python3.9/json/init.py", line 346, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.9/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/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 1 column 1 (char 0)

async def on_member_join(member):
    with open('users.json', 'r')as f:
        users = json.load(f)
        
    await update_data(users, member)
        
    with open('users.json', 'w') as f:
        json.dump(users, f) 
    channel = bot.get_channel(881094340087283722)
    embed=discord.Embed(title=f"Welkom {member.name}", description=f"Bedankt voor het joinen van {member.guild.name}!", colour = random.choice(colors)) # F-Strings!
    embed.set_thumbnail(url=member.avatar_url) # Set the embed's thumbnail to the member's avatar image!

    await channel.send(embed=embed)
    
@bot.event
async def on_message(message):
    with open('users.json', 'r')as f:
        users = json.load(f)
    
    await update_data(users, message.author)
    await add_experience(users, message.author, 5)
    await level_up(users, message.author, message.channel)
        
    with open('users.json', 'w') as f:
        json.dump(users, f) 
        
async def update_data(users, user):
    if not user.id in users:
        users[user.id] = {}
        users[user.id]['experience'] = 0
        users[user.id]['level'] = 0
        
async def add_experience(users, user, exp):
    users[user.id]['experience'] += exp
    
async def level_up(users, user, channel):
    experience = users[user.id]['experience']
    lvl_start = users[user.id]['level']
    lvl_end = int(experience ** (1/4))
    
    if lvl_start < lvl_end:
        await bot.send_message(channel, '{} is een level omhoog, en is nu level {}'.format(user.mention, lvl_end))
        users[user.id]['level'] = lvl_end ```
hoary gust
#

No maybe not

wary ravine
cloud dawn
hoary gust
#

@wary ravine yep

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.

ionic wadi
wary ravine
#

get_... > fetch_...

cloud dawn
#

best fetch/get system is ```py
guild = bot.get_guild(2347234792347) or await bot.fetch_guild(23432423432)

hoary gust
#

Fetch api call

ionic wadi
wary ravine
marsh depot
#

¿?

ionic wadi
ionic wadi
cloud dawn
high flame
#

but okay

marsh depot
#

ty

cloud dawn
void fox
#

when someone connects to the my server nothing happens!
code:

import discord
from discord.ext import commands
from datetime import datetime
from discord import Game

client = commands.Bot(command_prefix=".")


@client.event
async def on_ready():
    print("Bot is ready!")



@client.event
async def on_member_join(member):
    channel = client.get_channel(id=882282531276345416)
    embed = discord.Embed(title=f"{member.mention}", description="Test")

    embed.set_author(name="New member")
    embed.set_footer(text="footer text")

    await channel.send(embed=embed)


client.run('TOKEN')


cloud dawn
void fox
#

Exception ignored in: <function _ProactorBasePipeTransport.del at 0x000001805D299EE0>
Traceback (most recent call last):
File "D:\python\lib\asyncio\proactor_events.py", line 116, in del
File "D:\python\lib\asyncio\proactor_events.py", line 108, in close
File "D:\python\lib\asyncio\base_events.py", line 746, in call_soon
File "D:\python\lib\asyncio\base_events.py", line 510, in _check_closed
RuntimeError: Event loop is closed

void fox
cloud dawn
#

This is a new one

wary ravine
#

i'm sure we can yes

void fox
wary ravine
#

color

cloud dawn
#

Replace # with 0x so 0xFFC0CB not in a string

high flame
#

replace # with 0x

wary ravine
final iron
#

I'm guessing its possible to find the amount of emoji's a server has by looping through a list I just need some help with it because im terrible with looping through lists and arrays

sly hamlet
#

i made a fork of discord.py and have i seet it up but do not how do i import it how do i

void fox
cloud dawn
void fox
#

yes

wary ravine
cloud dawn
marsh depot
#

@cloud dawn all good , ty for your help

void fox
marsh depot
cloud dawn
vale pendant
sly hamlet
cloud dawn
void fox
cloud dawn
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.

sly hamlet
cloud dawn
sly hamlet
cloud dawn
#

I don't understand so you only want to change the name?

sly hamlet
#

just want to import it

cloud dawn
vale pendant
unkempt canyonBOT
#

Hey @void fox! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me

Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!

final iron
#

I'm trying to list the amount of roles a server but its only listing 2 instead of 60 . This is the code

        amount_of_roles = 0
        for member in ctx.guild.members:
            for role in member.roles:
                amount_of_roles += 1
slate swan
#

GUYS SOMEBODYYY HELP ME WITH HEROKU PLEASE

#

pleaseee help

sly hamlet
slate swan
#

ive been working on this for like 4 days and i cant give up now

cloud dawn
minor totem
void fox
#

i changed the token but it still doesn't work!
and i get a error:RuntimeError: Event loop is closed

slate swan
#

like it keeps givin me this error

sly hamlet
minor totem
slate swan
slate swan
#

outdated python version

minor totem
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.pydis.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
#

delete the lock file and hope for the best

slate swan
unkempt canyonBOT
#

Hey @slate swan!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

slate swan
#

its too big

slate swan
#

use the paste service

#

don't paste it directly here

cloud dawn
minor totem
unkempt canyonBOT
#

Hey @slate swan!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

slate swan
#

!paste

cloud dawn
hoary gust
#

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

!paste

cloud dawn
void fox
slate swan
#

ahrhr someoneee helpppp

minor totem
void fox
minor totem
cloud dawn
minor totem
# void fox pycharm!

Wait what Python version is this? Because that is indeed a very odd error 😅

cloud dawn
slate swan
# minor totem ahrhrhr pleaseeeee send the tracebaaaaaaaacck

TypeError: 'Lock' object is not iterable

2021-08-31T18:35:25.339381+00:00 app[worker.1]: Unclosed client session

2021-08-31T18:35:25.339382+00:00 app[worker.1]: client_session: <aiohttp.client.ClientSession object at 0x7f0b768e6550>

2021-08-31T18:35:25.499954+00:00 heroku[worker.1]: Process exited with status 1

2021-08-31T18:35:25.610673+00:00 heroku[worker.1]: State changed from up to crashed

#

thats the end one

final iron
void fox
#

python 3.9

cloud dawn
void fox
stark junco
#

Hey, I'm new to this server, and um you have to have a verified account to add bots to your own server right?

minor totem
minor totem
minor totem
# void fox

Huh, I presume this is the version on PyPi (pip)?

minor totem
minor totem
cloud dawn
slate swan
#

can i dm u now?

stark junco
minor totem
slate swan
#

kayy.

#

2021-08-31T18:35:25.300497+00:00 app[worker.1]: await super().send(data)

2021-08-31T18:35:25.300505+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/site-packages/websockets/protocol.py", line 371, in send

2021-08-31T18:35:25.300682+00:00 app[worker.1]: yield from self.write_frame(opcode, data)

2021-08-31T18:35:25.300691+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/site-packages/websockets/protocol.py", line 740, in write_frame

2021-08-31T18:35:25.300906+00:00 app[worker.1]: with (yield from self._drain_lock):

2021-08-31T18:35:25.300938+00:00 app[worker.1]: TypeError: 'Lock' object is not iterable

2021-08-31T18:35:25.339381+00:00 app[worker.1]: Unclosed client session

2021-08-31T18:35:25.339382+00:00 app[worker.1]: client_session: <aiohttp.client.ClientSession object at 0x7f0b768e6550>

2021-08-31T18:35:25.499954+00:00 heroku[worker.1]: Process exited with status 1

2021-08-31T18:35:25.610673+00:00 heroku[worker.1]: State changed from up to crashed

#

thts the whole error

#

finalllyyyyy

void fox
#

i update the pip but doesn't work it!

stark junco
#

I still cant make bots! Anoying

minor totem
minor totem
slate swan
void fox
#

i can't 😩

slate swan
#

bluenix is now surrounded by dum idiots 🤣

minor totem
minor totem
#

RESET IT ASAP

void fox
# minor totem Are you sure that is all of the output? I am thinking that there may be an error...

Traceback (most recent call last):
File "D:\python\lib\site-packages\discord\http.py", line 300, in static_login
data = await self.request(Route('GET', '/users/@me'))
File "D:\python\lib\site-packages\discord\http.py", line 254, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized

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

Traceback (most recent call last):
File "D:\discord\main.py", line 31, in <module>
client.run('za2l0l9VScNUMaHkIQisyASQAnsBy2Ul')
File "D:\python\lib\site-packages\discord\client.py", line 723, in run
return future.result()
File "D:\python\lib\site-packages\discord\client.py", line 702, in runner
await self.start(*args, **kwargs)
File "D:\python\lib\site-packages\discord\client.py", line 665, in start
await self.login(*args, bot=bot)
File "D:\python\lib\site-packages\discord\client.py", line 511, in login
await self.http.static_login(token.strip(), bot=bot)
File "D:\python\lib\site-packages\discord\http.py", line 304, in static_login
raise LoginFailure('Improper token has been passed.') from exc
discord.errors.LoginFailure: Improper token has been passed.
Exception ignored in: <function _ProactorBasePipeTransport.del at 0x0000020BCFCC9DC0>
Traceback (most recent call last):
File "D:\python\lib\asyncio\proactor_events.py", line 116, in del
self.close()
File "D:\python\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "D:\python\lib\asyncio\base_events.py", line 746, in call_soon
self._check_closed()
File "D:\python\lib\asyncio\base_events.py", line 510, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

Process finished with exit code 1

minor totem
#

CHANGE YOUR TOKEN IMMEDIATELY

hoary gust
#

Guys someone suggest me a command

minor totem
hoary gust
#

@minor totem wth

minor totem
#

You tell me, why doesn't it work in the first place?

hoary gust
#

Lol

sly hamlet
#

i made a fork of discord.py how do i cahnge the import from discord to echodiscord

hoary gust
#

🤣🤣

slate swan
#

"NameError: name 'music' is not defined"

import discord
from discord.ext import commands

cogs = [music]

client = commands.Bot(command_prefix='!', intents = discord.Intents.all())

for i in range(len(cogs)):
    cogs[i].setup(client)


client.run("TOKEN")
minor totem
hoary gust
#

Someone suggest me a command

void fox
#

so idk

sly hamlet
cloud dawn
minor totem
hoary gust
#

@cloud dawn what are this commands?

final iron
#

I'm trying to get the owner of a guild with ctx.guild.ownerbut its returning a None value

cloud dawn
hoary gust
#

Ok and any other suggestion?

cloud dawn
stark junco
vale pendant
minor totem
hoary gust
#

Anything more?? 😅

cloud dawn
vale pendant
slate swan
#

Hey, is it possible to start a Discord Bot via a Webpanel? Like pressing a button on the website and then it starts the bot

cloud dawn
cloud dawn
slate swan
cloud dawn
cloud dawn
hoary gust
#

!eval

unkempt canyonBOT
#
Command Help

!eval [code]
Can also use: e

*Run Python code and get the results.

This command supports multiple lines of code, including code wrapped inside a formatted code
block. Code can be re-evaluated by editing the original message within 10 seconds and
clicking the reaction that subsequently appears.

We've done our best to make this sandboxed, but do let us know if you manage to find an
issue with it!*

hoary gust
#

!eval source

unkempt canyonBOT
#
Bad argument

Unable to convert '!eval' to valid command, tag, or Cog.

hoary gust
#

!source eval

unkempt canyonBOT
#
Command: eval

Run Python code and get the results.

Source Code
slate swan
cloud dawn
#

😂

vale pendant
cloud dawn
#

Sorry, couldn't help myself. This is pretty custom so you'd need to make it yourself unfortunately.

slate swan
#

Because i searched for a tutorial but i couldnt find one. Im just to stupid to find out how to start a discord bot via website

cloud dawn
#

I recommend quart

slate swan
cloud dawn
hoary gust
#

Guys do you know a MySQL db hosting service

#

You*

cloud dawn
# slate swan ok

So like i said: "This is pretty custom so you'd need to make it yourself unfortunately.".
So we can help a bit but you first need an actual site running first.

cloud dawn
hoary gust
#

@cloud dawn I think it's paid

#

Right?

slate swan
cloud dawn
hoary gust
#

@cloud dawn but why?

maiden fable
#

Uhhh, cz they wanna earn profit.....?

cloud dawn
void fox
cloud dawn
#

Developing = investing, if you are not willing to invest you can't have the nice toys.

hoary gust
#

Any online SQL db that is free to run for a period of time like mongo?

cloud dawn
#

None that i know of, but hey i do everything on local host.

hoary gust
#

I will have to keep my pc on for 24*7 and I can't do that

cloud dawn
#

So it's not even finished why would you want to run it then?

hoary gust
#

@cloud dawn my bot is lacking speed with mongo I want to Increase that speed

hoary gust
#

MySQL is the fastest right?

cloud dawn
#

postgresql is the fastest.

#

Well gl guys i'm gonna sleep.

#

that ) is looking rather green

#

Now i'm gonna sleep

#

You missed an "

slate swan
prisma wedge
#
 @commands.command(brief="gives you the digits of pi that Python knows")
  async def pi(self, ctx):
    await ctx.send(math.pi)

  @commands.command(brief="reverses text")
  async def reverse(self,ctx,*,args=None):
    if args:

      reversed = args[::-1]

      await ctx.send(content = f"{reversed}", allowed_mentions=discord.AllowedMentions.none())
      
    if args is None:
      await ctx.send("Try sending actual to reverse")```
#

how would i make these into non cog form

high flame
slate swan
high flame
high flame
prisma wedge
#

I got it nvm

sour basalt
#

This grey line
how put this in embed

kindred epoch
sour basalt
#

Thanks

gritty flame
#

why doesnt view kwarg work in

#

dpy

final iron
#

I'm trying to display the time a guild was created using guild.created_at but its showing down to the milliseconds. I don't know how to format the time and its not allowing me to splice off the numbers so could I have some help?

#

Really all I need to know is either how to splice the result or how to format the time

kindred epoch
#

use datetime.timedelta

final iron
steady flume
#

guys pls help solve it

waxen granite
#
            if ctx.channel.id not in limitedChannels:
                if commandInvoker != self.ownerid:
                    await ctx.channel.send(f"{commandInvoker.mention}, this command isn't allowed here.")
                    raise commands.CommandError('The command is limited.')```
#

i am trying if the commandInvoker is owner it should pass it

#

but it still raises error

opaque trail
# final iron How would I implement that?

guild.created_at returns the timestamp of the guild creation in UTC
so, to get the datetime object do:

from datetime import datetime

guild_creation_date = datetime.utcfromtimestamp(guild.created_at)
print(guild_creation_date)  # incase you dont like the format change it using .strftime (google)
steady flume
opaque trail
final iron
final iron
#

Then I just have an f string

#

Sending created_at

opaque trail
#

replace commandInvoker by commandInvokerId

opaque trail
#

Oh i get it, the docs werent clear about the behavior of created_at, turns out it already returns a datetime.datetime object so you can just do this:

await ctx.send(ctx.guild.created_at)  # Again if you dont like the format use .strftime
steady flume
#

how solve it

#

??

visual yarrow
#

In discord.py, does anyone happen to know if VoiceChannel.voice_states is guaranteed to be at least as up-to-date as VoiceChannel.members? I don't think the documentation is entirely clear about this.

#

It seems that if you start the bot when there are people already in a voice-channel, that VoiceChannel.voice_states will contain those members, and VoiceChannel.members will not.

slate swan
# visual yarrow In discord.py, does anyone happen to know if `VoiceChannel.voice_states` is guar...

VoiceChannel.members is basically the list of member objects of IDs you get from the key of the mapping of VoiceChannel.voice_states.
Bot's internal cache is prepared after the startup but I guess API only returns the ID and their voice states with the channel data, and not the whole Member object, so dpy just try to form those objects using the stored cache.

Basically you need voice_state intents to receive the low level .voice_states, and if you also have member intents to cache the members, you can also get the list of complete member objects using .members.

#

But from docs it seems like voice_states can guarantee accuracy

pliant gulch
#

The API does not need to return the member data from the channel

#

As the guild is cached as well as its properties, i.e memebers

slate swan
#

Oh then it's like when you don't request or have member data coz of missing intents?

pliant gulch
#

Just for whatever reason seems like member isn't cached anyhow since voice_states and members both use the same method except members also uses get_member

slate swan
sour basalt
#

how to add role to ctx.author

slate swan
#
so i wanna purge a user messages how do i add that to the command
``` ![aPES_Think](https://cdn.discordapp.com/emojis/493353113332219924.webp?size=128 "aPES_Think")
slate swan
#

!d discord.Member.add_roles

unkempt canyonBOT
#

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

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

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

What

#

how use

slate swan
unkempt canyonBOT
#

await purge(*, limit=100, check=None, before=None, after=None, around=None, oldest_first=False, bulk=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.

You must have the [`manage_messages`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to delete messages even if they are your own (unless you are a user account). The [`read_message_history`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission is also needed to retrieve message history.

Internally, this employs a different number of strategies depending on the conditions met such as if a bulk delete is possible or if the account is a user bot or not.

Examples

Deleting bot’s messages
sour basalt
#

for ctx author

slate swan
sour basalt
#

idk

slate swan
pliant gulch
slate swan
#

Add a check func to return true when your user is one you need @slate swan

#

Members are cached by member intents, right? If voice is present, you'll receive VoiceState which you're getting in the low level method voice_states, but for members, you need to have members intent to cache members

gleaming torrent
#

Hello

#

how do I add character limits for messages? In discord.py

pliant gulch
slate swan
#

Yes it won't work. You need to have Voice state intent for voice_states to work, and for members to work, you also need to have members intent along with voice state

slate swan
pliant gulch
gleaming torrent
#

Heya

#

How do I add character limits for words

#

like

#

eeeeeeeeeeeeeee

#

to prevent that?

pliant gulch
slate swan
slate swan
gleaming torrent
#

Anyone knows how to fix that?

pale turtle
gleaming torrent
cursive spindle
#

how i can change voice channel user limit?

pale turtle
#

!d discord.VoiceChannel.edit

unkempt canyonBOT
#

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

Edits the channel.

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

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

There is a user_limit kwarg that accepts integers.

cursive spindle
#

Enable tracemalloc to get the object allocation traceback

pale turtle
#

Did you await it?

cursive spindle
#

await voice_channel.edit(user_limit=10)

pale turtle
#

!paste Can you show full traceback please?

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.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.

visual yarrow
slate swan
visual yarrow
#

Just checking my understanding.

slate swan
# visual yarrow So, to explain why the bot was able to get the member if they joined the voice-c...

I'm not sure if bot can get the member once after they join since I never worked with voice. But yes, the voice_state_update event contains the member id whose state is changed as the key and VoiceState object as the corresponding value, like the payload described in https://discord.com/developers/docs/resources/voice#voice-state-object

Yes I think bots cache those members returned in event update unless you've set MemberCacheFlags.voice = False.

visual yarrow
#

Right, thanks for the help!

slate swan
south kayak
#

Ok. Last time I will ask something here

#

I need to know how to parse a message AND DM the author of the message, knowing that on_message method only can have as argument the message

#

How can i do this?

slate swan
#
@bot.command()
async def codep(ctx):
    embed = discord.Embed(
        description=f"React below for the roles"

        colour=0x3D9AF2)

    await ctx.send(embed=embed)``` Why is this an invalid syntax?
#

@trail flower

#

@rancid inlet

trail flower
forest blade
#

Looks like you are missing a comma between your embed arguments

#

Probably shouldn’t ping people, someone will help when they can

slate swan
#

oh yeah thanks

#

but they're helpers?

#

it's their job

forest blade
#

They are volunteers that use their free time to help

kindred epoch
gritty flame
#

i subclassed commands.Bot

#

how would i

#

add bot.owner

floral crypt
#

helo

brittle remnant
#

can you make a bot disconnect people from voice channels

floral crypt
#
        msg_id = 881859325063200841
        canal_sugerencias = guild.get_channel(881858899379118080)
        mensaje_sugerencias = canal_sugerencias.get_partial_message(881859325063200841)
        if payload.message_id == msg_id:

            if str(payload.emoji) == ':soyfonSugerencia:':
                await payload.member.send('Envía tu sugerencia, recuerda que todas las sugerencias deben ser serias, en caso contrario podrás ser sancionado, muchas gracias. Escribe `cancelar` para salir.')
                await mensaje_sugerencias.remove_reaction(':soyfonSugerencia:', payload.member)
                def check(m):
                    return m.channel.id == payload.member.id and m.author == payload.member
                message1 = await bot.wait_for('message', check=check)
                if message1.content.lower() == 'cancelar':
                    await payload.member.send('Sugerencia cancelada.')
                    return
                
                else:
                    with open("sugerencias.txt") as read_file:
                        executed = int(read_file.readline().strip())
                    titulo_sugerencia = f'Sugerencia #{executed}'
                    executed += 1
                    descripcion_sugerencia = message1.content
                    embed_sugerencia = discord.Embed(title=titulo_sugerencia, description=descripcion_sugerencia, color=0xb522ba)
                    embed_sugerencia.set_footer(text=payload.member, icon_url=payload.member.avatar_url)
                    await canal_sugerencias.send(embed=embed_sugerencia)
                    await payload.member.send('Sugerencia enviada.')
                    with open("sugerencias.txt") as write_file:
                        write_file.write(str(executed))
                        write_file.close()```
#

the embed is not being sent

brittle remnant
#

just make it so it dose

#

now

#

can you make a bot disconnect people from voice channels

floral crypt
#

and if i message1.content = 'cancelar' then its not printing what it should

floral crypt
brittle remnant
#

just make it work

#

by coding

#

or smt

brittle remnant
#

cool

gritty flame
brittle remnant
#

uuuuu

#

i can jst google

#

why

gritty flame
#

@brittle remnant await member.edit(voice_channel = None)

brittle remnant
#

thats class

#

tnx

gritty flame
#

dont do voice_channel

gritty flame
#

well yeh voice_channel

#

lol

gritty flame
#

works for me @brittle remnant

brittle remnant
#

r u talking to me

gritty flame
#

wait no

#

noo no my bad

brittle remnant
#

show some respect

#

to the elderly

gritty flame
#

sorry sorru

#

huh how old are you

brittle remnant
#

16

gritty flame
#

nah its alright just move on

brittle remnant
#

i was j jk

gritty flame
#

ik

#

lets just move on

#

i dont wana get in trouble

brittle remnant
#

k

blazing coral
#

keep getting a syntax error saying somthings wrong with the a in await in my code any idea why it looked good to me

#

@client.command()
async def random(ctx, number = random.randint(1000, 9999)
await ctx.send("The number is ", number)

floral crypt
#

Error

blazing coral
#

yes

floral crypt
#

Ah yes, good error

prisma wedge
#
@client.command()
async def dropdown(ctx):
  await ctx.send('testing for help command',
                  components=[
                    Select(placeholder='Select Something!', options=[SelectOption(label='A', value='a'), SelectOption(label='B', value='b')])
                  ]
          )
  interaction = await client.wait_for("select_option", check=Lambda i: i.component[0].value=="a")
  await interaction.respond(content=f"You clicked the 'A' value!")```
#
File "main.py", line 1043
    interaction = await client.wait_for("select_option", check=Lambda i: i.component[0].value=="a")
                                                                      ^
SyntaxError: invalid syntax```
#

error

kindred epoch
#

and idek why you have that check

#

you want the user to click the a and not the b?

vagrant brook
#

python is case sensitive so lambda and not Lambda

valid niche
#

You forgot an await

floral crypt
#

And if message1.contwnt is cancelar

#

Not sending sugerencia cancelada

#

I think its something of the check

twin shadow
#

`--- Help ---

info

Commands

.help
Opens the help page, where information about the bot is stored along with all of the commands.

.play
Starts a game of Rock, Paper, Scissors, Shoot.`

#

^

#

how can i send a message like the one above through a bot?

floral crypt
#

Is this ok for a dm

valid niche
floral crypt
#

Okay

slate swan
#

when i go to run this code it says "expected an indented block" how do i fix this

slate swan
prisma wedge
#

i have this code

#
@client.command()
async def selectmenu(ctx):
  await ctx.send("Pick one of the buttons.", components = [Select(placeholder="Select One Of The Values", options=[SelectOption(label="A", value="A"), SelectOption(label="B", value="B")])])

  interaction = await client.wait_for("select_option", check = lambda i: i.component[0].value == "A")

  await interaction.respond(content = f"You have selected `{interaction.component[0].label}`")

  interactionb = await client.wait_for("select_option", check = lambda i: i.component[1].value == "B")

  await interactionb.respond(content = f"You have selected `{interactionb.component[1].label}`")```
#
    result = condition(*args)
  File "main.py", line 1040, in <lambda>
    interaction = await client.wait_for("select_option", check = lambda i: i.component[0].value == "A")
TypeError: 'Select' object is not subscriptable

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

and this error

slate swan
#

ok so now its saying " 'Client' object has no attribute 'command' "

sage otter
#

Are you using discord.Client or using one of the bot classes from the commands extension?

sage otter
forest vortex
slate swan
#

How do i get a discord bot to join a call

dapper cobalt
slate swan
#

Voice channel

dapper cobalt
unkempt canyonBOT
#

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

An abstract method called when the client initiates the connection request.

When a connection is requested initially, the library calls the constructor under `__init__` and then calls [`connect()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.VoiceClient.connect "discord.VoiceClient.connect"). If [`connect()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.VoiceClient.connect "discord.VoiceClient.connect") fails at some point then [`disconnect()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.VoiceClient.disconnect "discord.VoiceClient.disconnect") is called.

Within this method, to start the voice connection flow it is recommended to use [`Guild.change_voice_state()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Guild.change_voice_state "discord.Guild.change_voice_state") to start the flow. After which, [`on_voice_server_update()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.VoiceClient.on_voice_server_update "discord.VoiceClient.on_voice_server_update") and [`on_voice_state_update()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.on_voice_state_update "discord.on_voice_state_update") will be called. The order that these two are called is unspecified.
dapper cobalt
#

I think that should work.

slate swan
#

Thanks

dapper cobalt
#

No problem.

wooden viper
#

Hey how do you assign a color when creating a role?

#

await ctx.guild.create_role(name=color, color="0x" + colorhex[1:])

#

this is what im doing but its not right

#

colorhex is this
#ffffff

uncut harness
#

!eval

#

!eval ```py
print("Hello?")

unkempt canyonBOT
#

@uncut harness :white_check_mark: Your eval job has completed with return code 0.

Hello?
wooden viper
#

!d set role color

unkempt canyonBOT
#
set

class set([iterable])``````py

class frozenset([iterable])```
Return a new set or frozenset object whose elements are taken from *iterable*. The elements of a set must be [hashable](https://docs.python.org/3.10/glossary.html#term-hashable). To represent sets of sets, the inner sets must be [`frozenset`](https://docs.python.org/3.10/library/stdtypes.html#frozenset "frozenset") objects. If *iterable* is not specified, a new empty set is returned.

Sets can be created by several means:

• Use a comma-separated list of elements within braces: `{'jack', 'sjoerd'}`

• Use a set comprehension: `{c for c in 'abracadabra' if c not in 'abc'}`

• Use the type constructor: `set()`, `set('foobar')`, `set(['a', 'b', 'foo'])`...
zinc geyser
#

is there an equivalent of break for if

visual island
#

but you can do like

if True:
    print("hi")
    raise
    print("won't be printed") 
slate swan
#

how can i make a bot that sends a announcement message in each existing channel with discord.py

outer violet
#

did anyone here switch to hikari yet ._.

soft trout
#

if u use dislash for slash commands how long would it take to load the slash commands?

proud shoal
#

how do I make a status for my bot?

stark bobcat
proud shoal
#

@client.event
async def on_ready():
print('client is online')
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=str(len(client.guilds)) + ' servers | ' + str(len(set(client.get_all_members()))) + "My Prefix Is G, Gcommands"))

#

this is it but for some reason its adds "1"

last moss
#
                                channel=dormant.channels[x]
                                await channel.move(category=avaliable)
                                await channel.send(embed=avaliableEmbed)
                                await asyncio.sleep(0.2)
#

Im getting a textChannel does not have move attribute error

#

but

#

!d discord.TextChannel.move

unkempt canyonBOT
#

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

A rich interface to help move a channel relative to other channels.

If exact position movement is required, [`edit()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.TextChannel.edit "discord.TextChannel.edit") should be used instead.

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

Note

Voice channels will always be sorted below text channels. This is a Discord limitation...
last moss
#

it is?

boreal ravine
proud shoal
#

if its working since I make changes to it daily

kindred epoch
slate swan
#

how can you make a bot send the same message to all existing channels with discord.py?

lean lance
#

discord.py won't work or won't be continued anymore?
I'm using google translator *

slate swan
visual island
slate swan
kindred epoch
#

Then iterate through all the channels and then send it

visual island
#

ratelimit, be careful

kindred epoch
#

^

#

And idk why you want to do that

slate swan
slate swan
kindred epoch
#

Everyone role exists

slate swan
kindred epoch
#

Announcement channel exists

oak quest
#

is it even worth it if i make my commands that work with prefix ?

slate swan
visual island
kindred epoch
oak quest
kindred epoch
#

Anyone would write a would that is a command and the bot for some reason sends something

kindred epoch
#

And thats what discord wants us to do so

oak quest
kindred epoch
#

No way out

oak quest
visual island
#

it's just will be changed to priviledge intents

#

not removed

kindred epoch
kindred epoch
visual island
#

i don't want to verify my bot either

kindred epoch
#

Welp, I already sent the application

#

Hope it does not get striked for inorganic growth

#

Well, I think I'll be fine

hearty edge
#

Slash commands sucks

final iron
#

I want to create a command that shows images off certain subreddits

#

I'm guessing I would use the Reddit api

#

But I've never used it and I have no idea how to get started

lament mesa
#

There is a library named async praw which is a wrapper for the reddit api

final iron
#

How's the documentation for it?

lament mesa
#

!pypi async praw

unkempt canyonBOT
lament mesa
#

not that

#

!pypi asyncpraw

unkempt canyonBOT
#

Async PRAW, an abbreviation for `Asynchronous Python Reddit API Wrapper`, is a python package that allows for simple access to reddit's API.

lament mesa
#

That

slate swan
celest zinc
#

how do i get my discord bot to retreive the number of members in my server

twin shadow
#

coming together

#

not great but im just a dumb 13 y/o trying to learn python KEKW

vale pendant
#

It should be easy to create a rps game.

celest zinc
#

how do i get my discord bot to retreive the number of members in my server

vale pendant
#

len(ctx.guild.members) I believe.

vagrant brook
#

ctx.guild.member_count works too

vale pendant
#

Ahh yes, I just wrote what came to mind.

valid patio
#

can anyone tell how to keep my server 24x7 online even if my pc is offline from scratch

#

i have absolutely no idea i need someone to tell me step by step

jade jolt
#

use a vps

valid patio
#

someone told me heroku i have no idea how to

#

pls tell me step by step

jade jolt
#

don't use heroku 😶

valid patio
#

then wat do i do

jade jolt
#

use aws

valid patio
#

is it free

jade jolt
#

google will help you with that

#

im not sure

slate swan
#

replit

final iron
#

I'm having an issue importing a module that I just installed

#

I know this is for discord bots but the module does have something to do with discord bots

#

And I don't think its worth taking up a help channel just for this

#

I'm trying to import the module but its just not showing up

#

Is it possible I installed it in the wrong directory?

valid patio
jade jolt
slate swan
valid patio
#

i saw a vid about replit only thing the code isnt working

valid patio
jade jolt
slate swan
valid patio
#

i tried it dosent work

valid patio
# slate swan Search in youtube

what is wrong with this ?```from flask import Flask
from threading import Thread

app = Flask('')

@app.route('/')
def home():
return 'Hello,yep I am still here'
def run():
app.run(host ='0.0.0.0',port=3108)

def keep_alive():
t = Thread(target=run)
t.start()```

valid patio
vagrant brook
#

I don't see anything wrong but is it even appropriate to ask about Flask in #discord-bots

clever wind
#

hey

#

can someone help me with a bot

fossil patio
#

any new python library to fill the void left by discord.py

slate phoenix
slate phoenix
clever wind
slate phoenix
clever wind
#
@client.command(pass_context=True)
async def register(ctx, member: discord.Member, nick):
    await member.edit(nick=nick)
    await ctx.send(f'You have registered as {member.mention} ')

so basically with this, u have to do this command

=register @mighty crater nick

and if theres a space in the nick you have to use "".

i want to make it you can just type =register nick
and even if nick has a space in it, u dont have to use ""

#

@slate phoenix

spring flax
#
async def register(ctx, member:discord.Member, *, nick```
slate phoenix
#

^ I can’t type fast enough

#

Using * it will include all text after pinging the member

clever wind
#

oh yeah thanks! i was wondering what it was lol

glacial mesa
#

just join and do something

tropic marlin
#
from discord.ext import commands
prefix = "?"
bot = commands.Bot(command_prefix=prefix)


@bot.event
async def on_ready(message):
    await message.channel.send('Hello!')


channel = bot.get_channel(882470225877024821)
await channel.send("hi")


@bot.event
async def on_message(message):
    print("The message's content was", message.content)
    await bot.process_commands(message)


@bot.command()
async def ping(ctx):
    latency = bot.latency  # Included in the Discord.py library
    await ctx.send(latency)

How can It so it sends a message to a channel every 10 seconds

vagrant brook
#

!d discord.ext.tasks.loop

unkempt canyonBOT
#

discord.ext.tasks.loop(*, seconds=0, minutes=0, hours=0, count=None, reconnect=True, loop=None)```
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/stable/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
final iron
#

How would I send the guilds name that a member is joining

    @commands.Cog.listener()
    async def on_member_join(self, member: discord.Member):
        for channel in member.guild.channels:
            if str(channel) == "join-leave":
                embed = discord.Embed(color=0xff0000)
                embed.add_field(name="Welcome", value=f"{member} has joined {}", inline=False)
                embed.set_thumbnail(url=f'{member.avatar_url}')
                await channel.send(embed=embed)
unkempt canyonBOT
#
Bad argument

Converting to "int" failed for parameter "pep_number".

vagrant brook
#

!d discord.ext.commands.Bot.get_guild

unkempt canyonBOT
final iron
#

Would I make a variable with the guilds id?

vale pendant
#

and on_member_join just needs member, you don't have to add member: discord.Member

final iron
#

The code would work if a bot joined the server right

#

I'm just inviting and kicking a bot to test it

lament mesa
vale pendant
final iron
#

Alr

#

So uh the code isn't working

#

I'm getting no error message

#

It just doesn't send the message

vale pendant
#

Is this gonna be for a lot of servers or just one?

final iron
#

Multiple

#

Thats why im not just grabbing the channel id

vale pendant
#

I think you can do if channel.name = "join-leave":

final iron
#

Do I keep the for loop?

vale pendant
#

Yeah because you still have to cycle through the channels.

slate swan
#
author = ctx.message.author
    if  author.voice.channel == None:
        await ctx.send("You must be in a voice channel")
        return``` mmm it doesnt give me errors but it doesnt work so
final iron
#

Nope its still not working

vale pendant
final iron
#

Literally just doesn't send anything

#

No error in the console

vale pendant
#
@commands.Cog.listener()
    async def on_member_join(self, member: discord.Member):
        for channel in member.guild.channels:
            if str(channel) == "join-leave":
                break``` try this then send the embed outside the for loop, also, do you have intents on?
slate swan
vale pendant
vale pendant
slate swan
#

nope*

#

i tried that b4 but doesnt work

final iron
vale pendant
final iron
#

How would I get them

vale pendant
slate swan
#

ig i have another error?

vale pendant
#

Do you have intents on?

slate swan
#

ye

#
intents = discord.Intents.all()
client = commands.Bot(command_prefix=".",intents=intents)```
vale pendant
#

is it a command or on_message?

slate swan
#

enable them on the web site and put da on ur code @final iron

vale pendant
#

!intents

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

vale pendant
slate swan
final iron
#

So I just turn on these?

vale pendant
#

I know just a extended way of doing it

final iron
#

Then add some stuff to my code?

slate swan
surreal swallow
#

Sorry to interrupt, but has there been any update on sticker features getting implemented in the API

slate swan
final iron
#

I would need all right

slate swan
#

members works aswell

final iron
#

imma just do all

#

rn the bot is just for me

slate swan
slate swan
vale pendant
# slate swan oh alr

Yeah bro i don't know why that's not working. it should be if ctx.author.voice is None:

final iron
#

alr I have intents lemme test out the code

#

it worked thank you

#

Whats the point of intents anyway

slate swan
vale pendant
#

ahhhh lmfao

slate swan
final iron
slate swan
vale pendant
maiden fable
#

Intents are there cz discord thinks that they give u "sensitive information"

slate swan
#

why not work

maiden fable
slate swan
maiden fable
maiden fable
vale pendant
#

Also put the error in codeblock aswell

slate swan
slate swan
maiden fable
#

Wait wait wait

#

Can I see yr cog file?

#

The one which is erroring?

visual island
#

hi @maiden fable potatowave

vale pendant
slate swan
slate swan
slate swan
#

@maiden fable

visual island
#

i just came

slate swan
maiden fable
#

Lmao

vale pendant
#

lmfao

slate swan
maiden fable
#

Kylee gonna help u cz why not

visual island
slate swan
maiden fable
slate swan
slate swan
#

if message.content.startswith('$help'):

#

like this

vale pendant
#

bro that ain't the way to go

#

use commands instead of on_message

#

trust

slate swan
maiden fable
slate swan
#

@vale pendant

#

600 wrds

vale pendant
#

bro?

maiden fable
#

There u go. Now u know the reason why he ain't using commands.command @vale pendant

visual island
slate swan
#

any proper ytber

maiden fable
vale pendant
slate swan
#

lol pls help me

#

for commands.cog

maiden fable
vale pendant
visual island
maiden fable
maiden fable
slate swan
maiden fable
#

It's online school, so PepeGiggleHehe

maiden fable
visual island
#

cool

maiden fable
visual island
maiden fable
#

Lmao I slept at 2 or something last night, that's why I woke up at 10

prisma wedge
#
@client.command()
async def guildinfo(ctx,guild):
  bots = 0
  users = 0
  for x in guild.members:
    if x.bot is True:
      bots = bots + 1
    if x.bot is False:
      users = users + 1
  static_emojis = 0
  animated_emojis = 0
  usable_emojis = 0
  for x in guild.emojis:
    if x.animated is True:
      animated_emojis = animated_emojis + 1
    if x.animated is False:
      static_emojis = static_emojis + 1
    if x.available is True:
      usable_emojis = usable_emojis + 1
  
  embed = discord.Embed(title="Guild Info:",color=random.randint(0, 16777215))
  embed.add_field(name="Server Name:",value=guild.name)
  embed.add_field(name="Server ID:",value=guild.id)
  embed.add_field(name="Server region",value=guild.region)
  embed.add_field(name="Server created at:",value=f"{guild.created_at} UTC")
  embed.add_field(name="Server Owner:",value=guild.owner)
  embed.add_field(name="Member Count:",value=guild.member_count)
  embed.add_field(name="Users:",value=users)
  embed.add_field(name="Bots:",value=bots)
  embed.add_field(name="Channel Count:",value=len(guild.channels))
  embed.add_field(name="Role Count:",value=len(guild.roles))
  embed.set_thumbnail(url=(guild.icon_url))
  embed.add_field(name="Emoji Limit:",value=guild.emoji_limit)
  embed.add_field(name="Max File Size:",value=f"{guild.filesize_limit/1000000} MB")
  embed.add_field(name="Shard ID:",value=guild.shard_id)
  embed.add_field(name="Animated Icon",value=guild.is_icon_animated())
  embed.add_field(name="Static Emojis",value=static_emojis)
  embed.add_field(name="Animated Emojis",value=animated_emojis)
  embed.add_field(name="Total Emojis:",value=f"{len(guild.emojis)}/{guild.emoji_limit*2}")
  embed.add_field(name="Usable Emojis",value=usable_emojis)

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

i have this

maiden fable
#

So?

prisma wedge
#

Ignoring exception in command guildinfo:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 1127, in guildinfo
for x in guild.members:
AttributeError: 'str' object has no attribute 'members'

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

#

error

maiden fable
#

Ah

#

U gotta get the guild using bot.get_guild

visual island
vale pendant
vale pendant
maiden fable
#

Well I got my own room, so yea. I can sleep whenever I want :D

maiden fable
maiden fable
#

Well we also have the option for offline one but as I said, no one cares

spring flax
#

!ot

unkempt canyonBOT
slate swan
austere ivy
#

well i have a question

maiden fable
#

😂

maiden fable
austere ivy
#

how do i make a bot reply to dms

valid patio
#

how to make a whatsapp bot

maiden fable
austere ivy
#

like if someone dms the bot it replies with something

maiden fable
unkempt canyonBOT
#

await send(content=None, *, tts=False, embed=None, file=None, files=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=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/stable/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/stable/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

If the `embed` parameter is provided, it must be of type [`Embed`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Embed "discord.Embed") and it must be a rich embed type.
valid patio
maiden fable
vale pendant
austere ivy
#

yea but how do i check for dms

#

like how would the bot know it got a dm

maiden fable
visual island
#

when my parents are gone i dont sleep Hehe

visual island
#

but still, if they're at home i have no choice

maiden fable
#

Well, my parents don't really mind when I sleep. They give me this much freedom at least cz.... I am gonna be 16, ig?

slate swan
visual island
#

maybe they thought im still a kid?

maiden fable
#

😂

slate swan
visual island
slate swan
visual island
maiden fable
#

Anyways let's take this to an ot channel

#

ot0?

visual island
#

which ot

#

sure

slate swan
#

im 15 and my mum thinks im a child cri

austere ivy
maiden fable
slate swan
slate swan
maiden fable
slate swan
#

hol is there a way that u can control over 10 tokens?

#

in 1 code

#

like u can run 10 tokens

#

Why would you even do that

slate swan
#

Bot needs to be ran separately with the token

slate swan
#

how can i make my on_message event react to every message
like it shouldn't be if message.content.startswith or if "hello" in message.content

#
client.event
async def on_message(message):
  if message.channel.id == 882257233872814133:
                embed = discord.Embed(title="zxzc")
                embed.add_field(name="asdasd")
                await message.channel.send(embed=embed)``` i tried this but doesn't work any idea why?
slate swan
#

You can't pass a list when it's expecting a string

slate swan
slate swan
slate swan
#

tnx tho

patent lark
slate swan
#

😩

#

Error should be shown in the terminal or cmd though

patent lark
#

right.

slate swan
#

no errors were shown that's what i am confused with

#

wait

patent lark
#

could be something else in your code

slate swan
#

it's still not working

patent lark
#

hm.

#

no errors ?

vale pendant
#

maybe because there’s no error handler?

slate swan
#

no errors

patent lark
#

they don’t need an error handler

vale pendant
#

what’s the problem?

patent lark
#

there’s a thing called a terminal

slate swan
#

Not about commands

#

That's not the Terminal as you can see

patent lark
#

processing commands doesn’t matter with this error

slate swan
#

nor there's any problem in terminal

patent lark
#

go to your terminal mate

slate swan
#

Quick confirmation, you're sending the message in the channel with the ID you're checking above right?

slate swan
#

yes i did

#

no results

patent lark
#

odd

#

make sure it’s the correct ID lol.

slate swan
#

hmm you have any error handlers?

slate swan
#

...

slate swan
#

No...

#

Comparing an int with an int doesn't raise an error..

vale pendant
#

did you end up adding that value or no?

slate swan
#

yes i did

patent lark
#

interesting

vale pendant
#

hmm

patent lark
#

at this point i’d add print statements to see where your code is stopping

slate swan
#

that's what i am doing

maiden fable
#

Here comes the professional

slate swan
#

!d discord.VoiceChannel

unkempt canyonBOT
#

class discord.VoiceChannel```
Represents a Discord guild voice channel.

`x == y` Checks if two channels are equal.

`x != y` Checks if two channels are not equal.

`hash(x)` Returns the channel’s hash.

`str(x)` Returns the channel’s name.
patent lark
#

i think your code is stopping before you get to your check, cause if it wasn’t, an error would have raised given that your value parameter for the embed was missing.

#

since this event is called on every message

#

whether it’s correct ID or not

slate swan
#

it's not printing anything

#

tf

patent lark
#

uhhhh

#

intents.messages enabled lol?

slate swan
#

yes

vale pendant
#

is that a thing?

slate swan
#

yes it is

#

Yes it is

patent lark
#

!d discord.Intents.messages

unkempt canyonBOT
slate swan
#

Specifically later it will be a privileged intent

vale pendant
#

tf i could of sworn i could use on_message without intents

patent lark
#

no

#

!d discord.on_message

unkempt canyonBOT
#

discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Message "discord.Message") is created and sent.

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

Warning

Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
patent lark
#

read this

vale pendant
#

bro what

#

hold on

patent lark
#

@slate swan idk, i would say the event isn’t being called.. but why or how?

slate swan
#

idk lol i am also confused