#discord-bots
1 messages ยท Page 913 of 1
show the error when you await it
kk
c:\Users\thebe\Downloads\Mecha\src\cogs\verify.py:113: RuntimeWarning: coroutine 'BotBase.add_cog' was never awaited
bot.add_cog(verify(bot))
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Extension 'cogs.verify' raised an error: TypeError: object NoneType can't be used in 'await' expression
@boreal ravine
Await add_cog
its the weirdest shit, do i have to go into my cogs and do await bot.add_cog(verify(bot))?
yes
trying that now
"await" allowed only within async function
def setup(bot):
bot.add_cog(utility(bot))
with await this doesnt work
should i not use the def setup and have the cog on its own
@summer thunder https://gist.github.com/Rapptz/6706e1c8f23ac27c98cee4dd985c8120 please read this
Make it async
async def setup?
im really stupid holy shit
trying it bnow
@boreal ravine tysm
How would I make a check like this?
chekc if the user has administrator
or any other perm like ban / kick
Well i already have it set up like
@commands.has_permissions(ban_members=True)```
you have to check the members permissions
and then use ctx to respond?
yeah
you can get the members permissions by using member.guild_permissions.<permission>
if isinstance(error, MissingPermissions):
text = "Sorry {member.mention}, you do not have permissions to do that!".format(ctx.message.author)```
there is no reason for the format
i havent been using guild permissions
it checks the members permissions in the guild
like
if member.guild_permissions.administrator:
return ctx.send("nonono!!!")
@lusty sky
how do i add a welcome message
just send the content in a specific channel set by a user
im skidding code rn, as im trying to learn python. i just installed vsc yesterday lol
.......
what do you expect from us then ๐
i want code for a join msg. my best bet is learning from skidding and then creating my own stuff
!d discord.on_member_join
discord.on_member_join(member)``````py
discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") join or leaves a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
And yes, don't forget about the intents

what
im so confuse
ah yes, the docs
i get sent those everytime i ask a question lol
Czzzzzz
use the on_member_join event, and send the welcome message in the appropriate channel 
and this requires member intent
i dont know how to set that up...
PoV: He dk what's an event or an intent 
!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.
No?
@slate swan read this
i am and its still confusing me
learning python is your best option
im trying
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('$hello'):
await message.channel.send('Hello! This is my only cmnd at the moment lol')
client.run('token')```
Hmm
my code so far
Lemme guess... you got it from the docs?
yep!
Hehe
im learning doe lol
It's fine
client.event if somethin happens or sum shit. client.user checks that it isnt a bot
It takes a single arg, the member who joined
Just like on_message takes the message arg
Try it for yourself, the same way you made the on_message
async def on_member_join(member):
await member.send('Private message')```
@maiden fable dis gud?
wait no. it doesnt specify the channel to send it in
thats a bare send, but yes that will work if the member's dms are opened
where do i edit the msg?
msg = await member.send(...)
await msg.edit(...)
wha
meaning
Okay so, look into classes and objects
You need to have a basic understanding
im just trying to get this set up for a server asap, then imma go thru it slo0w
Well
I'd rather just make it for you and let you take all the credit 
sarcasm
Paid work for free ๐
yeah cz why not
then thx for being nice ๐
DONT PUT AWAIT MEMBER.SEND('PRIVATE MESSAGE')
@client.event
async def on_command_error(ctx, error):
embed=discord.Embed(timestamp = datetime.datetime.utcnow(),title='**You do not have the permission(s) to run this command.**')
embed.set_footer(text = ctx.author.name, icon_url = ctx.author.avatar_url)
await ctx.send(embed=embed)
if isinstance(error, commands.MissingPermissions):
await ctx.send("You do not have the permission(s) to run this command.")
else:
raise error```
what this mean
Okay
@maiden fable
Yea I'm here lol
do i just copy paste "name"
async def on member_join(member):
# DONT PUT AWAIT MEMBER.SEND('PRIVATE MESSAGE')
msg = await member.send('private message')
await msg.edit('edited')
What's the issue
async def on member_join(member):
msg = await member.send('private message')
await msg.edit('edited')```
Yes
oh
But there's one issue
wdym
edit(content="")
I was wondering how to make it embed this command
await ctx.send("You do not have the permission(s) to run this command.")
else:
raise error```
can u rewrite w spaces
because right now this is what it does instead
Can't understand
Uhhhh
@client.event
async def on_command_error(ctx, error):
embed=discord.Embed(timestamp = datetime.datetime.utcnow(),title='**You do not have the permission(s) to run this command.**')
embed.set_footer(text = ctx.author.name, icon_url = ctx.author.avatar_url)
await ctx.send(embed=embed)
if isinstance(error, commands.MissingPermissions):
await ctx.send("You do not have the permission(s) to run this command.")
else:
raise error```
copy paste..?
just use an Embed
can someone help me in #help-popcorn
await ctx.send(embed=embed)("You do not have the permission(s) to run this command.")
else:```
like this?
it fixed it thanks Ashley
im lost
help pls?
uhhh, that syntax was invalid huh
!e
await ctx.send(embed=embed)("You do not have the permission(s) to run this command.")
else:
@cosmic agate :x: Your eval job has completed with return code 1.
001 | File "<string>", line 2
002 | else:
003 | IndentationError: unexpected indent
dms also join the server and leave if u want, i just want to know if the join msg works
what tf is this
idk
this one @buoyant zodiac
maybe that's new
me just testings
ion really code anymore tbh
pls???
?
nvm
hmm
but that syntax was invalid 
can anyone tell me the code for the following
if i type .official > the bot will give the pinged member a specific role
if i type .vc > the bot will join the specific vc
and what shoul be the imports like
import discord
import python
!d discord.Member.add_roles
await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
!d discord.VoiceChannel.connect
await connect(*, timeout=60.0, reconnect=True, cls=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Connects to voice and creates a [`VoiceClient`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceClient "discord.VoiceClient") to establish your connection to the voice server.
This requires [`voice_states`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.voice_states "discord.Intents.voice_states").
hmm only import discord ?
And code for
if i type .official it will give specific role
can anyone tell me the code for the following
if i type .official > the bot will give the pinged member a specific role
if i type .vc > the bot will join the specific vc
and what shoul be the imports like
import discord
import python
U only need discord import
Can you help me with heroku ?
suggest some logs
?
like i have msg channel delete voice join leave and alll
Ah
or suggest a command
Idk
iirc nope
:<
how to make your bot edit message?
2048 command
what
๐พ Join the numbers and get to the 2048 tile! Careful: this game is extremely addictive!
.
um what
idk
how can i make this only trigger if the bot is mention?
if message.content.startswith("luBOT"):
instead of saying luBOT, you can just mention it?
a not very fancy way is to copy the developer id of your bot and then paste it like this < @ 1234567890 >
But all together
ohh
That would count as a mention
I suggest you don't
u cant
Why?
Because it isn't supposed to be used as a hosting service
Bruh
yes
why u want replit as host

That's better than what you would pay for on replit
50$ 
50$ what
per month?
which hosting
What is this 50$ for
Replit hacker pack
Bruh
HACKER IN REPLIT
Stop trying on replit

Just get a vps
Price?
private server
Yes we know
we are not selllers
i dont
He never said we are
Any website you know?
He's asking for a general price
Yes
no idea
Usually 2-3$
per month
I know one that does 0.50$ per month
prob low spec
@slate swan
It is
clicked and laged

any free hosting ?
Perhaps
.
That is not hosting

wdym
Bad
then.
I meant it as not hosting for discord bots
I am telling for free
alright
Just self host
cant
Self host?
Then pay
Yes
i said free
How?
use ur pc
How?
You run the bot file on your pc then leave it on 24/7
If i close my pc what happened?
magic
๐
ur bot goes offline
Then every running thing gets turned off
i thought that was mod
cant
You can learn how to make friends then smooth talk them to host the bot for you
nvmd
Like there is a option sleep and shutdown
here sometimes the electricity goes
So It will work?
huh?????
๐ ๐
@slate swan is there any video on yt ?
heroku?
Self host
ik its uptime is down
Anyone have self host video?
are you using an IDE?
What happened if my windows go to sleep mode? @slate swan
wdym
ide for self hosting huh?
You can use everything that can launch your python file
Bhai me replit se file download kr raha ho too kuch show nhi ho raha file mai
yes but why?
self hosting isn't meant to be used in production anyways
the ide will run in back

whats the different of:
print("send")
print(f'send')
wrong channel for this
as you written there is no difference, the code will print send anyways
tysm
!rule 4
4. Use English to the best of your ability. Be polite if someone speaks English imperfectly.
Stop with the Hindi ๐
how to add my prefix to on_message function?
like
if message.content == (myprefix,"any message"):
await message.channel.send("a") ```
xd
Everyone is Indian here
wdym?
?
.startswith

tysm!
I'm too
i already learn python but i dont know how to use with prefix
most useless tutorials on youtube lol
ok then, let's assume that is not a bot, you want to check if a string has any special character as the first letter and then check if the message of that string is equals to "hello", how you would do that?
thanks you so much, please give me an example
Lol you wanna give him examples which most probably he will not understand because probably he doesn't know what decorators are
PoV: They use discord.Client 
my subclass hurt
Was jk but cool
No?
i mean i want to an example with "startwith" and prefix
i could bet on that answer
if message.content.startswith(prefix):
. . .
i think that i will start writing a book named "1000 reasons and more why you should know python before using any OOP package"
Sure, I will love to read it
While writing the code: discord.User.send() ๐
as you can try to be a sword eater without studying and practing on it, you would eventually die, but you can try
PoV: I started with discord.py when I didn't know what are even classes or smth like that even exists 
In short, I, uhhh, copied most of the code
I've seen plenty of people learn python through discord bots, they just need to be very persistent and decent at googling
well at least you learned from that and now you are conscious that it was stupid xD
Indeed, but I still learn new langs through the same method
Stack Overflow ftw!
well someone who isn't good enough with english sould not even start coding xD
That was me when I started with Python haha
hahahahaha
Bruh i started with C, and before moving to python i learned plenty language, assembly too xD
My CustomStatus is for you
Well yeah if i have some remorse his name is javascript lol
i would like to delete that language from my mind
Hahaha
if i want to write
if message.content == (my prefix,"hi")
await message.channel.send("hi")
then, how to do it?
bro you don't know python lol. What you wrote doesn't have any sense
You know what? i will show him how an on_message event should work, if he will understand then i will help him
classic example: check if users send some forbidden words:
Blvck, please write your book in MS Word, not here
Blvck has the easiest time completing 1000 word essays
with open("forbidden_words", 'r') as f:
forbidden = f.readlines()
@bot.listen("on_message")
async def forbidden_check_event(message):
if any(word in message.content for word in forbidden):
await message.delete()
await message.send(f"warned {message.author} for using forbidden word")
if you can explain this simple code i will help you

also he is playin at roblox lol
@proper acorn there's https://discord.gg/djs in case u code in JS
[0;40m\u001b[1;32mThat's some cool formatted text right?
[0;40m[1;32mThat's some cool formatted text right?
javascript is shit
javascript just kinda handles most things badly
guys can u give good tutorial for meme command with buttons
TypeScript is good, provided you can purge from your mind that it transpiles to js
It's totally different
javascript doesn't handle xD
The only reason I hate JS is cz NO TYPE CHECKING but it's ot soooo
in that case you should definitely look into typescript
oh no hunter is going to use OT
Nah
Indeed 
this is why we need threads 
everything is a string in js D_D
who would win?
JavaScript or one large number boi
U can send a string ID to the API too
It's just discord.py that has made everyone think that IDs are int
(Idk about other modules)
Ik about ts
๐๐ผ
But ig I need a project to work on, since I don't learn langs without any project in mind
๐
๐๐ผ
Yea
Lol bro for me we could send data as byte too, it changes nothing to us. What changes is when you would do some operations with data and the output you get is entirely different from the output you except
guys anyone
Just use the reddit JSON API, store the url's in a list
And on button click, send a random url
Show code
i remove but ill give base code
@bot.command(pass_context=True)
async def memee(ctx):
embed = nextcord.Embed(title="", description="")
async with aiohttp.ClientSession() as cs:
async with cs.get('https://www.reddit.com/r/memes/new.json?sort=hot') as r:
res = await r.json()
embed.set_image(url=res['data']['children'] [random.randint(0, 25)]['data']['url'])
button = Button(label="Next Meme", style=nextcord.ButtonStyle.green)
async def button_callback(interaction):
await interaction.response.edit_message()
await ctx.send(embed=embed)
Get the memes with a task and use a botvar 
I see pass_context ๐
!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.
i should add pass context back to nextcord for the lols
bot.memes = ... # GET MEMES AND SET THIS BOTVAR TO THE RESPONSE
async def callback(...):
await interaction.response.send_message(random.choice(bot.memes))
@bot.command(...)
async def meme(...):
view = View(...)
btn = Button(...)
btn.callback = callback
view.add_item(btn)
await ctx.send(random.choice(bot.memes), view=view)
(And yes, I wrote the code on mobile, don't tell that it has any mistakes)
Yea, but updating the git manually do be a pain
U still gotta use anything to get the memes from the git
Which requires the use of an API
Any one know how to fix this? https://paste.pythondiscord.com/tazonebobu
Error?
Nvm, it's self.bot
Not self.client
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "c:\Users\thoma\Desktop\discord server bot\cogs\log.py", line 14, in on_ready
if not self.bot.ready:
AttributeError: 'Bot' object has no attribute 'ready'```
!d discord.Client.is_ready
is_ready()```
[`bool`](https://docs.python.org/3/library/functions.html#bool "(in Python v3.10)"): Specifies if the clientโs internal cache is ready for use.
self.bot.is_ready()
Thanks all set
Just a question
On a profile cmd can you store a user age in js file?
orjson
msgem = discord.Embed(title = "Cooldown", description = "**This command is <t:{}:R>**".format(int(time.time() + error.retry_after)))
``` returns it to **In 0 minutes** instead of **In a few seconds**
you need the epoch value of the timestamp
That's what it returns?
time.time() is the current epoch and retry_after is the seconds
On default it is 1970
wait so you can add that to the epoch? huh?
pffttt i suck
Highly debatable
Nothing
Probably wrong Python version or didn't install
this is the error i get: Traceback (most recent call last): File "main.py", line 1, in <module> import discord ModuleNotFoundError: No module named 'discord'
^^^
Monke
There are different styles
But the question why does it return to In 0 minutes if the cooldown is 5 seconds long
Integrate your service with Discord โ whether it's a bot or a game or whatever your wildest imagination can come up with.
thats how discord works?
ig
idk
Because it's rounded off
I really liked R style, so i used it
Well
He's manually inputting that
Also discord itself dk the real age of most users
Ohh wait i thought the bot can record the user age instead of me manually doing this?
And yes
i noticed @unkempt canyon uses bot.http_session to do requests, how do i set that up?
bot = commands.Bot(...)
bot.http_session = aiohttp.ClientSession(...)
ah its that simple
!botvar for more information
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!
It has a hidden attribute
can i use it like i normally use clientsession
yes
ah cool
I remember there's something like bot._http.session
๐
Not worth accessing
If you'd want to make raw requests to discord API maybe it is
But for other cases the custom session is preferable
Yea
Does anyone know how I can access the items that are inside items1 and items2?
{
"Items": {
"Items1": {
"a": 500,
"b" : 70,
"c": 90
},
"Items2": {
"a": 400,
"b": 110,
"c": 80
}
}
}
@native onyxhttps://www.w3schools.com/python/python_json.asp
thankss
I just like it how people tend to use dpy without learning Python
(Just a general statement, not targeting anyone)
even when made with discord bot maker
||Everybody thinks that discord bots are F.U.N. until they get to the real stuff||
I mean, Stack exists for spoonfeeding
Is okay
I mean, whats better, annoying alive human beings in real time or copying a website 
Doing paid work for free, huh ๐
lol that was fine
I mean, the first few bots I made were made with the same
I mean, there's a stack for every issue ๐ but if you just post them here, you're having 4 people targeting you as a spoonfeeder in an indirect manner
nvm
Why do u ghost ping me 
its better than getting warned 
I hate ghost pings, so make use of yr brain before sending messages 
I dont have one 
Hmm I forgot
await bot.logout?
Not logout
hm
Uh
awkward
Nah

!d discord.Client.close
await close()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Closes the connection to Discord.
oo
There, smh dpy weird
Help if monke exists, I already tried styles R good
i use kill command if im not using IDE
emergency shutdown
my friend annoying af
its ok nothings wrong
๐ as usual he ignores me
can relate
I'mma just go away
xdd
BTW @final shard
If u want the stop the bot all of a sudden, then use exit else use bot.close
i understand
from os import system
system("shutdown /s /t 1")

Just delete Sys32
No thanks
dude
Bet
Monke no exist ๐
@floral frigate exists, thanks
I already know
then why u repeatedly asking the same thing
What is happening 
Probably, I am a bit too annoying for people to handle
๐
Lmao
seems fun ngl
AGAIN GHOST PING
how fix me dump
Actually its a common thing now
not me
Thanks for clarifying, u were the first suspect
lol
Ask discord, not me
Hey discord, how fix time getting rounded off?
is that the official one?
No
Why are you guys sending random invites?
makes sense
I meant, there are many discord devs in there, and the server is used for posting API stuff, but its still unofficial
So discord terms it as the official unofficial API Server
i do exist
message.reply
oh ok tysm
C:
hm
lol he used that code in his bot without even knowing how it works
Lol
ahh ok tysm, my eye is broken lol
!d discord.Message.reply
await reply(content=None, **kwargs)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A shortcut method to [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") to reply to the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message").
New in version 1.6.
Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") or [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError "(in Python v3.10)") instead of `InvalidArgument`.
i feel sad now
AND NOW HE WANTS TO USE JSON lol
i know how to use json but i just ask can i use json file on that code
Blvck going at it
how to json with economy??
k tysm
json is not meant to be a storage method, you should know
send him docs, don't spoon feed him xD
but still nothing change
where to learn discord.py?
i ussually learn on youtube
i did it
@slate swan wait, what happend if i use asyncio.sleep(1) ?
no
to learn discord.py you should know what is OOP, what are methods and parameters, what is a coroutine, what is a decorator and basic python knowledge
i think mention if have any delay it will work
let me try
lol
still didnt get ping
.mention
and that's the last thing that i'll read from you lol
it's not a bug
thanks you so much!
please stop spoon feeding him, he will never learn nothing like this
Bro seriously if we would help you as we help others in this group you will understand nothing at all
You were trying to use a method without having an object instance
he has done the basic, now he will ask us how to mute, ban, commands etc. How would you explain to him that? you can only send him code which is pretty useless without knowing what is an object of discord.py
bro my ping command isn't working
#[command]
async fn ping(ctx: &Context, msg: &Message) -> CommandResult {
msg.reply(ctx, "Pong!").await?; Ok(())
}
``` ;-;

Rick roll bot doing a mod bot's work ๐
help?
@bot.event
async def on_member_update(before, after):
if before.activity != after.activity:
channel = bot.get_channel(channel id here)
required_activity = "vanity url"
for activity in after.activities:
if str(activity).startswith(required_activity):
emb = discord.Embed()
emb.description = f"""
thank for vanity :wowow:
"""
emb.color = 0x2f3136
emb.set_footer(text="maow")
await channel.send(f"<@{after.id}>", embed=emb)
else:
return```
it sends the embed twice ??
You got the bot running twice?

uh what
Are you running the bot 2 times
why would i tho
where is the bot running?
wdym?
is it hosted somewhere?
no its not
Check task manager
If python is running in the background and you run python again, then the instance running in the background automatically gets killed iirc
I can run multiple instances if i want.
alrighty
I just like it how people tend to leak bot tokens accidently
ODAwOTc4NTQyMjI1MzkxNjU2.YAYfQ.TO8k7-5sqJYYuuwHU0Yjs is totally not HunAI's token
wh
Would be fun if that worked ๐
Lmao
Eh, still half of the token is correct
Indeed
That's what I did, with half timestamp being correct too
ye happend i ran two instances with screen one time
i thought why the hell dosnt code change xD
Yeah lol
it still sends it twice
@cloud dawnwb long time no see
Do you have multiple events?
I've been busy..
why i say wb
wait wrong reply
wait no nvm
those r the only events ^^
Maby the event gets triggered twice and is true both times?
kill the bot and see if it still responds?
Ah i see the issue you are for looping activity what could be a list
!d discord.Member.activity
property activity```
Returns the primary activity the user is currently doing. Could be `None` if no activity is being done.
Note
Due to a Discord API limitation, this may be `None` if the user is listening to a song on Spotify with a title longer than 128 characters. See [GH-1738](https://github.com/Rapptz/discord.py/issues/1738) for more information.
Note
A user may have multiple activities, these can be accessed under [`activities`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member.activities "discord.Member.activities").
aah ok
this tho? A user may have multiple activities, these can be accessed under activities.
Yeah most reasonable answer
im not sure i understand
but why is he making an embed like that
and mentioning a user like that
and a lot more I don't understand
required activity var
else: return
bc its like more clean for me
๐
ok
im so sorry but im confused
I don't know how 2 activites are supposed to start with vanity url
or is that just a placeholder
oh icic
from discord import Member, ActivityType
@bot.event
async def on_member_update(before: member, after: member):
if before.activity != after.activity:
if act := [activ.name for activ in after.activities if activ.type == ActivityType.custom and activ.name == "vanity url"]:
channel = bot.get_channel(channel id here)
emb = discord.Embed(color=0x2f3136)
emb.description = f"""thank for vanity :wowow:"""
emb.set_footer(text="maow")
await channel.send(f"<@{after.id}>", embed=emb)
Something like this ig
aint before and after a member object already or smt
what's :=
The activity is a bit weird programmed for users end
Walrus operator
ill try this thanks
what it do
!e ```py
if e := (10 + 10):
print(e)
@cloud dawn :white_check_mark: Your eval job has completed with return code 0.
20
and shouldn't it be if before.activities != after.activities
Does it matter?
I don't know
What does != do ?
activity checks for the first activity only innit
not equal to i think
!e ```py
if 1 != 2:
print("yes")
if 2 != 1:
print("yes")
@cloud dawn :white_check_mark: Your eval job has completed with return code 0.
001 | yes
002 | yes
this ain't related
So doesn't matter if you switch them
to what I just said
I didn't even switch them
I used the activities attr instead of the activity one
to check if none of the users activites changed
@cloud dawnhey brother what does if act := do?
I can make it shorter but for the difficulty sake
Assigns a variable inside an if statement for example.
oh damn you oneliners ๐
how do i add buttons on my message?
Lemme see how short it can get
class discord.ui.View(*, timeout=180.0)```
Represents a UI view.
This object must be inherited to create a UI within Discord.
New in version 2.0.
spam stonks
please make the embed normal
also chain the footer to the definition line
1 line embed
uhh
File "main.py", line 16, in <module>
async def on_member_update(before: member, after: member):
NameError: name 'member' is not defined
is this where I come if I need help with a bot?
thank you
how do i add buttons on my message?
capital letter
oh yea
Member
i? how do i add buttons on my message?
I am wanting to add an input box to my embed
and you don't even need it
class discord.ui.View(*, timeout=180.0)```
Represents a UI view.
This object must be inherited to create a UI within Discord.
New in version 2.0.
@client.command(name="idea")
async def Discord(context):
questions = [
"What have ya got?",
"Hit me with it!",
"Oh, this should be good!",
"Ah! Well, spit it out man!",
"What have ya now?"
]
random_question = random.choice(questions)
embed4 = discord.Embed(title=random_question, description='')
await context.message.channel.send(embed=embed4)
to me?
there is my command code
๐ญ
@bot.event
async def on_member_update(before: __import__('discord').Member, after: __import__('discord').Member):
if before.activity != after.activity and [activ.name for activ in after.activities if activ.type == __import__('discord').ActivityType.custom and activ.name == "vanity url"]: await bot.get_channel(channel id here).send(f"<@{after.id}>", embed=discord.Embed(color=0x2f3136, description="thank for vanity :wowow:").set_footer(text="maow"))
``` Done
if ur asking why the name in the ping is diff im helping my friend
ehh? can you give me more? @slate swan
the check=check?
I hate it and love it at the same time
alright
do you know that discord has a reply feature?
so, that is there to make sure it doesn't over flow?
I'm learning rust rn
can you use it when talking to me?
oh
oooohhh...
now I feel like an idiot
alright
so where would that go?
@client.command(name="idea")
async def Discord(context):
questions = [
"What have ya got?",
"Hit me with it!",
"Oh, this should be good!",
"Ah! Well, spit it out man!",
"What have ya now?"
]
random_question = random.choice(questions)
client.wait_for('message',check=check)
embed4 = discord.Embed(title=random_question, description='')
await context.message.channel.send(embed=embed4)
quizes already exist?
I can't tell if you are genuinely surprised or hinting
after it sends the embed I'm assuming?
im building a quiz bot and thought it was unic
never seen one before
oh, lol
yeah, quiz bots are cool
now but I also want it to show up in the embed
what bot should i create?
for the description
basically, I had the idea to make an idea input for the bot
and the embed would have an input box for you to type the idea
yes
or is that impossible?
U can
I hAvE fEeDbAcK
Look into Modals
please, go on.
!d disnake.ui.TextInput
class disnake.ui.TextInput(*, label, custom_id, style=<TextInputStyle.short: 1>, placeholder=None, value=None, required=True, min_length=None, max_length=None)```
Represents a UI text input.
This can only be used in a [`Modal`](https://docs.disnake.dev/en/latest/api.html#disnake.ui.Modal "disnake.ui.Modal").
New in version 2.4.
an input box in an embed?
Nope
modals?
isn't that what he just said
well, hunter, this is what I'm looking for
Sorry 
Well... Discord is js based... soo
I'll the embed then you say the message, then it deletes the message and the previouse embed and creates a new one with the idea in the description.
Better Discord + private proxy server + webserver to route and save the messages.
Indeed
may someone assist me with this?
!d discord.Client.wait_for
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.10)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.10)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.10)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
oh
!d discord.Message.edit
await edit(content=..., embed=..., embeds=..., attachments=..., suppress=..., delete_after=None, allowed_mentions=..., view=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the message.
The content must be able to be transformed into a string via `str(content)`.
Changed in version 1.3: The `suppress` keyword-only parameter was added.
Changed in version 2.0: Edits are no longer in-place, the newly edited message is returned instead.
Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") instead of `InvalidArgument`.
lmfao
It's normal to get ignored here, dw (:
so then would I make a variable with the message sent?
I have discord at 90% zoom with a small font size and no space between message groups 
so many messages
Same
vertical 1440p monitor
beat that
brb getting a vertical untrawide
80% Zoom for Mobile for me
virtical ultrawide sounds like a normal monitor
so in theory I could tell xfce that all 4 of my screens are on top of each other and drag the window across them all ๐ณ
My mobile screenshot
thank you, but how do I do that?
I got 3 1440p monitors
msg = await bot.wait_for(...)
I'mma just go 
i feel sorry for those who have to write those forbidden-word lists
monke, go back to #ot0-psvmโs-eternal-disapproval
@client.command(name="play")
async def play(ctx):
def check(m):
return m.author == ctx.author and m.channel == ctx.message.channel
number = random.randint(1,100)
await ctx.send('I have a number in mind between 1 and 100, guess it')
for i in range(0,5):
guess = await client.wait_for("message", check=check)
if int(guess.content) > number:
await ctx.send("The number is greater")
elif int(guess.content) < number:
await ctx.send("The number is smaller")
elif int(guess.content) == number:
await ctx.send("You guessed the number!!")
else:
await ctx.send("It has to be a positive integer between 1 to 100")
else:
await ctx.send("You lost, type $play to play again.")
``` here is an example
1why
U also code discord bots?
used to
so like this?
msg = await client.wait_for('message',check=check)
Oh, then nvm
What's check?
Hunter being rude again smh
I'm not in my correct mind state 
Me neither i've been up for almost 36 hours now
@slate swan help, please

Ares too here, that's my cue to leave
I severely regret this
@odd trench I provided example ;-;
Same
why tho ๐ฟ
You do know it's normal to be ignored here, right?
That emoji tops it off
it helped. thanks!
Cz u r the master, and we are just mere students
I know but this message was very large.
verrie big
lambda m: all([m.author == ctx.message.author, m.channel == ctx.channel])
Indeed
!d discord.Message.delete
await delete(*, delay=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Deletes the message.
Your own messages could be deleted without any proper permissions. However to delete other peopleโs messages, you need the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission.
Changed in version 1.1: Added the new `delay` keyword-only parameter.
lambda m: all((m.author == ctx.message.author, m.channel == ctx.channel))โ
Tuples > List
Gn
How to create a webhook and then send a message through it
!d discord.TextChannel.create_webhook
await create_webhook(*, name, avatar=None, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a webhook for this channel.
Requires [`manage_webhooks`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_webhooks "discord.Permissions.manage_webhooks") permissions.
Changed in version 1.1: Added the `reason` keyword-only parameter.
!d discord.Webhook.send
await send(content=..., *, username=..., avatar_url=..., tts=False, ephemeral=False, file=..., files=..., embed=..., embeds=..., allowed_mentions=..., view=..., thread=..., ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message using the webhook.
The content must be a type that can convert to a string through `str(content)`.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object.
If the `embed` parameter is provided, it must be of type [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") and it must be a rich embed type. You cannot mix the `embed` parameter with the `embeds` parameter, which must be a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects to send.
Changed in version 2.0: This function will now raise [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError "(in Python v3.10)") instead of `InvalidArgument`.
Try fetching the member
question

Hmmm what topic should I cover in a bot tutorial next ๐ค
Don't literally copy the method. It's just .delete()
"Why you should know python before gettin' into discord.py"
nah bro just started python today like hours ago, i came here to ask for help from the masters like you 
What do you got so far?
all the way up to a rewrite of my cogs tutorial, but everything beyond that is message command based and doesn't apply to slash commands
Instead of .get .fetch and await it
Like this?
@client.command(name="idea")
async def Discord(context):
def check(message):
return message.author == ctx.message.author and message.channel == ctx.channel
questions = [
"What have ya got?",
"Hit me with it!",
"Oh, this should be good!",
"Ah! Well, spit it out man!",
"What have ya now?"
]
random_question = random.choice(questions)
embed4 = discord.Embed(title=random_question, description='Idea goes here')
msg = client.wait_for('message',check=check)
client.delete()
await context.message.channel.send(embed=embed4)
When i was learning Discord bots i threw my bot away like every week.
what about deleting
uh? I have no clue what this function does. Does this even work?
I create random bots often enough that I can now make a whole new bot just using noo clone my-bot bot
well, it creates an embed and then saves the next message sent as a variable
that'll create a whole new project from a template
is
@has_permissions()
a thing?
Iirc yes
it's supposed to send an embed, grab the idea you send and save it to a variable, and then delete the message and embed, then make a new embed with the message sent
!d discord.ext.commands.has_permissions
@discord.ext.commands.has_permissions(**perms)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member has all of the permissions necessary.
Note that this check operates on the current channel permissions, not the guild wide permissions.
The permissions passed in must be exactly like the properties shown under [`discord.Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions").
This check raises a special exception, [`MissingPermissions`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingPermissions "discord.ext.commands.MissingPermissions") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
๐
i think that you can use has_permissions() without a command, it is necessary that the function has the context as parameter i think
@commands.has_permissions()

i'll check the source code so i can tell you if you can or not
@cloud dawn help, please?
Can someone help me? I'm getting this error
NotImplementedError: Type "class 'nextcord.channel.TextChannel'>" isn't a supported typing for Application Commands
code?
@client.slash_command(name="announce", description="Announce an announcement to a specified text channel")
@commands.has_permissions(manage_messages=True)
async def announce(interaction: Interaction, channel: nextcord.TextChannel, *, msg):
await interaction.send("Notice : Successfully send the announcements.")
em = nextcord.Embed(title="Notice : New Announcement", description=f"{msg}", color=0x00FAFF)
em.set_footer(text=f"Announcement by {interaction.user}", icon_url=interaction.user.avatar.url)
em.timestamp = datetime.datetime.utcnow()
await channel.send(embed=em)
Have you tried if the code works?
hang on
I feel like we are coding blind here
yup, the decorator doesn't check if the function where the decorator is called is a command function, so actually you can call @has_permissions decorator even without using a command function, it is only need that your function has a context object as first parameter
how do i add roles and remove roles from members?
Hmm you can't typehint a text channel in nextcord? Do they still use the old system?
i see, kinda weird
!d discord.Member.add_roles
await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
await member.add_roles(role)
idk
!d discord.Member.remove_roles
await remove_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Removes [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s from this member.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the removed [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
probably this is applied to most of discord.py check decorators
Mind showing me the command?
you mean code?
Yes
@client.slash_command(name="announce", description="Announce an announcement to a specified text channel")
@commands.has_permissions(manage_messages=True)
async def announce(interaction: Interaction, channel: nextcord.TextChannel, *, msg):
await interaction.send("Notice : Successfully send the announcements.")
em = nextcord.Embed(title="Notice : New Announcement", description=f"{msg}", color=0x00FAFF)
em.set_footer(text=f"Announcement by {interaction.user}", icon_url=interaction.user.avatar.url)
em.timestamp = datetime.datetime.utcnow()
await channel.send(embed=em)
can someone create a text filter? for my bot?
!pypi nextcord
A Python wrapper for the Discord API forked from discord.py
we can help you with it but were not going to write it for you
Does str get auto formatted?
ok
should i send what i have?
ya
yeah
Think an issue with the lib all the examples on their git are also without channel formatting.
@cloud dawn check dms
later
ok
how do i send files ||using a bot||
Uhh ic
@client.command(name="dance")
async def cat(context):
dances = [
"dances/dance1.gif",
"dances/dance2.gif",
"dances/dance3.gif",
"dances/dance4.gif",
"dances/dance5.gif",
"dances/dance6.gif",
"dances/dance7.gif",
"dances/dance8.gif"
]
random_dance = random.choice(dances)
await context.send(file=discord.File(random_dance))
Use the file kwarg in the send method
!d discord.abc.Messageable.send
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
No thanks.
And convert the file to a File obj
well, it works
Okay good :)
i saw that
What




