#discord-bots
1 messages · Page 900 of 1
So he’s great and all but makes bad tutorials and uses bad practices 
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
https://gist.github.com/wasi-master/835adfeec4802423f6a1522c25689010 never mind found it
You can use an infinite loop
While true:
Asyncio.sleep(15*60)
Send message
Thanks robin
tysm!
Or the tasks extension. It was made for this specific purpose
lmfao
hmm
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
true
Oh right, that’s new isn’t it
Rather try to solve problems yourself without searching for a tutorial. Referring to the documentation and asking others for help is fine
yes
If all these tutorials didn't encourage using JSON as a database most beginners wouldn't even see it as a option. They would instead ask "what's the best way to store data for my economy bot", we'd respond "a database" and overtime using a database would be the de-facto, just how it should be
But anyway that's more for #pedagogy i suppose
Sometimes I feel like spamming Lucas's comments 
Okay, part 1 seems very nitpicky about his coding style and doesn’t actually say anything, also, like, what are you supposed to do if your tutorial is outdated. Not his fault, imo, maybe a disclaimer in the description 🤷♂️ either way, that’s kind of irrelevant
Going to see the rest
Well that's what I meant by tutorials are inherently flawed
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
In general, exactly
High seo with outdated tooling
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
https://gist.github.com/wasi-master/835adfeec4802423f6a1522c25689010 already had 2 issues today from part 10 in the gist
Last active 3 minutes ago
Lol
Who?
wasi-master
Chill guy. Knew him on d.py
Pretty well known in the community, wouldn't say he's a stranger
Noice
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') ```
well it depends on what you want it to do
wdym?
.
💀
I used to watch him
is it possible to make a discord bot that tells when a person is online even if he is invisible ?????
i just want make command that counts message from users and second command that adds points
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
🤷♂️ it’s on latest, by the way
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
Ahhh
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
The actual contents of the message.
discord.py doesnt seem to have a way to get it
thats what this is
@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?
message content intent isn't even forced yet
make sure u have it enabled
Never heard of that module before lmao
nice
So ur telling me if u need to enable intents you don’t need to open the dev portal?
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
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
Why doesn’t this work it’s giving anyone the role
It’s giving people with no default avatar
show the whole code
Member.default_avatar is something that always exists
Instead you should check if user does not have an actual avatar
if not member.avatar:
...``` to be exact
!d discord.Member.avatar it's None if the avatar or user is a default one
property avatar```
Equivalent to [`User.avatar`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.avatar "discord.User.avatar")
Wait so if a member has a default avatar it will do something
Not anylonger, it's change in discord.py 2.0
It will..
What do you understand by typing.Optional? Xd
It does still work in dpy 2.0
!d discord.User.avatar
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").
yea the developer was high while writing this.
I feel like I was a little out of context
how?
they want to check if the user has default avatar or not? And that's literally the only way
I thought u said it wasn't possible to get avatar like this. I just saw ur message that it returns None
oh oki
LETS GO IT WORKS
Great
I was just building a security bot
Just use created time it’s more accurate
Oh hmm so checking suspicious accounts without an Avatar
I mean like if date is within like 15d or something
Yes because spam raid account have no avatar
How?
And also it blocks raid bots
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
Hey is there a way to make it so the bot can remove a role
!d discord.Member.remove_roles
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.
I see someone doesn't like reptiles anymore 👀 (BCC: @slate swan)
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
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
you can use the on_member_update event
@slate swan u also bought nitro 
and see what roles were added
someone gifted me
Same thing
how did i bought that then
Oh ok
I have.
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...
i dont see the same thing in your code
on_member_role_update I’m using this
How do you know?
its in your webserver's url bar
it takes 2 args , before and after
which are discord.Member objects
It says on weburl
Oh
'Context' object has no attribute 'member'
can anyone help why i am getting this error
@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
this is my answer
um when i do ctx.author it tags me but i want it to tag the member i mentioned can you help me how
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
then run the command like !Hug @someone. it won't work if you don't mention
alr
Pretty sure it will work if it's a valid ID/username in the server
!hug 830328082724290611
or
!hug Sven77 should work
yeah
oh wait I didn't say that, sorry mb
I mean like if he does only !Hug then it won't work
ah
uwu hi
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”)
@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
Is the url defined
yeah
Ouh Wasi here 👀
Hi hunter
Hi alex
@maiden fable im here too
Hi arl
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
how to do
await ctx.send(random.choice(number) + "/10")
Uhh, the honors is all yours
await ctx.send(str(random.choice(number)) + "/10")
Don't go 
i will watch your career from afar and with great interest
Meh, I am going
im using replit
Cool
so i dont think i can upload a picture there
You can
great so i won't be missing much
how to get message content from a message id and channel id?
Just like u upload from pc lol
!d discord.TextChannel.fetch_message
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.
!d discord.Client.get_partial_messageable
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.
Just come back here. Why is everyone watching me going to hell, from afar today?
o
👀 Never knew this existed
tldr burnout
😔
taking a few days off because I have so many plans and not enough time and too much stress etc
ohmygod the things i have planned vs the number of hours in a day are atrocious
how bout read the file and then pass it into the file kwarg?
😔 Go sleep arl
Ye you just drag it onto repl
@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
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())```
whats the slash argument
i think im using it wrong
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
This is not a Modmail thread.
?rtfm BotMissingPermissions
?
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
if guild.me.guild_permissions.send_messages:
#Do something```
ill try it, thanks
\👍
solve pls
🥲
are you sure that wasn't your real username and password?
😔
my pass is secret i dunno wanna reveal
can i do with channel tho
thats why
that just looks like its only for guild
it is not discord bot related
yes it is i wanna make custom prefix without json so i use database
oh idk about databases
that has nothing to do with discord bots
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
Sure
ye you can use txt
@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?
yup
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?
you haven't turned on intents
xd
@slate swan wont i get ratelimited?
no
bot has higher rate limit quote than the normal user
theres like a hundred channels in my server tho
does it? 👀
and ill be using this in multiple servers
Ye
no prob
okay if u say so lol
It shows error at end you need to turn intents on
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
if guild.me.guild_permissions.mention_everyone:
#Do something```
why you want to do?
When user does command it checks if user id is in txt if not the bot sends message your not white listed
You can unindent the below blacklist = f.read()
How are the ids formated inside the txt file?
userid1
Userid2
Userid3
@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
\👍
hey you are right i put wrong name
\👍
Not sure if it would make difference, but I'd create a list by the whitelist.txt
of database
\👍
but a new error comes
Where every element is split by (\n)
sending...
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?
idk here is all error
hmm line 69
Does the error show as soon as you start the program?
and 207
yes
Send line 207 and lines near it of your bot
bot.loop.run_until_complete(create_db_pool())
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
ok
you need to run the bot
You havent added token too
do you have an on_message event?
if there isnt a run method, what will the token do 
@client.event
async def on_message(message):
msg = message.content
with open('whitelist.txt', 'r') as f:
whitelist = f.read()
if message.author.id in whitelist:
return
else:
await ctx.send("not whitelisted")```Do this
1 printed but 2 have error
Client.run(“token”)
so error in the bot.db line
Ok
Does it show error?
Isn't that gonna spam everytime when someone messages and they aren't in the txt file
ye but he asked so thats why
does it show logged in as bot?
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
@slate swan
Kk
Broo convert it into a list
is it really a bot?
whitelisted_ids = whitelist.split('\n')
does the bot come online when you do start it
you can use in function in strings too
yeah but it's awkward
mhmm bot has permissions?
mhmm invite me to the server
and send the bot token in DM
let me test myself
is that allowed
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
for testing yes
whats the error and what you wanna do?
show your whitelist txt?
whats this for
oh nvm wait
I dont think you should always read the file on on_message events
It’s user id checking but no error
you should use readlines instead or split that text
he can do .read() as he is searching the string
My user ids in txt file are like:
875711009606729808
875711009606729808
@slate swan
whats the problem that is happening with it?
yeah though, readlines splits the text every line and returns a list
Bot isn’t replying to command
@slate swan whitelist is a string
875711009606729808\n875711009606729808
make it a list
[875711009606729808,875711009606729808]
because the id is in list
But will not reply to those whose IDs are in the list
@slate swan if u want to add a global check, look into bot.check
Ok
!d discord.ext.commands.Bot.check
@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...
That’s the opposite I want it to do
the problem is nothing
how about you install the packages 1 at a time
to find the faulty package
how about installing discord first
according to the command the bot will say "Not whitelisted" to those whose ids are not in the file
maybe
Ok
@slate swan but it’s not sending message would on_message be reason?
which message? the "Not whitelisted" one?
Wym
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
and your library's documentation

is discord.py better than discord.js? which is better in which case?
Both in practical use are the same man but discord.js has more of the new stuff already in it
discord.js allows you to receive audio back
js is also preferred to make apis and api calls
The simple thing: Dpy is preferred if u use Python, elif use djs if u use JS
hello
what's that
are discord bots allowed to store all the messages we type in a database? surely that has to be against tos?
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
depends on why you want to store them
well, you can do it, but it may ratelimit your bot, you may need to run a task
why would it be allowed?
idk, maybe chatbot and stuff
oh like how
Also you cannot delete messages more than 2 weeks old*
Yes, but u gotta delete it every 30 days
well yeah, discord's TOS not uwu 😔
My bot saves some part of the message, and discord doesn't have an issue with it
Not discord ToS, an API limitation
How tf do u think not being able to delete messages more than 2 weeks old is a ToS issue?
Yea thats fine, this is just so that if the user spams and then we detect it, it would help us delete all the spammed messages easily

Ah
well, I did think, my bad
If u wanna make an anti spam 👇 👇
is there a way to store info using the discord API?
Yea
what i had in mind is writing to a txt file every time a user sends a message
Just request it and, uhhh, save it to a db?
what does this do??
Makes an anti spam totally not doing free paid work
😔 Rip yr txt file
lol
where is the documentation for it?
or is it not in the stable version?
there's the TextChannel.purge() method you can use to delete their messages, or if you're banning them then you could delete their messages in that method instead
CooldownMapping is undocumented so you'll need to read the source for more info on that
Oh I see
sure
But purge doesnt delete user specific, so ive to make a list of all the msg and then use channel.delete_messages ig?
Add a check if you want it to be user-specific
you can pass a check function to purge and return a condition
oh its even listed as an example in the documentation for purge
oh wow
So I should go into each channel and THEN check for the user message right
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
line 81, in avatar
memberAvatar = member.avatar_url
AttributeError: 'Member' object has no attribute 'avatar_url'```
member.avatar.url
doesnt work either
huh?
How are you building your Member object?
line 81, in avatar
memberAvatar = member.avatar.url
AttributeError: 'NoneType' object has no attribute 'url'```
....
Yes, but where are we getting member from?
@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)```
?
dpy version?
no disnake
ok works
Coolio
Oh, I misread it as Member is None
automated system
is there a way to avoid that
Stop using replit
An online computer which runs 24/7
(I'm the worst at explaining things, I'mma leave it to Shi Tsu to explain)
guys please did someone face this issue ?
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.
This channel specifically isn't the place for this.
Instead, you can get assistance for this via one of the help channels.
#❓|how-to-get-help
then storing sent messages from on_message would be the most preferable way to do it, rather than scanning all the channels
bots generally get ratelimited faster on replit, ive tried doing that
I really cant ig, I just came back from a 104f fever
better if you would do the honours
basically its replit + uptime robot battle pass
you use vsc + vps
nooooo, replit is not a vps
yeah ik
does it work on mobil
no
and using replit and uptime robot is bad for discord bots
for mobile i suggest you to use self hosting
i broke i cant do self hosting and vps so i use replit
mometn
yes high ping and slow responses
and, the api ratelimiting issue
what is that
Ouch, take care
Never got a high ping on replit
you too
thankee
oeh
Yeah about to say that too
Replit hosted bots usually have 40ms ping
flexes 0 ping on replit
When i host my bot on my vps it's usually 80ms now
i c
It's twice the usual ping but it is in miliseconds
mhm, ive only got twice or thrice lol
Or vps there's really good vps hosting for cheap if you look hard enough in reddit
average 43 ms
how to delete autodetect multiple channels and delete them?
i cant afford a vps as a 14 year old teeenager that dollars need to be 4x to be my currency
can you specify what do you want
Well there's a free way
i want the bot to automatically detect multiple channels and del them with a cmd
Im using it right now
PoV: Your bot is ratelimited
I can tell you something that might help you in your situation
how do i prevent from being ratelimited in replit
pov: your bot gets banned because someone created a ddos thing on your ip
@heavy hound
Plot Twist: i don't run my bot anymore
By not using replit
Double Plot Twist: I don't code discord bots anymore
can uptime robot run for vsc flask
what do you mean by 'multiple' channels? it sees 2 channels and deletes them? 
!d on_channel delete
No documentation found for the requested symbol.
i forgor what is it called
🗿
Nope, u need to add a public IP or smth for the flask app in order to make uptimerobot ping yr website
probably anti nuke bot that prevents random user bot to add mass channel to the server
channels with same name
Triple Plot twist: you have a life out of discord
alright enough, already got cringy
Shi Tsu or people in #web-development probably have more information since they into web deving more than me
has guild for sure
you can just manually delete it smh
Quadruple Plot Twist: I ain't got an irl life
Anyways OT
!d discord.on_guild_channel_delete
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.
me and danny same brain
i want my bot bruh if u know tell otherwise dont
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.
danny
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
duplicate = any(name == channel.name for channel in channels)
will it help?
detecting multiple channels?
almost
await duplicate.delete()?
replace name with channel2.name for example
ok
btw it wout detect only if i enter channel name
i want to auto detect multiple channel names
this event triggers when a channel is created
the if statement is true if the name of the new channel is the same as another channel's name
don't give random people admin
i want to recover already nuked server
lol
don't give random people admin
bruh it is already nuked no meaning in giving them now
you gave random people admin
yes
🗿
how to define a channel with it's position
guild.channels[position]
ok
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
Asyncpraw?
Yeah
how to change vanity invite discord py
doubt u can
what's the issue
httpx.patch("https://discord.com/api/v9/guild/941405317651124314/vanity-url/test")
why isnt it working
Anyone pls tell me Eval of js
;
Headers
@cold sonnet
what's your code on this command
async with httpx.AsyncClient(headers= {"Authorization": "Bot %s" % (self.client.http.token)}) as AsyncClient:
AsyncClient.patch("https://discord.com/api/v9/guild/941405317651124314/vanity-url/test)
now?
Also %22?
async for entry in guild.audit_logs(
limit=1,
after=datetime.datetime.now() - datetime.timedelta(minutes=2),
action=discord.AuditLogDiff.vanity_url_code):
if entry.user.id in IGNORE :
return
else:
async with httpx.AsyncClient(headers= {"Authorization": "Bot %s" % (self.client.http.token)}) as AsyncClient:
await AsyncClient.patch("https://discord.com/api/v9/guilds/941405317651124314/vanity-url/venomtest")
print("Done")
why isnt it working
!d discord.AuditLogDiff
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.
!d discord.Guild.edit
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...
use the vanity_code= kwarg
you're using the minus operators - instead of assignments =
Oh
Does someone mind taking a look at this code for me because for some reason my slash command isn't being registered but i'm not getting any errors when I run the bot.
This is my main.py file https://paste.pythondiscord.com/exigeyerol
This is my cogs.users.py file https://paste.pythondiscord.com/oqunuxobul
This is my utils.services.py file https://paste.pythondiscord.com/ofuyehohul
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?
how do i define vanity code
Is there a way to play music in a vc using a bot coded in discord.py?
You should get an error after
I'll let someone else deal with this since im gonna sleep
because of thispy try: await mess.delete() except: passif it errors your passing on the error (ignoring it)
And never just use except. Always try to catch a specific error rather than only except
Yes as i have said
yeah i was just clarifying it as it seemed they were getting confused
how do i define before guild vanity
If you are using globals, the global keyword must be inside of the function
pls help me
And yeah don't use bare except, catch discord.HTTPException instead
What
how to i remove a particular segment of letters from the message
Use string functions I guess
give me ex pls like on message bot would reply in last few letters
We don't make complete code here
teach me how to do it
What is your python experience level
nothin almost and dont tell me to learn now
i am in hurry actually
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
i know py btw incomplete
dont want just teach me to edit a particular segment in a word
i just want the vanity code of a guild only code
how do i define that cant find it in docs
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)
!d discord.Guild.vanity_invite
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.
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)```
why are they even syncing the slash commands inside of the slash command
!d str.replace
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.
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
why is there a tip on basic math lol
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 ?
What do you mean conflict with each other
i'm gonna use pics bc idk how to explain
look thats my problem
Still don't get it
the problem being that the word "memes" is in your link? or that it should be looking from the HistoryMemes subreddit?
the commands should be a r/historymemes not a r/memes
that should be looking from the HistoryMemes subreddit yes exactly
does stopping a task just stop it from looping or does it stop immediately
you mean the task loop's stop() method?
yes
its not an embed ?
pretty sure that's an embed
its a embed just without color i think
well youd want to design your commands such that they reference their own lists of memes
yes
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").
it is an embed
set it to the same color as the embed
^
so this is not fully related to discord.py since you're struggling with the reddit part
try swapping to light theme and i bet you'll be able to see it
same colour as the embed bg colour
its a code for discord.py so
anyway, did someone know how to lock a server without lock private channels ?
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
using discord.py
!d discord.TextChannel.overwrites_for
overwrites_for(obj)```
Returns the channel-specific overwrites for a member or a role.
How do I make slash commands
thanks
the embed color would appear as grey/black for them
not disnake, nextcord etc.
one question: how experienced are you with python?
Seems like module error wtf
Just decent I'd say
think i fized it
should it be ()
You forgot a closing "
tyyy
doesn't look like it though, you tried to do [] on a method
https://gist.github.com/Rapptz/c4324f17a80c94776832430007ad40e6#slash-commands-and-context-menu-commands you need to use the master branch tho
Is it a method
os.environ returns a dict
Where? huh
I remember there's getenv that is a method, but that thing is a dict isn't it
so btw, should I move to nextcord or disnake
not what i was talking about
"my_secret
they did ```py
client.run['my_secret']
O
no
if you want to make them easily consider using a fork
since the slash commands implementation in discord.py is very complex
for a fork, ill suggest disnake
use the variable you made and put it inside client.run's arguments
ah, didnt notice that
the error had something similar so..
In the run?
yes
ty, cuz ive been considering it
Didn't I already do that? sorry
my_secret = os.environ['CODE']
``` This is fine, right?
Yeah but I am in replit so everything is public if you get me
i am also using replit
client.run('my_secret')
``` that did not work
for everything but it is private
Hm, how?
string
put it in a string
Like that
just directly put the id
what?
yes but mine is private
How? Paid or?
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)
No... private is paid
yes
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
Yeah lol
don't name a bot instance client
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
lag thats all
No mate
It works already what are you saying?
Just got a other error
I am using that, no clue what you are saying
whats with the random '). and u dont put the token since my_secret is already your token
anyone knows how I tell ppl they gotta reinvite the bot if they don't have the application.commands scope??
No... it's just lag
But it works now I guess, just a error in some of the cogs I assume
and, it tells u how to fix, in the error
replit things
u have to install it through the package manager i think
not sure how because I don't use replit
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
Still doesnt work :/
@wicked lily You use replit right?
@slate swan got any clue?
You're running it in the Python REPL, not the shell.
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.
Type this command in shell
you mean the methods
I'm super noob at discord bots
go to shell and type that command man
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

ok thanks I think I get it
Just type >>>
@command()
async def uwu(ctx):
await ctx.send("> uwu quote")
No no inside an embed
oh nvm didnt read that
Need to test xD
is that even possible though? 
h
replit should already autoinstall just by scanning your file imports, and also the async lib motor should be used instead of pymongo to avoid blocking the bot
this wont work i think
the decorator is incomplete but otherwise that is how you'd display quoted text
works inside embed description too
its for a member or a role, not for private channels ?
it is surprisingly flexible
use \n
\n?
that looks like its using the embed's description
its not
can you show the full embed?
i said the full embed
@kindred drum read the doc about embed
but even if its in field value there's not much that changes about what you write
how would I format the fields like that tho
like its a list
its not the description tho?
if its not the description just do add_field
Better discord smh
nah powercord
How would I do it in add_field
someone know the code about lock a whole server not just one channel pls ?
cause like I don't get the multiple lines in 1 thing
">something"
"something"
value="test")
``` that doesn't work
what is this?
embed.add_field(name = "", value = "", inline=True)
wow I did not know you could have multiple lines in an embed
....
just do \n
i also forgot about that
read the doc
someone know the code about lock a whole server not just one channel pls ?
know the code?....
that's a damn lot of API calls
What listener detects boosts?
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
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?
there is no dedicated listener for this, you can only listen for a system message whose .type equals MessageType.premium_guild_subscription
which only works if the server settings has a system channel the bot can see and has boost messages enabled
doesn't it show up in the audit log
@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
or a guild update event that triggers boosts
Yea guild update get's dispatched on boosts, that would probably be easier than to just check message
but the problem its(is?) this i have to choose a channel before
huh then why is it in the docs
oh actually yeah good point
oh this an AuditLogAction
what a lucky guess
idk and its annoying i don't see the reason
There is also on_member_edit which can be dispatched by roles
how do you get an AuditLogAction event
Different detection, but you would need to use another method of checking whether or not it is a nitro boost role
!d discord.AuditLogEntry
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.
ah this
!d discord.Role.is_premium_subscriber
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.
what would you rather use to detect if a member's roles changed
on_member_update
on_member_update event or AuditLogEntry
No documentation found for the requested symbol.
or what's the event that gets AuditLogEntry
member_update, because it's from the gateway
It's an event, where as AuditLogEntry will need you to fetch the audit logs first
ew
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.
yes that's work just have to fix the bot bc he send "salon fermé" (= close channel)
it does have a premium_since one
attribute, not method
what does it return if member ain't a booster
False?
None?
Still get this error even though I did pip install in shell
is it possible to make a bot which shows read and unread msgs ?
👀 I see someone doesn't like reptiles anymore
hii bro
any suggestions ?
@junior verge
read and unread as in?
Phew, I was already scared of yr banner
So how will I fix it? I don't get it, sorry.
just import it and replit should handle installing the package for you
no
all messages are “read”
read and unread are only on user clients
XDD
I did man
And then it still gives the same error
which library?
pymongo
whats the issue?
you might need to try editing the pyproject.toml file to specify the proper version of the library to install then
also motor...
What is that?
I just moved my files from visual studio code to replit
the async lib
motorshould be used instead of pymongo to avoid blocking the bot
How do I?
if you really want to manually install the libraries, just use repl shell to use pip
I just did and still gives me that error
It lags most of the times and then repl crashes
show a screenshot of your imports
or try reloading the page once and then do so
never happened to me
Has happened with me a few times now tbh
my bot goes offline for like 5 minutes everyday but it doesn't crash it just boots back after
Sad
replit or something?
Where u hosting the bot?
replit
there u go
it's a replit thing ig
it is
if you don't want to host it on replit you can use another computer
raspberry pis apparently works well
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?
Don't use replit for hosting bots 💀
i do that
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")```
It would be better if you find another host, there are some free hosts across discord
can someone help me, pls
sure
replit is my preferred option
@slate swan with this
Replit has shared ips, meaning if any bot being hosted there gets banned ur bot will get banned too
Yes it's better to find another host
ok
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")```
What do you mean by "do not"
You would need to check if they are in the server, if they are just ban
i mean i can blacklist people without them being a part of a discord server
Oh that
its blacklist, like so they cant use the bots commands
You need their id, and use fetch_user