#discord-bots
1 messages · Page 1145 of 1
Wtf
Why not just go ahead and write a bot in Rust 😎
Because Rust is fast and memory safe and like yeah rust cool yk
you have 2 on_message events out of which one is not allowing the commands to work
ohh right
sad javascript noises
i forgot to add the thing for the second on_message
js 
but rust 😔
works now thank you
How about compile Nim to JS
typescript is a superset of javascript, so ig that works
me
Nobody is using you for anything
boom roasted 🥵🔥💯
rude

ash but aren't you a subset of javascript
Ash isn't even in the Code Jam cool club
both can be related to No Sleep and unclear errors
anything that suits you
its a relation which is also a one one and onto function
kakashi suits me :D
also, you should consider using .listen() decorator since you're using multiple events with same name
!ot
HA
😔
😔 imagine
too much maths
Ok im making a paginator
that's impossible
ew
!e print(2+2-1)
@dusky pine :white_check_mark: Your eval job has completed with return code 0.
3
:mehh: my paginator better

Guys I’m considering coding a bot in djs what are the pros and cons of using djs compared to dpy
cons - its js
cons - you have to write your own command parser
pros - you get to use TypeScript
What’s good about ts
you dont get an inbuilt command handler
get ready for "learn js" first in .gg/djs
breaking changes in most updates
its javascript so it sucks
Javascript with types, that means more intellisense and typechecking etc whateevr
Oh I see
and a transpiler that allows you to use newer features
What would be better if I wanted to make a rpg game bot
With gifs in embeds
whatever language you;re comfortable with
write your bot in Rust.
both cover the same API
rust fetish 🤨
rust is the way to go
serenity ❤️
rust is life
agreed discord bots are boring
Sarth
epicRPG exists anyways soooooo
Don't you ever say the b word again
b
What’s fun nowadays?
rust 
bullying kids on discord
I already do that on a hourly basis
!kindle
Kindling Projects
The Kindling projects page on Ned Batchelder's website contains a list of projects and ideas programmers can tackle to build their skills and knowledge.
What type of tasks do they usually give?
you choose that.
If it’s not “ Make a sorting algorithm with a data blah blah blah “ I’ll give it a shot
:o
Is it a website
nah they'll provide you with "what to do" with "what steps" and you'll be writing code for that
Ty I’ll give it a try
@commands.Cog.listener()
async def on_presence_update(self, before, after):
if before.activity != after.activity:
print("runned this")
with open("setup.json", "r") as log:
db = json.load(log)
log_channel = bot.get_channel(db['bot']['modules']['log_system']['channel_id'])
if before.activity == None:
embed = discord.Embed(title="New Status",
description=f"{after.name} has created new status!\n`status`: {after.activity}")
embed.set_thumbnail(url=after.avatar.url)
embed.set_footer(text=f"user id: {after.id}")
await log_channel.send(embed=embed)
elif after.activity == None:
embed = discord.Embed(title="Status Update",
description=f"{after.name} has removed their status")
embed.set_thumbnail(url=after.avatar.url)
embed.set_footer(text=f"user id: {after.id}")
await log_channel.send(embed=embed)
else:
embed = discord.Embed(title="Status Update",
description=f"{after.name} has updated their status \nfrom:\n `{before.activity}`\nto:\n{after.activity}")
embed.set_thumbnail(url=after.avatar.url)
embed.set_footer(text=f"user id: {after.id}")
await log_channel.send(embed=embed)```
it is working fine as expected to send message on member status updates
but it is sending duplicate 2 messages with same content
i'm in `2.0.0b7`
I can’t find what’s wrong lol
return a*b
what the heck has happened
isnt this one of the easiest and first challenges given?😭
they thought it was rust, its fine
return it
frrrr😭
define the aliases in the command decorator and pass in a list of strings to it
!d discord.ext.commands.Command.aliases
The list of aliases the command can be invoked under.
return is so 1990s
and I still use it 
cringe
https://paste.pythondiscord.com/ocenojawix So I have returned 😦 was hoping I would need to but yeh,
OK, so I have pretty muhc got my reaction embed nailed down everything works, if a throw out the command !embed the bot posts it and reacts to it, but when I get my test user account to react to the embed, its not able to get any roles..... All intents is set as well as the bot have full admin. No errors or tracebacks being made when reacting to the post, so I can online assume somewhere in the where True block, I am doing something wrong, if any could assist I would much appreciate it.
im so confused making paginator
me
user == reaction.message.id == msg.id
this is why its failing
&me
Command "me" is not found
i would referenced you but i have ownership over you 😳
because capybaras rule the world hence the ownership
Ok, cheers I'll dig around ❤️
imma gonna push all capybaras out of the heap
sparky
you leaved them cuz theyre stacked up 😤

server link pls :>
of what
oh
non nitro flex
i dont know what the hell paginator im making
Guys got any reference materials(links) for Embeds? I'm using disnake
!d disnake.Embed
class disnake.Embed(*, title=None, type='rich', description=None, url=None, timestamp=None, colour=..., color=...)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.10)") except using dotted access, e.g. `embed.author.icon_url`.
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") are implicitly cast to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") for you.
Much appreciated
How about if I'm using an event decorator?
which event ur using
@bot.listen()
@bot.event
async def on_message(message):
if message.content.startswith('$greet'):
channel = message.channel
await channel.send('Say hello!')
def check(m):
return message.author.id == m.author.id and message.channel == m.channel and m.content == 'hello'
msg = await bot.wait_for('message', check=check)
await channel.send(f'Hello {msg.author}!')```
i want to add a specified time to that command
On member join
if user does not sends hello in 5 sec
bot will cancel the command
how can i code that?
discord.on_member_join(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") joins a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild").
This requires [`Intents.members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
i mean
member.guild
will give the guild
the member joined
and
!d discord.Guild.channels
property channels```
A list of channels that belongs to this guild.
stupid capys, need to pop them out
Still a bit lost so I'll just save the conversation link for now lol
use .bm while reply
can somebody help me please?
on that link
Ahh
it saves
👍
Will try rereading these later
okay
commands.cooldown(1,10,commands.BucketType.user)
@bot.command(aliases=['w'])
async def work(message):
id = str(message.author.id)
if id in data:
gain = random.randint(10, 50)
num1 = random.randint(50, 100)
num2 = random.randint(50, 100)
ans = num1 + num2
channel = message.channel
await channel.send(f'answer in 10sec,\n\n`{num1} + {num2} = ?`')
def check(m):
return message.author.id == m.author.id and message.channel == m.channel and m.content == str(ans)
msg = await bot.wait_for('message', check=check, timeout=10)
await channel.send(f"{message.atuhor.name } gained {gain}$")
with open("values.json", "w") as f:
data[id]['cash'] += gain
json.dump(data,f,indent=4)
else:
await message.reply("You dont have an account yet.")
@work.error
async def work_error(ctx, error):
if isinstance(error, commands.CommandOnCooldown):
await ctx.reply('wait `{e:.1f}` seconds'.format(e = error.retry_after))```
bots not responding when user answers
can soembdoy help me pleasae?
I've always been curious, what does an actual 'rate limit' msg from discord look like? Ik there's a few different types but I'm just looking for a brief overview
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Thanks sarth
Is there any way to get information about user joined guilds without Oauth2? If not can I somehow get information to my py bot without the another page?
No, you can only get mutual servers without Oauth2
Pretty much stuck on this now, I know Ryuga did mention I was going wrong here; user == reaction.message.id == msg.id but I am not sure what I should be changing it with, google while decent has showing examples different to what I have built. What should I be looking at in order to allow people to receive the roles once reacting to the embed message?
I have tried changing the user part to ctx to no avail. My coding skills aren't the greatest, thank you in advance 🙂
@client.command()
@commands.cooldown(1, 45, commands.BucketType.user)
async def hunt(ctx):
await open_account(ctx.author,ctx)
users = await get_bank_data()
bag = users[str(ctx.author.id)]["bag"]
earn = random.randrange(500)
if "Sniper" in bag:
e = discord.Embed(description=f"All that time spent in the woods you found nothing.",color=discord.Colour.dark_theme())
e1 = discord.Embed(description=f"While going through the woods you killed a deer and sold it for {earn}", color=discord.Colour.dark_theme())
e2 = discord.Embed(description=f"Going through the open field you killed a rabbit and ate it... you get nothing-", color=discord.Colour.dark_theme())
e3 = discord.Embed(description=f"you gave up on hunting but, someone gave you {earn} just because you tried.",color = discord.Colour.dark_theme())
e4 = discord.Embed(description=f"You killed a worm and sold it for {earn} maybe it's worth alot.",color=discord.Colour.dark_theme())
list23 = [e,
e1,
e2,
e3,
e4]
await ctx.send(embed=random.choice(list23))
users[str(ctx.author.id)]["wallet"] += earn
with open("mainbank.json", 'w') as f:
json.dump(users,f)
``` no errors
no response sent by the bot
dead channel 
People offer help for free, patience.
You sure the if statement is getting triggered?
Almost all of your code is inside the if statement
You can print the bag and check what it really is
Usually the json is different from what someone expects it to be
Also use a database
hey could you explain what you want to do with that command? cause it can be improved a lot!
Guys can anyone help me i wana make a bookmark comand like @lament depot can anyone tell any good way to make it?
What does that command do
if you reply to a message with .bm it sends the message to your dms
.bm message_id/message_url does the same
Any good way to make?
you have been told about that yesterday, is there something specific that you dont understand navi?
Should I use bot.wait_for?
Or reaction add event
wait_for
Oh k
try making the command without that reaction thing first
And how can we send dm?
so if someone replies the message with .bm, it gets sent to their dms
ctx.author.send >?
Sure, the entire code is basically to run an embed post with multiple reactions, so when I do !embed, the bot does post all the listed reactions, etc. but when I use my test account to react to the post to retrieve a role, I just ain't getting any role assigned. Pretty much been at it these last 2 hours since first asking and just not sure what else I can do now to get it working.
so, first you can send the message using the send/reply method py msg = await send/reply(embed=embed) and then add reactions to it using Message.add_reactions ```py
await msg.add_reaction("emoji")
That's easy
yes so do that first 😄
Yeh, that part is fine. According to Ryuga, it was user == reaction.message.id == msg.id that is broke. (Don't want to tag anyone as not sure on timezones/work, etc)
there's much more stuff wrong there
CSGO = discord.utils.get(ctx.guild.roles, id=780182144747569193)
- you should be using
ctx.guild.get_role(id)instead
hey, i downloaded all the discord libraries but there is an error with missing imports
WF = discord.utils.get(ctx.server.roles, id=780244861130768395)
``` 1st point is still valid, and ctx.`server` is not a thing, its ctx.guild that you used earlier
downloading all discord libraries is the problem itself, all you need is discord.py
or any fork/lib you're using
not all of them
ok
I thought server was wrong, but it was more just trying to test until something was working, but thank you for your help/advice, I'll go research more now 🙂 ❤️
may i know what IDE you are using?
or code editor
Visual Studio
PyCharm is good too
Actually i would've chosen atom
Either Atom, VSCode or Pycharm are great options.
great, i'll suggest you to typehint stuff, like ctx there is a commands.Context object so if you would do py async def embed(ctx: commands.Context): you will get a list of all attributes of ctx when you type ctx., that saves you from a lot of mistakes
Also i use Codium
i'll not suggest it to anyone anylonger, because its discontinued.
I have used Atom, not to bad, but more familiar with VS Code due to work (ansible/terraform) so its just something I can use without issues 🙂
My message about the depreciation is deleted
No worries, I'll take all that in to consideration for next time, thank you very much for your time and assistance!
VSCode is more general, it isn't great at a certain thing but rather average across all languages.
Certainly worse in java
i use vscode for py and rust and kotlin (while learning), didnt face any issue
Yeah... For Java smth like IntelijIdea would be better
Or how's it called
Intellij IDEA
I hate proprietary stuff
So i would like to find a open-sourced code editor that has features like terminal and appearance options like having a image in the background and stuff
Its ur choice, but would u maybe first try to look at the docs then ask? U would learn by that(I dont mean this mean)
you're talking about vscode already...
I use codium though a MIT licensed build of VScode
VScode is also opensourced
But it's a microsoft's thing and i hate using microsoft's stuff
Hopefully they don't buy discord
github :V
Emacs?
How to get link of message?
i just use vscode in github codespaces
It works for all of your use cases. At least in the context of a windows manager on Linux
You mean title link?
Sorry i typed wrong first
FLEX
Mac?
Nahh
Mm personally don’t like display managers
I ain't using that proprietary dumpster fire
Looks good though
Anyone tell me pls
It's xfce
i use xfce with defaults ;-;
I meant to say desktop environment. Don’t know why I said “display manager” lmao
Just edit the gtk.css in .config/gtk-3.0/gtk.css add
.xfce4-panel { border-radius: 15px; }
To get the rounded corners
Ew rounded corners
windows manager + desktop environment + your display = display manager
Make sure to add a transparent separator at the end and the start
what distro is that?
Lemme send it
there are like 20 popular distros and idk how many in existence
@slate swan How to get link of message?
!d discord.Message.jump_url
property jump_url```
Returns a URL that allows the client to jump to this message.
Most likely too much.
Ty
Ah but my friend, choosing is half the fun!
!e
code
!eval <code, ...>
Can also use: e
*Run Python code and get the results.
This command supports multiple lines of code, including code wrapped inside a formatted code block. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.
If multiple codeblocks are in a message, all of them will be joined and evaluated, ignoring the text outside of them.
We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!*
Since when does Discord auto format an url
#bot-commands
It's a laptop screen so please don't bully me for the huge terminal
Yeh
I tried
else:
await ctx.send(“you don’t have sniper in your inv.”)
And after I bought sniper
The command response inside the if statement did nothing
Does the command even trigger?
jump_url = f"https://discord.com/channels/{event.guild_id}/{event.channel_id}/{event.message_id}"```
tbh these quotes are marvelous and should work.
yeh
How to use it?
Lemme try something else in it
\u201d : RIGHT DOUBLE QUOTATION MARK - ”
In list?
message.jump_url
else:
await ctx.send("you don’t have sniper in your inv.")
Looks like something copied straight from the geeksforgeeks thing
g4g wouldn't use those quotes afaik
It doesn't?
Arch linux sorry for the late response
Picom for the blur stuff
Conky for the timer
Hi sarth
💀 i just use debian/kali with whiskers menu and default customs
yo wsup
Rules of a linux veteran
- If someone uses kali they are pretending to be a hacker while they are not
- If you find someone showing kids how to install kali kill them on spot
- If someone changes the distro just because they don't like the appearance explain them that is not how it works
i installed it cause i cleaned up my disk without a backup and had only kali on my usb kek
meh im comfy with that for now
Bruh
its been a year and a half
...
Rule 4: don't tell people that something that empirically does work for them doesn't work
wut ? i daily used it for almost 2 years
It's bloat
You don't even use most of the tools
so ?
And considering you use it as a daily driver it can make your overall experience bad
it did not
you dont even need to install them all
i used plenty
"Plenty" ?
just uncheck the default kali tools option
a large or sufficient amount or quantity; more than enough.
yes that means most of the tools
Well i meant kali to be a worse distro for other people who use it as a daily driver
empirically ?
What does that mean?
through proven experience, rather than looking from a purely theoretical or logical perspective
based on experience/ testing
Some people man they just think Having a GPU and not Having a GPU gives the same performance in games
Like message = id
And message.jump_url?
Message object
I don't disagree with the general sentiment, Kali is not a typical daily-drive OS and really isn't designed with that in mind, my point is more that if it works well for someone then let it be; there's little point in convincing someone that a tool they've used doesn't work when for them it evidently does
any help?
Works if I remove if “Sniper” in bag:
idk man it worked pretty nice for me ¯_(ツ)_/¯
My only point is it's just gonna make their experience badder if they just use it to flex
Unless you are a hacker who uses those tools
i can say the same about arch
If you have good hardware resources available, Kali is fine.
Have you ever used arch before??
conten = (reply.cached_message or await ctx.fetch_message(reply.message_id)) do it return message object?
Linux gala-arch 5.18.7-arch1-1 #1 SMP PREEMPT_DYNAMIC Sat, 25 Jun 2022 20:22:01 +0000 x86_64 GNU/Linux
you guys can stop and take this to an ot channel smh
yes daily drive it for about 3 years now
.
yes
message should be a discord.Message object
Ty
Does that even work?
should do
yes
I never knew there was an or in python :\
i doubt the or
I never knew there was an or in python :\

!d discord.ext.commands.Context.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/latest/api.html#discord.Message "discord.Message") from the destination.
ok yes that works.
!e print(False or "this is or")
@slate swan :white_check_mark: Your eval job has completed with return code 0.
this is or
it looks for the first Trueish value,
and can be used to look for the first Falseish value too
truthy and falsy :P
falsey
And how to add url to title of embed?
Embed(title, url=url)
@commands.Cog.listener(name="on_member_remove")
@commands.guild_only()
async def fm(self,member):
await member.ban(reason="User left while freeloader mode was on.")
this should ban the user who leaves right?
@neat field I really really mean it arch is not equal to kali, arch is a distro that is made with minimalism in mind and you can install what you want as you go, kali is a distro made for hackers/pentetester it has way too many tools preinstalled which can be useful for an hacker but bloat for a normal user my point is i'm not saying a person to "not use kali as a daily driver" instead i'm saying that it's gonna be seriously worse if you use it as a daily driver when you are not gonna use those tools
i still dont agree with you, u can daily drive kali just fine,
tbh u wiil have more errors on arch than kali
tbh u wiil have more errors on arch than kali
You won't if you know what you are doing
It's possible to daily drive kali
But still it makes your experience worse i've used it before trust me it ain't fun
what was the issue ?
Way too many login loop errors
You’re using a specialized OS as a general purpose daily driver, obviously the experience is going to be subpar
ehh
And too many fails in updates
cries in pacman -Syy
Update the mirror list :\
thats more like a debian/apt thing than kali itself
i did make a script that does that for me so no longer an issue 😄
also can we move to #ot2-never-nester’s-nightmare or #unix with the discussion cause i feel like people are hesistating with the original topic questions because of an ot discussion
Sorry i'll move there
💯
How to add url to a value in field of embed?
Just add it?
u need to use the mark down format
text
yes, and you can use the link directly too depending on what you need.
wait u can have url in a field ?
value=["text"](link here) like this ?
in field's value as normal text yes.
Erm ofc you can
"text"
.
Quotes are unnecessary
naa i meant as we have in title
Hey does bot.latency return how long it took for your bot to finish the command or is it just your ping to discord server?
i think so
!d discord.ext.commands.Bot.latency
property latency```
Measures latency between a HEARTBEAT and a HEARTBEAT\_ACK in seconds.
This could be referred to as the Discord WebSocket protocol latency.
^
What is heartbeat
It doesn’t 💀
Do i need to put 'display text on hover'?
nope, thats optional
Ok
Delay showing how often you should send heartbeat websocket message, read more on dev portal
And can i use f string in it?
can i see more code, is there any other function names fm in the cog?
is the cogs loaded?
where?
The cog is loaded by ,fm on
The response for ,fm on is sent after the cog loads
send the cog file
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
At the url varible
import discord
from discord.ext import commands
class fmode(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener(name="on_member_remove")
@commands.guild_only()
async def fm(self,member):
await member.ban(reason="User left while freeloader mode was on.")
async def setup(client):
await client.add_cog(fmode(client))
Typehint member
And ig you get no errors because of improper error handler, you were supposed to get AttributeError
And um 2 decorators?
Am I missing something
the guld only listener is useless 
@commands.guild_only()
this is useless
on_member_remove event will be dispatched when a member leaves a guild
any guild?
yup
if exists
you have the member object, the member has a guild parameter
!d discord.Member.guild
The guild that the member belongs to.
so you can do something like if member.guild.id == id: #do something
!e print(id) # 😏
@vale wing :white_check_mark: Your eval job has completed with return code 0.
<built-in function id>
yeah don't use id as variable name of course 
won't really effect inside a function scope ig
@slate swan is there any other way to add url to field?
no
😩
...
how do you want it to work
embed.add_field(name='\u200b', value="[text](https://google.com)")
Bruh
I can't add varible to the link
whats ur variable?
url
u can in a f string
I asking will f string wirk
f"[text]({link})"
Ok
f"{hi}"
wont work unless hi is defined
nvm
Yeah i know
how to get member avatar url?
ema.set_footer(text=f"{member.id}",icon_url=member.avatar.url)
AttributeError: 'str' object has no attribute 'url'
avatar.url only exists in dpy 2.0 / forks, for 1.7.3 you'll have to use avatar_url
@slate swan
@bot.command()
async def bm(ctx):
reply = ctx.message.reference
conten = (reply.cached_message or await ctx.fetch_message(reply.message_id)).content
contents = (reply.cached_message or await ctx.fetch_message(reply.message_id))
url = contents.jump_url
auth = contents.author
await ctx.send("message bookmarked")
embf = discord.Embed(title=f"{auth}\nbookmark",color=discord.Color.green())
embf.add_field(name="bookmark message",value=conten,inline=False)
embf.add_field(name="bookmark link",value=f"[link to message]({url})", inline=False)
embf.set_thumbnail(url='https://media.discordapp.net/attachments/993363454519955466/996046786928070696/unknown.png')
await ctx.author.send(embed=embf)
Done!
nais
Me also use replit on mobile
bro if you're in pune ill give you my old laptop
DUDE STOP REVEALING WHERE YOU LIVE
Imagine being so generous 
It's dangerous
nobody will give a shit, nobody cares 
its ok there are 10 people every square meter where i live theres no chance anyone will find me
I do and i certainly think the owners don't want anyone being doxed in
You think so? Yes it is true that it will be hard nabbing you but still you have narrowed it down from the world to a single place
How hard do you really think it is to get your name
imagine stalking people 😔
not hard at all, everything is on my website 😄
I'm a stalker btw not really to the extreme but i still terrify people by knowing more about what accounts they have in social media
dangerous person thy is 
how are you uninstalling?
Nice website btw
Is the bottom stuff svg?
ty :)
the icons? yes
And that just remembered me that i've moved and i have to change that on my website too 
Can we chat more on dm ?
I would really really like to know how you made that website
sure
replit uses poetry ?
replit 
YES
if you come to pune i can give you my old laptop
Why would you use your phone?
zeffo stop advertising
That's not called advertising
singlehandledly boosting my country's tourism industry 😏
can I come
no lol
rude
think about the downsides, you'll have to meet nova
he lives with you? 
Is nova a pet ?
we all live next to each other just check out the fcking population density
nvm I'm fine
Actually loll means just moving your feet kinda
A single l can change the meaning of everything
mood killer
google says otherwise and im not saying it cuz yes
it's polite to ask before asking
:\
https://paste.pythondiscord.com/ekecajeher how can i make that if a user unreacts that it removes again the role?
on_reaction_remove
thanks
same code with remove_roles instead of add_roles
thank you :D
I say that always because i will have the one guy who will ask to ask but never really ask the question
i mean yeah, dropping the question directly is a quick process
isn't your headache, is it? 
you can be polite while asking the question itself
They just leave me in a suspense especially when i'm giving support to something i made
i keep waiting for minutes too lmao.
sorry
Ah it's ok
but yeah its totally fine to ask before asking if you really want to
It is but if they are just gonna ask to ask without asking the question it really drives me mad
ok, cool
I mean asking to ask is better than asking and then not being able to so it's just better to ask rather than asking but it's always politer to be asking to ask
bro
😂 lets not make it a topic to debate about.
why are u discussing now about that
I really don't know why whenever i chat i start a debate
btwww i found a way to attach more than 1 image in Embed's image field
your profile picture is too suspicious
what
Ashley — Today at 17:25
i just like the anime xd
knew it was coming
like this, and yeah all of them are different

?av
fr lmao

lemon best.

W
.topic
Suggest more topics here!
Bruh he told just city not his address
,
Yeah i k

thats cool
now use wait_for with "reaction_add_event" and keep waiting for the event to dispatch until people stop reacting (using a timeout)
this is basically what it will look like
*part of code*
await ctx.send(
embed=embed,
components = [
Select(
placeholder = "Выберите нужный раздел!",
options = [
SelectOption(label = "Развлечения", emoji=":balloon:", value = "fun"),
SelectOption(label = "Связь", emoji=":e_mail:", value = "conenect"),
SelectOption(label = "Приватные войсы", emoji=":mobile_phone:", value = "private"),
SelectOption(label = "Свадьбы", emoji=":ring:", value = "marry"),
SelectOption(label = "Экономика", emoji=":dollar:", value = "eco"),
SelectOption(label = "Профиль", emoji=":man_frowning:", value = "profile"),
SelectOption(label = "Реакции", emoji=":grinning:", value = "react"),
SelectOption(label = "Модерация", emoji=":shield:", value = "moder")
]
)
]
)
res = await self.bot.wait_for("select_option")
await res.respond(content="тест успешен")
hello everyone, i have a problem. Bot writing error "the interaction failed", i dont know why, help pls(
(this code writing in cogs)
libbary: discord_components
lang: python
Can you provide the full traceback please? Hard to diagnose the error with nothing more than "interaction error"
in console dont writing a error
I'm talking about any errors in your terminal
The generic "interaction error" on discord is, well, generic and doesn't help much
.
Do you have any error handlers?
while True:
try:
payload = await bot.wait_for("raw_reaction_add", check=lambda p: p.message_id == <your message object>.id, timeout = <some timeout>)
# add role to payload.member
except:
# stop listening to the event
no
can you translate it to english?
interaction error...
is that Interaction Failed or Interaction Not Responded
interaction failed
Could just be an issue with discord_components
I feel like it might have to do with those last 2 lines
i used discord_components
Practically. Don't think it was any good in the first place
yeah they should be using discord.py v2 for components. that would be the best.
im should use a discord_componets
@slate swan I would say be 100% sure you don't have any error handlers. I don't see any other reason for why you wouldn't be getting any errors in console
I guess discord_components made it one
I've seen similar things, like button_click, so I would assume yes
sorry, i wrong translate a error, right translate is "This interaction failed"
as robin mentioned, do you get any errors in the console?
..Which means something went wrong in your code. Yet you don't have any errors in console. Which is what leads me to believe you have a faulty error handler eating up errors somewhere
this translate like "This interaction failed" too
Bro read what robin said 
noooo
Damn, I don't speak English well, it's hard to explain the problem
just use discord.py2.0
if i go to it will all my past commands work?
Lmao no you will have to change all slash commands deco's
If they don't have any interactions, then yes
The interaction is his problem
If they have things like application commands, buttons, select menus, etc, yes you will have to rewerite
мб по русски базарит кто?
!rule 4 hi there, please use english
4. Use English to the best of your ability. Be polite if someone speaks English imperfectly.
^(
you just have to adjust the your previous code to dpy
you already did the hard parts of figuring out the structure of your previous code, now you just to have to tweak it slightly which is easier than it looks
is there anyway of making a restart bot command? ive looked on youtube and google found nothing?
i'll suggest to migate to v2, because there will be breaking changes on the release, so its better to refactor your code according to that already
Hi
depends on wym by restart. just the bot or the complete script?
Like turn it off and on
again, just the bot or the complete script?
usually, your script pretty much runs the bot only
in case you still dont understand, you want the bot to go offline and come back online again
or the file stops running, and then starts rerunning
bot
stopping the bot != stopping the script.
and there's no built in way of making your bot restart
you can use py await bot.close() to stop it, and await bot.connect() to reconnect it to the socket
!d discord.Client.connect
await connect(*, reconnect=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a websocket connection and lets the websocket listen to messages from Discord. This is a loop that runs the entire event system and miscellaneous aspects of the library. Control is not resumed until the WebSocket connection is terminated.
I've seen in quite a few places that recommend against using this
await close()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Closes the connection to Discord.
reasons?
the best way would be to use bot.close() and use a process manager restart the bot again
The only good way to restart your bot is to shut it down and have your process manager handle it. You can shutdown your bot by running Bot.close().
Do use:
- run your bot in a process manager such as:
- systemd
- openrc (gentoo, devuan)
- runit (void linux)
- supervisord
- upstart (old ubuntu)
- docker
- manually reboot it
Do not use:
- a bash loop (it can eat your C-c by rapidly spawning python and if your bot fails it won't stop it from constantly failing)
- subprocess.call (you will eat your memory up by not letting your old processes die)
- os.exec*
bot.close stops the bot but the script process is still running, dont see how creating another process is good
i didnt suggest any of them
Bruh the hell are you talkin about lmao?
@slate swan do you know what is called before the bot shuts down (lightbulb.BotApp)
I tried to overwrite close but it doesn't seem to get called
The bot doesn't run with the code, Client or Bot instance has a run method
that makes the connection with discord API
Stopped/StoppingEvent
thx
figgerd how to do it and it was a lot easer im a bit dumb lol
@bot.command
@commands.has_role('PRO HACKER')
async def restart(ctx):
await ctx.send("Restarting bot...")
restart_bot()
😄
you have to call bot.command
what makes you think that wasnt a troll
the average person in need of help in this channel does not know python
Ikr
Just init it in MyView (also please call your cog Tickets it's naming convention)
!pep 8
its a convention which just means a common good practice
Starting with small letter, breaking classes naming convention. Should be CamelCase
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
You better do otherwise your code might become unreadable hell for you and others
How did you do that
You need to init superclass as well
I suggest reading about inheritance and OOP generally in python when you have time
Can someone link me to the docs for what discord.app_commands.command accepts as args, mainly I'm looking for if I can have a list of attachments as a arg (dpy 2.0)
Call super().__init__() to init superclass
I think that should be somewhere on discord dev portal, lemme look it up
Yes
But not in cog
Cogs don't need superclass init
. not , and you don't need to call the super class.
@flat solstice there's no way to attach a list of attachments it seems https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-type
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
hmm well that's annoying
Right 🥲
You could pass the bot instance ig I personally have a View coded like this.
class MyView(View):
def __init__(self, bot: Bot, *, timeout: float = 180.0) -> None:
super().__init__(timeout=timeout)
self.bot = bot
You get this error since MyView doesn't have a timeout attribute. But the View class does we address the View class using the super call.
Because it doesn't get overwritten and keeps the __init__ from superclass
True since then it grabs the underlying init from View. But since you overwrite it in MyView you have to call it again.
I've provided an example as shown.
pro hacker
Very pro
@pastel solar I will use this example to explain further on how to implement a select menu.
yessirr
i have a question about heroku
from discord.ui import View
from discord.ext.commands import Bot
class MyView(View):
def __init__(self, bot: Bot, *, timeout: float = 180.0) -> None:
super().__init__(timeout=timeout)
self.bot = bot
View is the base class of implementing Buttons and/or Select menus.
Could you provide the error + code?
Where do you load the cogs?
Could you show that?
Are you using discord.py 1.7.3 or 2.0?
!pypi py-cord
This can also be ```py
bot.load_extensions(["cogs.tickets", "cogs.close"])
You don't really have to.
With the callback the interaction is passed, that contains the bot variable.
async def callback(self, interaction: Interaction) -> None:
channel = interaction.guild.get_channel(...)
@pastel solar get channel does need to come from either a guild or client/bot object.
The ApplicationContext object aka Interaction contains a lot of information about the command, guild and bot you can read all it's attributes here -> https://docs.pycord.dev/en/master/api.html?highlight=interaction#discord.Interaction
A wait_for is only accessible by the bot/client object.
wait_for is a Client ONLY method not a Guild method
You would use interaction.bot.wait_for(...)
how would the if statement look alike?
But I don't recommend using a wait_for these days. Any reason why you would need the message?
Use client instead of bot
interaction.client.wait_for(...)
can you send your code again
but i use bot
yeah 1sec
I recommend using a modal for a ticket system.
it has to be same emojis right?
Modals allow you for user input without needing to wait_for and it intergrades better with an interaction.
uh yes
its correct then
!d discord.on_raw_reaction_remove
discord.on_raw_reaction_remove(payload)```
Called when a message has a reaction removed. Unlike [`on_reaction_remove()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_reaction_remove "discord.on_reaction_remove"), this is called regardless of the state of the internal message cache.
This requires [`Intents.reactions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.reactions "discord.Intents.reactions") to be enabled.
yeah and use raw events
Most people like it raw 🐒
the if statements would be same.. thats literally the same code with adds replaced with removes
Okay guys I've got kind of an issue, would you rather, have a interaction menu with buttons and dropdown menu's to customize/add something or use slash command instead with little visualization.
how can i have input on my discord bot
!d discord.ui.Modal
class discord.ui.Modal(*, title=..., timeout=None, custom_id=...)```
Represents a UI modal.
This object must be inherited to create a modal popup window within discord.
New in version 2.0.
Examples...
modals 
So the buttons and menu's?
use letters instead

@bot.command()
async def ship(ctx, user1:discord.Member, user2:discord.Member):
try:
if user1 == user2:
await ctx.send("You can't ship yourself with yourself")
else:
percent = random.randint(1, 101)
await ctx.send(f"{user1.mention} and {user2.mention} are {percent}% compatible")
except Exception:
await ctx.send("Please provide two valid users")
when I try to ship 2 random things it gives an error in the console but doesnt send anything in chat
and the error is
raise MemberNotFound(argument)
discord.ext.commands.errors.MemberNotFound: Member "test" not found.
does the bot have member intents
Is there a member named "test" in the server?
nope
yep
that would explain the error
yeah but the exception block isnt being triggered
because it's erroring on the argument input, it isn't even reaching that try/except
you probably want to make an error handler for that command
uh i dont understand
@ship.error
async def ship_handler(self, ctx, error):
"""A local Error Handler for our command do_repeat.
This will only listen for errors in ship.
The global on_command_error will still be invoked after.
"""
# Check if our required argument inp is missing.
if isinstance(error, commands.MemberNotFound):
await ctx.send("Please provide two valid users")```
^ example of a command error handler that should deal with your issue.
the try/except is checking if it errors in THIS block of code
but the error happens HERE so the try/except doesn't come into play
the cmd error handler will deal with it tho
👍
👍
hi guys
i have a question
async def on_reaction_remove(reaction, user):
Channel = bot.get_channel(988526792602177636)
if reaction.message.channel.id != Channel.id:
return
if reaction.emoji == "🌈":
Role = nextcord.utils.get(user.guild.roles, name="Divers")
await user.remove_roles(Role)
if reaction.emoji == "♀️":
Role1 = nextcord.utils.get(user.guild.roles, name="Weiblich")
await user.remove_roles(Role1)
if reaction.emoji == "♂":
Role2 = nextcord.utils.get(user.guild.roles, name="Männlich")
await user.remove_roles(Role2)
if reaction.emoji == "😳":
Role3 = nextcord.utils.get(user.guild.roles, name="18+😳")
await user.remove_roles(Role3)
if reaction.emoji == "👨🦱":
Role4 = nextcord.utils.get(user.guild.roles, name="15-17")
await user.remove_roles(Role4)
if reaction.emoji == "🧒":
Role5 = nextcord.utils.get(user.guild.roles, name="13-15")
await user.remove_roles(Role5)```
why isnt this working? it gives nothing in the console too
You should correct the size by yourself and typehint user with discord.Member instead of discord.User because ig you have separate pfps for servers and discord.User gives the global one
Use dictionary please, all these ifs are hellish
And yeah variables naming convention is lower_snake_case
Nah just use dict
I kinda don't understand what pfp you need, the global one or the local one?
are ifs bad?
These are
why
These are pretty much the same with a few things varying
Read about code refactoring when you have time
ok
You said it doesn't?
one for reaction role and if they remove the reaction it goes away(which doesnt work)^
!d discord.on_raw_reaction_remove try this
discord.on_raw_reaction_remove(payload)```
Called when a message has a reaction removed. Unlike [`on_reaction_remove()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_reaction_remove "discord.on_reaction_remove"), this is called regardless of the state of the internal message cache.
This requires [`Intents.reactions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.reactions "discord.Intents.reactions") to be enabled.
for what is the payload if i can ask?
Docs exist
okay
sry, im gonna look further into it later.
class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild").
This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User").
x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") instances too.
x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") instances too.
hash(x) Returns the member’s hash.
str(x) Returns the member’s name with the discriminator.
!d discord.Member.avatar should work @slate swan
property avatar```
Equivalent to [`User.avatar`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User.avatar "discord.User.avatar")
still doesnt work
@bot.event
async def on_raw_reaction_remove(reaction, user):
Channel = bot.get_channel(988526792602177636)
if reaction.message.channel.id != Channel.id:
return
if reaction.emoji == "🌈":
Role = nextcord.utils.get(user.guild.roles, name="Divers")
await user.remove_roles(Role)
if reaction.emoji == "♀️":
Role1 = nextcord.utils.get(user.guild.roles, name="Weiblich")
await user.remove_roles(Role1)
if reaction.emoji == "♂":
Role2 = nextcord.utils.get(user.guild.roles, name="Männlich")
await user.remove_roles(Role2)
if reaction.emoji == "😳":
Role3 = nextcord.utils.get(user.guild.roles, name="18+😳")
await user.remove_roles(Role3)
if reaction.emoji == "👨🦱":
Role4 = nextcord.utils.get(user.guild.roles, name="15-17")
await user.remove_roles(Role4)
if reaction.emoji == "🧒":
Role5 = nextcord.utils.get(user.guild.roles, name="13-15")
await user.remove_roles(Role5)
File "/home/container/.local/lib/python3.10/site-packages/nextcord/client.py", line 445, in _run_event
await coro(*args, **kwargs)
TypeError: on_raw_reaction_remove() missing 1 required positional argument: 'user'
Ignoring exception in on_raw_reaction_remove
Traceback (most recent call last):
File "/home/container/.local/lib/python3.10/site-packages/nextcord/client.py", line 445, in _run_event
await coro(*args, **kwargs)
TypeError: on_raw_reaction_remove() missing 1 required positional argument: 'user'
raw reactions doesn't take reaction, user it's just a payload
!d discord.RawReactionActionEvent
class discord.RawReactionActionEvent```
Represents the payload for a [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") or [`on_raw_reaction_remove()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_raw_reaction_remove "discord.on_raw_reaction_remove") event.
@bot.event
async def on_raw_reaction_remove(payload):
Channel = bot.get_channel(988526792602177636)
if payload.message.channel_id != Channel.id:
return
if payload.emoji == "🌈":
Role = nextcord.utils.get(payload.guild.roles, name="Divers")
await payload.remove_roles(Role)
if payload.emoji == "♀️":
Role1 = nextcord.utils.get(payload.guild.roles, name="Weiblich")
await payload.remove_roles(Role1)
if payload.emoji == "♂":
Role2 = nextcord.utils.get(payload.guild.roles, name="Männlich")
await payload.remove_roles(Role2)
if payload.emoji == "😳":
Role3 = nextcord.utils.get(payload.guild.roles, name="18+😳")
await payload.remove_roles(Role3)
if payload.emoji == "👨🦱":
Role4 = nextcord.utils.get(payload.guild.roles, name="15-17")
await payload.remove_roles(Role4)
if payload.emoji == "🧒":
Role5 = nextcord.utils.get(payload.guild.roles, name="13-15")
await payload.remove_roles(Role5)
``` i fixed it, but it still doesnt work. do you maybe have an answer? @cloud dawn
but it still doesnt work
Elaborate please
It doesnt remove the role, nothing in the console
Probably because you're comparing a discord.PartialEmoji object to a str, so it will never be true
You can try something like this:
if str(payload.emoji) == '😎':
...
Also please use a dict, the code is very redundant
I dont know how to do that, im sorry. i started python a few weeks ago
Thanks
Just map the emoji to the name of the role:
mapping = {
"🍌": "Banana",
"🍎": "Apple",
"🍊": "Orange",
"🍇": "Grape",
}
role = discord.utils.get(payload.guild, mapping[str(payload.emoji)])
# remove role here
still doesnt work sadly
oh okay thanks
Is the event getting fired?
Also are you sure you're reacting to the message in the channel with ID 988526792602177636?
idk
Wait
yes, iam
sry for late answer
Try doing a print statement as the first line in the event to see if it's getting triggered in the first place
Sure, just print something
Okay
Doesn't matter what it is, we just need to make sure the event is getting fired
okay
Yes, it prints the channel name
Okay, now can you print(str(payload.emoji))?
okay
Uh no it doesnt print that
Did you react in discord?
Can I see the code real fast?
async def on_raw_reaction_remove(payload):
Channel = bot.get_channel(988526792602177636)
print(Channel)
if payload.message_id != Channel.id:
return
if str(payload.emoji) == "🌈":
print(str(payload.emoji))
Role = nextcord.utils.get(payload.guild.roles, name="Divers")
await payload.remove_roles(Role)
if str(payload.emoji) == "♀️":
Role1 = nextcord.utils.get(payload.guild.roles, name="Weiblich")
await payload.remove_roles(Role1)
if str(payload.emoji) == "♂":
Role2 = nextcord.utils.get(payload.guild.roles, name="Männlich")
await payload.remove_roles(Role2)
if str(payload.emoji) == "😳":
Role3 = nextcord.utils.get(payload.guild.roles, name="18+😳")
await payload.remove_roles(Role3)
if str(payload.emoji) == "👨🦱":
Role4 = nextcord.utils.get(payload.guild.roles, name="15-17")
await payload.remove_roles(Role4)
if str(payload.emoji) == "🧒":
Role5 = nextcord.utils.get(payload.guild.roles, name="13-15")
await payload.remove_roles(Role5)
oh ok
It prints the emoji
Could you send a screenshot?
And do you have an if case for that?
await payload.remove_roles
huh?
I don't believe discord.RawReactionActionEvent has that method
Why are you not getting any errors for that?
Do you have a badly written error handler?
i dont have an error handler, kinda
You should probably try to find it and fix it up because it would've saved us a lot of time
oh, iam sorry
what wouldve it be instead?
You can try to get the member object and call the method on that
It's not ideal but you can try to get it from user_id
could u send me example code? sry for being dumb
Very error prone but here:
member = bot.get_guild(payload.guild_id).get_member(payload.user_id)
Putting the checks in place to make it less error prone is up to you
hey i asked this question before but then i fell asleep >-> anyways
Im trying to write a message onto a file what somebody inputs a !setname command i made
it keeps giving me errors that i need message.content but i cant use .content in a function with a @client.command decorator
what
^^ and i replaced the open('file.txt','w')
and it just sets the file to a weird thing
Commands accept a discord.ext.commands.Context instance as the first parameter
In your case, it thinks the message is the discord.ext.commands.Context instance, rather than a discord.Message as you would expect
like this?
No, https://discordpy.readthedocs.io/en/stable/ext/commands/commands.html see here for a very basic command example
i definitly havent tried it the right way
Well, look at what the error says
right it doesnt have the attribute that means i cant use the .ctx at the end of message correct?
That's right
would i use ctx itself?
str is just a primitive python type, no reason for it to have a context as that's a discord concept
You could just use message
So if I were to run this command, given your bot's prefix was !:
!setname "Hello, world!"
the message variable would be Hello, world!
You didn't use it but discord.py always provides the context as the first argument
if you removed ctx, then message would be the first argument, which would be the context instead
ahhhh
is that the case with every function or only functions with the decorator of clientcommand
Only functions registered as discord.py commands
No, different events will take different arguments
Only commands will provide you with a commands.Context instance
hi guys. How is it possible to use bot on 1 discord server and check if member in other server has certain role? (bot is a member of other server)
member_has_role_in_other_server = role_id in [role.id for role in bot.get_guild(other_guild_id).get_member(member_id).roles]
Make sure you check for edge cases like get_guild or get_member returning None
omg thank you
you can shorten it as ```py
role_id in bot.get_guild(other_guild_id).get_member(member_id)._roles
Hey sorry to come back with a question so quickly, but why is my for loop not working
ive never seen an issue like this before with a for loop
does the csv file have some content?
yeah
how to do it..?
i have commas
and newlines
well that problem was that i only had the header ig
oh nope i didnt have newlines
ty sarth!
@sick birch why it is error here
if (1111 in [role.id for role in member.get_guild(11111).get_member(11111).roles]):
embed = discord.Embed(color=0x37393d,
description=f"{ctx.author.mention}, true")
await ctx.send(embed=embed)
else:
embed = discord.Embed(color=0x37393d,
description=f"{ctx.author.mention}, false")
await ctx.send(embed=embed)
member = Guild.get_member(id) or await Guild.fetch_member
!d discord.Guild.fetch_member
await fetch_member(member_id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") from a guild ID, and a member ID.
Note
This method is an API call. If you have [`Intents.members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.members "discord.Intents.members") and member cache enabled, consider [`get_member()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.get_member "discord.Guild.get_member") instead.
Changed in version 2.0: `member_id` parameter is now positional-only.
elaborate wym my user input
!d discord.on_message
discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message") is created and sent.
This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.
Warning
Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
use these event
!d discord.Message.content message variable there is Message object and you can use .content property to get the message content
The actual contents of the message. If Intents.message_content is not enabled this will always be an empty string unless the bot is mentioned or the message is a direct message.
@slate swan may u help me with ?
if (1111 in [role.id for role in member.get_guild(11111).get_member(11111).roles]):
embed = discord.Embed(color=0x37393d,
description=f"{ctx.author.mention}, true")
await ctx.send(embed=embed)
else:
embed = discord.Embed(color=0x37393d,
description=f"{ctx.author.mention}, false")
await ctx.send(embed=embed)
discord has no atribute "on_message"
on_message is an event, which gets fired when someone sends a message on discord.
the message is stored as a discord.Message object in the first paramater of the on_message function
sure, but help with?
can my bot send an image file that is in my pc?
something like:
await interaction.response.send_message(/folder/image.png)
thank you !
@slate swan
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'get_member'
if (995806453753454603 in [role.id for role in
client.get_guild(982622742136389662).get_member(lst[i]).roles]):
ktempcount = ktempcount + 1
if (985871153555976244 in [role.id for role in
client.get_guild(937811716438380624).get_member(lst[i]).roles]):
ktempcount = ktempcount + 1
if (982622893408157696 in [role.id for role in
client.get_guild(937811716438380624).get_member(lst[i]).roles]):
ktempcount = ktempcount + 1
if (995054761797754940 in [role.id for role in
client.get_guild(937811716438380624).get_member(lst[i]).roles]):
ktempcount = ktempcount + 1
@slate swan how can i fix that if member is not on server or he douesnt have one of roles
the serrver id doesnt seems right
that is correct
you've messed up with intents then. the server id is not in the cache.
oh yeah, sry
i fixed server id mistake and have it:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'roles'
!intents enable member 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 Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, 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.
well i give up @slate swan
client.get_guild(937811716438380624).get_member(int(lst[i])).roles]):
AttributeError: 'NoneType' object has no attribute 'roles'
what's list
if its a list f strings or a dictionary with string values that would never work,
@bot.command()
async def trustlist(ctx, user:discord.User=None):
if user == None:
await ctx.reply("**⛔ No id provided**")
try:
await ctx.guild.unban(user)
except discord.NotFound:
await ctx.reply("**⛔ This user doesn't have ban**")
else:
await ctx.reply(f"**✅ User {user.mention} is now whitelisted**")``` why this dont work properly?
list of people id's
iis there an error
no but the replies dont work properly
print something after each statement
dude its working fine, but the the bot replies to me at the wrong moments


