#discord-bots

1 messages · Page 900 of 1

gaunt ice
#

just a min away

alpine furnace
#

So he’s great and all but makes bad tutorials and uses bad practices thonk

sick birch
#

Someone wrote a massive gist of everything that was wrong with one of his tutorials. It was on the d.py server but I can't find it

alpine furnace
#

You can use an infinite loop

While true:
    Asyncio.sleep(15*60)
    Send message
#

Thanks robin

sick birch
sick birch
#

We had a good laugh about that one back on d.py

gaunt ice
#

lol

#

who do u suggest

#

for dpy tutorials

sick birch
#

The documentation

#

I find tutorials to be inherently flawed in their core concept

gaunt ice
#

hmm

sick birch
#

Often times you'll be copying down what someone says which doesn't help your problem solving skills, making you more and more dependant on said tutorials

gaunt ice
#

true

alpine furnace
sick birch
#

Rather try to solve problems yourself without searching for a tutorial. Referring to the documentation and asking others for help is fine

sick birch
#

But anyway that's more for #pedagogy i suppose

maiden fable
#

Sometimes I feel like spamming Lucas's comments lemon_pensive

alpine furnace
#

Going to see the rest

sick birch
#

Well that's what I meant by tutorials are inherently flawed

alpine furnace
#

Misleading to beginners that don’t know the version of the package they’re using, I guess

#

It’s also more of a problem with videos, you’re right

sick birch
alpine furnace
#

High seo with outdated tooling

sick birch
#

Unfortunate but that just seems to be what most beginners were doing. I wish there was a video up on the algorithm where if you searched "discord bot python tutorial" it would pop up with something like "why most python discord bot tutorials are bad" or something along those lines. too much to ask I suppose

alpine furnace
#

Last active 3 minutes ago
Lol

sick birch
#

Who?

boreal ravine
#

wasi-master

sick birch
#

Chill guy. Knew him on d.py

#

Pretty well known in the community, wouldn't say he's a stranger

alpine furnace
#

Noice

slate swan
#

i have question this is would work or i need it to do in other way or something or need make changes. sorry for asking question like that but i think i need to ask question like this. the first command .```
messageCount = {}

@bot.event
async def on_message(ctx):
author = str(ctx.author)
if author in messageCount:
messageCount[author] += 1
else:
messageCount[author] = 1

await bot.process_commands(ctx)

@bot.command()
async def messages(ctx: commands.Context, *, user: discord.User=None):
"""Aby zobaczyć, ile wiadomości wysyła użytkownik"""
user = user or ctx.author
msg = messageCount.get(str(user))
if msg:
await ctx.send(f"{user} wysłał lącznie {msg} ")
else:
await ctx.send(f"{user} nie wysłał jeszcze żadnej wiadomości") Second command @bot.event
async def add_points(ctx, users, user, pts):
users[user.id]['points'] += pts
@bot.command(pass_context = True)
async def give(ctx, member, amount):
with open('users.json', 'r') as f:
users = json.load(f)
await add_points(users, member, amount)
with open('users.json', 'w') as f:
json.dump('users', 'f')
await ctx.send(f'given {member} {amount} programming points') ```

velvet tinsel
alpine furnace
#

Lol wtf is this

velvet tinsel
#

wdym?

cunning ice
#

is it possible to make a discord bot that tells when a person is online even if he is invisible ?????

slate swan
glacial echo
#

is there an discord.py alternative that still has message_intent abilities?

#

since im making a bot for like only my servers i just want the option of grabbing all message content and actually using it

glacial echo
#

meh

#

all my motivation for wokring on this bot is gone tbh since there isnt proper easy support for the type of message_content im trying to use

drowsy thunder
#

Ahhh

glacial echo
#

message intents

#

message content intent*

#

ok but slash commands arent useful for this

#

i need to get the info in a message to determine how many poinst a word is worth in the game

#

like slash commands ok sure i could deal with that it would just take learning them

#

but i cant seem to get the plain contents of a message

#

yes im aware

unkempt canyonBOT
glacial echo
glacial echo
#
@client.listen()
async def on_message(message):
  if message.author != client.user:
    await message.channel.send(f"{message.content} sent by {message.author}")
#

it only gets the message.content now if you mention the bot or use an interaction or DM it

#

intents = discord.Intents.default()
intents.message_content = True

#

i have this?

quick gust
#

make sure u have it enabled

slate swan
#

Never heard of that module before lmao

boreal ravine
#

nice

glacial echo
#

yeah ok i did that

#

but still doesnt have a message.content

#

i did

slate swan
#

So ur telling me if u need to enable intents you don’t need to open the dev portal?

glacial echo
#

message intents code enabled

#

y e s

slate swan
#

O yea I read the line wrong mb

#

@glacial echo 100% all intents enabled from dev?

glacial echo
#

yes

#

i did

#

oh

#

still nothing

#
import discord
from discord.ext import commands

intents = discord.Intents().all()

token = "ODg1Mz"

client = commands.Bot(command_prefix="b|", case_insensitive = True)

@client.listen()
async def on_message(message):
  if message.author != client.user:
    await message.channel.send(f"{message.content} sent by {message.author}")

client.run(token)


#
  File "c:\Users\herok\OneDrive\Desktop\python stuff for school\tempCvrtr.py", line 15, in <module>
    client.run(token)
  File "C:\Users\herok\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 704, in run
    return future.result()
  File "C:\Users\herok\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 683, in runner
    await self.start(*args, **kwargs)
  File "C:\Users\herok\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 647, in start
    await self.connect(reconnect=reconnect)
  File "C:\Users\herok\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 588, in connect
    raise PrivilegedIntentsRequired(exc.shard_id) from None
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001CAAC87A3B0>
Traceback (most recent call last):
  File "C:\Users\herok\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\herok\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\herok\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 745, in call_soon
    self._check_closed()
  File "C:\Users\herok\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 510, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed```
#

uh

#

ah i forgot the presence and member ones

#

you are a goddamn angel

#

you have made my stuff work again

#

thank you sooooo much

slate swan
#

What was problem even I only saw first half

glacial echo
#

discord.py changed between 1.7.3 and 2.0.0a to needing special bs to ge message_content

#

and my game bot heavily relies on message_content

formal basin
#

Why doesn’t this work it’s giving anyone the role

#

It’s giving people with no default avatar

honest shoal
#

show the whole code

formal basin
#

Then what does it do?

slate swan
#
if not member.avatar:
   ...``` to be exact
#

!d discord.Member.avatar it's None if the avatar or user is a default one

unkempt canyonBOT
#

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

What do you understand by typing.Optional? Xd

rocky trench
#

It does still work in dpy 2.0

slate swan
unkempt canyonBOT
#

property avatar```
Returns an [`Asset`](https://discordpy.readthedocs.io/en/master/api.html#discord.Asset "discord.Asset") for the avatar the user has.

If the user does not have a traditional avatar, `None` is returned. If you want the avatar that a user has displayed, consider [`display_avatar`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.display_avatar "discord.User.display_avatar").
slate swan
#

yea the developer was high while writing this.

rocky trench
slate swan
#

they want to check if the user has default avatar or not? And that's literally the only way

rocky trench
# slate swan how?

I thought u said it wasn't possible to get avatar like this. I just saw ur message that it returns None

formal basin
slate swan
#

Great

formal basin
#

I was just building a security bot

slate swan
#

Oh hmm so checking suspicious accounts without an Avatar

#

I mean like if date is within like 15d or something

formal basin
formal basin
slate swan
#

Member.created_at gives you the datetime object of the time when the user created that account

#

you can subtract it with datetime.datetime.now() to get the account age

formal basin
#

Hey is there a way to make it so the bot can remove a role

slate swan
#

!d discord.Member.remove_roles

unkempt canyonBOT
#

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

Removes [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s from this member.

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

I see someone doesn't like reptiles anymore 👀 (BCC: @slate swan)

formal basin
#

Yeah but I want the event to when the member gets a role e.g the member gets the role and then I want it to take a role off them

formal basin
slate swan
maiden fable
#

@slate swan u also bought nitro lemon_pensive

slate swan
#

and see what roles were added

maiden fable
#

Same thing

slate swan
#

looli how did i bought that then

formal basin
formal basin
#

The error

oak warren
#

this means you have not read the docs

#

simple

formal basin
oak warren
#

not

#

!d discord.on_member_update

unkempt canyonBOT
#

discord.on_member_update(before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") updates their profile.

This is called when one or more of the following things change:

• nickname

• roles

• pending...
oak warren
#

i dont see the same thing in your code

formal basin
#

on_member_role_update I’m using this

slate swan
formal basin
slate swan
#

its in your webserver's url bar

slate swan
slate swan
formal basin
pliant ocean
#

'Context' object has no attribute 'member'

#

can anyone help why i am getting this error

pulsar stream
#

ctx.author not ctx.member

#

ctx.member doesn't exist, ctx.author is what you want

pliant ocean
#

@client.command(help='Gives Warm Hugs')
async def Hug(ctx):
await ctx.reply(f"gives a warm hug to {ctx.member.mention}")

#

this is my command

pulsar stream
pliant ocean
pulsar stream
#

take a second parameter in your function

#

called member

#

and add a discord.Member typehint to it. i.e member: discord.Member

#

then do member.mention

pliant ocean
#

alright

#

thank you

pulsar stream
#

then run the command like !Hug @someone. it won't work if you don't mention

pliant ocean
#

alr

quick gust
#

Pretty sure it will work if it's a valid ID/username in the server

#

!hug 830328082724290611
or
!hug Sven77 should work

pulsar stream
#

yeah

#

oh wait I didn't say that, sorry mb

#

I mean like if he does only !Hug then it won't work

quick gust
#

ah

vast gale
#

uwu hi

slate swan
#

So I got a txt file of white list users but I want to make it so if user id in txt command works else await message.send(“your not whitelisted”)

pliant ocean
#

@client.command(help='Av sven')
async def Griff(ctx):
user_id = "905068632801943563"

await ctx.reply(f"<@{user_id}>" 'url')

#

when i am mentioning the user it works correctly but the link is also visible along with the image

#

in the url

#

how can i make the link not show and just the image

slate swan
#

Is the url defined

pliant ocean
#

yeah

slate swan
#

So u just want image sent not link

#

Correct?

maiden fable
#

Ouh Wasi here 👀

slate swan
#

Hi hunter

maiden fable
#

Hi alex

pliant ocean
#

basically i dont want the link that is being shown

vast gale
#

@maiden fable im here too

maiden fable
#

Hi arl

vast gale
# pliant ocean

your solution is either to

  • upload file
  • use embed
  • do not include the mention to the user, and have no content
#

hunter will continue to explain since imma go sleep cya

slate swan
#

how to do

await ctx.send(random.choice(number) + "/10")
maiden fable
maiden fable
vast gale
#

nop imma sleep bai

#

have fun!! :catpat:

maiden fable
vast gale
#

i will watch your career from afar and with great interest

maiden fable
#

Meh, I am going

pliant ocean
#

im using replit

maiden fable
#

Cool

pliant ocean
#

so i dont think i can upload a picture there

maiden fable
#

You can

vast gale
hot sparrow
#

how to get message content from a message id and channel id?

maiden fable
#

Just like u upload from pc lol

maiden fable
unkempt canyonBOT
#

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

Retrieves a single [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") from the destination.
vast gale
#

!d discord.Client.get_partial_messageable

unkempt canyonBOT
#

get_partial_messageable(id, *, type=None)```
Returns a partial messageable with the given channel ID.

This is useful if you have a channel\_id but don’t want to do an API call to send messages to it.

New in version 2.0.
maiden fable
hot sparrow
#

o

maiden fable
maiden fable
#

😔

vast gale
#

taking a few days off because I have so many plans and not enough time and too much stress etc

maiden fable
#

Sad

#

Gonna miss you lemon_pensive

vast gale
#

ohmygod the things i have planned vs the number of hours in a day are atrocious

maiden fable
#

Hahahaha

#

Good night then!

heavy folio
vast gale
#

should work

#

but that's uploading the file 😛

maiden fable
#

😔 Go sleep arl

slate swan
#

@maiden fable what’s best way to make command only work for user id

#

i want to add database from pgadmin 4 but i have issue

slate swan
hot sparrow
#

i think im using it wrong

slate swan
#

how to check if bot has permissions to send messages in a channel

#

im using this in a loop so dont give me command code

novel apexBOT
#

This is not a Modmail thread.

slate swan
#

?rtfm BotMissingPermissions

slate swan
#

i wanna shift to databases but it give me error

async def create_db_pool():
    bot.db = await asyncpg.create_pool(database="test",user = "postgres", password = "parashar305")
    print("Db added successfully")

bot.loop.create_task(create_db_pool())```
#
    bot.db = await asyncpg.create_pool(database="test",user = "postgres", password = "secret")
  File "C:\Users\mahes\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncpg\pool.py", line 413, in _async__init__
    await self._initialize()
  File "C:\Users\mahes\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncpg\pool.py", line 441, in _initialize
    await first_ch.connect()
  File "C:\Users\mahes\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncpg\pool.py", line 133, in connect
    self._con = await self._pool._get_new_connection()
  File "C:\Users\mahes\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncpg\pool.py", line 511, in _get_new_connection
    con = await connection.connect(
  File "C:\Users\mahes\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncpg\connection.py", line 2085, in connect
    return await connect_utils._connect(
  File "C:\Users\mahes\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncpg\connect_utils.py", line 895, in _connect
    raise last_error
  File "C:\Users\mahes\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncpg\connect_utils.py", line 881, in _connect
    return await _connect_addr(
  File "C:\Users\mahes\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncpg\connect_utils.py", line 781, in _connect_addr
    return await __connect_addr(params, timeout, True, *args)```
#
    tr, pr = await compat.wait_for(connector, timeout=timeout)
  File "C:\Users\mahes\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncpg\compat.py", line 66, in wait_for
    return await asyncio.wait_for(fut, timeout)
  File "C:\Users\mahes\AppData\Local\Programs\Python\Python39\lib\asyncio\tasks.py", line 481, in wait_for
    return fut.result()
  File "C:\Users\mahes\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncpg\connect_utils.py", line 691, in _create_ssl_connection    tr, pr = await loop.create_connection(
  File "C:\Users\mahes\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 1061, in create_connection
    raise exceptions[0]
  File "C:\Users\mahes\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 1041, in create_connection
    sock = await self._connect_sock(
  File "C:\Users\mahes\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 955, in _connect_sock
    await self.sock_connect(sock, address)
  File "C:\Users\mahes\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 702, in sock_connect
    return await self._proactor.connect(sock, address)
  File "C:\Users\mahes\AppData\Local\Programs\Python\Python39\lib\asyncio\windows_events.py", line 812, in _poll
    value = callback(transferred, key, ov)
  File "C:\Users\mahes\AppData\Local\Programs\Python\Python39\lib\asyncio\windows_events.py", line 599, in finish_connect
    ov.getresult()
ConnectionRefusedError: [WinError 1225] The remote computer refused the network connection```
#

how to check if bot has permissions to send messages in a channel
im using this in a loop so dont give me command code

slate swan
slate swan
slate swan
slate swan
maiden fable
#

😔

slate swan
slate swan
#

thats why

#

that just looks like its only for guild

slate swan
#

can u show me

slate swan
slate swan
slate swan
slate swan
slate swan
#

I think you can't do it

slate swan
# maiden fable ?

I got bot command that I only want certain user ids to work for what should I do I was thinking txt file would work

maiden fable
#

Sure

slate swan
#

@client.event
async def on_message(message):
  
  username = message.author.display_name
  msg = message.content
  with open('whitelist.txt', 'r') as f:
    blacklist = f.read()
    if message.author.bot:
      return
    elif msg.lower() in blacklist:
      await message.delete()```
#

My buddy made this for deleting blacklisted words

#

But I’m sure you could change to user id form

#

wdym?

#

@slate swan what if i try to send a message in the channel, will i get an error if it doesnt have permissions to send?

slate swan
#

you can use try except block there

#

yess

#

thats perfect

#

\👍

#
Ignoring exception in on_shard_disconnect
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "/home/runner/Zeon-v2-3/cogs/System.py", line 423, in on_shard_disconnect
    shardlog.set_author(name="Shard Status", icon_url=f'{self.client.user.avatar_url}')
AttributeError: 'NoneType' object has no attribute 'avatar_url'
Traceback (most recent call last):
  File "main.py", line 327, in <module>
    client.run(os.environ.get('BOT_TOKEN'), reconnect=True)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 723, in run
    return future.result()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 702, in runner
    await self.start(*args, **kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 666, in start
    await self.connect(reconnect=reconnect)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/shard.py", line 445, in connect
    raise item.error
discord.errors.PrivilegedIntentsRequired: Shard ID 0 is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.
 
#

anyone?

slate swan
#

xd

#

@slate swan wont i get ratelimited?

#

no

slate swan
slate swan
maiden fable
slate swan
#

and ill be using this in multiple servers

slate swan
slate swan
maiden fable
#

okay if u say so lol

slate swan
slate swan
#

how to check if i have @ everyone permissions @slate swan

#

@client.event
async def on_message(message):
  msg = message.content
  with open('whitelist.txt', 'r') as f:
    blacklist = f.read()
    if user.id:
      return
    elif user.id in whitelist:
      await ctx.send(“not whitelisted”)``` would this work for white list
slate swan
slate swan
tidal hawk
#

How are the ids formated inside the txt file?

slate swan
#
@client.event
async def on_message(message):
  msg = message.content
  with open('whitelist.txt', 'r') as f:
    whitelist = f.read()
  if user.id in whitelist:
    return
  else:
    await ctx.send("not whitelisted")```
#

Ok thanks

#

\👍

slate swan
slate swan
tidal hawk
#

Not sure if it would make difference, but I'd create a list by the whitelist.txt

slate swan
#

of database

slate swan
tidal hawk
#

Where every element is split by (\n)

slate swan
#

🥲

slate swan
#
  File "C:\Users\mahes\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncpg\connect_utils.py", line 699, in _create_ssl_connection
    do_ssl_upgrade = await pr.on_data
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\mahes\AppData\Local\Programs\Python\Python39\lib\asyncio\tasks.py", line 492, in wait_for
    fut.result()
asyncio.exceptions.CancelledError

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

Traceback (most recent call last):
  File "c:\Users\mahes\OneDrive\Documents\Dank Frost Online\Dank-Frost\main.py", line 207, in <module>
    bot.loop.run_until_complete(create_db_pool())
  File "C:\Users\mahes\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 642, in run_until_complete
    return future.result()
  File "c:\Users\mahes\OneDrive\Documents\Dank Frost Online\Dank-Frost\main.py", line 69, in create_db_pool
    bot.db = await asyncpg.create_pool(database="guilds",user = "postgres", password = "secret")
  File "C:\Users\mahes\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncpg\pool.py", line 413, in _async__init__
    await self._initialize()
  File "C:\Users\mahes\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncpg\pool.py", line 441, in _initialize
    await first_ch.connect()
  File "C:\Users\mahes\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncpg\pool.py", line 133, in connect
    self._con = await self._pool._get_new_connection()```
#
    con = await connection.connect(
  File "C:\Users\mahes\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncpg\connection.py", line 2085, in connect
    return await connect_utils._connect(
  File "C:\Users\mahes\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncpg\connect_utils.py", line 895, in _connect
    raise last_error
  File "C:\Users\mahes\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncpg\connect_utils.py", line 881, in _connect
    return await _connect_addr(
  File "C:\Users\mahes\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncpg\connect_utils.py", line 781, in _connect_addr
    return await __connect_addr(params, timeout, True, *args)
  File "C:\Users\mahes\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncpg\connect_utils.py", line 825, in __connect_addr
    tr, pr = await compat.wait_for(connector, timeout=timeout)
  File "C:\Users\mahes\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncpg\compat.py", line 66, in wait_for
    return await asyncio.wait_for(fut, timeout)
  File "C:\Users\mahes\AppData\Local\Programs\Python\Python39\lib\asyncio\tasks.py", line 494, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError```
#

🥲

#

which line shows the error?

slate swan
#

hmm line 69

#

Does the error show as soon as you start the program?

#

and 207

slate swan
#

Send line 207 and lines near it of your bot

slate swan
#

can you send more code?

#

nearby lines too

#
async def create_db_pool():
    bot.db = await asyncpg.create_pool(database="guilds",user = "postgres", password = "")
    print("Db added successfully")
#

here create_db_pool

#

ah

#

whats asyncpg?

#

asyncpg postgres database

#

Ok

#

it shows asyncio.exceptions.CancelledError which means the operation is being cancelled some way

#

hmm

#
async def create_db_pool():
    print(1)
    bot.db = await asyncpg.create_pool(database="guilds",user = "postgres", password = "")
    print(2)
    print("Db added successfully")```Use this code and check if 1 is printed or not
slate swan
#

you need to run the bot

slate swan
#

You havent added token too

#

do you have an on_message event?

slate swan
slate swan
slate swan
#

Client.run(“token”)

slate swan
#

Ok

#

Does it show error?

supple thorn
slate swan
#

does it show logged in as bot?

supple thorn
#

Also is the msg even gonna be used

#

Or is it just there forgotten

slate swan
#

k

#

discord is installed tho

#

is the bot even in your guild?

slate swan
#

LOL this thing really doesn’t like you

#

mhmm convert it into string

#
@client.event
async def on_message(message):
  msg = message.content
  with open('whitelist.txt', 'r') as f:
    whitelist = f.read()
  if str(message.author.id) in whitelist:
    return
  else:
    await message.channel.send("not whitelisted")```
#

wait

tidal hawk
#

Broo convert it into a list

slate swan
#

is it really a bot?

tidal hawk
#

whitelisted_ids = whitelist.split('\n')

slate swan
#

does the bot come online when you do start it

slate swan
tidal hawk
#

yeah but it's awkward

slate swan
#

mhmm bot has permissions?

#

mhmm invite me to the server

#

and send the bot token in DM

#

let me test myself

leaden jasper
slate swan
#

import os
import discord
from discord.ext import commands


bot = commands.Bot(command_prefix='$')


@bot.event
async def on_ready():
  print(f"{bot.user} is online")



@bot.event
async def on_message(message):
  msg = message.content
  with open('whitelist.txt', 'r') as f:
    whitelist = f.read()
  if str(message.author.id) in whitelist:
    return
  else:
    await ctx.send("not whitelisted")

@bot.command()
async def test(ctx):
  await ctx.send("working")```

Whitelist.txt 
875711009606729808
875711009606729804
#

@slate swan not working

slate swan
slate swan
slate swan
#

oh nvm wait

leaden jasper
slate swan
slate swan
#

he can do .read() as he is searching the string

slate swan
maiden fable
#

@slate swan

slate swan
slate swan
slate swan
leaden jasper
#

@slate swan whitelist is a string
875711009606729808\n875711009606729808
make it a list
[875711009606729808,875711009606729808]

slate swan
slate swan
maiden fable
#

@slate swan if u want to add a global check, look into bot.check

slate swan
#

Ok

maiden fable
#

!d discord.ext.commands.Bot.check

unkempt canyonBOT
#

@check```
A decorator that adds a global check to the bot.

A global check is similar to a [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is applied on a per command basis except it is run before any command checks have been verified and applies to every command the bot has.

Note

This function can either be a regular function or a coroutine.

Similar to a command [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check"), this takes a single parameter of type [`Context`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context") and can only raise exceptions inherited from [`CommandError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError").

Example...
slate swan
#

the problem is nothing

leaden jasper
#

how about you install the packages 1 at a time

#

to find the faulty package

#

how about installing discord first

slate swan
#

according to the command the bot will say "Not whitelisted" to those whose ids are not in the file

leaden jasper
#

maybe

slate swan
#

@slate swan but it’s not sending message would on_message be reason?

leaden jasper
#

buttons are for 2.0

#

ur using version 1.7.3

#

in ur requirements.txt

slate swan
#

Wym

#

and your library's documentation

leaden jasper
#

its in beta btw

empty quest
#

is discord.py better than discord.js? which is better in which case?

leaden jasper
#

Both in practical use are the same man but discord.js has more of the new stuff already in it

slate swan
maiden fable
hot sedge
#

hello

boreal ravine
#

or eris

#

i heard some big bots use it

maiden fable
#

what's that

manic wing
#

use discii

#

with absolutely no resuming and no ratelimiting, discii is much superior

boreal ravine
maiden fable
#

Ah JS

#

Thought it was in Python lol

empty quest
#

are discord bots allowed to store all the messages we type in a database? surely that has to be against tos?

untold oriole
#

Hey is there a way to purge all the messages sent by the user in a server, like !purge 5 <user_handle> would go to each channel that the user has messaged and then delete 5 of their last message

slate swan
slate swan
empty quest
slate swan
maiden fable
maiden fable
slate swan
maiden fable
#

My bot saves some part of the message, and discord doesn't have an issue with it

maiden fable
slate swan
#

you can, I've tried it frog_sip

maiden fable
#

How tf do u think not being able to delete messages more than 2 weeks old is a ToS issue?

untold oriole
slate swan
#

well, I did think, my bad

maiden fable
#

If u wanna make an anti spam 👇 👇

empty quest
#

is there a way to store info using the discord API?

empty quest
#

what i had in mind is writing to a txt file every time a user sends a message

maiden fable
#

Just request it and, uhhh, save it to a db?

untold oriole
maiden fable
#

Makes an anti spam totally not doing free paid work

untold oriole
#

where is the documentation for it?

#

or is it not in the stable version?

hushed galleon
#

CooldownMapping is undocumented so you'll need to read the source for more info on that

untold oriole
boreal ravine
hushed galleon
#

you can pass a check function to purge and return a condition

#

oh its even listed as an example in the documentation for purge

untold oriole
#

So I should go into each channel and THEN check for the user message right

hushed galleon
#

if you automate purging every channel that can lead to excessive api calls

#

are you making an automated system for detecting spam? or just watching out for it manually

#

if its the former, you could temporarily keep track of messages and then when they exceed your threshold, you know exactly which messages to delete and the channels they're in

south jetty
#
line 81, in avatar
    memberAvatar = member.avatar_url
AttributeError: 'Member' object has no attribute 'avatar_url'```
south jetty
slate swan
odd prawn
#

How are you building your Member object?

south jetty
#
line 81, in avatar
    memberAvatar = member.avatar.url
AttributeError: 'NoneType' object has no attribute 'url'```
slate swan
#

....

odd prawn
#

Yes, but where are we getting member from?

south jetty
#
@client.command(aliases=['ava'])
async def avatar(ctx, member : discord.Member = None):
  if member == None:
      member = ctx.author

  memberAvatar = member.avatar.url

  embed = discord.Embed(title=f"{member.name}'s Avatar")
  embed.set_image(url = f"{memberAvatar}")
  embed.timestamp = ctx.message.created_at
  embed.set_footer(text=f"ID: {member.id}", icon_url=member.avatar.url)

  await ctx.send(embed=embed)```
south jetty
south jetty
supple thorn
#

Member.display_avatar

#

iirc

south jetty
supple thorn
#

Coolio

maiden fable
#

Oh, I misread it as Member is None

slate swan
maiden fable
#

May your bot rest in peace

slate swan
#

is there a way to avoid that

maiden fable
#

Stop using replit

slate swan
#

then what should I use

#

@maiden fable

slate swan
#

what is that

maiden fable
#

(I'm the worst at explaining things, I'mma leave it to Shi Tsu to explain)

sacred phoenix
#

guys please did someone face this issue ?

odd prawn
#

Unless repl.it has started making erroneous calls to whatever it's connecting to since I've gotten back into the loop, I don't see how a change in platform would impact a 429 error.

odd prawn
hushed galleon
slate swan
slate swan
#

better if you would do the honours

heavy hound
#

you use vsc + vps

slate swan
#

nooooo, replit is not a vps

heavy hound
#

yeah ik

slate swan
heavy hound
#

no

slate swan
#

and using replit and uptime robot is bad for discord bots

heavy hound
#

for mobile i suggest you to use self hosting

#

i broke i cant do self hosting and vps so i use replit

#

mometn

heavy hound
slate swan
#

and, the api ratelimiting issue

heavy hound
#

what is that

maiden fable
supple thorn
#

In simple terms

maiden fable
slate swan
heavy hound
supple thorn
#

Replit hosted bots usually have 40ms ping

slate swan
supple thorn
#

When i host my bot on my vps it's usually 80ms now

supple thorn
#

It's twice the usual ping but it is in miliseconds

heavy hound
#

imma try my ms

slate swan
#

mhm, ive only got twice or thrice lol

supple thorn
heavy hound
#

average 43 ms

light violet
#

how to delete autodetect multiple channels and delete them?

heavy hound
heavy hound
light violet
# manic wing what

i want the bot to automatically detect multiple channels and del them with a cmd

supple thorn
#

Im using it right now

maiden fable
supple thorn
heavy hound
#

how do i prevent from being ratelimited in replit

cold sonnet
#

pov: your bot gets banned because someone created a ddos thing on your ip

slate swan
maiden fable
maiden fable
heavy hound
manic wing
heavy hound
unkempt canyonBOT
#
Noooooo!!

No documentation found for the requested symbol.

heavy hound
#

i forgor what is it called

supple thorn
maiden fable
heavy hound
slate swan
maiden fable
#

Shi Tsu or people in #web-development probably have more information since they into web deving more than me

cold sonnet
#

has guild for sure

heavy hound
maiden fable
cold sonnet
#

!d discord.on_guild_channel_delete

unkempt canyonBOT
#

discord.on_guild_channel_delete(channel)``````py

discord.on_guild_channel_create(channel)```
Called whenever a guild channel is deleted or created.

Note that you can get the guild from [`guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.GuildChannel.guild "discord.abc.GuildChannel.guild").

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

oh well

#

!d discord.on_guild_channel_create

unkempt canyonBOT
#

discord.on_guild_channel_delete(channel)``````py

discord.on_guild_channel_create(channel)```
Called whenever a guild channel is deleted or created.

Note that you can get the guild from [`guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.GuildChannel.guild "discord.abc.GuildChannel.guild").

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

get the first channel object here

#

and compare this channel's name in a for loop through every other channel with every other channel's name

light violet
#

duplicate = any(name == channel.name for channel in channels)

will it help?

#

detecting multiple channels?

cold sonnet
#

almost

light violet
#

await duplicate.delete()?

cold sonnet
light violet
#

ok

cold sonnet
#

for channel2 in guild.channels

#

and if the if statements is true, delete channel

light violet
#

i want to auto detect multiple channel names

cold sonnet
#

this event triggers when a channel is created

light violet
#

btw i want to recover a nuked server

#

auto matically

cold sonnet
#

the if statement is true if the name of the new channel is the same as another channel's name

cold sonnet
light violet
#

lol

cold sonnet
#

don't give random people admin

light violet
#

bruh it is already nuked no meaning in giving them now

cold sonnet
#

you gave random people admin

light violet
#

yes

supple thorn
light violet
cold sonnet
#

guild.channels[position]

light violet
#

ok

pliant ocean
#

I'm trying to make a meme command which posts random meme when it's used how do I do it with an API can anyone help

pliant ocean
#

Yeah

supple thorn
#

You can start by checking out asyncpraw's docs

#

And checking how to use it first

light violet
#

how to change vanity invite discord py

cold sonnet
#

doubt u can

slate swan
#

await is only valid in async functions and the top level bodies of modules

#

Anyone?

cold sonnet
#

what's the issue

light violet
slate swan
#

Anyone pls tell me Eval of js

light violet
#

;

slate swan
#

@cold sonnet

cold sonnet
#

what's your code on this command

light violet
# sweet geyser Headers

async with httpx.AsyncClient(headers= {"Authorization": "Bot %s" % (self.client.http.token)}) as AsyncClient:

#

now?

sweet geyser
#

Also %22?

light violet
#

no it was not in the repl

#

copy prob

light violet
#

why isnt it working

#

!d discord.AuditLogDiff

unkempt canyonBOT
#

class discord.AuditLogDiff```
Represents an audit log “change” object. A change object has dynamic attributes that depend on the type of action being done. Certain actions map to certain attributes being set.

Note that accessing an attribute that does not match the specified action will lead to an attribute error.

To get a list of attributes that have been set, you can iterate over them. To see a list of all possible attributes that could be set based on the action being done, check the documentation for [`AuditLogAction`](https://discordpy.readthedocs.io/en/master/api.html#discord.AuditLogAction "discord.AuditLogAction"), otherwise check the documentation below for all attributes that are possible.

iter(diff) Returns an iterator over (attribute, value) tuple of this diff.
hushed galleon
unkempt canyonBOT
#
await edit(*, reason=..., name=..., description=..., icon=..., banner=..., splash=..., discovery_splash=..., community=..., afk_channel=..., owner=..., afk_timeout=..., ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the guild.

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

Changed in version 1.4: The rules\_channel and public\_updates\_channel keyword-only parameters were added.

Changed in version 2.0: The discovery\_splash and community keyword-only parameters were added.

Changed in version 2.0: The newly updated guild is returned...
hushed galleon
#

use the vanity_code= kwarg

formal basin
#

How do I define?

#

I’m learning json

sweet geyser
#

?

#

Its called dictionaries in python

hushed galleon
#

you're using the minus operators - instead of assignments =

formal basin
#

Oh

flat solstice
slate swan
#

well......dont use globals

#

use a wait_for

supple thorn
#

Why do you have a try and except

#

If the deletion failed you should get an error

#

But because of you using try and except

#

It's eating up the error

#

The deletion didn't fail or there was no error?

light violet
#

how do i define vanity code

supple thorn
#

Because of the except

#

Why do you even have a try and except

#

Just remove it

empty quest
#

Is there a way to play music in a vc using a bot coded in discord.py?

supple thorn
#

You should get an error after

#

I'll let someone else deal with this since im gonna sleep

flat solstice
#

because of thispy try: await mess.delete() except: passif it errors your passing on the error (ignoring it)

fluid spindle
#

And never just use except. Always try to catch a specific error rather than only except

supple thorn
flat solstice
fluid spindle
#

What are you trying to do here exactly?

#

And where did mess come from?

light violet
#

how do i define before guild vanity

vale wing
#

If you are using globals, the global keyword must be inside of the function

light violet
#

pls help me

vale wing
#

And yeah don't use bare except, catch discord.HTTPException instead

vale wing
light violet
vale wing
#

Use string functions I guess

light violet
#

give me ex pls like on message bot would reply in last few letters

vale wing
#

We don't make complete code here

light violet
vale wing
#

What is your python experience level

light violet
#

i am in hurry actually

vale wing
light violet
#

i know py btw incomplete

light violet
light violet
#

how do i define that cant find it in docs

flat solstice
#

When making dpy 2.0 app commands is the syntax thispy @app_commands.command() @app_commands.guilds(discord.Object(id=default_guild)) async def tree(interaction: discord.Interaction): bot.tree.sync(guild=discord.Object(id=interaction.guild_id)) await interaction.response.send_message(f'Synced the tree.', ephemeral=True)or thispy @app_commands.AppCommand() @app_commands.guilds(discord.Object(id=default_guild)) async def tree(interaction: discord.Interaction): bot.tree.sync(guild=discord.Object(id=interaction.guild_id)) await interaction.response.send_message(f'Synced the tree.', ephemeral=True)

boreal ravine
unkempt canyonBOT
#

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

Returns the guild’s special vanity invite.

The guild must have `VANITY_URL` in [`features`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.features "discord.Guild.features").

You must have the [`manage_guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_guild "discord.Permissions.manage_guild") permission to use this as well.
hushed galleon
# flat solstice When making dpy 2.0 app commands is the syntax this```py @app_commands.command()...

according to the gist https://gist.github.com/Rapptz/c4324f17a80c94776832430007ad40e6, neither of those
writing a slash command would look like this ```py
import discord
from discord.ext import app_commands

client = discord.Client(...) # or commands.Bot
tree = app_commands.CommandTree(client)

@tree.command()
async def add(interaction, x: float, y: float):
await interaction.response.send_message(x + y)```

boreal ravine
#

why are they even syncing the slash commands inside of the slash command

unkempt canyonBOT
#

str.replace(old, new[, count])```
Return a copy of the string with all occurrences of substring *old* replaced by *new*. If the optional argument *count* is given, only the first *count* occurrences are replaced.
vale wing
#

Ig you need to make mess global

#

Should work and you may also wrap await mess.delete into try-except in case mess is not defined yet or failed to delete

#

Use it

#

But not bare

boreal ravine
#

why is there a tip on basic math lol

vale sierra
#

hello, i try to make reddit code (https://paste.pythondiscord.com/monafokaxa). I have two commands +redditmeme and +reddithistorymeme but +redditmeme send a (sometimes) history meme and meme. Same for +reddithistorymeme. This two commands conflit each other. How can i fix this pls ?

final iron
vale sierra
vale sierra
final iron
hushed galleon
#

the problem being that the word "memes" is in your link? or that it should be looking from the HistoryMemes subreddit?

vale sierra
vale sierra
ornate linden
#

does stopping a task just stop it from looping or does it stop immediately

hushed galleon
#

you mean the task loop's stop() method?

ornate linden
#

yes

hushed galleon
ornate linden
#

ah

#

thanks

vale sierra
#

its not an embed ?

ornate linden
#

pretty sure that's an embed

vale sierra
#

its a embed just without color i think

hushed galleon
unkempt canyonBOT
#
str

class str(object='')``````py

class str(object=b'', encoding='utf-8', errors='strict')```
Return a [string](https://docs.python.org/3/library/stdtypes.html#textseq) version of *object*. If *object* is not provided, returns the empty string. Otherwise, the behavior of `str()` depends on whether *encoding* or *errors* is given, as follows.

If neither *encoding* nor *errors* is given, `str(object)` returns [`object.__str__()`](https://docs.python.org/3/reference/datamodel.html#object.__str__ "object.__str__"), which is the “informal” or nicely printable string representation of *object*. For string objects, this is the string itself. If *object* does not have a [`__str__()`](https://docs.python.org/3/reference/datamodel.html#object.__str__ "object.__str__") method, then [`str()`](https://docs.python.org/3/library/stdtypes.html#str "str") falls back to returning [`repr(object)`](https://docs.python.org/3/library/functions.html#repr "repr").
quick gust
#

it is an embed

ornate linden
#

set it to the same color as the embed

quick gust
#

^

hushed galleon
ornate linden
#

try swapping to light theme and i bet you'll be able to see it

quick gust
#

same colour as the embed bg colour

ornate linden
#

if you don't supply a color what is it by default?

#

or is it a required field

#

ah

vale sierra
#

anyway, did someone know how to lock a server without lock private channels ?

verbal fox
#
PS D:\Python\Coinbase> python bot.py
Traceback (most recent call last):
  File "D:\Python\Coinbase\bot.py", line 3, in <module>
    from discord import Client
  File "C:\Users\neild\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\__init__.py", line 20, in <module>
    from .client import Client, AppInfo, ChannelPermissions
  File "C:\Users\neild\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 38, in <module>
    from .state import ConnectionState
  File "C:\Users\neild\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\state.py", line 36, in <module>
    from . import utils, compat
  File "C:\Users\neild\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\compat.py", line 32
    create_task = asyncio.async
                          ^^^^^
SyntaxError: invalid syntax
#

does anyone know how do fis this error

vale wing
unkempt canyonBOT
jolly basalt
#

How do I make slash commands

vale sierra
#

thanks

jolly basalt
boreal ravine
#

the embed color would appear as grey/black for them

jolly basalt
#

not disnake, nextcord etc.

junior verge
#

How do I do this in repl.it since .env does not work anymore

boreal ravine
junior verge
#

Just decent I'd say

verbal fox
junior verge
#

should it be ()

vale wing
jolly basalt
#

tyyy

boreal ravine
slate swan
junior verge
vale wing
#

I remember there's getenv that is a method, but that thing is a dict isn't it

jolly basalt
boreal ravine
vale wing
boreal ravine
#

they did ```py
client.run['my_secret']

vale wing
#

O

junior verge
#

Yeah

#

Should it be ('my_secret')

#

just my_secret did not work

boreal ravine
#

no

slate swan
boreal ravine
#

use the variable you made and put it inside client.run's arguments

slate swan
#

the error had something similar so..

boreal ravine
#

yes

jolly basalt
junior verge
#
my_secret = os.environ['CODE']
``` This is fine, right?
wicked lily
#

or just

#

do this

#

client.run('id')

#

very easy

junior verge
wicked lily
#

i am also using replit

junior verge
#
client.run('my_secret')
``` that did not work
wicked lily
#

for everything but it is private

junior verge
wicked lily
#

put it in a string

junior verge
#

Like that

wicked lily
#

just directly put the id

junior verge
#

Isn't it in replit?

wicked lily
#

what?

wicked lily
junior verge
wicked lily
#

public is paid

#

right

#

oops

#

it is public

junior verge
#

Got this now

import discord
import os
from discord.ext import commands

client = commands.Bot(command_prefix = ".")
my_secret = os.environ['CODE']

@client.command()
async def load(ctx, extension):
    client.load_extension(f'cogs.{extension}')

@client.command()
async def unload(ctx, extension):
    client.unload_extension(f'cogs.{extension}')

for filename in os.listdir('./cogs/'):
    if filename.endswith('.py'):
            client.load_extension(f'cogs.{filename[:-3]}')

client.run(my_secret)

junior verge
wicked lily
#

yes

junior verge
wicked lily
#

import discord
import os
from discord.ext import commands

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

@client.command()
async def load(ctx, extension):
client.load_extension(f'cogs.{extension}')

@client.command()
async def unload(ctx, extension):
client.unload_extension(f'cogs.{extension}')

for filename in os.listdir('./cogs/'):
if filename.endswith('.py'):
client.load_extension(f'cogs.{filename[:-3]}')

client.run('code')

#

try this

junior verge
#

Yeah lol

slim ibex
junior verge
#

Tried his code, what he send me

#

Oh oki

#

Okay

#

But that's the error I still am getting

#

Wait...

#

I refreshed the page and it looked really weird haha

#

Think it works, but got a normal error now

leaden jasper
#

lag thats all

junior verge
#

No mate

#

It works already what are you saying?

#

Just got a other error

#

I am using that, no clue what you are saying

quick gust
# junior verge

whats with the random '). and u dont put the token since my_secret is already your token

haughty quartz
#

anyone knows how I tell ppl they gotta reinvite the bot if they don't have the application.commands scope??

junior verge
#

No... it's just lag

#

But it works now I guess, just a error in some of the cogs I assume

quick gust
#

and, it tells u how to fix, in the error

junior verge
quick gust
#

replit things

junior verge
#

erm

#

How to fix, uh?

quick gust
#

u have to install it through the package manager i think

#

not sure how because I don't use replit

leaden umbra
#

noob question: if I have a userid and an array of roleids to grant it, what is the command to do so? Also to get an array of the userid's current roles if possible

junior verge
#

@wicked lily You use replit right?

#

@slate swan got any clue?

minor totem
#

There might be two tabs, I don't fully remember. If there isn't, then you might be more-or-less unable to install pymongo.

leaden plaza
leaden umbra
#

I'm super noob at discord bots

brittle axle
tame nymph
#

bruh I cannot even see my bot token anymore

#

it says I can only view it once

#

and I need 2FA codes every time I regenerate

leaden umbra
#

ok thanks I think I get it

kindred drum
#

how do you get the quote symbol in an embed?

#

this

whole shoal
#

Just type >>>

kindred drum
#

explain 😄

#

s

whole shoal
#

I think they should

#

Not embeds but the

quote

slate swan
whole shoal
slate swan
#

oh nvm didnt read that

whole shoal
#

Need to test xD

slate swan
#

is that even possible though? frog_sip

whole shoal
#

h

hushed galleon
kindred drum
hushed galleon
#

the decorator is incomplete but otherwise that is how you'd display quoted text

#

works inside embed description too

vale sierra
hushed galleon
#

it is surprisingly flexible

kindred drum
#

how do i format an embed like this

vale sierra
#

use \n

kindred drum
#

\n?

hushed galleon
#

that looks like its using the embed's description

kindred drum
#

its not

hushed galleon
#

can you show the full embed?

kindred drum
#

thats a field

hushed galleon
#

i said the full embed

vale sierra
#

@kindred drum read the doc about embed

hushed galleon
#

but even if its in field value there's not much that changes about what you write

kindred drum
#

how would I format the fields like that tho

#

like its a list

#

its not the description tho?

hushed galleon
#

yeah thatd be the text

#

just use add_field then

vale sierra
#

if its not the description just do add_field

final iron
hushed galleon
kindred drum
#

How would I do it in add_field

vale sierra
#

someone know the code about lock a whole server not just one channel pls ?

kindred drum
#

cause like I don't get the multiple lines in 1 thing

#
                        ">something"
                        "something" 
                        value="test")
``` that doesn't work
vale sierra
#
embed.add_field(name = "", value = "", inline=True)
kindred drum
#

wow I did not know you could have multiple lines in an embed

cold sonnet
#

....

kindred drum
#

i also forgot about that

vale sierra
#

read the doc

#

someone know the code about lock a whole server not just one channel pls ?

cold sonnet
#

know the code?....

vale sierra
#

like all the channels is lock nobody can talk

#

i read it but couldn't find lol

cold sonnet
#

that's a damn lot of API calls

tidal hawk
#

What listener detects boosts?

hushed galleon
#

the most preferable way to do that is to edit the send_messages permission of the role that everyone has
(edit: was corrected after this, listening for on_member_update() and checking .premium_since should work)

#

but that relies on people having organized permissions

pliant gulch
#

You could just edit the guild's default role's permission

#

The hierarchy would cause an issue if the user has a role above default with send messages

#

In that case either way, perhaps it is a staff role or something?

hushed galleon
#

which only works if the server settings has a system channel the bot can see and has boost messages enabled

cold sonnet
#

doesn't it show up in the audit log

vale sierra
# pliant gulch You could just edit the guild's `default` role's permission
    @commands.command()
    @commands.has_permissions(ban_members=True)
    async def lock(self, ctx, channel : discord.TextChannel=None, setting=None):
        if setting == '--serveur':
            for channel in ctx.guild.channels:
                await channel.set_permissions(ctx.guild.default_role, reason=f"{ctx.author.name} a fermé {channel.name} avec --serveur", send_messages =False)
            await ctx.send("Serveur fermé.")
        if channel is None:
            channel = ctx.message.channel
        await channel.set_permissions(ctx.guild.default_role, reason=f"{ctx.author.name} a fermé {channel.name}", send_messages =False)
        await ctx.send("Salon fermé.")
``` i make this code but the problem is to close the whole server we need to close a channel before, and that's not what I want
cold sonnet
#

or a guild update event that triggers boosts

pliant gulch
#

Yea guild update get's dispatched on boosts, that would probably be easier than to just check message

vale sierra
#

but the problem its(is?) this i have to choose a channel before

cold sonnet
#

huh then why is it in the docs

hushed galleon
#

oh actually yeah good point

cold sonnet
#

oh this an AuditLogAction

vale sierra
#

idk and its annoying i don't see the reason

pliant gulch
#

There is also on_member_edit which can be dispatched by roles

cold sonnet
#

how do you get an AuditLogAction event

pliant gulch
cold sonnet
#

!d discord.AuditLogEntry

unkempt canyonBOT
#

class discord.AuditLogEntry(*, users, data, guild)```
Represents an Audit Log entry.

You retrieve these via [`Guild.audit_logs()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.audit_logs "discord.Guild.audit_logs").

x == y Checks if two entries are equal.

x != y Checks if two entries are not equal.

hash(x) Returns the entry’s hash.

Changed in version 1.7: Audit log entries are now comparable and hashable.
cold sonnet
#

ah this

pliant gulch
unkempt canyonBOT
#

is_premium_subscriber()```
[`bool`](https://docs.python.org/3/library/functions.html#bool "(in Python v3.10)"): Whether the role is the premium subscriber, AKA “boost”, role for the guild.

New in version 1.6.
cold sonnet
#

what would you rather use to detect if a member's roles changed

pliant gulch
#

on_member_update

cold sonnet
#

on_member_update event or AuditLogEntry

unkempt canyonBOT
#
Not in a million years.

No documentation found for the requested symbol.

cold sonnet
#

or what's the event that gets AuditLogEntry

pliant gulch
#

member_update, because it's from the gateway

#

It's an event, where as AuditLogEntry will need you to fetch the audit logs first

cold sonnet
#

ew

unkempt canyonBOT
#

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

Creating a Bot account is a pretty straightforward process.

vale sierra
#

yes that's work just have to fix the bot bc he send "salon fermé" (= close channel)

cold sonnet
#

it does have a premium_since one

#

attribute, not method

#

what does it return if member ain't a booster

#

False?

#

None?

junior verge
#

Still get this error even though I did pip install in shell

cunning ice
#

is it possible to make a bot which shows read and unread msgs ?

maiden fable
#

👀 I see someone doesn't like reptiles anymore

cunning ice
cunning ice
maiden fable
#

Phew, I was already scared of yr banner

junior verge
hushed galleon
#

just import it and replit should handle installing the package for you

manic wing
#

all messages are “read”

#

read and unread are only on user clients

cunning ice
#

XDD

junior verge
#

And then it still gives the same error

slate swan
junior verge
#

pymongo

slate swan
hushed galleon
#

you might need to try editing the pyproject.toml file to specify the proper version of the library to install then

#

also motor...

junior verge
#

I just moved my files from visual studio code to replit

hushed galleon
#

the async lib motor should be used instead of pymongo to avoid blocking the bot

junior verge
#

How do I?

slate swan
junior verge
maiden fable
slate swan
#

or try reloading the page once and then do so

slate swan
maiden fable
#

Has happened with me a few times now tbh

outer sigil
#

my bot goes offline for like 5 minutes everyday but it doesn't crash it just boots back after

maiden fable
#

Sad

quick gust
#

replit or something?

maiden fable
#

Where u hosting the bot?

outer sigil
#

replit

quick gust
#

there u go

outer sigil
#

it's a replit thing ig

quick gust
#

it is

outer sigil
#

if you don't want to host it on replit you can use another computer

#

raspberry pis apparently works well

trail oxide
#

Hi, how can I make sure that the ones I blacklist from my bot do not have to be a part of a discord server the bot is also in?

whole shoal
#

Don't use replit for hosting bots 💀

high apex
trail oxide
#

Hi, how can I make sure that the ones I blacklist from my bot do not have to be a part of a discord server the bot is also in?

Source:

@Client.command()
async def blacklist(ctx, user: discord.Member):
    Client.blacklisted.append(user.id)
    data = read_json("blacklist")
    data["Blacklisted"].append(user.id)
    write_json(data, "blacklist")
    await ctx.send(f"Hej, {user.name} er nu blevet blacklisted")```
whole shoal
trail oxide
#

can someone help me, pls

slate swan
high apex
#

replit is my preferred option

whole shoal
high apex
#

oh

#

replit changes ip every few hours

whole shoal
#

Yes it's better to find another host

high apex
trail oxide
#

Hi, how can I make sure that the ones I blacklist from my bot do not have to be a part of a discord server the bot is also in?

Source:

@Client.command()
async def blacklist(ctx, user: discord.Member):
    Client.blacklisted.append(user.id)
    data = read_json("blacklist")
    data["Blacklisted"].append(user.id)
    write_json(data, "blacklist")
    await ctx.send(f"Hej, {user.name} er nu blevet blacklisted")```
boreal ravine
whole shoal
trail oxide
#

i mean i can blacklist people without them being a part of a discord server

whole shoal
#

Oh that

trail oxide
whole shoal
#

You need their id, and use fetch_user

trail oxide
#

so what should i change?

#
async def blacklist(ctx, user: discord.Member, fetch_user):```