#discord-bots
1 messages · Page 612 of 1
the argument could be an id, the name of it or mention
it would work like -role @hi and not like -role hi, right?
it will work by both ways
i see
even by putting the ID
so i make it async def role(ctx, role: discord.Role):?
yes
by coding it again, you mean all the variables used?
instead of role try role id
by that i meant, removing the code and programming it again and understanding what i am doing in each line
i changed it to
@client.command()
async def role(ctx, role: discord.Role):
guild = ctx.author.guild
role1 = discord.utils.get(ctx.author.guild.roles, name= role)
if role1 not in ctx.author.roles:
await ctx.author.add_roles(role1)
await ctx.send(f'Gave Role : **{role}**.')
elif role1 in ctx.author.roles:
await ctx.author.remove_roles(role1)
await ctx.send(f'Took role : **{role}**')
elif role not in guild.roles:
await ctx.send('This role does not exist.')``` but it still sends an error if i enter a non existent role
discord.ext.commands.errors.RoleNotFound: Role "hi" not found.
because that role doesnt exist
did u put the id ir the role name? and is the role hi already created
no it isn't
try putting the id or mentioning it
create it then first
idk ask some pro then like @maiden fable
Wym
so you want to do stuff if the role doesnt exist
Wrong message but who cares
yes
Tf, no I ain't lmao
Goodmorning guys
gm
What did they even mean by the role not exist
idk never saw someone creating a command to see if a role exists or not
too useless to exist
theyre checking the list twice, they could just use else
Thats for checking roles to the author correct?
and giving/removing i guess
if u are gonna write a whole command with 2 args, why not just click on the user's profile and give them the role
some people prefer keyboard
actually, in this case only for themself
Couldn't they just do else:?
yes they can
Bruh
lmao
it will be a bit better because python wont check for the item again
Yeah
@sullen shoal does this basically means its a discord member that has not been given?
(member: discord.Member = None)
Im kinda confused about it
if the argument wasnt provided the value of it would be the default value
Oh
which is None in the snippet
!e
def func(arg="hello world"): print(arg)
func()
func("hello oki")```
@sullen shoal :white_check_mark: Your eval job has completed with return code 0.
hello world
Yeah i know about kwargs
Is there a way to stream video into voice chat 
its a positional argument but with a default value
How isnt it a kwarg?
Is there a way I can cooldown an event per user and not per server?
it can be a kwarg too,
you can also do, func(arg="hello world")
A bot can't lol
for keyword only arguments
Ok so a kwarg is something that gets called when a function gets called?
an event, oh
yea
!e
def func(*, arg): print(arg)
try: func("h")
except Exception as e: print(e)
func(arg="hello world")```
@sullen shoal :white_check_mark: Your eval job has completed with return code 0.
001 | func() takes 0 positional arguments but 1 was given
002 | hello world
The team reacts if no argument is specified or the person does not have a support role, but if the command was entered correctly, then nothing happens and there are no errors
a kwarg is an argument that was passed with its name like, func(arg="")
it is useful in some functions
The button arg is a keyword arg correct?
Ahh i get it now thx
yes, its a keyword only argument, meaning it can only be passed as a kwarg
because i added an * before it
Curiosity question, how many instances of a bot do u reckon u can run on same token
(arg) is a positional argument because its default value is None correct?
i think youre pretty confused with these stuff
Nah i just forgot them let me check them out again
Alr i got it now
pls .add_role(role) adds role right?
!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.
ohhh its a coroutine
wot
Cause its a list of roles you want to add
ty
Yw
lets test it, tell me the argument type of reason in the above snippet
Alr
Is it a positional arg with a default value of None?
keyword arg?
async for message in channel.history(limit=1):
m = message.content
news = m or "No updates!"
newmbed = bot.embed(ctx.author,title="Latest News",description=news)
``` the channel has no message. its raising `local variable 'm' referenced before assignment` but its not sending **No updates!**
yeah
how can I do the wait_for button click?
A Positional args value is always given when you call a function so its a keyword because the reason is None?
nope that is because, *roles will eat all the positional arguments
Why exactly?
Wait nvm
!e
def func(*args, r=None):
print(args, r, sep="\n")
func("hejej", "jeje", "jsjs")
func("jsjs","jsjs","sksk", r="oof")```
@sullen shoal :white_check_mark: Your eval job has completed with return code 0.
001 | ('hejej', 'jeje', 'jsjs')
002 | None
003 | ('jsjs', 'jsjs', 'sksk')
004 | oof
that is the reason
Ahhh i see now🤔
It will print the default value
yes because the default value is None
Yeah i see that
If you don't provide a default value to function at all the code won't work as it is syntax error
Yeah ik
You want arguments to be roles, reason, right?
But atleast a arg is needed or it will say 0 positional arguments where given
No myxi is just explaining
how do I add a role to a user
.
?
!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.
If you provide no args the list of them will just be empty
if the function accepts an arg and it doesnt have a default value, it will raise TypeError
!e def f(*args): print(args)
f()
@vale wing :white_check_mark: Your eval job has completed with return code 0.
()
or maybe some other error
I see
@sullen shoal :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 2, in <module>
003 | TypeError: f() missing 1 required positional argument: 'a'
yeah TypeError
🤔
!e
def f(a="default value 6969420"): print(a)
f()```
@sullen shoal :white_check_mark: Your eval job has completed with return code 0.
default value 6969420
Thats a kwarg right
it can be a kwarg
So what is it
it is a positional argument with a default value
Isnt a kwarg a keyword arg?
it is
Oh ok i thought i was tripping
!e
def f(a="default value 6969420"): print(a)
f()
f(a="hello world") ```
@sullen shoal :white_check_mark: Your eval job has completed with return code 0.
001 | default value 6969420
002 | hello world
!e
def func(*args, **kwargs): print(args, kwargs)
func("oof", "hello", "okimii", confused="okimii", with="function arguments")```
@sullen shoal :x: Your eval job has completed with return code 1.
001 | File "<string>", line 2
002 | func("oof", "hello", "okimii", confused="okimii", with="function arguments")
003 | ^^^^
004 | SyntaxError: invalid syntax
oops
So a is now a kwarg because hello world was given and in the first its a positional because its a arg with a default value
Why you bully me😭
gotta fix it later
Im not jk i got it with this💀
yes
Makes sense😮💨
im still confused why it raised the error
\👀
!e
def func(*args, **kwargs): print(args, kwargs)
func("oof", "hello", "okimii", confused="okimii", with="function arguments") ```
oh
lol
!e
def func(*args, **kwargs): print(args, kwargs, sep="\n")
func("oof", "hello", "okimii", confused="okimii", _with="function arguments") ```
@sullen shoal :white_check_mark: Your eval job has completed with return code 0.
001 | ('oof', 'hello', 'okimii')
002 | {'confused': 'okimii', '_with': 'function arguments'}
The first 3 are positional args because theirs a * so it means its a unknown amount and theres 2 kwargs because theirs 2 ** which means a unknown number of kwargs which confused means me and with means function arguments
slightly wrong
i feel the same 😂
the positionals are arguments that are passed by just the value not with the name, it is not unknown
isnt that what i said
oh yes
Then i am right
yes youre right
Finally 😭
You're wrong
Yeah so guys im moving to js👍
Lol
js also have that stuff
I wanna learn go
atleast es6 does
Im moving to rust
good luck
No need
but you said youre moving
Dont need your luck
Im jk @sullen shoal thx for explaining got it now👍
You got a nokia or sm?
nah
Flip phone?
that would have lasted longer than my life
True🤷♂️
an android
Noice
how i can put a timestamp in an embed?
i think theres a method for it i gotta check
okk
either with
embed.timestamp = #datetime object
or in the embed constructor:
embed = discord.Embed(
title="title",
url="title URL"
description="description",
color = #color str / hex
timestamp = #datetime obj
)
tnxxxx
np
is it not embed.set_timestamp?
no
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
!d discord.Embed.timestamp
The timestamp of the embed content. This is an aware datetime. If a naive datetime is passed, it is converted to an aware datetime with the local timezone.
How can I code that just people with for example the booster role can use !!snipe or !!avatar
@has_role decorator
it will not help to put timestamps in an embed
!d discord.ext.commands.has_role
@discord.ext.commands.has_role(item)```
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 invoking the command has the role specified via the name or ID specified.
If a string is specified, you must give the exact name of the role, including caps and spelling.
If an integer is specified, you must give the exact snowflake ID of the role.
If the message is invoked in a private message context then the check will return `False`.
This check raises one of two special exceptions, [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") if the user is missing a role, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
Changed in version 1.1: Raise [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
@slate swan did you get the answer
!d discord.utils.format_dt
discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.9)") for presentation within Discord.
This allows for a locale-independent way of presenting data using Discord specific Markdown...
You could pass in a name but its ideal to pass in a role id, if the bot is only in one server.
Nah nah nvm i forgot that if you add **kwargs the amount is unknown and if not given the value is None
Alr
<t:1618953630:d>
@discord.ext.commands.has_role("912010635431260210")
Like that?
attribute error string object has no attribute id
<t:99999999:d>
not unknown, kwargs will be an empty dict if no keyword arguments are given
<t:9999999999:d>
it will not exist at all
Yeah that
<t:0:d>
Yea ik
its considered a dict right
It's an empty dict
Im having a stroke
yeah
yes its still a empty dict
!e ```py
print({} is None)
just not truthy
I see
@pliant gulch :white_check_mark: Your eval job has completed with return code 0.
False
If a kwarg isnt given will it send a type error?
if it doesnt have a default value, yes
np
Get it way better now
however i still have a feeling that you have some wrong information about function arguments
@bot.command() @discord.ext.commands.has_role("912010635431260210") async def snipe(ctx): channel = ctx.channel try:
discord.ext.commands.errors.MissingRole: Role '912010635431260210' is required to run this command.
This is my error
how do i add a role to a user
!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.Member.add_roles
ive done add_role(name of role) and (id of role)
oop
but it returns an attribute error
roles*
you need a role object
wdym
fetch or get the role from the guild
you need an instance of discord.Role
!d discord.Guild.get_role
get_role(role_id, /)```
Returns a role with the given ID.
My definitions
arg = None /positional argument with a default value
arg /positional arg
*arg/unknown amount of arguments
kwarg/a argument that its value is given with its name
**kwarg/unknown amount of kwargs
I don't think you really need to do all the get_role nonsense here tbh
The docs say roles is a list of Snowflakes
Just make a discord.Object and pass the ID
yes
Because get_role is gonna require an ID either way, this is just faster
true you could type hint it too if its a command
def func(a, b, c, *, d, e, f, g): ...
all the arguments after the * are keyword only arguments
I see🤔
Yo @sullen shoal, I found kind of what was going on, if you remember me
And if you don't put a=None it's a optional arg/kwarg else it's not.
yeah i remember
so I added a print(e) to the exception
try:
player_ids = games[game_id][:]
print(player_ids)
random.shuffle(player_ids)
team1 = player_ids[:qsize / 2]
team1_ids[game_id] = team1
team2 = player_ids[qsize / 2:]
team2_ids[game_id] = team2
except Exception as e:
print('didnt work lul')
print(e)
raise e
Why is that so?
Well otherwise it's not defined.
a, b ,c can all be passed as kwargs. If you truly want it to be pos only you can add / to the function signature
and it gives the game_id +1 as an integer in the output
you explained it yourself
lol
So is it a key error, whatever it is isnt showing as an error
gotcha
But would you know how to fix this?
read after that too because we discussed it a bit, i may have mislead you unintentionally.
any1 can help me to solve this error?
another name for "arg/kwarg with a default value" is "optional arg/kwarg"
idk why it isnt raising jt
kinda weird
Yeah ik
yeah its very strange
Yes the answer is ||-----------||
thank you, it helped me a lot
How did you know?
extreme amount of knowledge
alright im done procrastinating 😂
Np it also was a hint that you censored 80% so we can't possibly give you a solid answer.
Dangerously amount
This is going to haunt me
i jus- i just censored my C:
I cant solve it
even more than freecodecamp's misguided kids
What are we gonna do take your storage😭
yeah 
What is that import?
im making a discord.py function that counts numbers of messages posted each day then at the end of each day it resets to 0 and pastes what it got onto a graph
@client.command()
async def heyy(ctx):
await asyncio.sleep(86400)
global xmes
dmes = xmes
xmes = 0
while 1 == 1:
print('day complete')
print('messages sent: ', dmes)
await heyy(ctx)
``` I have an on_message function that adds 1 ton xmess every message that is sent but im having a problem getting dmes(final value from day) into a list
This i agree, i saw the guy make a Discord bot. Can't ever unsee it.
import plotly.graph_objects as go
import time
xmes = 0
def onm():
global xmes
bumby = input('say 1: ')
if bumby == '1':
xmes += 1
print(xmes)
heyy()
def heyy():
time.sleep(10)
global xmes
dmes = xmes
fig = go.Figure(data=go.Scatter(x=['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'],
y=[dmes,dmes1,dmes2,dmes3,dmes4...dmes7?])
fig.show()
while 1 == 1:
print('day complete')
print('messages sent: ', dmes)
onm()
onm()
``` example here of what im trying to get at
u should probably use a database in case lol
nothing, but you wouldn't understand because it's in another language...
whats that
...?
Myxi(the freecodecamp biggest hater)
And?
from decouple import config
and... nothin' more

a place to store your count value so if your program stops you dont lose your count
From where are you trying to import that?
ohh
from my .env file
Is there a way I can delete this message that comes when a message is pinned?
And did you load this file?
snipe_message_author = {}
snipe_message_content = {}
@bot.event
async def on_message_delete(message):
snipe_message_author[message.channel.id] = message.author
snipe_message_content[message.channel.id] = message.content
snipe_message_time[message.channel.id] = datetime.datetime.utcnow()
@bot.command(name = 'snipe')
async def snipe(ctx):
channel = ctx.channel
try:
embed = discord.Embed(color = 0x87CEEB,
title=f"{snipe_message_content[channel.id]}"
)
embed.set_author(name=f"{snipe_message_author[channel.id]}")
embed.timestamp = snipe_message_time[message.channel.id]
embed.set_footer(text=f"#{channel.name}")
await ctx.send(embed=embed)
except:
await ctx.reply("¿Que buscabas?")
manage server > automatic messages (off)
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 762, in on_message_delete
snipe_message_time[message.channel.id] = datetime.datetime.utcnow()
AttributeError: type object 'datetime.datetime' has no attribute 'datetime'
Anyone with manage message perms can.
I want to delete it by the bot automatically
create a event
Well anulado solution is rather better lol.
You could do after you pin something it deletes the msg
i want to make that in the embed timestamps its the time when the message was deleted
nah alr tried
Then try the given way
main: ```py
TOKEN = config("TOKEN")
bot.run(TOKEN)
.env: ```py
TOKEN = my.toke.here
Also note that the auto message isn't a user or bot so you would be deleting blindly.
!pypi python-dotenv
Hi does anyone know how I can make it so when a user who is hosting a discord bot types something in the terminal it will send something in the discord server?
Well you can't really "type" into the terminal. I did this by making a website GUI
Is it possible that for example we got a new person who got the Owner role, and the bot updates it by himself
..?
For Example
We got one Person in Role Owner
And we getting a new Owner
Uhm what do you mean
and the bot will add the person himself to the embed
Is this embed permanently there?
You can use input() to type in a terminal??
Yeah
I'd freeze your whole bot, not really practical...
!d discord.on_member_update
discord.on_member_update(before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") updates their profile.
This is called when one or more of the following things change:
• nickname
• roles
• pending...
Is this enough info?
Not really
So you first need to check if the role that got added to the user is the owner role. If it is update it.
before and after are member objects.
ye
You get it?
nah
^^
Idk what more to tell, do you not understand the explanation or how to code it?
Well you need to event and create an if statement and compare the 2 member objects. If the role that got changed is the owner role, update the embed by getting the message object and then resending it.
Well you could be the if condition isn't that long.
Is there a way I can make it asyncronous
Dms
Not that i know of, i instantly used a web solution
I would prefer keeping it here. welp, sorry candian.
@cloud dawn , could you look in dm's?
can some1 help me with a timestamps for a snipe command?
timestamp=datetime.datetime.utcnow(),
elaborate?
I've seen it but let's keep it here.
yes but i want it to be when the message was deleted
Alr, what do you think?
Yeah you just need the event and then put the if and update in there.
okay
snipe_message_author = {}
snipe_message_content = {}
timestamp = {}
@bot.event
async def on_message_delete(message):
snipe_message_author[message.channel.id] = message.author
snipe_message_content[message.channel.id] = message.content
timestamp[message.channel.id] = datetime.datetime.utcnow()
@bot.command(name = 'snipe')
async def snipe(ctx):
channel = ctx.channel
try:
embed = discord.Embed(color = 0x87CEEB,
title=f"{snipe_message_content[channel.id]}"
)
embed.set_author(name=f"{snipe_message_author[channel.id]}")
embed.timestamp = timestamp[message.channel.id]
embed.set_footer(text=f"#{channel.name}")
await ctx.send(embed=embed)
except:
await ctx.reply("¿Que buscabas?")```
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 763, in on_message_delete
timestamp[message.channel.id] = datetime.datetime.utcnow()
AttributeError: type object 'datetime.datetime' has no attribute 'datetime'```
i have this
!indention
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
indent the block
no1 can help me?
datetime.utcnow()
import datetime
didn't direct towards you @silk mauve
ok
!d discord.Message.created_at
property created_at: datetime.datetime```
The message’s creation time in UTC.
How
press tab...
Read this
I recommend using the library as much as possible without just adding a new library for every issue.
I did but still error
Send an ss.
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've seen some issues that are weird with python indention maby it is this case.
!codeblock
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.
yeah I've faced it quite some times
async def test(ctx):```
some of my commands take in different indentation than others
why have u indented bot.command?
its not in a cog is it
My IDE just decided to mix spaces and indention lol
thats annoying
should work if the rest of the indentation is correct
Devkid i recommend learning some python first since this library is not beginner friendly.
@ is an error
@fast tree
Okay
if i have 5 roles (1,2,3,4,5) can i consecutively give a member a role for every message they say
But Let's do solve this so you can see what is going wrong, send more code.
I've a bot event
Like after each message? Doesn't matter what channel etc
?
on_member_update?
that isn't what they asked for, send the code of the command thats not working
and the error it gives, if any
I know, but I need a minute
okay
async def on_member_update(before, after):
@bot.command()
async def test(ctx):
uhh
Well the event has to contain actual code.
So?
so code
So...? Why do you have an event that does nothing.
It needs to do something
How can I check if a user has access to a text channel with an if statement?
Define "something"
if member in channel.members:
Oh wait
I want a list of roles and if a new member joins that I dont need to chage something on code
So the member will be in the embed
Like:
@winged charms(Role)
-Devkid
Etc..
I'm very confused lol
Use a codeblock so you wont @ anybody
Selam
Same
How?
This exists member.roles
```py
code here
```
@DevKid
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.
Doesnt ping anyone
Then use it
then use the knowledge next time
^
You can also use inline code @pandabweer
^
ok lets get rid of that
why are you asking for help if you dont even know what you need help with
I got a stroke
someone cant even spoonfeed you rn
Read the docs

That should be a emoji for the server
It's from the discord.js server, those people are savages.
Yeah ik 😭
Well he is in here but he can't see the messages. Can I check if the "read_messages" permission is enabled/disabled?
I don't have nitro so thats why i want it here
you may use,
🚫 🥣
till then
how can i download the git?
Yes
\🚫 \🥣
🚫 🥣
ty
could have googled tbh
i arl searched
Bro people get basic syntax errors and they come here when you can fix it yourself or read the docs if you get a attr error 
but the most results founded was: gitdownloadforwindows.com
doesnt exist
This should be your last option
either github knows how dumb some of their users who use their os are and created a specific site for them to download git or someones trying to spread malware
🤔
if member in channel.members and member.permissions_for(channel).read_messages:
ikr
This took me to at least 3 nested objects lol
thxx
I recommend looking into the attributes of member and channel most answers are lying just there.
exec("print('hello world')")
my computer died when i did,
from itertools import count
list(zip(count(), count()))```
not joking tho

My computer died when i did:
A = range(1000000000)
for b in A:
print(b)

10**10000
lmao
Omg
why dude
Why not
i always wanted to try
😭
!e
from itertools import count
list(zip(count(), count()))```
@sullen shoal :warning: Your eval job timed out or ran out of memory.
[No output]
What does this even output?
you're right
rip
Appereantly it crushes your memory lol
count is an interator which basically counts
infinitely
can i ask a question here?
This froze my python console
by calling list, python will try to convert the yield'd values to a list, which will never happen
and our memory will run out
rip 🤣
unfortunately i didnt get the chance to close the script
i thought i would get atleast 3 seconds
How do you print a str 5 times i kinda forgot

multiply
well okay i know why it would freeze your pc lmaooo
use a for loop
or *
No bruh
!e print('okimii'*5)
@sullen shoal :white_check_mark: Your eval job has completed with return code 0.
okimiiokimiiokimiiokimiiokimii
use *
Yes that
yep
Forgot how you do it 🤷♂️
didnt except it to be that powerful though
Pc go brrrr
i was just checking out what would happen
You can.
yep
cough cough
i need to know how to send webhooks with my bot as an event
like when someone types the command the bots send the webhook
Discord webhook or other webhook?
discord webhook
hello, that link and similar ones like lmgtfy are purposely deleted on this server. please read the #code-of-conduct and our #rules
im sorry
Use the discord.py webhook driver thingy, they have a pretty good example in the documentation also
like this
appreciate it - thanks for understanding!
When making commands please use the integrated system, don't make an on_message command bot.
i just started so yeah idk what r u talking bout rn
from discord import Webhook, AsyncWebhookAdapter
import aiohttp
async def foo():
async with aiohttp.ClientSession() as session:
webhook = Webhook.from_url('url-here', adapter=AsyncWebhookAdapter(session))
await webhook.send('Hello World', username='Foo')
This site should get you started -> https://vcokltfre.dev/
So u wanna do webhooks like this
Best tutorial
It looks like an ip grabber
yes just adding roles after each message
What the tutorial?
hi , guys i want to build a discord bot that's he can talk with my language
Just put the strings in ur langauge?
@slate swan Its not its one of the best tutorials out there thats up to date which is made by a helper in this server
oh thanks
His name in the server is Alec but his discord is vcokltfre
I like how he says u need intermediate knowledge
I didnt have any python knowledge when i started
You do lmfao
I just had a bit of source code my friend gave me and i worked it out
Dpy isnt beginner friendly and you need knowledge of classes and asynchronous programming
Not beginner friendly^
just putting your code on on_ready or on_message isnt enough
I disagree u dont need knowledge of them really, u just need to know how to use them for discord.py
Which is pretty simple
:/
You can know the syntax but not the meaning
Which means you dont actually know it
Thats what im saying
You just know the syntax
lets not talk with kids
Which is simple
yes
You have 0 knowledge of python do you
I had 0 knowledge when i started
I was able to work it all out just looking at my friends code and then in a day i made like 10 new commands
Knowing syntax isnt knowing dpy
And most of the commands were interacting with restful apis
Its the kids like you that say they know it and then come here with a attr error
SyntaxError: invalid syntax how to fix this error?
So i feel a bit better than those kids
Im not saying your stupid,but im saying your actions arent correct
In that i was able to actually understand the errors
learn python
And use the errors to fix what went wrong
Like sometimes im surprised ppl just dont read the errors
And now i feel confident in using python to do basic stuff and interact with apis. I was even able to use the skills at work
@slate swan i dont recommend knowing dpy only its syntax because you will just not have a good time and not having good knowledge classes and asynchronous programming you will not have a good time or understanding of what your doing
My way of learning worked for me
Still dont really know what a class is but my discord bot go brrrrrr
I remember when i first learnt how to use functions
Yes thats your way but everybody here doesnt learn your way we make general suggestions so users dont have knowledge holes
B4 that i would write my entire code as a script lol
I think my way translate to alot of what ppl want, which is to make stuff
And u should have a goal and learn as u go along making that goal
Its better knowing somethings deeply then knowing everything lightly
And then if u enjoy it. Start learning python properly
Depends on ur end goal
Not at all
Im gonna do a proper python course soon, but me doing it now vs me doing it b4 when i knew nothing
Will result in me doing it now learning things more deeply i think
basically waste of time if thats what you wanted to do later
it is, all this could have been covered in like 2 weeks if you had taken a good python course
I liked learning it myself, its like an rpg, and when u gain a skill all these new stuff become available to you
Learned python basics in like a week but i know it deeply after 7months since i started
you werent learning
Like when i learnt about lists and dictionaries
Ngl best way to learn python is python docs
Once i learnt those i realised i can do alot of things with them
Good examples good explanations
Python docs are aids lmao
Discord.py docs really good
Not really theyre really good
python docs are very detailed and good
I didnt really like them
Exactly
I found them confusing especially right at the start
because you looked at the wrong section
Its not difficult you just have to read it and not breathly
https://docs.python.org/3/tutorial/ this was what you should have checked
Its not clear, especially if im just tryna get something done, theres much better sources of information
My favourite is google
Seems like you despise knowledge 🤷♂️
Google is good. I learnt alot googling for similar things and then working out how to apply all the concepts to my end goal
they will teach you how it will somehow work python docs will teach you how it works
Seems like u assume
Not good
No, i can work out how stuff works
Most stackoverflow stuff are outdated or are in 2.0
Python docs arent that great
If you actually read it
they are great for those smart people who read https://docs.python.org/3/tutorial/
Works for me, im not just copying code im just looking at how stuff works
Knowing outdated stuff isnt a good thing
Im not learning outdated stuff
You probably are🤷♂️
okay tell me the difference between
class foo(object)```
and
```py
class foo()```
the answer is very simple
I told you i dunno what a class is
LOL?
Then you dont know dpy
every single damn thing of an object oriented programming language is a class
you always need them
thats not how it works then
Then your not using dpy then
I am using discord.py
#python-discussion heres a channel for you
youre using it, not learning how it works
You need to know classes and asynchronous programming for dpy
okay im done with this kid
I know how to use asyncronous libraries
Thats all i need to know
Seems like you dont
I do though
What do i know about dpy ive only been on it for 7 months🤷♂️
Anything i dont know how to do
I will learn how to do it
If classes become important for me to learn
To do what im doing
I will learn classes
If you had education on your face would you reject it?
Thats a dumb question
Answer it then
Not so polite
U getting triggered coz i found a way of learning that works for me
Seems like your the one whos triggered
Im saying even if you dont need it you should learn it
At some point maybe, but i dont need to learn it
!mute 788098387354452060 1D That's not the way we expect members to behave in this server. Please re-read our #rules and #code-of-conduct .
:incoming_envelope: :ok_hand: applied mute to @slate swan until <t:1637604281:f> (23 hours and 59 minutes).
sorry 'bout that
Nah its alr
I think he misunderstood my point
I never tried to offend him in any way
i've wasted my beginner days using the same stuff i know because i sucked at english which i still do, later as every other kid i tried discord.py, i wasted around 2 months on it doing the absolute basic commands then when it came to stuff like custom help commands, i looked up Stella's guide to subclassing HelpCommand then i came to know why i sucked at python, i didnt know about classes i spent like 2 months learning how classes work from that day im improving
eh rip
wrote that for him but rip
Same i started not knowing anything but knowing syntax and it was a big waste of time
And i dont want any beginner to waste like a month and quit python or their dreams
yeah its kinda hard when youre learning by yourself at first
Yeah you just have to know that everything is up to you
we dont know what skills we need and stuff and how to actually improve
Yeah
Its unlike college in college you have everything to learn in your face unlike self programmers who need to search for it
Good thing of a self taught programmer is that everything is at your paste
yeah
I started 7 months ago cause i want to be ahead of my class when i got to college
So everyone is starting python when i have years of experience
i wanted to be those people with green text on black screen
Yeah same
Ive been inspired to programming cause ive always liked tech and stuff and i dont regret learning python
oh yeah i liked
tech and stuff even when i used to play games on my dads nokia
those java games were fun
I used to play those traffic car games which you could go left or right and up and down with the cross in the flip phone
Best games ever
I had only 4 it was the car game, snake,cards,and space shooter type of game
just downloaded every damn game i could find on some sites that start with wap
😭
Lmfaoo
@bot.command
async def guide(ctx):
embed=discord.Embed(title = 'luxé helper' , description = 'under construction' , url = 'https://youtu.be/KLBWiXFLc_I' , color = 0xE6E6FA)
code not working? please
You have to send the embed
no url kwarg
in an embed
There is a url kwarg iirc
The URL of the embed. This can be set during initialisation.
I assume you have ```py
await ctx.send(embed=embed)
oh thx
hey
👋
uh someone replied to my 3 years old youtube cringe comment
hope u guys are well
yeah im doing well
And as said you need the url kwarg
Happens
i check if the bot is in the same voice channel as the guy who sent the command
this should work but its not. am i doing something wrong?
no idea what that is
I would check the guild.me.voice
instead of voice_client's
@slate swan ^
trying this rn
that should work
hmm still didnt work
check if its None

perhaps ctx.author.voice is not the same type of object as ctx.guild.me.voice?
oh i see
both return VoiceState
lmao
The voice channel that the user is currently connected to. None if the user is not currently in a voice channel.
why not check the voice channel itself?
@sullen shoal it worked thank you
how can it be none if its the author of the command?
https://discordpy.readthedocs.io/en/stable/api.html#discord.Member.voice
its optional in the docs
if its none, you will get that nonetype error
may as well add it
question - what other useful features do you guys regularly use bots for besides music
!e None.channel
@sullen shoal :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | AttributeError: 'NoneType' object has no attribute 'channel'
this one
or is music the most useful thing a bot could do
moderation is prob the second most used.
well i use it to check if theres any new python version available haha
Moderation,fun others
the most illegal one
😳
AttributeError: 'Member' object has no attribute 'permissions_for'
idk what ur talking about, im using boobtube-dl
May i please see the bot
what the
lol
im not hosting it anymore
and I still assume it downloads music from youtube
Not really but you can
ah i just got warned for one thing gotta keep that in mind next time
if member in channel.members and channel.permissions_for(member).read_messages:
u just host it from ur pc ?
Raspberry users
You just run your code and the bots gets online
What thing?
There are some sites that allow music downloading, but ofc those severely lack music since it only has non copyright stuff.
yesn't exactly
maybe because when a user here got syntaxerror i told him to learn python which was bad i realized
lol
I remember
!d discord.Guild.create_custom_emoji
await create_custom_emoji(*, name, image, roles=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a custom [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji") for the guild.
There is currently a limit of 50 static and animated emojis respectively per guild, unless the guild has the `MORE_EMOJI` feature which extends the limit to 200.
You must have the [`manage_emojis`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_emojis "discord.Permissions.manage_emojis") permission to do this.
what is roles in this
roles (Optional[List[Role]]) – A list of Roles that can use this emoji. Leave empty to make it available to everyone.
``` but how does that work>
Its a list of all the roles in your guild
Well telling someone to learn python beforehand is completely normal. But i think it was more aimed towards "do not talk to this kid".
whats it purpose in create_custom_emoji
Idk havent seen it
You just have to be careful how you put it
When you add custom emojis yourself, there isn't an option to specify the roles that can use the emoji
they mentioned something related to an error in the warn message so it has to be that message because i never talked about errors with Noobian
@sullen shoal sorry for the ping, I managed to use deta database as you said above and stored some data there but how can I have multple data for specific user?
use a dict as the value
If something is not clear or unknown i recommend to just test it.
mongoDB?
Can you maybe give me a little bit of example something like this?
user = ctx.author.id
db.put({"user" {"quote":message}})```
Deta database
one sec i gotta be sure after checking the docs
Remember the kid who had a simple syntax error and you just said:
learn python lmao or something like that
yep
I would explain anything but i won't 
put(data: typing.Union[dict, list, str, int, float, bool], key:str = None):```
you would get the dict you passed there as,
```py
get(key)["user"]["quote"]```
yep it has to be that one
Yeah
Noobian knew what he was doing
Yeah he just needed a bit of guidance
he wasnt a beginner, the warn message included the user being beginner
Makes sense
put(data: typing.Any, key: str = None):
you can create multiple databases so you can organize your stuff like this,
self.db_project_key = os.environ.get("DETAPROJECTKEY")
self.server_db = deta.Deta(self.db_project_key).Base(name="serverdb")
self.user_db = deta.Deta(self.db_project_key).Base(name="userdb")
self.bot_db = deta.Deta(self.db_project_key).Base(name="botdb")```
hey
👋
hello
nice
async def add(ctx, member : discord.Member):
channel = ctx.channel
if member in channel.members and channel.permissions_for(member).read_messages:
await ctx.channel.set_permissions(member, read_messages=False)
await ctx.channel.send(f"Removed {member.mention} from this channel.")
elif member in channel.members and not channel.permissions_for(member).read_messages:
try:
await ctx.channel.set_permissions(member, send_messages=True, read_messages=True)
await ctx.channel.send(f"Added {member.mention} to this channel.")
except:
await ctx.channel.send("Please provide a user.")```
For some reason this always has the first if statement true. No matter what perms the user has it always sends "Removed {member.mention} from this channel."
the key can be the user id
Could print channel.permissions_for(member)?
let me check
help??```py
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 167, in wrapped
ret = await coro(*args, **kwargs)
File "/home/runner/cogs/general.py", line 613, in _news
await ctx.reply(embed=newmbed, reference=ctx.replied_reference, view=LinkButton(links))
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/context.py", line 400, in reply
return await self.message.reply(content, **kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/message.py", line 1564, in reply
return await self.channel.send(content, reference=self, **kwargs)
TypeError: send() got multiple values for keyword argument 'reference'
Oh i see it,
from py if member in channel.members and channel.permissions_for(member).read_messages: to ```py
if channel.permissions_for(member).read_messages:
If I make key userID how would I fetch every data related to the user?
Trying to code in a remind me feature for my bot, how could i implement this? I have no previous coding experience, i inhereted the bot. https://github.com/Adure/remind-me-bot-py
Dont recommend dpy for beginners
oh kk let me try
I dont even know what that means
Dont recommend discord.py for beginners
ah i see. unfortunately the entire bot is written in it so i dont have much of a choice
I'm sorry but we won't provide code for entire functions. You need to some research yourself. If you run into anything when making it we can help.
i sent a github code, just want to know how i could integrate it

Nah man still it always says "Removed {member.mention} from this channel."
If I print it it gives me this "<Permissions value=8523873535>"
Well you install Python and pip install the packages.
It notepad++ good?
thats where i did the coding for the rest of the bot
I recommend an IDE like VSCode, Atom or Pycharm.
How can I have my bot do something when a specific reaction is clicked (on a message)
i have atom, i'll open that up
!resources @slate swan read the link to learn python and after you learn python then you can learn discord.py
Could you dir this object?
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
suppose the user has some information you need to store such as,
x = dict(name='cia', age=None)```
and `y` is their ID
you may store the data as,
`put(x, y)`
and get it by
`x = get(y)`
now `x` is the dict again meaning you could do,
`x['name']` and `x['age']`
Unfortunately this is not the help i need. Thank you though!
Do you know about python?
I knew enough to take the skeleton of the bot i was given and expand it
Also my personal favorite 😉
Do you got Python installed?
If i see one command i could replicate it basically infinite times
I see then you could learn dpy if you know about asynchronous programming and classes
Can i ask why not just {}?
So i don't know python, but i have coded in it. I suppose
unfortunately this is not what i am looking for, sorry :(
['__abstractmethods__', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__slots__', '__str__', '__subclasshook__', '_abc_impl', '_client_status', '_copy', '_from_message', '_from_presence_update', '_get_channel', '_presence_update', '_roles', '_state', '_try_upgrade', '_update', '_update_from_message', '_update_inner_user', '_update_roles', '_user', 'activities', 'activity', 'add_roles', 'avatar', 'avatar_url', 'avatar_url_as', 'ban', 'block', 'bot', 'color', 'colour', 'create_dm', 'created_at', 'default_avatar', 'default_avatar_url', 'desktop_status', 'discriminator', 'display_name', 'dm_channel', 'edit', 'fetch_message', 'guild', 'guild_permissions', 'history', 'id', 'is_avatar_animated', 'is_blocked', 'is_friend', 'is_on_mobile', 'joined_at', 'kick', 'mention', 'mentioned_in', 'mobile_status', 'move_to', 'mutual_friends', 'mutual_guilds', 'name', 'nick', 'pending', 'permissions_in', 'pins', 'premium_since', 'profile', 'public_flags', 'raw_status', 'relationship', 'remove_friend', 'remove_roles', 'request_to_speak', 'roles', 'send', 'send_friend_request', 'status', 'system', 'top_role', 'trigger_typing', 'typing', 'unban', 'unblock', 'voice', 'web_status']```
What are you looking for then bruh
i use it when its easier than doing it with {}
Ah ok so I can just do db.get(y) which would retrieve all data stored from the y variable?
way to intergrate the github page's remind me function (or any other source code regarding remind me fuctions) into the bot
This is the member object i was looking for this ```py
print(dir(channel.permissions_for(member)))
Oh.. I'm sorry xd
ctrl + c ctrl + v 
it would fetch and return all the data you stored with y as the key
which part should i copy and where should i paste them?
the bot has multiple py files
The function lmfao
what's "the function"?
You shouldn't copy anything at all, you need to clone the repo.
Gotcha thanks lemme try it

I see. So what should be the first thing i do?
i assume all dpy bots have a bot.py file
?
@cloud dawn Bruuh nevermind bro, the Person I used to test it out has admin perms. I thought that the if statement checks the perms for THAT SPECIFIC user. But no, it just checks if he has perms to see it in general. I'm sorry but I'm dumb ;(
Well i can also call it thisfileisnotabotoranythingrelatedtodiscord.py
I like how prob everyone here took the time to read my file name 😊
I have not but i do have cogs.

which py to open?
ohh lol yeah that would explain a lot.
xdd
No bruh
Every bot isnt exactly the same
Nope, depends if you need it
How can I have my bot do something when a specific reaction is clicked (on a message the bot sends)
With a Check
!d discord.on_raw_reaction_add
discord.on_raw_reaction_add(payload)```
Called when a message has a reaction added. Unlike [`on_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_reaction_add "discord.on_reaction_add"), this is called regardless of the state of the internal message cache.
This requires [`Intents.reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.reactions "discord.Intents.reactions") to be enabled.
for all i know discord could need a cogs folder for a bot to function. as i said i really dont know






