#discord-bots
1 messages · Page 803 of 1
then when i change it to youruser it changes to member
then when i put youruser again it says command is outdated
you can do stuff you already know, but faster with it. time saved
you don't need to retype the whole shit
if you have no errors and you get spoonfeeded everything im not sure if thats a good idea
isnt that good
there's a reason andy wants to make docs with copilot
nope
why do we have to learn python when the bot can write the code for us
how would you learn if you get no errors?
now thats wrong
just saying lol
seems like the same thing
lol
slashcommands go brrrrrrrrrrrr

you are misinterpreting this, you shouldn't really use it actively, but its very useful for doing stuff, you know how to do, without retyping the whole thing. And if you have enough knowledge, looking at the wrong code and the most likely right code (given by copilot) will help you understand where you went wrong
thats the thing people will get addicted and start using it for basic errors?
that's their problem...?
why when i delete a webhook it deletes a entire channel?
instead of deleting just the webhook
In no sense is this bad, except it watches you code and learns
yes
thats just creepy
not really
getting watched by an ai lol
okimii u need sleep
go to waitlist
nah ill stick with idle and myself
ok
it doesn't watch you, it watches your code
i cant go to sleep im hungry
me😳
how to make a code that checks if there is a txt file with a name
that we entered
is it just
if with open(f"{member.guild.name}.txt", mode="r"):
...
no
it would probably give a missing expression error
how do i do it
use listdir
os.listdir?
yeah
ok
and just check the file names
\🍦
for file in os.listdir(f"/{member.guild.name}.txt"):
this?
no in os.listdir() you must add the directory the file should be in
how do i check how much reactions i have in a message?
if the file with that name exists then i guess yeah?
halp
can i have a example then
and also how can i know what reaction has the most reacts?
How can i get a channel webhook name?
how can i like detect that the author in a voice channel or not and join that voice channel if yes
you should make a loop
which checks that
bruh....\no i mean the cmd to detect the author in a voice channel or not....
its a help channel
not a channel for free scripts
we can give you an idea but not do the work for you
🥴 ok
just check if the author of the command is in a voice channel
if it is then join the channel
voice_state = member.voice
if voice_state is not None:
# do stuff
else:
print("user is not in a voice")
it will look something like that
ok
thanks
np
the documentation is very confusing
property voice: Optional[discord.member.VoiceState]```
Returns the member’s current voice state.
u can use this
0ok
just do
voice_state = member.voice
if voice_state:
# do stuff
else:
print("user is not in a voice")
yes you could also use that
thanks
ikr
yeah i was using that but i did if message.author != Member.voice:, i think that's why it was not working
ofc, message.author returns a different object than member.voice, u cant compare them
i just started using this so can somebody please help me
i've installed the python extension
i've downloaded python twice
py pip install discord.py
try pip install discord without the 3 or what okimii said
discord.py is not being worked on anymore
neither worked
oh
also it should be py -m pip install discord.py
it should be still on pypi tho
what does -m do again
it is, maybe they dont have pip installed
mid
nah
mod
is pip an extension?
its probably not in there env vars
or something
have u ever installed pip?
nope
there we go
how would i do that
@client.command()
async def play (ctx, song_name):
if member.voice:
ctx.send("First please join a Voice Channel")
else:
ctx.send("Working")
This one is still giving me error
Traceback (most recent call last):
File "C:\Users\GUDDU\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\GUDDU\Desktop\Program\Projects with my friends\music_bot.py", line 13, in play
if member.voice:
NameError: name 'member' is not defined
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\GUDDU\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\GUDDU\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\GUDDU\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'member' is not defined
why not
look up install pip
you probably didnt installed pip with python
..
ctx.author.voice
when I downloaded python it had a choice to install it
yeah it does
is it not print([i async for i in rct.users()])
somebody
there is more then one way ,
1 : download bootstrap from python website and run it
2 : reinstalling python and clicking install pip
oh
OH wait
still not working
error?
i thought once i pressed download on the python site it'd be done
yeah
is it a python installer
send the error
or check if pip is in env vars
its for packages
Traceback (most recent call last):
File "C:\Users\GUDDU\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\GUDDU\Desktop\Program\Projects with my friends\music_bot.py", line 13, in play
if ctx.author.voice != member.voice:
NameError: name 'member' is not defined
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\GUDDU\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\GUDDU\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\GUDDU\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'member' is not defined
...
ohhhhh
the tb says it all tho?
line 13
if ctx.author.voice != member.voice:
NameError: name 'member' is not defined
import discord
from discord.ext import commands
from yt_dlp import YoutubeDL
client = commands.Bot(command_prefix='$')
@client.event
async def on_ready():
print("Music Bot is Online")
@client.command()
async def play (ctx, song_name):
if ctx.author.voice != member.voice:
ctx.send("First please join a Voice Channel")
else:
ctx.send("Working")```
why != member.voice?
and await .send
use if not ctx.author.voice
wasting your time
oop
😂 seriously\
oh i have to restart it?
yes
uhok
ye vscode does not update stuff like that til u restart
ah
how would i go about pulling the game someone is playing from discords api for a bot
!d discord.Activities
No documentation found for the requested symbol.
!d discord.Member.activities
The activities that the user is currently doing.
Note
Due to a Discord API limitation, a user’s Spotify activity may not appear if they are listening to a song with a title longer than 128 characters. See GH-1738 for more information.
This
Basically, using .activities on a discord.Member object would get you their activities as a list
how to send code in a specific channel?
hello
member = discord.Member
Ctx.send(message)
is there a way for me to do that without having to restart my bot every time?
like could i make a command where i do
for example (!send (message))
@weary galeare you an actual arab?
yes
inshallah
Wrong answer
anybody have any idea?
Are you trying to make the command a user types in "!send" and then the bot sends the message?
The code is easy but we don't want to spoonfeed
So ye. Have you written anything thus far?
the user types !send (message)
and the bot sends the message they just typed
no
Well, do you know how to write a script?
As in, what should be imported for the script to work?
new to both
code:```py
@bot.command()
async def verify (ctx):
unverifiedRole = discord.utils.get(ctx.guild.roles, name="unverified")
await member.remove_roles(unverifiedRole)
verifiedRole = discord.utils.get(ctx.guild.roles, name="member")
await member.remove_roles(verifiedRole)
embed=discord.Embed(description=f"{member.mention}, you're now verified", colour=0)
await ctx.send(embed=embed)error: discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'member' is not defined```i don't know how to define member.
hmm. well, i'd suggest you learn py first but i started learning py two days ag as well
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
wait so can somebody please help me with the !send command or give me an example
no im sure that wouldnt work
async def verify (ctx, member=discord.Member)
try this instead
hm
it might be wrong but worth a shot
Tutorial resource to start with. Begin with something basic like getting the user to input a command and get the bot to send the message hello world. It will get you working with the bare basics of dpy and give you groundwork to work off of for what your wantibg to do
I'll teach you basics of python
No
yes, thats it
you want to do something like !verify @member ?
okay?
yeah
async def command_name(ctx ,member : discord.Member):```
typehints are done with : , not =
yeah forgot
@slate swan could you please give me an example on how i could make
a command where i could type !send (message)
and the bot would send it
well, first start with knowing what python is
python is a coding language
python is basically
(you set conditions)
print(based on conditions you set what you want)
yes
So say,
x=5
y=10
print(x+y)```
same as the code I sent above , but you won't be typehinting it as discord.Member
You would like using asterisk to consume the complete string
The code will print 15
Say if you did not assign any variables
anyone have any idea why this isnt returning the game?
here x and y are variables, variables can have any value
ah
because game is not a property of User/Member
do you want that command to be used by anyone or only you?
only admins
but if you tried doing
print(x)
the send command
It would return an error
oh okay
how come?
Because you did not give any value to X
Variables are supposed to have values
Since x is variable, you should assign a value
or else it will return error
how would i make that a property of a user/member
oh i thought u meant x=5
print(x)
that this wouldnt print anything
!e
print(x)
@neat tartan :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | NameError: name 'x' is not defined
i was confused
if you did
x=5
print(x)
it would return 5
yup ok
You can't, use author.activities to get all the activities of the user
makes sense
But like, you'd not be using print() when you're coding a discord bot
Id suggest opening a help channel for covering this stuff and !e can help provide actual outcomes
thats kind of redundant
go book #help-chili
y
except for debugging purposes
what do i ask
anything
its taken
now go to #help-chocolate
what the cmd to join the voice channel same as the author
cn = MemberCacheFlags.voice()
this way we will get the channel id?
and theres absolutely no way for me to match it to member so i could pull the game?
not even with user = message.author
await Member.voice.channel.connect()
Member is the Member object, in your case the author
show your code
@bot.command()
async def verify (ctx, member=discord.Member):
unverifiedRole = discord.utils.get(ctx.guild.roles, name="unverified")
await member.remove_roles(unverifiedRole)
verifiedRole = discord.utils.get(ctx.guild.roles, name="member")
await member.remove_roles(verifiedRole)
embed=discord.Embed(description=f"{member.mention}, you're now `verified`", colour=0)
await ctx.send(embed=embed)```
u need to typehint
you need to type hint it, not giving a default value
discord.ext.commands.errors.MissingRequiredArgument: member is a required argument that is missing.
Ok?
how did you invoke the command
+verify
Read the error
Read ur error
give something to the member argument then
look, i dont understand much errors and theyre meanings. i understand them once theyre explained to me. please do not expect me to know everything.
Its simple english what do u wanna understand
It clearly states MissingRequiredArgument
member is an argument that is missing. what do u learn from that?
Is this command meant to work like +verify and the user who used the command will get the role?
Member is a thing in the cmd when invoked which is missing?
Simple english
no, the member just does it themself :D
Google the meaning of argument please
i couldnt care less about simple english
Yea so they use the command, and get the role
That's it?
yep!
+verify @member shud be the syntax
Oh shoot it pinged
remove the member argument from the function, and replace member with ctx.author inside the function
oh alr tysm
you're welcome, also if you don't understand what an error means you can always reference to the docs
They will make things clear
ty!
🥴 it's not working
show code
They just use await Member.voice.channel.connect directly, bet
@client.command()
async def play (ctx, song_name):
if not ctx.author.voice:
await ctx.send("First please join a Voice Channel")
else:
await ctx.author.voiceChannel.connect()
how to do help
.voice.channel.connect
wait trying that
does having lesser line of code improve performance / decrease ram usage by a lot of just a little bit ?
My bot have 28 k lines of code and in 200 servers and it eating a lot of ram. If I make my code better / delete unnessary line will it gain more performance ?
btw i forgot
how to write like in this box?
I thought I didn't wrote voiceChannel 
isn't bot.event and client.event the same thing?
3 times ` before and after the code
`
I could try to make it from 28k -> 26k max
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
oh thanks
Traceback (most recent call last):
File "C:\Users\GUDDU\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\GUDDU\Desktop\Program\Projects with my friends\music_bot.py", line 17, in play
await ctx.author.voicechannel.connect()
AttributeError: 'Member' object has no attribute 'voicechannel'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\GUDDU\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\GUDDU\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\GUDDU\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Member' object has no attribute 'voicechannel'
error
Yes and no, but mostly no
voice<dot>channel
whats the main difference?
voice.channel
as in, the main noticeable difference?
you didnt change it to voice.channel
no, lines don't really matter
The memory you code uses does
And yea you should consider using cogs rather than writing everything in a single file
oh
I am using cogs
"voice.channel"
I mean all the code combined
Great, so you may just try to not define useless variables, loops etc
the number lines won't affect
Traceback (most recent call last):
File "C:\Users\GUDDU\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\GUDDU\Desktop\Program\Projects with my friends\music_bot.py", line 17, in play
await ctx.author.voice.channel.connect()
File "C:\Users\GUDDU\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\abc.py", line 1277, in connect
voice = cls(client, self)
File "C:\Users\GUDDU\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\voice_client.py", line 199, in __init__
raise RuntimeError("PyNaCl library needed in order to use voice")
RuntimeError: PyNaCl library needed in order to use voice
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\GUDDU\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\GUDDU\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\GUDDU\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: RuntimeError: PyNaCl library needed in order to use voice
``` error again
!pip pynacl
I dont know the specifics but i think client refers to a specific user/id (the bots) and bot refers to the bot as a whole. Please someone correct me if this is wrong but this is my understanding. They are very similar to each other
🙂 it's working now
thanks
Essentially whether it treats it like a bot or like any other user i think is how best to sum it up
just to ask, but is await member.add_roles(verifiedRole) a thing?
!d discord.Member.add_roles is a thing
So assuming that member is a discord.Member object, yes!
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.
CODE:
import discord
import os
from PIL import Image
client = discord.Client()
@client.event
async def on_ready():
print('bot is radi')
@client.event
async def on_message(message):
user = message.author
img2 = user.avatar_url
img1 = Image.open("adamay.gif")
img1.paste(img2, (0,0), mask = img2)
if message.content.startswith('$twerk'):
await message.channel.send(img1)
client.run('')
ERROR:
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\prana\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "c:\Users\prana\Downloads\main.py", line 19, in on_message
img1.paste(img2, (0,0), mask = img2)
File "C:\Users\prana\AppData\Local\Programs\Python\Python310\lib\site-packages\PIL\Image.py", line 1537, in paste
raise ValueError("cannot determine region size; use 4-item box")
ValueError: cannot determine region size; use 4-item box
I would like to sent a message to discord by calling a function without typing a command into discord. Any turorials how to do this?
you can t ry await message.channel.send(img1)
@client.event
async def on_message(message):
channel=message.channel
message=message.content
if message == "edit deez texts":
reply=await channel.send("Edit this")
reply="This has been edited"
await message.edit(content=reply)```
not workie

if message.content.startswith():
what i want to do is basically
the bot sends a message
yes
and after a few seconds it edits the message that it sent to something else
oh
await reply.edit
kind of like
bot: Loading 
5seconds later
bot: Process complete
pls help
wait
read the error, you cannot have a required argument after an argument with default value
so shouldi write it like
async def addrole(ctx, member:discord.Member=None, role:str=None)
thanks. it worked. how do i make the reply.edit thing work a few seconds late?
like, delay by a few seconds
!d asyncio.sleep
coroutine asyncio.sleep(delay, result=None)```
Block for *delay* seconds.
If *result* is provided, it is returned to the caller when the coroutine completes.
`sleep()` always suspends the current task, allowing other tasks to run.
Setting the delay to 0 provides an optimized path to allow other tasks to run. This can be used by long-running functions to avoid blocking the event loop for the full duration of the function call.
Deprecated since version 3.8, removed in version 3.10: The `loop` parameter. This function has been implicitly getting the current running loop since 3.7. See [What’s New in 3.10’s Removed section](https://docs.python.org/3/whatsnew/3.10.html#whatsnew310-removed) for more information.
Example of coroutine displaying the current date every second for 5 seconds:
this will make the function sleep for the mentioned time
@slate swan ?
okay thanks
yea that may do the job :0
but why is member set to None?
help
reaction , user
What function should i use to just sent a message by calling the function
yea so?
tu ku ha idar it me phlexy
!rule 4
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
define not working
meaning error
is there
4. Use English to the best of your ability. Be polite if someone speaks English imperfectly.
well youuse self inside the check function ¯_(ツ)_/¯
so ? tell me wha should i do
now ?
remove self
k
remove self from ???
self.bot.wait_for
the check function
NO
k
then??
.
error?
i want to execute whatever im getting from the user
no response from bot
your check does not return True
its saying i cant execute a string
check=true
so you are trying to do py await "some string" which is not possible
no, i mean the condition in the check is not satisfied
how do i turn the string in code?
and could you elaborate wym by 'execute'
oh, an eval command?
!pip jishaku just use jishaku
A discord.py extension including useful tools for bot development and debugging.
my bot's status is not changin to idle can anyone help
and by your code ill assume you're using disnake, so use disnake-jishaku
code?
bot.change_presence(status=discord.Status.idle)
await it
yes done
forgot to type await
hm
u r the one u suggested me this did u forget...
but its not changing
suggest what? disnake?
are you doing this in on_ready event?
yes
also, make sure you have only 1 instance of the bot running
you should not, make some command , or use await bot.wait_until_ready() before changing the presence
ohh thx
btw u r indian ?
yep
i saw your bio
@slash_command(name = 'balance', description = 'Посмотреть баланс', guild_ids = [939170043667828766])
async def balance(self, inter):
emb = discord.Embed(description = f'Баланс пользователя {inter.author.mention} - **{self.collection.find_one({"_id": inter.author.id})["coin"]}**')
row = ActionRow(
Button(style = ButtonStyle.gray, emoji = '', custom_id = 'coin')
)
message = await inter.send(embed = emb, components = [row])
@commands.Cog.listener()
async def on_button_click(self, inter):
if inter.component.id == 'coin':
await message.edit('coin_test')
``` pls help, code not work edit
How do I add emoji in a bot reply?
can i store them into the dictionary using the guild_id as a key ?
hi everyone i need some help
Command raised an exception: OAuthException: unauthorized_client error processing request (Only script apps may use password auth)
im trying to make a meme command
but it keeps on putting thi
@client.event
async def on_member_update(before,after):
print(after.nick,before.nick)
hey why its not showing anything in the terminal when i change nick?
do you have member intents?
My bot wont join my voice channel. I imported everything I needed
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: RuntimeError: PyNaCl library needed in order to use voice
pip install pynacl
hey can i call on_message method from on_member_update method?
pip install discord.py[voice] fixes everything tho
well you would need a message object to pass to the on_message
where would you get that message object
@commands.command()
@cooldown(1,15,BucketType.user)
async def scout(self,ctx):
names = ["bed","air","UFO","sink"]
opt = []
index = 0
scout = []
for n in names:
num = random.randrange(1,100)
scout.append({f"{index}": {"name": n, "amount": num}})
index += 1
for i in range(3):
while True:
add = random.randrange(0,len(names))
if add not in opt:
opt.append(add)
break
for s in scout:
print(s["0"])
``` it says keyerror "0"
can someone help me?
wdym
you sure 0 is a valid key in the dict you're looking it up in?
yesss
so scout is an empty list
but I append to it yk
well I think you meant to do s[0]
[{'0': {'name': 'bed', 'amount': 96}}, {'1': {'name': 'air', 'amount': 33}}, {'2': {'name': 'UFO', 'amount': 51}}, {'3': {'name': 'sink', 'amount': 6}}]
I made it a string tho
did I do something wrong?
ahh, it seems like you're trying to look up 0 on every iterated dict
so, when it gets to the next dict (the one with 1), it can't find 0, hence the error
{'0': {'name': 'bed', 'amount': 12}}
{'1': {'name': 'air', 'amount': 69}}
{'2': {'name': 'UFO', 'amount': 1}}
{'3': {'name': 'sink', 'amount': 99}}
ohhhh how do I fix it?
do I use break?
it = "0"
for s in scout:
print(s[it])
it = str(int(it) + 1)
but like do you see the other for loop?
what I'm trying to do is do opt[0]
for item1 and etc
@slate swan so do you know any way to fix it?
what's opt?
the solution I gave you fixes the error
in the old code there's a list that's called opt
3 random numbers would append to the list
right right lemme rewrite my code then
@commands.command()
@cooldown(1,10,BucketType.user)
async def beg(self, ctx):
user = ctx.author
await self.open_account(ctx,user)
num = random.randrange(0,101)
quote = [f"A stranger gives you {self.num(num)}.", f"A mysteriously man knows that you have money, but he still gives you {self.num(num)}", f"I'm poor, but I still give you {self.num(num)}", f"Stop being a beggar!! {self.num(num)}"]
await ctx.send(random.choice(quote))
await self.update_wallet(ctx,user,"+",num)
@commands.command()
@cooldown(1,15,BucketType.user)
async def scout(self,ctx):
names = ["bed","air","UFO","sink"]
opt = []
index = 0
scout = []
for n in names:
num = random.randrange(1,100)
scout.append({f"{index}": {"name": n, "amount": num}})
index += 1
for i in range(3):
while True:
add = random.randrange(0,len(names))
if add not in opt:
opt.append(add)
break
for s in scout:
item1 = s[str(opt[0])]["name"]
item2 = s[str(opt[1])]["name"]
item3 = s[str(opt[2])]["name"]
this is what I'm trying to do
@slate swan
Is there a way I can make the bot recieve input from a button/dropdown if there's only 1?
For example, there's a single message in a channel with a button/dropdown
Is there a way I can make the bot continuouly receive the inputs from it?
(Nextcord)
Set the time out to None
ah sorry to interrupt, but can we make Discord Bots using Python, because idk Java but I am good at python, so if yes, how?
Oh, ok.
!pypi disnake
ohh thank you
!pypi nextcord
A Python wrapper for the Discord API forked from discord.py
There are tutorials on discord.py
or this if you want
kk
ok thanks (:
Btw, how do I make the bot detect when the button is pressed? (there's no command or anything, so I am not sure how)
Is there an event for button clicks?
hi can anyone suggest me for help commands
!d nextcord.ui.View.on_interaction

It'd be a good idea to subclass it, for it to update with your command changes
How do I implement this?
subclass View and use @discord.ui.button to construct the button , the function below it would be the callback.
Not this...
I can't find an on_button_click event in nextcord's docs
Is on_interaction the only way?
on_button_click is only in disnake.

How do I specify which certain button?
Yea
If you're subclassing it, you can specify a custom ID to the button and check for it in the event
:O
Thanks
class MyView(View):
@discord.ui.button(label='label')
async def the_callback(self, button , interaction):
# this is triggered when the button is clicked
...```
Is there a function that can be called to sent a message?
!d discord.abc.Messageable.send
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=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.9)") 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.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
on_message need a command to sent i would like to just sent message when call the function
F I misundertood the question
use this, tonny
textable_channel.send()
thanks will try
Oh, I am not using discord.py
nextcord is a fork of discord.py so everything other than discord->nextcord remains same
Okeh
you can refer to this example too ,https://github.com/nextcord/nextcord/blob/master/examples/views/confirm.py
!d discord.utils.get
discord.utils.get(iterable, **attrs)```
A helper that returns the first element in the iterable that meets all the traits passed in `attrs`. This is an alternative for [`find()`](https://discordpy.readthedocs.io/en/master/api.html#discord.utils.find "discord.utils.find").
When multiple attributes are specified, they are checked using logical AND, not logical OR. Meaning they have to meet every attribute passed in and not one of them.
To have a nested attribute search (i.e. search by `x.y`) then pass in `x__y` as the keyword argument.
If nothing is found that matches the attributes passed, then `None` is returned.
Examples
Basic usage...
use this, with name as the attribute
tryed it gives none type for some reason everytime
show code
ok
wait
role = discord.utils.get(ctx.guild.roles, name="Muted")
else :
perms = discord.Permissions(send_messages=False, speak=False)
await ctx.guild.create_role(name="Muted", permissions=perms)
role = discord.utils.get(ctx.guild.roles, name="Muted")
there's no role named muted in that server
.
i want to have a bollean that if role is not found then create the role
creating role
this is not working as well
role = utils.get(...
if not role :
role = Guild.create_role(*args)
oh i can do directly
fig.write_image("images/fig1.png",format='png',engine='kaleido')
this hangs the vscode terminal and the program stops then and there...i wish to save the plots
as pngs
to send it as embeds
in my discord bot
@slate swan does this workes
if not role := discord.utils.get(...):
:^)
can also use this right? await ctx.send(embed=embed)
yep!
h
im trying to call a function from somcommands.py and getting discord.ext.commands.errors.ExtensionNotFound: Extension 'somecommands' could not be loaded.
Do i have to import bot.py and call from there or import the somecommands.py
Seems like the path is wrong
show the coide
Which library should I use, to make a bot?
!pypi nextcord
A Python wrapper for the Discord API forked from discord.py
!pypi disnake
i would use disnake
ooh, its that the one most are using now a days? or your personal preference?
there are also non-forks like pincer and hikari, but they are much more complicated
i don't really make bots or do python dev much anymore, but I used nextcord
oooh
i want some library which has good support, nice docs and the new features, do you think it suits me?
disnake prolly
but def watch out for pincer and hikari since they have things like customizable middleware
oooh, thanks ill note that
@client.command(pass_context=True)
async def verify(ctx, user: discord.Member, role: discord.Role):
await user.add_roles(user, role)
await ctx.send(f"{user} has been given {role}")```
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NotFound: 404 Not Found (error code: 10011): Unknown Role
the role you are trying to add prolly doesn't exist
from discord.ext import commands
from dotenv import load_dotenv
from os import getenv
import discord
load_dotenv() # You can pass the location of the .env file if it's not in a standard location
token = getenv("DISCORD_TOKEN")
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!")
bot.load_extension("somecommands") # Note, we don't need the .py file extension
bot.run(token)
the load_extension has to be in a setup function
andw where is this extension somecommands evben coming from
just replace somecommands with disnake-debug 😳
its await Member.add_roles(role)
and pass_context is not needed anymore
user in your case
ooooh so i can remove it?
yeah fixed
ok
pass context is outdated btw
^
BanEntry is a namedtuple, use BanEntry.user
a User object
that is its repr
just User.id
sure
property id```
Equivalent to [`User.id`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.id "discord.User.id")
wdym
user_found = banned_user.user.id in your first if
banned_user.id?
banned_user is a BannedEntry namedtuple, they need the user id so BannedEntry.user.id
oh yeah, I thought they were iterating through members nvm
use disnake
so you see a BanEntry is a namedtuple, its returned by bans method. It has an attribute called .user, this returns an User object.
What kind of bots are you programming?
I want to program a kind of bot
we all should probably just make a bot that's fucking easy to use
🗿
I want to make a bot which can give command ideas
Make a bot that uses rin
ok if you ever suceed on making that please make it public istg
Good idea
Andy gonna make one and complete it
lets do it
make a bot that is easy af to use
😎
makes sure to suggest rin to everyone 👀
rin is just too cool 😩
any help with this?
I'm gonna refactor components today! so it will be a lot cooler as well
Oh cool!
BTW andy
A suggestion... Write some parts of it in cython 👀
The wrapper is already compatible with uvloop so that gives a lot of speed, I might later write c++ bindings for some parsers
Like the http and the gateaway part 👀
It doesn't use asyncio?
The wrapper uses asyncio but can also use uvloop
Well, up to the user to decide for now
But it's still compatible
Ah okay. Never really used uvloop so idrk too much about it
Basically asyncio's loop but with cython
with ActionRowBuilder() as builder:
@builder.button(...)
async def button1(...) -> None:
...
@builder.button(...)
async def button2(...) -> None:
...
```components refactor sneak peek! 👁️ 👁️
looks shit
unusable in classes
how ⁉️
😂
Welp, the old one was the regular generic one which everyone does
Still, using a context manager... Seriously?
what how, are you hiding some code
The __exit__ will be caching the objects and doing some cleanup, but you also won't need to use a context manager with this design
from discord.ext import commands
from dotenv import load_dotenv
from os import getenv
import discord
load_dotenv() # You can pass the location of the .env file if it's not in a standard location
token = getenv("DISCORD_TOKEN")
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!")
bot.load_extension("somecommands") # Note, we don't need the .py file extension
bot.run(token)
from discord.ext import commands # Again, we need this imported
import discord
import time
from datetime import datetime
class SomeCommands(commands.Cog):
"""A couple of simple commands."""
def __init__(self, bot: commands.Bot):
self.bot = bot
self.last_msg = None
# Embded message command shows the embded info
@commands.command()
@commands.has_role("Admin")
async def hello(self, ctx: commands.Context, productname):
embed = discord.Embed(title=test, url="https://test.com", colour=0x87CEEB, timestamp=datetime.utcnow())
embed.set_author(name="something", icon_url="https://avatars.githubusercontent.com/u/16879430")
embed.add_field(name="Field 3", value="Look I'm inline with field 2!", inline=True)
embed.set_footer(text="Powered by United Digital Company!", icon_url="https://cdn.discordapp.com/emojis/754736642761424986.png")
await ctx.send(embed=embed)
def setup(bot: commands.Bot):
bot.add_cog(SomeCommands(bot))
import bot
sent = hello(productname)
sent()
wheres the class and setup stuff in that somecommands.py
forgot to paste 😛
Ah okay... I guess you should just implement it and then we will see if its good (tho seems like a different idea tbh)
and the setup thing?
also
is somecommands.py in a diff folder?
same folder
is bot token the application id or the public key?
what is this call.py
AttributeError: 'Command' object has no attribute 'has_permissi
ons'``` why do i keep getting this error?
thanks!
call.py is file where i can would like to pass trough some variable to sent an embeded message to a channel
can you show entire traceback @slate swan
ok
im legit so bored i want to make a bot that is simple to use with some1 but i use disnake and everyone still using discord.py 😔
n <module>
@commands.has_permissions(manage_messages=True)
AttributeError: 'Command' object has no attribute 'has_permissions'```
imagine
show imports
wdym imagine,
import os
import requests
import json
import random
import sys
import colorama
from discord.ext import commands
from discord.ext.commands import has_permissions, MiissingPermissions
what permissions does a bot need to get and send messages
does it need to 'read message history'?
send message, read message
imagine using dpy lol
i dont use dpy 💀
same here
@commands.has_permissions(ban_members=True)
@bot.command()
async def ban(ctx, user: discord.Member, *, reason="Ueason unspecified"):
await user.ban(reason=reason)
ban = discord.Embed(title=f"Ban: {user.name}!", description=f"Reason: {reason}\nBy: {ctx.author.mention}")
await ctx.message.delete()
await ctx.channel.send(embed=ban)
await user.send(embed=ban)
colour=0x3D9AF2```
okimii do you use disnake
3072
yes
weird idk
i kinda wanted to code a simple to use bot with some1 that uses disnake but i think you're too advanced with discord bots 😔
rip
the indents
the indents are not like that in the code
and your kwargs arent in the constructor and iirc .command() should always be on top idk
doing
def func():
print("wtf")
is fine in python toh
@shadow wraith :white_check_mark: Your eval job has completed with return code 0.
???
pep8 is screaming
!e
!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.
We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!*
!e py @commands.has_permissions(ban_members=True) @bot.command() async def ban(ctx, user: discord.Member, *, reason="Ueason unspecified"): await user.ban(reason=reason) ban = discord.Embed(title=f"Ban: {user.name}!", description=f"Reason: {reason}\nBy: {ctx.author.mention}") await ctx.message.delete() await ctx.channel.send(embed=ban) await user.send(embed=ban) colour=0x3D9AF2
@scarlet aurora :x: Your eval job has completed with return code 1.
001 | File "<string>", line 5
002 | ban = discord.Embed(title=f"Ban: {user.name}!", description=f"Reason:
003 | ^
004 | SyntaxError: unterminated string literal (detected at line 5)
uh who uses disnake and wants to code a bot with eachother that does something
you cant eval dpy lol
why tf are you trying to run discord.py 💀
oh
#bot-commands guys please use this
so why wont my stuff work
how to see logs in heroku cli
the bot command decorator should be at top iirc (im not copying okimii tho)
i did that
Does someone have a Solution to this ?
I added the cooldown and it is working, but the problem is I get the cooldown message on my Console instead of the Discord server. I tryed many different ways to add a the Cooldown text into discord but didnt worked.
When i select the Command twice in the discord it says the application is not responding
you didn't
how to get the invite link of the bot
async def embed(ctx, *, query):
em = disnake.Embed(
color=0x4e5ece,
description=
f"{' '.join(ctx.message.content.split(' ')[1:])}"
)
await ctx.send(embed=em)
await ctx.delete()```
why doesnt the command delete
wait what
you want to delete the message which contains the command used to make the embed?
yup
your color kwarg should be in the constructor because rn its a bar and ctx.channel is not needed context already has a channel obj use it and param naming lol
use await ctx.message.delete()
thanks
np
why delete the msg after sending it just use delete_after lol
@slate swan hes talking about the msg that is like !embed <query>
well should it be the first thing after the function
nvm i got it
its in general lol
i dont know why but im eating carrots
bro.
@bot.command()
@commands.has_permissions(manage_messages=True)
async def codex(ctx):
embed = discord.Embed(
```what's wrong with this
just the top 2 lines
nothing
then why is it erroring
AttributeError: 'Command' object has no attribute 'has_permissi
ons'```
not sure why its giving an error
because it does have that attr
!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").
yep
im so bored that i want to make a bot with someone but nobody wants to 😭
sucks to suck
u can help me
with commands
yeah mini
Is there a way to add a Costume reply when the command is on cooldown ?
I get a message in the console that the command is on cooldown, i tryed many ways to add it in the discord chat. But instead of sending it the bot in the discord says "application is not responding"
Do you have any Idea what i need to add that the bot will send the remaining time and text while it is still on cooldown ?
do you have a command named commands?
i saw @slash#1402 or something 💀
OH SHIT
OOOOOOOOOOOHHHHHHHHHHHMMMMMMMMYYYYY GOOOOOOODDDDDDD


YESSS, I FORGOT
Its @median bridge.slash
it works now, thanks so much
@grim oar you smart man
i can't believe i forgot about that
what do you guys recommend for slash commands
disnake
give example
ty 🥳
disnake, nextcord
disnake has the best slash command support in my opinion
better than discord_slash 🥶
how can i create an event in a cog?
!d discord.ext.commands.CommandOnCooldown.cooldown | for a msg if the command is on cooldown
!d discord.ext.commands.Cog.listener
A class with attributes rate and per similar to the cooldown() decorator.
classmethod listener(name=...)```
A decorator that marks a function as a listener.
This is the cog equivalent of [`Bot.listen()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.listen "discord.ext.commands.Bot.listen").
lol
i need an event not a message listener
listeners and events do the same thing
:/
and cogs only have listeners
oh
i just used listeners for on_message events
yes
thanks
listeners to events
the fuck events rambling about
huh
no i just thought listeners to events sounds weird
whats the !d about.
!d
shows documentation of something
!d
alias for !doc

Python bot written probably using python for helping others do the same using python
they should make the python bot case insensitive
I added !d but it writes me that its invalid syntax
!source yeah it uses python
Unable to convert 'yeah it uses python' to valid command, tag, or Cog.
!d WhAt Is ThIS So UgLy
No documentation found for the requested symbol.
oops
hi
hoii
however, can anyone come to dms??
What do you need, ask here.
B() and b() aren't the same```py
class A:
def B(self):
pass
def b(self):
pass
why use Class here bruh
ofc they arent the same?
Oh ok
if you are searching for 2 different docs
I understood his reference
he just gave up
case insensitive is a kwarg in the bot constructor
its a bad idea.
oh wait
i misunderstood
case_insensitive=True || False
why add false just dont add it lol
Hey I got more arguments I am cooler-
yeah thats it being not case sensitive
Print "hello" in the most complex way you can think
make it esoteric
print("Hello")
I said the most complex way -_-
!e
x = "hello"
lst = []
for i in x:
lst.append(i)
print(str(lst).strip("()[],"))
naah
How can I make that my bot writes every morning at 9 AM a message
i wonder if i can make a dict inside a dict in pymongo like
cluster.insert_one(
{"_id" : guild.id,
"role" : "None",
"channel" : "None",
"users" : {45 : "None"}}
)```
a task
how
discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True, loop=...)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
use the called_once_a_day method
not sure why you couldnt lol
isn't supposed to be possible like anywhere? in python?
ye but i mean idk how to add data to the dict without changing anything
But thats just hours minutes and seconds and i need a time
dictionaries are mutable now it seems
str.join() exists?
print("".join([i for i in "hello"]))
I hate golfing
im using pymongo doe
dictionaries are mutable
before they weren't
They’ve always been mutable. The only immutable iterable that exists are tuples.
!e
print("".join([i for i in "hello"]))
exactly
you cant append to a tuple
You also have frozensets
Those exists yeah.
create a thousand variables who cares
the heck is a frozenset
Basically an immutable version of a set
a set+tuple in bland terms
ah ic
Your memory cares.
FROZEN set
Sets are cool! I don't see why people forget about them 😔
in what way
@client.event
async def on_guild_join(guild):
cluster.insert_one(
{"_id" : guild.id,
"role" : "None",
"channel" : "None",
"users" : {45 : "None"}}
)```
the only time I’ve used a set in any of my stuff Is when I cast to a set so I can remove duplicates and shit.
What are you trying to do
yeah making a set to remove duplicates is nice
I am dumb but can unpack set?
roles1 = set(list_of_roles)
roles2 = set(message.author.roles)
if roles2.intersection(roles1):
return
``` Here the intersection is `O(n)` where N is the LOWEST set amount. If you were to iterate the two lists it would be O(n * m)
andy
bro
are you joking
no
basically when an user joins a guild the bot is going to add the user id and the word to ```py
{"users" : {id : "word"}}
Idk what any of that shit is tbh. Computer science nerds man.
fr
the heck is O(n)
basically sets make checking if a author has a role from a list of roles faster!
It’s a measurement of time?
use json
yeah iirc
yes
O(n) is linear time, time goes up with amount of elements
I only work with json and sql
ok nerd
oh alr alr
json isnt a db so why mention it
Can use as it
But should you tho?
you can use a txt file if you wanted
I use it for my items in shop for my economy bot
Is the real question.
Just for speciality sake
no.
bro.
Yeah I got bored of sql as well. I store all of my data in punch tape.
i got bored of sql so i stored all my data in a .txt file
Why is everyone suddenly bored of SQL?
bruv
i have this code
@bot.command()
async def testing(ctx, tag):
row = reps_sheet.find(tag).row #getting row no
await ctx.send(row)```


