#discord-bots
1 messages · Page 769 of 1
You mean the message content privileged intent?
Yes
That's April 2022.
is there something else happening
No precise date, so can be anytime in April.
No, nothing else; maybe the new way to ask for user input or slash commands permission system.
yeah, the amount of confused people that ask why their favorite bot isn't "functioning" anymore will increase
Although I'd guess they're in very early stage so won't happen that soon, but you never know.
on small bots, surely you will
If you get access to the intent, yes you can.
Otherwise no. And the change only affects verified bots.
Ok then there is no reason to use a library other than discord.py
Since commands will still work
Discord.py doesn't have slash commands
It's not the API wrapper library defining what intents you can use..
slash_util, but it isn't 100% stable
It's the API of Discord and it doesn't matter which library you use.
Is it another lib that someone made as an add-on or is it baked in?
API wrappers have no influence on intents privileges.
just that discord will make message intent privileged so if your bot is verified you must ask for the intent so the bot can check a messages content if not your bot cannot read a msg and thats why some verified bots use slash commands since their bot doesnt have the intent btw privileged intents only affect verified bots which people hate what will happen since getting intents is a trouble
Ok thanks
a helper from dpy made it, you have to do an extra pip install, and it'll be added to your discord.py package
yw
No need of an extra pip as far as I know.
https://gist.github.com/XuaTheGrate/5690a3d9dadb280d3d15f28f940e02d1
Simply get discord.py 2.0 and follow that guide.
Then you're good to go.
@commands.Cog.listener()
async def on_guild_channel_update(self, before, after):
async with aiohttp.ClientSession() as session:
async with self.db.execute(
f"SELECT webhook, guild_id from 'logging' where guild_id = {before.guild.id}",
) as cursor:
config = await cursor.fetchone()
if config is not None:
webhook = Webhook.from_url(config[0], adapter=AsyncWebhookAdapter(session))
if before.guild.id == int(config[1]):
async for entry in before.guild.audit_logs(action=discord.AuditLogAction.channel_update,
oldest_first=False):
embed = discord.Embed(
description=f'Channel was updated ({after.mention})',
color=discord.Color.dark_theme()
)
embed.set_author(name=entry.user, icon_url=entry.user.avatar_url)
embed.timestamp = datetime.datetime.utcnow()
embed.set_footer(text=f'{self.bot.user}', icon_url=self.bot.user.avatar_url)
embed.add_field(name='Creation date', value=f'<t:{round(before.created_at.timestamp())}:D>',
inline=False)
if before.overwrites:
embed.add_field(name='Overwrite deleted',
value=f'For: role Undefined',
inline=False)
if after.overwrites:
embed.add_field(name='Overwrite created',
value=f'For: role Undefined',
inline=False)
await webhook.send(embed=embed)```does anyone know why the field is not added, although I add a permission to a channel
yeah, that's in case you're on v2+ 🙂
Which is much better than using some additional plugin inside.
or are you just simply not able to install it on v1.7.3? idk
I think its finally time for me to subclass my help command
Best of luck
So if I wanted to create the help command with drop down menus for the cogs would I have to hardcode that bit?
property cogs: Mapping[str, discord.ext.commands.cog.Cog]```
A read-only mapping of cog name to cog.
preferably the loaded ones
Then you can use walk_commands() etc. But I'd guess that's in the Gist tutorial.
I should probably actually make some commands with drop down menus before making my help command
totally not just stalling
yeah, testing first, you don't hear it often
Any ideas for commands that would use them?
use an ||amongus ||api😳
@bot.event
async def on_member_join(member):
welcomechannel = bot.get_channel(934556383033065523)
embed = discord.Embed(colour=discord.Colour.blue())
guild = bot.get_guild(934554396975575061)
role = discord.utils.get(guild.roles, name="Member")
req = PreparedRequest()
req.prepare_url(
url='https://api.xzusfin.repl.co/card?',
params={
'avatar': str(member.avatar.url.with_format("png")),
'middle': 'welcome',
'name': str(member.name),
'bottom': str(f'Member #{guild.member_count}'),
'text': '#CCCCCC',
'avatarborder': '#CCCCCC',
'avatarbackground': '#CCCCCC',
'background': '#000000' #or image url
}
)
embed.set_image(url=req.url)
await welcomechannel.send(embed=embed)
await member.add_roles(role)``` is someone able to tell me what is wrong in the code?
Traceback (most recent call last):
File "C:\Users\bert\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 351, in _run_event
await coro(*args, **kwargs)
File "c:\Users\bert\Downloads\discord bots\bertie's discord bots.py", line 44, in on_message_delete
await logs.send( embed=embed)
File "C:\Users\bert\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\abc.py", line 1422, in send
data = await state.http.send_message(
File "C:\Users\bert\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\http.py", line 335, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embeds.0.fields.0.value: This field is required
** This field is required**
Wrong code. The error is at line 44.
In the on_message_delete event.
I don't see how that would use drop down menus
for your stats
make one😠
that code works fine...
Error says the opposite :)
@bot.event
async def on_message_delete(message):
embed = discord.Embed(title="Message deleted from {}".format(message.author.name+'#'+message.author.discriminator),
description="", color=0x3498db)
embed.add_field(name='**Deleted message:**', value=message.content,
inline=True)
logs = bot.get_channel(934554464042487848)
await logs.send(embed=embed)```
And errors don't lie.
is it the description part?
The field value=message.content is empty when you delete images and embeds.
Well, check the value of message.content when you delete an image.
I see
Debug it; print the value and try it out.
Then you know what check to add to not get the same issue.
And instead of doing .name and .discriminator you can just do ctx.author.
It will return the same.
yh ik
handled the error, now this: AttributeError: 'NoneType' object has no attribute 'send'
await welcomechannel.send(embed=embed)
welcomechannel = bot.get_channel(924753718895865917)
Well you need to get the channel before trying to send a message.
Then you need to use
channel = ...get_channel(id) or await ...fetch_channel(id)
Yall got any idea of commands I can create that use dropdown menus?
I want to learn how to use them before I create a help command
isnt that what I used?
You need to make an API call when the channel is not in cache, therefore the or ...fetch_channel(id)
No, you only have the part with get_channel.
It basically tries get_channel and if it returns None, which is your case, then it tries fetch_channel.
well the channel isnt None...
Because the channel is in cache.
uh
handled the error, now this: AttributeError: 'NoneType' object has no attribute 'send'
!e
print(type(None))
@slate swan :white_check_mark: Your eval job has completed with return code 0.
<class 'NoneType'>
so why doesnt the other one work
not sure what cache is...
So when it won't be in cache anymore, it also won't work.
Consider it as small memory your bot has.
I see
If it's not in that memory, then it's None.
so is there a way to bypass that
Therefore you need to fetch it from the API.
alr
^
It will first try from the cache, then use fetch_channel.
!e
a = None
print(a.strip("b"))
these errors happen when you try to do an action on a None type
@slate swan :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 2, in <module>
003 | AttributeError: 'NoneType' object has no attribute 'strip'
Yes, but keep the get_channel part.
You shouldn't always make API calls so you need to check the cache first.
thanks for the help, it works now!
So let's suppose get_channel returns None, it will be like that.
yeahhh
@commands.Cog.listener()
async def on_guild_channel_update(self, before, after):
async with aiohttp.ClientSession() as session:
async with self.db.execute(
f"SELECT webhook, guild_id from 'logging' where guild_id = {before.guild.id}",
) as cursor:
config = await cursor.fetchone()
if config is not None:
webhook = Webhook.from_url(config[0], adapter=AsyncWebhookAdapter(session))
if before.guild.id == int(config[1]):
async for entry in before.guild.audit_logs(action=discord.AuditLogAction.channel_update,
oldest_first=False):
embed = discord.Embed(
description=f'Channel was updated ({after.mention})',
color=discord.Color.dark_theme()
)
embed.set_author(name=entry.user, icon_url=entry.user.avatar_url)
embed.timestamp = datetime.datetime.utcnow()
embed.set_footer(text=f'{self.bot.user}', icon_url=self.bot.user.avatar_url)
embed.add_field(name='Creation date', value=f'<t:{round(before.created_at.timestamp())}:D>',
inline=False)
if before.overwrites:
embed.add_field(name='Overwrite deleted',
value=f'For: role Undefined',
inline=False)
if after.overwrites:
embed.add_field(name='Overwrite created',
value=f'For: role Undefined',
inline=False)
await webhook.send(embed=embed)```does anyone know why the field is not added, although I add a permission to a channel
!e
channel = None or 12345566
print(channel)
@slate swan :white_check_mark: Your eval job has completed with return code 0.
12345566
eh
That's bascially how it looks.
like how do I make smthng like that? if welcomechannel == None?
None would be the return of get_channel.
use is and not operators
You don't need to do any check here since fetch_channel will always return a channel.
yh I'm using fetch atm
if welcomechannel is None:
but not cache anymore
yh I get it
^
ah that way
The entire line is meant to be used.
or if using disnake use getch
Not option 1 or option 2
wait
Yeah you need to set what you need.
i think theirs no getch for channels?
nothing
Yeah just member and user if I remember correctly.
Should be added for channels though..
yes
Back at working I go
gl
I need help with select Menu
Im trying to make it reply
import random, Data, discord
from discord.ext import commands
from discord_components import DiscordComponents, Select, SelectOption, Button,ButtonStyle
class Command(commands.Cog):
def __init__(self, Client):
self.bot = Client
@commands.command()
async def test(self, ctx):
print("ok")
await ctx.send(f'test', components=[Select(placeholder="Test", options=[
SelectOption(
label="Test",
value="test",
description="e",
emoji="😂"
)
])])
def setup(Client):
Client.add_cog(Command(Client))```
but...?
Im failing horribly
Anyone got any ideas for commands that use dropdown menus? I want to learn how to use them before I actually make my help command
How do I get select event inside cog?
Yeah im trying to make it reply with the user choosed
!d discord.ext.commands.Paginator
class discord.ext.commands.Paginator(prefix='```', suffix='```', max_size=2000, linesep='\n')```
A class that aids in paginating code blocks for Discord messages.
len(x) Returns the total number of characters in the paginator.
you do listeners with @commands.Cog.listener
yes that’s what pagination is
Don’t use dpy
what else should i use?
import random, Data, discord
from discord.ext import commands
from discord_components import DiscordComponents, Select, SelectOption, Button,ButtonStyle
class Command(commands.Cog):
def __init__(self, Client):
self.bot = Client
@commands.command()
async def Menu(self, ctx):
print("ok")
await ctx.send(f'test', components=[Select(placeholder="Test", options=[
SelectOption(
label="Test",
value="test",
description="e",
emoji="😂"
)
])])
@commands.Cog.listener.on_select_option
async def Event(Interaction):
print(Interaction.values[0])
def setup(Client):
Client.add_cog(Command(Client))``` ?
Nextcord or some other fork
or even a non fork like Hikari or Pincer
dpy doesn’t have any new features
ok so let's say
Why are you setting self.bot to client?
what nextcord has "new" ?
views, buttons, slash commands (soon), application commands (context menus, slash commands, etc)
prolly a few more things too
it has buttons, views... slash commands..
No not without using an external lib
yeah but u can still do the same shit
Not really
i will wait till nextcord will bring some new features that actually can provide smth for the bot
!pypi disnake
use disnake it's better
bro said nextcord has to prove something
all g
alr back to my question
can u send me an pagination example made in discord.py v2?
or even nextcord cuz i know the code is similiar
similar
so i can convert it
@slate swan is there a way to check if my bot has deleted a message? I would like to not log it if he deletes it...
https://images-ext-1.discordapp.net/external/7LlvAYIeAM__4zIoVPdA8T2Ct6SP6SVx6X6hTPqD8-g/https/cdn.upload.systems/uploads/67OFfmHE.png
he deleted this one
but logged it
@slim ibex
Welcome back to another discord.py video.
Read description for links!
----------------------------------------------------------------------------------
Need Help?
Require help with your code? Why not head on over to our dedicated support discord where you can receive only the best support: https://menudocs.link/discord
Our Partner:
Than...
message.author.bot returns a boolean if the message author was a bot.
that will show an example
thanks a lot
mhmm
awesome
nono I mean if he deletes a message by someone else sent
or also log person who deleted the message
wrong one
Like this in audit log
!d discord.on_message_delete
You'd need to check the audit logs in that case.
You can't see who deleted the message without looking at the audit logs.
I see...
Irrelevant for the question.
k
So how can I make a bot check logs?
you have to install it
what's the pip name
oh wait

pip install buttons
thanks a lot
mhmm
@slate swan any news?
Well without it, it breaks
Actually haven't seen your message, my apologies
how did you create the bot
!d discord.Guild.audit_logs
async for ... in audit_logs(*, limit=100, before=None, after=None, oldest_first=None, user=None, action=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") that enables receiving the guild’s audit logs.
You must have the [`view_audit_log`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.view_audit_log "discord.Permissions.view_audit_log") permission to use this.
Examples
Getting the first 100 entries:
```py
async for entry in guild.audit_logs(limit=100):
print(f'{entry.user} did {entry.action} to {entry.target}')
```...
import random, Data, discord
from discord.ext import commands
from discord_components import DiscordComponents, Select, SelectOption, Button,ButtonStyle
class Command(commands.Cog):
def __init__(self, Client):
self.bot = Client
@commands.command()
async def Menu(self, ctx):
print("ok")
await ctx.send(f'test', components=[Select(placeholder="Test", options=[
SelectOption(
label="Test",
value="test",
description="r",
emoji="😂"
)
])])
@commands.Cog.listener()
async def on_select_option(Interaction):
print(Interaction.values[0])
def setup(Client):
Client.add_cog(Command(Client))``` I tried this but it didnt work and theres no errors
how do you create the bot
Wdym
Follow the naming conventions, will save you lots of errors.
what is the code where you instantiate the bot like bot = commands.Bot() etc
What do you mean?
Conventions?
Variables not with capital letters and same for functions.
^
So not
async def Menu(...)
but
async def menu(...)
Kk ill make sure to avoid that
Coding conventions that you should definitely follow.
But any idea why it wont work?
i told you
show me the code where you instantiate the bot
client in the way you used it is a random argument that does nothing
I removed it
The self.bot
show me the code where you instantiate the bot
kk
import Data, os, sys, discord, asyncio
from discord.ext import commands
from colorama import Fore, Back, Style
from discord.ext.commands import CommandNotFound, MissingPermissions
from os import system
sys.dont_write_bytecode = True
os.system("mode con cols=120 lines=30")
system("title "+ "River Client")
Intents = discord.Intents.default()
Bot = commands.Bot(
command_prefix = Data.Info.Prefix,
intents = Intents,
case_insensitive = True,
description = "River Bot"
)
ReSizing = True
Indent = " "
Bot.remove_command("help")
class DirClasses:
Admin = "Commands/Admin"
def LoadCommands(Dir, DirName):
for Function in os.listdir(f"./{Dir}"):
try:
if Function.endswith(".py"):
FileName = Function[:-3]
try:
Bot.load_extension(f"Commands.{DirName}.{FileName}")
except Exception as Error:
Data.Function.ErrorPrint(f"Failed > [{Fore.BLUE}{Error}{Fore.WHITE}]")
Name = Function.replace(f".py", "")
except Exception as Error:
Name = Function.replace(f".py", "")
Data.Function.ErrorPrint(f"Failed > [{Fore.BLUE}{Name}.py{Fore.WHITE}]")
Data.Function.ErrorPrint(f"Failed > [{Fore.BLUE}{Error}{Fore.WHITE}]")
@Bot.event
async def on_ready():
Data.Function.Print(f"Ascend Satus > [{Fore.BLUE}Success{Fore.WHITE}]")
Data.Function.Print(f"Client User > [{Fore.BLUE}{Bot.user.name}#{Bot.user.discriminator}{Fore.WHITE}]")
Data.Function.Print(f"Client ID > [{Fore.BLUE}{Bot.user.id}{Fore.WHITE}]")
LoadCommands(DirClasses.Admin, "Admin")
Data.Function.Print(f"Loaded > [{Fore.BLUE}Commands{Fore.WHITE}]")
@Bot.event
async def on_command_error(ctx, Error):
if isinstance(Error, CommandNotFound):
Data.Function.ErrorPrint(f"Failed > [{Fore.BLUE}Command{Fore.WHITE}]")
Data.Function.ErrorPrint(f"Failed > [{Fore.BLUE}{Error}{Fore.WHITE}]")
elif isinstance(Error, MissingPermissions):
Data.Function.ErrorPrint(f"Failed > [{Fore.BLUE}Command{Fore.WHITE} (Permissions)]")
Data.Function.ErrorPrint(f"Failed > [{Fore.BLUE}{Error}{Fore.WHITE}]")
await ctx.message.channel.send("You do not have Permissions to run this command.", delete_after = 15)
Bot.run(Data.Info.Token)```
Ipay, I made some things
@bot.event
async def on_message_delete(message):
guild = message.guild
async for entry in guild.audit_logs(limit=1):
print(f'{entry.user} did {entry.action} to {entry.target}')
if entry.user.id is bot.user.id:
return
else:
if message.content == None:
return
else:
embed = discord.Embed(title="Message deleted from {}".format(message.author.name+'#'+message.author.discriminator),
description="", color=0x3498db)
embed.add_field(name='**Deleted message:**', value=message.content,
inline=True)
logs = bot.get_channel(934554464042487848)
await logs.send(embed=embed)```
But it still logs the !rules it deletes
import Data, os, sys, discord, asyncio
from discord.ext import commands
from colorama import Fore, Back, Style
from discord.ext.commands import CommandNotFound, MissingPermissions
from os import system
sys.dont_write_bytecode = True
os.system("mode con cols=120 lines=30")
system("title "+ "River Client")
Intents = discord.Intents.default()
bot = commands.Bot(
command_prefix = Data.Info.Prefix,
intents = Intents,
case_insensitive = True,
description = "River bot"
)
bot.remove_command("help")
class DirClasses:
Admin = "Commands/Admin"
def loadCommands(Dir, DirName):
for Function in os.listdir(f"./{Dir}"):
try:
if Function.endswith(".py"):
FileName = Function[:-3]
try:
bot.load_extension(f"Commands.{DirName}.{FileName}")
except Exception as Error:
Data.Function.ErrorPrint(f"Failed > [{Fore.BLUE}{Error}{Fore.WHITE}]")
Name = Function.replace(f".py", "")
except Exception as Error:
Name = Function.replace(f".py", "")
Data.Function.ErrorPrint(f"Failed > [{Fore.BLUE}{Name}.py{Fore.WHITE}]")
Data.Function.ErrorPrint(f"Failed > [{Fore.BLUE}{Error}{Fore.WHITE}]")
@bot.event
async def on_ready():
Data.Function.Print(f"Ascend Satus > [{Fore.BLUE}Success{Fore.WHITE}]")
Data.Function.Print(f"Client User > [{Fore.BLUE}{bot.user.name}#{bot.user.discriminator}{Fore.WHITE}]")
Data.Function.Print(f"Client ID > [{Fore.BLUE}{bot.user.id}{Fore.WHITE}]")
loadCommands(DirClasses.Admin, "Admin")
Data.Function.Print(f"Loaded > [{Fore.BLUE}Commands{Fore.WHITE}]")
@bot.event
async def on_command_error(ctx, Error):
if isinstance(Error, CommandNotFound):
Data.Function.ErrorPrint(f"Failed > [{Fore.BLUE}Command{Fore.WHITE}]")
Data.Function.ErrorPrint(f"Failed > [{Fore.BLUE}{Error}{Fore.WHITE}]")
elif isinstance(Error, MissingPermissions):
Data.Function.ErrorPrint(f"Failed > [{Fore.BLUE}Command{Fore.WHITE} (Permissions)]")
Data.Function.ErrorPrint(f"Failed > [{Fore.BLUE}{Error}{Fore.WHITE}]")
await ctx.message.channel.send("You do not have Permissions to run this command.", delete_after = 15)
bot.run(Data.Info.Token)```
No need to check the ID, check the .bot attribute on entry.user, it will return a boolean.
def setup(bot):
bot.add_cog(CogName(bot))
kk
im not sure how to do this
After you've fixed that issue, you could take a look at this
https://www.datasciencecentral.com/best-naming-conventions-when-writing-python-code/amp/ and rename lots of things so that your code is much better ^^
but I feel like this doesnt work
After this what do I do to fix reply
What is the audit log?
Oh you deleted a message
await ctx.message.delete()
is what the bot does
but it says in audit log that I did it
lol that's not possible.
Are you sure it's that message?
Because it's not really possible.
pretty sure
check again, the time probably doesn't line up
@slate swan Do you know how to check for select option event?
Library?
Been trying
That
What library are you using.
Oh
Im using discord.py v2
alright
@bot.command()
async def delete(ctx):
await ctx.message.delete()```
made this, so bot should delete it right?
https://github.com/Rapptz/discord.py/blob/master/examples/views/dropdown.py
Take a look at the example they provide.
Yes
Now make it delete and compare the time now and in audit log.
how do i import that example into my repl
wait nvm
Oh 😅
embed error still there
yk the no message.content
@bot.event
async def on_message_delete(message):
guild = message.guild
async for entry in guild.audit_logs(limit=1):
print(f'{entry.user} did {entry.action} to {entry.target}')
if entry.user.bot:
return
else:
if message.content == None:
return
else:
embed = discord.Embed(title=f"Message deleted from {message.author} by {entry.user}",
description="", color=0x3498db)
embed.add_field(name='**Deleted message:**', value=message.content,
inline=True)
logs = bot.get_channel(934554464042487848)
await logs.send(embed=embed)```
Traceback (most recent call last):
File "C:\Users\bert\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 351, in _run_event
await coro(*args, **kwargs)
File "c:\Users\bert\Downloads\discord bots\bertie's discord bots.py", line 53, in on_message_delete
await logs.send(embed=embed)
File "C:\Users\bert\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\abc.py", line 1422, in send
data = await state.http.send_message(
File "C:\Users\bert\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\http.py", line 335, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embeds.0.fields.0.value: This field is required
@slate swan sorry for ping, just wanna make sure u here :)
Replace == with is
ok
how do i geri n discord py v2?
You don't need to blindly copy paste it.
I didnt
Check the GitHub README.md installation part.
I checked it and tried to implement how it worked into my code
oh okay thanks
Installing the development version
Or something similar
Then you didn't checked it correctly
But I had trouble because the way it did the menu is different from me
do I add like a small asyncio.sleep?
Well I never really worked with audit logs like that but does the print work?
it doesnt print
i spent this entire time for reactions 😂
but it does add it to logs
if the bot deletes smthng it doesnt show up in audit log
Bertie#0001 did AuditLogAction.message_delete to Bertie's bot#5320
Bertie#0001 did AuditLogAction.message_delete to Bertie's bot#5320
Bertie#0001 did AuditLogAction.message_delete to Bertie's bot#5320
Bertie#0001 did AuditLogAction.message_delete to Bertie's bot#5320
this is the print
Well apparently it doesn't log in audit logs 😅
Never really worked with audit logs so I can't really help.
But seems like it doesn't even save on Discord's side.
Otherwise it would show up.
I found a fix on it
the log is like the opposite way
added
if entry.target.bot:
return```
Oh okay, interesting though
might be usefull one day
Docs says opposite but yeah
Oh I don't really code bots anymore so don't think so 
after.roles and before.roles
Returns a list of roles objects
Won't be able to help further for now, I really need to work ^^ But I'm sure someone else will be here soon and take over :)
Have a great one 
hello i wanna do something but i don't know the syntax i did a xp bot and if a player send a message which start with . it will remove him 5 xp but i don't know how can i do that
i know there is something like startwith() but i don't know it's working
i want to do something like
if startwith("."):
xp = stats["xp"] - 5
but obviously that not working
await ctx.send(f'test', components=[Select(placeholder="Test", options=[
SelectOption(
label="Test",
value="test",
description="eee",
emoji="😂"
)
], custom_id = "trolled")])
while True:
try:
Interaction = await self.bot.wait_for("select_opition", check = lambda inter: inter.custom_id == "trolled" and inter.user == ctx.author)
Res = Interaction.values[0]
print(Res)
except Exception as Error:
await ctx.send(Error)``` Does anyone know specifically why this code doesnt work?
pep8

?
@slate swan py @bot.event async def on_member_update(before, after): guild = await bot.fetch_guild(934554396975575061) if len(before.roles) < len(after.roles): async for entry in guild.audit_logs(limit=1): print(f'{entry.user} did {entry.action} to {entry.target}') # The user has gained a new role, so lets find out which one newRole = next(role for role in after.roles if role not in before.roles) print(f'{entry.user} added the role {newRole} to {entry.target}') logs = bot.get_channel(934554464042487848) await logs.send(f'{entry.user} added the role \'{newRole}\' to {entry.target}') if len(before.roles) > len(after.roles): async for entry in guild.audit_logs(limit=1): print(f'{entry.user} did {entry.action} to {entry.target}') oldRole = next(role for role in before.roles if role not in after.roles) await logs.send(f'{entry.user} removed the role \'{oldRole}\' from {entry.target}')
got it working :D
Variable names should be named with snake_case
What
What
@slate swan Do you know any discordpy forks for select menues without having to make a new command handler
@commands.Cog.listener()
async def on_message(ctx, *, message):
stats = Levels.find_one({"id":message.author.id})
if (message.startwith(".")):
xp = stats["xp"] - 5```
can someone help me pls
that not working i know it's because of the if (message.startwith(".")):
but i don't know how to fix it so it can works
on message only takes one param
If you're trying to make it remove xp when a command is run you can use a check
and what is that if statement no need for the extra ()
ok thanks
Anything wrong with this code?
Interaction = await self.bot.wait_for("select_opition", check = lambda inter: inter.custom_id == "trolled" and inter.user == ctx.author)
Res = Interaction.values[0]```
how check is working ?
Can you rephrase that?
you said i could use check
but how
i never used this to do that so i don't know it's working
||docs||
Lemme see if I know what I'm doing
||docs||
!d discord.ext.commands.Bot.add_check
add_check(func, *, call_once=False)```
Adds a global check to the bot.
This is the non-decorator interface to [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.check "discord.ext.commands.Bot.check") and [`check_once()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.check_once "discord.ext.commands.Bot.check_once").
Oh shit
its a global check
I actually remembered
lollll
||DOCS||
So?
Did u run it
||DOCS||
not sure if he wants that
True
i want something that will check if someone type .
You literally just want that?
If they have a . at the start of a message?
at the start of the message
just use the message param
yes
i started python today i don't know which parameters i should use
i know i need to use the *
If message.content.startswith…
i did already
@commands.Cog.listener()
async def on_message(self, message) -> None:
if message.startswith("."):
...
Then why are u making bots
Yeah
Did it work?
im trying to learn
No
Learn basics first
and then https://vcokltfre.dev/
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 wanna learn with bots because it's easier for me but yeah im doing basics too at school
import random, Data, discord
from discord.ext import commands
from discord_components import DiscordComponents, Select, SelectOption, Button,ButtonStyle
class Command(commands.Cog):
def __init__(self, Client):
self.bot = Client
@commands.command()
async def Menu(self, ctx):
await ctx.send(f'test', components=[Select(placeholder="Test", options=[
SelectOption(
label="Test",
value="test",
description="eee",
emoji="😂"
)
], custom_id = "trolled")])
while True:
try:
Interaction = await self.bot.wait_for("select_opition", check = lambda inter: inter.custom_id == "trolled" and inter.user == ctx.author)
Res = Interaction.values[0]
await Interaction.send(Res)
except Exception as Error:
await ctx.send(Error)
def setup(Client):
Client.add_cog(Command(Client))```
Are you familiar with asynchronous programming
pep8 is screaming
!pep 8
no
indeed
Something you should read
Hb api wrappers
Im gonna fix the capital stuff after I figure respond thing
bro those naming conventions are horrible
Client capital did you subclassed the bot class?
cause classes should and only be capital not functions or class instances
Why are class instances named using pascal case
and dont name functions capital only classes smh PEP8
i tried and it didn't works
Got damn I get it but my main focus right now is the respond issue
ctrl c ctrl v?
Whats the issue
@commands.Cog.listener()
async def on_message(message) -> None:
stats = Levels.find_one({"id":message.author.id})
if message.startswith("."):
xp = stats["xp"] - 5```
my error is : ```TypeError: levelsys.on_message() takes 1 positional argument but 2 were given```
Try if msg.content.startswith
When I select a option it doesnt reply with what I chose
U forgot self
Lemme see
Use ui views for that
Docs or examples?
Hi there, sry for chat interruption.
I was asked to make an "intro-timer" feature on a discord server, so that a member can see the other rooms after "N" time
So I was wondering if any bot already does this function, because I checked the documentation and saw that it is possible to get the "joined_at" that shows the time a member enters a guild.
Does anyone know which bot does this?
Google search engine
ty
Whats intro timer
Maybe a role that its removed after X time
Can I have the examples for the dropdown menus?
or, a role that is given after that time
Use a task
what you mean by that
@final iron sorry not that this https://github.com/DisnakeDev/disnake/blob/master/examples/views/select/dropdown.py
Thanks amigo
🫂
In on join store a timestamp when the role should be removed, then have a task that periodically checks for every new member if the current time is greater then the timestamp u stored
If current time is greater remove the role
dang they really stole my color idea from discord.py's dropdown.py example 😂
its a fork after all😭🏃
I mean, im intersting in doing a bot with the function later on the year, but right now Im wondering if there is some that does it, so I could use it. @cedar stream
Ohh, idk, check on top.gg
I see, thanks for the help
Good luck
Those thieves, I bet they also cloned discord.py code
The nerve!
the audacity
Lmfao
bro

ikr
what
andy is funny ngl
Actually you can't say my wrapper is a dpy clone anymore!
Cause I archived it and started working on a new one
one day forks will be forked and those forks will be forked🧍♂️
It aint?
completely different from discord.py
Thats cool
Okimi I gave up doing the listener rewrite cause I got to lazy
So no more lefi?
Yes it's Rin now
really😠
Any ideas how I can implement dropdown menus in to my bot?
we need the rewrite
Why did u archive it
I want to learn them before I create a help command
Cause lefi was not very well typed and I didn't like how close it was to discord.py
So now we have Rin
||docs||
your gonna endup the same if you dont fix them listeners boy
Nicee, dpy has a nice api tho
andy rewrite them or i will say the cursed word😠
I meant ideas for commands that use them
I wanna hear the cursed words
Help command
Thats 2 words and a symbol
Reaction roles
Lmao
dekriel
what
you monster 😭
🧑🦯
exactly
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.

do it again I dare you
!ot
haha


i did
ok
Lmao

look here mf
!ot
hehe
!ot-names @cedar stream
Off-topic channels
There are three off-topic channels:
• #ot0-psvm’s-eternal-disapproval
• #ot1-perplexing-regexing
• #ot2-never-nester’s-nightmare
The channel names change every night at midnight UTC and are often fun meta references to jokes or conversations that happened on the server.
See our off-topic etiquette page for more guidance on how the channels should be used.

discord.js or discord.py? you guys might be a little biased though haha
get your commands right
discord.js
Dpy
drb
Dumass
🤸
Have u ever tried js
lol
have you ever heard of gun = death
discord.py broken
discord.js superior
I like javascript better than python but only have experience with discord.py
no your aim = bad
Have u ever heard of fuck.js
Lmfaooo
you guys lmaooo
have you ever heard of your IP address?
bro I clutch shot someone mid air with BR
I prefer eating cow shit that JavaScript
Yea, but rin's current implementation is quite the refresher, E.g ```py
async def main() -> None:
token: str = os.getenv("DISCORD_TOKEN") # type: ignore
client = rin.GatewayClient(token, intents=rin.Intents.default())
@client.once(rin.Event.READY)
async def on_ready(user: rin.User) -> None:
print(f"LOGGED IN AS: [{user.id}]")
await client.start()
asyncio.run(main())
in discord rb you need to use a bare endpoint to add a reaction lmaooo
nice
Mhm
cap
The internal structure itself and the codebase is extremely clean as well now!
Way better then the predecessor
want proof
lovely
Which is mostly my main reason for the rewrite
sexy
no
also @slate swan how's your twitter thing coming along
Ill check it out when I get on computer
havent worked on it
👁️ 👁️
o
maybe i should make the async bridge of it
Is it open source?
ive just gotten stuck on a error i have with sphinx so i cant make docs to learn rip
Yes, it's all in the repo I linked earlier
Nice
enslo your dog is dead
cat superior
you trying to get muted or something😭
I'm bored out of my tree
LMAO
Anyone got any commands I can steal
so am I
someone ask a question
use buttons
For what commands though
Step 1: open a browser
Step 2: search dpy docs
Step 3: type Guild.invites in the dpy search bar
you saved my life
you just murdered me, you...you...uh...dawg 😳
I got one
make a wallpaper getter which sends an image with a button which you can change to it with buttons and it will edit the embed with a new image when one of the buttons is press so forward and back
Gib wallpaper api
Step 1: read my message
¯_(ツ)_/¯
@cedar stream does it show per person or per guild
@bot.event
async def on_message(message):
if message.author.id == 802098197244674068:
await message.delete()
await ban(message.author, reason="dawg")
If you are trying to your bot in as many guilds as possible just make autoporn
step 1: we can read
How about no
step 1: stop being a smartass its corny
0 social life i can tell
step 1: iirc guild.invites shows the total number of invites
step 2: mf you're dead
now back to my question, how would I check the amount of invites per person
Idk, if It’ s an attribute of discord.Guild object
What do u think
!d discord.Guild.invites
await invites()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Returns a list of all active instant invites from 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 get this information.
there's a webiste called google.com which is amazing. https://stackoverflow.com/questions/61876097/getting-the-users-total-invites-in-discord-py
it gives you everything you need to know
!d discord.Invite
class discord.Invite```
Represents a Discord [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild") or [`abc.GuildChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.GuildChannel "discord.abc.GuildChannel") invite.
Depending on the way this object was created, some of the attributes can have a value of `None`.
x == y Checks if two invites are equal.
x != y Checks if two invites are not equal.
hash(x) Returns the invite hash.
str(x) Returns the invite URL...
🙃
ay robin
👋
progamer moment
robin we should play
we should find a time where we all play
that would be nice
i get like 28 kills every match
since I have robin and okimii
thats low
i get 5
dont you get like 10
I get 30 kills per match and thats my lowest
no 😳
Hb we hack enemies and make their computers explode
I become amazing near the end of the game
when
good way
@slate swan @sick birch should we make a gc
idk if robin wants sure
we find 5000th fibonacci number
nah we find the next biggest prime number
sure if you want though my time to play these days is limited
im available tmr
i cant
we can coordinate these somewhere else
i got school :((
I'll make a gc, is that ok with you?
imagine
😔
I get this error:
gif_channel = discord.utils.get(message.guild.channels, id=928014494142197820)
AttributeError: 'NoneType' object has no attribute 'channels'
For this:
@bot.event
async def on_message(message):
gif_channel = discord.utils.get(message.guild.channels, id=928014494142197820)
icon_channel = discord.utils.get(message.guild.channels, id=928014556926738433)
for attachment in message.attachments:
if attachment.filename.split(".")[1] == "gif":
gif_embed = Embed(color=0x0f0f0f)
gif_embed.set_image(url=attachment.url)
await gif_channel.send(embed=gif_embed)
elif attachment.filename.split(".")[1] in ["jpg", "jpeg", "png"]:
icon_embed = Embed(color=0x0f0f0f)
icon_embed.set_image(url=attachment.url)
await icon_channel.send(embed=icon_embed)
await bot.process_commands(message)
Erm, not the way we give help in this server Dekriel thanks.
!e
a = None
print(a.strip(" "))
basic nonetype error
@slate swan :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 2, in <module>
003 | AttributeError: 'NoneType' object has no attribute 'strip'
finally someone who spells my name right
Why not just use message.channel
hes being nice

good child
so i do message.channel instead?
igs
Yes
gif_channel = discord.utils.get(message.channel, id=928014494142197820)
icon_channel = discord.utils.get(message.channel, id=928014556926738433)
…
🚪🏃 💨
NOO
it's midnight here you cant do that
yk you don't have to be this vague, you could've said, "instead of using discord.utils.get() use message.channel()"
crazy how you're "support" lool
how are we support
gif_channel = message.channel(id=928014494142197820)
icon_channel = message.channel(id=928014556926738433)
if you're going to help someone, at least tell them what's wrong so they could learn from their mistakes
it's midnight
always rude at midnight then I'm nice in the morning
If you know you're going to be rude then go to sleep
yes
lollll
Implementing right now
So should I have a checkmark button, a next button and a x button?
I'm not going to have a backwards button because I'm just going to be requesting an api
I already found one but I'll check it out
You can also query r/wallpapers on reddit as well
They got some good wallpapers over there
Maybe have a drop-down to select the kind of wallpaper (desktop, phone, etc.)? 🤔
How can I make the bot listen a dropdown from a message for a long time? After some minutes I'm getting This Interaction failed when trying to select from dropdown and the bot have to resend that message(with dropdown) so I can use it. Any idea?
okie
How large should the image be for a phone because the size of the screens varies greatly
Also same thing for desktop
Oh yeah good point. Although I think it will be the aspect-ratio that matters most.
True
Hey, how are you doing it currently?
This api allows me to choose the image size
So I'll do 1920 by 1080 for desktop
But mobile will be a bit harder to figure out what to do
Can I DM you to explain there in more detail?
Erm, perhaps claim a help channel. I have my DMs closed sorry.
lets say I have a list called myList. It has an unknown amount of discord users in it. Example: @frank tartan
How can I search the roles of every user on the list?
I hope that makes sense
So I've made a command setup that sends a message with an embed and the dropdown
Is the list filled with discord.User objects or just integers?
I add them using
client.memberList.append("<@{0.id}>".format(member))
so i believe just integers
Why not append the member object?
idk
This is inside the setup command
https://pastebin.com/YmTHBJS3
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Alright, roles only make sense in the context of a guild. So you first need to get the member objects for those users in that guild. If you have the guild object, I believe you can do guild.get_member(user_id). You may need to have the members intent turned on for your bot in order for the member objects to be readily available.
Then what would you like to do with the roles?
Member objects have a roles attribute, which is just a list of the roles the member has.
Should the callback be outside the command function?
make it so if they have a specified role, they go onto another list, but removed from the original list
also, im confused on how i can add that to the list
I have not yet used interactions with discord.py, so I might not be the best person to help. Although I'll take a look.
Sounds like a good place to use sets.
what are those...?
A set is like a list, but the values contained within are unique and not in any particular order.
im looking on w3schools about them. they look like dictionaries
Although the values have to be hashable (which discord.Member objects appear to be).
Yeah similar.
Think of like a dictionary but with only the keys, no values.
But say you have a set of values xs = {1, 2, 3, 4}, and another set of values ys = {3, 4, 5}, and you want to remove all values from xs that happen to also be in ys, you can do: ```py
xs -= ys
And lots of other nifty things.
The result in this case will be that xs == {1, 2}
There wont be a 5?
Nah, it wasn't in xs to begin with.
Erm, sorry @raw latch which API wrapper are you using?
Didn't danny shit on pycord?
That all looks fine from the examples I see. Do you have any other information you could use to debug?
E.g. any logging output?
You're using 2? Thats some insane skill
welp
Nope, there's no error in the terminal..
*ba dum tss
indeed
Can I have a link to that?
Hello, may I ask how do I get the roles of the user who executed a command?
!d discord.Member.roles
property roles: List[Role]```
A [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that the member belongs to. Note that the first element of this list is always the default [‘@everyone](mailto:'%40everyone)’ role.
These roles are sorted by their position in the role hierarchy.
!d discord.ext.commands.Context.author
Union[User, Member]: Returns the author associated with this context’s command. Shorthand for Message.author
What in the sus
anyone know how i can implement an after function for discord.ffmpegopus
!d discord.Intents.guilds
Whether guild related events are enabled.
This corresponds to the following events...
Well the icon is None
!d discord.Guild.icon
property icon: Optional[discord.asset.Asset]```
Returns the guild’s icon asset, if available.
oh
ty
if ctx.guild.icon.url == None:
pass
else:
embed.set_thumbnail(url=ctx.guild.icon.url)
fixed
I guess
Traceback (most recent call last):
File "D:\Coding\Projects\MyMusicBot\venv\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "D:\Coding\Projects\MyMusicBot\bot\cogs\Music.py", line 137, in play
await ctx.send(f"Added {players[0].title if len(players) == 1 else 'songs'} to queue")
File "D:\Coding\Projects\MyMusicBot\bot\cogs\Music.py", line 95, in __check_queue
p = discord.FFmpegOpusAudio(player.stream_url, **FFMPEG_OPTIONS)
File "D:\Coding\Projects\MyMusicBot\venv\lib\site-packages\discord\player.py", line 324, in __init__
super().__init__(source, executable=executable, args=args, **subprocess_kwargs)
File "D:\Coding\Projects\MyMusicBot\venv\lib\site-packages\discord\player.py", line 138, in __init__
self._process = self._spawn_process(args, **kwargs)
File "D:\Coding\Projects\MyMusicBot\venv\lib\site-packages\discord\player.py", line 144, in _spawn_process
process = subprocess.Popen(args, creationflags=CREATE_NO_WINDOW, **subprocess_kwargs)
File "D:\Coding\Python\lib\subprocess.py", line 966, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "D:\Coding\Python\lib\subprocess.py", line 1375, in _execute_child
args = list2cmdline(args)
File "D:\Coding\Python\lib\subprocess.py", line 561, in list2cmdline
for arg in map(os.fsdecode, seq):
anyone got any idea as to why it raises?
it raises when ffmpeg is finished playing a song
never happened before
what is the error
Ping?
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\Coding\Projects\MyMusicBot\venv\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "D:\Coding\Projects\MyMusicBot\venv\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "D:\Coding\Projects\MyMusicBot\venv\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: expected str, bytes or os.PathLike object, not member_descriptor
whats the code
Lets see the code
^
Hmm?
global channel
channel=client.get_channel(934629001559932938)
@client.event
async def on_ready():
print(f'Connected to {client.user}')
print(channel)```
print(channel) returns 'None'
its the same as the discord.py music example
Is the id correct?
!d discord.ext.commands.Bot.get_channel
get_channel(id, /)```
Returns a channel or thread with the given ID.
yea the problem is that I made it catch the channel before the bot is even ready
thats the problem
how do I get ctx:context object from interaction : nextcord.Interaction ?
!d discord.ext.commands.Bot.get_context
await get_context(message, *, cls=<class 'discord.ext.commands.context.Context'>)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Returns the invocation context from the message.
This is a more low-level counter-part for [`process_commands()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.process_commands "discord.ext.commands.Bot.process_commands") to allow users more fine grained control over the processing.
The returned context is not guaranteed to be a valid invocation context, [`Context.valid`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context.valid "discord.ext.commands.Context.valid") must be checked to make sure it is. If the context is not valid then it is not a valid candidate to be invoked under [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").
option_type for slash_commands, specifically option 6 is a discord.User object right? Yet I can't pass in anyone who isn't in the server. E.g., Dyno has a /ban command and I can't use it on any other but a member in the guild, any way to be able to do this?
await get_context(interaction) ?
No
then how ?
actually there is message attribute
but i dont think it work
cuz it will be the bot message
its just button
Any idea how i can acheive something like this? everything i try keeps seperating all the lines
You can't get_context from slash commands no.
Best is to just tie whatever you doing to bot.
Account: jMarchinton PlayerID: 17284 Coins: 1,028,366
@oblique adder 😮 I can do it in the chat, but not sure how to format it into a string into pycharm
just do the same thing u write in chat and write there
Okay that didnt work
Account: jMarchinton PlayerID: 17284 Coins: 1,028,366
so many colors 😄
the discord.py have a event to check when a user joined???
on_member_join
How do you get it all on one line?
!d discord.Member.joined_at
An aware datetime object that specifies the date and time in UTC that the member joined the guild. If the member left and rejoined the guild, this will be the latest date. In certain cases, this can be None.
Account: jMarchinton PlayerOD: 123434 Counts 3423432
Account need to be capitalize
Awesome, how did you get it in yellow? 😄
use ml instead of prolog
How many different ones are there?
why my code dont worksss??????
import discord, os
class Client(discord.Client):
async def on_ready(self):
print('true')
async def on_message(self, message):
print(message.content)
async def on_member_join(self, member):
print('test =/')
bot = Client();
bot.run(os.environ['token'])
guys quick question
wym
a lot
what fork would you all recommend in terms of efficiency and the least amount of code i would have to fix
Know where i can find them all?
!pypi disnake
most people use disnake but I prefer nextcord
guys can i have a question?
thanks both of you! Ill check both of them out
ofcourse you can
Hey @fallow bridge! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me
Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!
dont write your token in the code @fallow bridge
ok im sry i dont know about that
also regenerate your token , someone might grab
Traceback (most recent call last):
File "main.py", line 10, in <module>
cogs[i].setup(client)
File "/home/runner/Bot-For-Dc-1/music.py", line 47, in setup
client.add.cog(music(client))
AttributeError: 'Bot' object has no attribute 'add'
then this problem comes out
!yt-dl
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
ok wait
No we don't help with this here, please delete the messages.
- YT_DL is against TOS so we can't help
- format your code properly if short or use a pasting service.
@oblique adder Using the ml method you just showed, is it possible to change a color of a individual word
for example local - grey or green or blue
but the rest of the sentence in the ml format all in one line? If that makes sense 😄
It depend. some code highlight change color according to capital letters , space , numbers , bracket , first letteres/symbol , quataion , etc
example
shouldnt the on_reaction_remove event work? it doesnt trigger at all when someone removes a reaction on my bot
as in i literally have it linked to solely a print statement and it outright refuses
Can we see your code?
@client.event
async def on_reaction_remove():
print("ran")
is literally it
Do you have intents?
yep, it works for adding reactions
discord.on_reaction_remove(reaction, user)```
Called when a message has a reaction removed from it. Similar to on\_message\_edit, if the message is not found in the internal message cache, then this event will not be called.
Note
To get the message being reacted, access it via [`Reaction.message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Reaction.message "discord.Reaction.message").
This requires both [`Intents.reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.reactions "discord.Intents.reactions") and [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
Note
Consider using [`on_raw_reaction_remove()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_remove "discord.on_raw_reaction_remove") if you need this and do not want to enable the members intent.
As you can see from the docs it takes reaction and user
tried it with those params. Nothing happened
How old is the message you are removing a reaction from
brand new.
If it isn't cached it won't be dispatched
[0;35mSup
@pliant gulch i can add reactions to it and get a response, but im never getting anything through on the removal.
#everything is correct above this
global channel
@client.event
async def on_ready():
print(f'Connected to {client.user}')
channel=client.get_channel(934629001559932938)
update.start()
@tasks.loop(seconds=5)
async def update():
if channel is None:
return```
its says channel is not defined in the tasks.loop line
semeone can help me?? (the event on_member_join dont works)
import discord, os
class Client(discord.Client):
async def on_ready(self):
print('true')
async def on_message(self, message):
print(message.content)
async def on_member_join(self, member):
print('test =/')
bot = Client();
bot.run(os.environ['token'])
what help?
i edited the message
does other two events work?
Well you don't have an init so this function is just confused.
but the above functions work

it would be easier if you make it outside the Client class
i follow the discord.py website
i still dont have a clue why the on reaction remove isnt working this actually is confusing me haha
!intents
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
try this```py
import discord, os
intents=discord.Intents.default()
intents.members=True
client=discord.Client(intents=intents)
@client.event
async def on_member_join(member):
print('test=/')
client.run(os.environ['token'])```
No it's intents lol
could you explain better?
that still wont work without intents
^^
yea intent
member intents
also , who uses Client in 2022 , just use commands.Bot
it would do everything Client can
enable intents in discord developer portal
ima go for breakfast
anyone help this too plz
dont use global , use bot vars
!botvar
Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:
bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"
@bot.command()
async def get(ctx: commands.Context):
"""A command to get the current value of `test`."""
# Send what the test attribute is currently set to
await ctx.send(ctx.bot.test)
@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
"""A command to set a new value of `test`."""
# Here we change the attribute to what was specified in new_text
bot.test = new_text
This all applies to cogs as well! You can set attributes to self as you wish.
Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!
so basically you can py bot.my_channel = bot.get_channel(... and use it anywhere again!
globals are bad
okimii is smart
🧠
smort
pip install it?
if u are using replit, go in packages and install, else, use pip install
I'm pretty sure its installed already though
replit having a stroke
yeah def
hmmmm
I forgot but I'm pretty sure replit has a .replit feature
but I forgot the syntax for importing through that
i dont use .replit feature
hm
why subclass client
just use the bot framework
and pep8 is screaming
and you probably need to turn on members intents so the bot caches the users
yea i see in stackoverflow (idk the forum name LOL)
open
take a look at open
infernum is so smort
dont you have to add the mode your viewing the file
?
not sure myself
yes
and are you using json as a db?
good
lovely
Very loudly
json is easy lol
REALLY LOUD
What's the appeal with json anyway
you too
no king doge
Imo SQL is easier and a lot more readable
me who doesn't even know how to read data stored in my db
i.e a response from an api is formatted in json

