#discord-bots
1 messages ยท Page 469 of 1
oh yeah...and what do i do fix this?
the guild id is not in the table
no, that will work
it is valid
it will work but won't get updated and will remain in its old state
oh okay'
then this should be the error
as Sir said
await webhook.send(content, username=message.author.name,avatar_url = message.author.avatar_url)```
so i have been trying to make this webhook work but it does not show member avatar and i am getting this error-
```line 36, in on_message
webhook = await message.channel.create_webhook(name="test",avatar_url = message.author.avatar_url)
AttributeError: 'Member' object has no attribute 'avatar_url'```
member.avatar try that
Hi
why does this sends a error? py while True:
!indent
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
still didn't work ._.
yeah when i did that it gives error at the top
Guys, i cant seem to find DiscordUtils' docs. anyone can help?
Hover over it and tell the error
Thankuuu
so i was getting an error in heroku cuz i didnt put asyncpraw in the requirements.txt file. how would i add it in here?
aiohttp==3.7.4.post0
async-timeout==3.0.1
attrs==20.3.0
chardet==4.0.0
discord.py==1.7.3
idna==3.1
multidict==5.1.0
typing-extensions==3.7.4.3
yarl==1.6.3```
no error but it would not send
Das a lot of red
Hey quick question - I'm wondering how can I set up the bot that it ignores commands via private message?
@commands.guild_only() maybe
@bitter kite https://stackoverflow.com/questions/48518300/discord-py-how-to-make-bot-not-respond-to-pms/48519097
anyone can help??
definitely @commands.guild_only()
What's causing all the red? ;-;
yeah
hi
i think its
is your code overindented?
while True:
@bot.event
async def on_message(message: discord.Message):
if message.guild is None and not message.author.bot:
print(message.content)
print(message.author)
embed = discord.Embed(title="Confirm Mail creation",description="This system is used for reporting bugs,reports concerning to the moderators.",color=0x3DFD1E)
a=await message.author.send(embed=embed)
await a.add_reaction('\u2705')
await a.add_reaction('\U0001f6ab')
def check(reaction, user):
return user == message.author and str(reaction.emoji) in ['\u2705','\U0001f6ab']
reaction, user = await bot.wait_for('reaction_add',check=check)
print(reaction.emoji)```
lemme send full code
why doesn't it print the reaction the user reacted on
@commands.command()
async def button(self, ctx):
one = Button(style=ButtonStyle.blue, label="1", id="embed1") #create buttons
two = Button(style=ButtonStyle.red, label="2", id="embed2")
three = Button(style=ButtonStyle.green, label="3", id="embed3")
four = Button(style=ButtonStyle.grey, label="4", id="embed4")
invite = Button(style=ButtonStyle.URL, label="Invite here ๐ค", url="https://discord.com/oauth2/authorize?client_id=834155102293721138&scope=bot&permissions=306048230")
embed1 = Embed(title="This is embed 1", description="for the blue button.", colour=discord.Colour.blue()) # create embeds
embed2 = Embed(title="This is embed 2.", description="for the red button.", colour=discord.Colour.red())
embed3 = Embed(title="this is embed 3.", description="For the green button.", colour=discord.Colour.green())
embed4 = Embed(title="This is embed 4.", description="for the grey button.", colour=discord.Colour.greyple())
await ctx.send(
"This is an embed test!",
components=[ # attach the buttons
[one,
two],
[three,
four],
[invite]
]
)
buttons = {
"embed1": embed1,
"embed2": embed2,
"embed3": embed3,
"embed4": embed4 #assign the buttons to the embeds
}
while True:
event = await self.bot.wait_for("button_click")
if event.channel is not ctx.channel: # wait for the button click, get the button id
return
if event.channel == ctx.channel:
response = buttons.get(event.component.id)
if response is None:
await event.channel.send(
"Something went wrong. Please try it again." # error
)
if event.channel == ctx.channel:
await event.respond(
type=4, # send the message (7 is editing the message)
embed=response
)```
i rewrote the entire image before u sent that lol
anyone
Yeah your code wasnt properly indented
@lyric moat What do I need to import to use button?
Sent via dm @unreal silo
the Discord developers
Not the .py
thnx tho
b
how to send video from pc to chat using discord bot
Is there any free discord.py hosting?
hey, why am i getting this error and how to fix it ? thankss
no
ctx.voice_client is None
check if its None first, if its not then stop it
how to ? like what should i tell it like if vc == none: stop ?
pseudo code
if the voice client is None:
tell the user the bot is not connected or something
else:
stop the voice client
ohk and i assume its gonna be put below the vc part ?
after assigning the variable that is
below what
sadness
cuz ur doing ctx.voice_client.stop() at the top
wait a second
how do we stop the voice client ?
i think this should have been play
not stop
do this before everything
yeah
like below import but above the class ?
how to send video from pc to chat using discord bot
no, ofc inside the command
!d discord.File
this is fine ig
class discord.File(fp, filename=None, *, spoiler=False)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for sending file objects.
Note
File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")s.
@hasty iron
you still aren't checking in the correct place
ahh man, its my first time making a discord bot, one second
vc = the voice client
if not vc:
send message
else:
do stuff
Guys, is there a way to send a message to a channel ASA the bot joins a server
ohk lemme try it out
also why do you have a play in there
make an event for like on_guild_join and then grab the default channel and send the message there
remove that ctx.voice_client.play after the ctx.voice_client.stop()
where ?
ohhh, thanx you
ohk i see
np, you should be able to find that stuff in the discord python docs to help you more
thenx
yeah
ight lemme try it out
How do i grab the default channel ๐ฅฒ
actually add a return after await ctx.send
so it doesnt execute whats after
go into discord python docs and see what attributes a guild object has, and if it tells you the default channel then grab that
ohhh thankuuu
ohk
Does anyone know (in terms of discord bot performace) if C# would be a much better option than using PyPy (python interpreter)
can I make it look like the bot is typing before it sends a message?
yes thats good
!d discord.ext.commands.Context.typing
async with typing()```
Returns a context manager that allows you to type for an indefinite period of time.
This is useful for denoting long computations in your bot.
Note
This is both a regular context manager and an async context manager. This means that both `with` and `async with` work with this.
Example Usage...
alright lemme try it again now
Hey guys
How can i see which version of discord py is installed?
Nothing
pip show discord.py
or print(discord.__version__)
btw how do we make the bot connect to vc ?
!d discord.VoiceChannel.connect
await connect(*, timeout=60.0, reconnect=True, cls=<class 'discord.voice_client.VoiceClient'>)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Connects to voice and creates a [`VoiceClient`](https://discordpy.readthedocs.io/en/stable/api.html#discord.VoiceClient "discord.VoiceClient") to establish your connection to the voice server.
hmm one second where do i put this in the code
you can get the author's vc by doing ctx.author.voice.channel
it shows me that error
and again ctx.author.voice can be None
py -m pip show discord.py
thanks
it wont connect to the vc tho
tried returning it too
wait i think theres a typo
ok idk how to fix it lol
yeah, i changed it
it should work now
it still didnt work, its not connecting and saying its not connected in a vc
!d discord.VoiceClient.move_to
await move_to(channel)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Moves you to a different voice channel.
hm
-m pip ...
Tyty im new to cmd so i still struggle
is it fine if i send the whole code ? @hasty iron
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.pydis.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.
Hey @brazen fractal!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
โข If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
โข If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
how to fix?
Traceback (most recent call last):
File "C:\Users\Xiv\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\http.py", line 300, in static_login
data = await self.request(Route('GET', '/users/@me'))
wrong token
oh wait
can someone help me with buttons command?
IT works !!! @hasty iron sorry it was my first time making a discord bot i forgot about the join thingy
its fine
thankss a lot tho
How to send a video correctly?
is there anyway i can restrict certain commands only to my account? im not referring to restricting through roles in a server. im talking about restricting it to my account, so no matter the server, or role, only i can use that particular command?
using absolute path, maybe?
Like this?
like how you load in your cogs
What's the best alternative to dpy as it is discontinued?
I am not using cogs in this case.
oh ok, so i can send you my code for loading the cogs, you just have to convert it
pycord. its a fork of d.py, so all your existing code will work. they have slash commands, buttons, etc.
Why would I need to download cogs if I don't use them?
so are there non dpy-forks too? Like if I'm starting from scratch, is that still the best?
i said change the code
yeah, old tutorials will still work
ohh, sorry I misunderstood you
Yes. There's Hikari iirc.
Yes, could you please post your example
is it better than pycord?
Not too sure about that, it is an option tho.
Well pycord is a dpy fork only iirc
So if u r good with dpy syntax, then I would prefer u use a fork, else use hikari
so as a beginner, hikari is better for me, right?
Well, sort of yea. But I don't really think many people here knows about hikari's syntax. Again I ain't sure
Hi
I have a problem when dealing with the log it gives me the wrong member
Code?
how to create a command which disconnects the user from the VC when used it ?
@valid galleon Can you throw your example?
!d discord.Member.voice
voice```
Returns the memberโs current voice state.
voice```
Returns the memberโs current voice state.
...
what did you mean ?
This returns the VoiceState of the user
can you share the code of that ๐
the bot seems to be offline
Which bot?
!d discord.Member.move_to pass it None to disconnect the member @sick talon
await move_to(channel, *, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Moves a member to a new voice channel (they must be connected first).
You must have the [`move_members`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.move_members "discord.Permissions.move_members") permission to use this.
This raises the same exceptions as [`edit()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Member.edit "discord.Member.edit").
Changed in version 1.1: Can now pass `None` to kick a member from voice.
Please tell me how to send the video correctly?
aahh already
?
it worked thanks a lot
(:
btw a quick question how do you make if " " in message.content check whether the user sent a message in that channel instead of a specific message or is there any way around for this ?
!d discord.Message.channel
The TextChannel that the message was sent from. Could be a DMChannel or GroupChannel if itโs a private message.
uhh could you please elaborate it..
if message.channel == bot.get_channel(id):
. . . .
thanks a lot man
(:
sorry for the late reply, i was afk:
for cog in listdir(path.join(path.dirname(path.abspath(__file__)), "cogs")): #change the directory to where your video is stored
if cog.endswith(".py"): #add your file extension here
client.load_extension(f"cogs.{cog[:-3]}") #add the ctx.send() line here
else:
print(f'unable to load {cog[:-3]}') #dont really know what you could do here. maybe just change the string to unable to load file?
thanks
@commands.Cog.listener()
async def on_message(self, msg):
data = get_leveling_data()
await create_leveling_acc(user, guild)
xp = data[str(guild.id)][str(user.id)]["xp"]
lvl = data[str(guild.id)][str(user.id)]["lvl"]
to_the_next_lvl = data[str(guild.id)][str(user.id)]["to_the_next_lvl"]
xp += 1
print("test")
if xp > to_the_next_lvl or xp == to_the_next_lvl:
data[str(guild.id)][str(user.id)]["xp"] = xp - to_the_next_lvl
data[str(guild.id)][str(user.id)]["to_the_next_lvl"] = round(to_the_next_lvl ** 1.02)
data[str(guild.id)][str(user.id)]["lvl"] += 1
with open("leveling.json", "w") as f:
json.dump(data, f)```
does anyone know why isn't it adding xp to the member? it prints test and I have no erorrs.
Embed = discord.Embed(title=msg, timestamp=datetime.now(), color=0x2F3136, url = url)
why am i getting invalid syntax in this
uhh it isnt working
actually i am building a anti afk thing
where if a user joins a VC firstly he have to send some message and after every 2 hrs, the bot would ping the user and if fails to reply it he would be disconnected from the VC (this is for the XP grinder who gain XP by being AFK and staying in the VC)
ok?
so when i joined the VC and sent some message in the channel whose ID i used in the code
it disconnected me after some time
Code?
gimme a second
can someone help me with this
show the error
if message.channel == client.get_channel(886095797375074375):
this part isnt working
i checked using this await tc.send("ok")
and the bot didnt send anything
alright
didnt work
uh yeah it was wrong channel ID
but now i am getting errors
Sure. What is the error?
i fixed it ๐ but still it isnt sending ok
Lol
๐
Can u share the code please?
@client.event
async def on_voice_state_update(member, before, after):
channel = before.channel or after.channel
tc = client.get_channel(886095797375074375)
if channel.id == 884734344558702596:
if before.channel is None and after.channel is not None:
role = discord.utils.get(member.guild.roles, id=886983232829141022)
await member.add_roles(role)
await tc.send(f'{member.mention} Hey')
await asyncio.sleep(5)
@client.event
async def on_message(message):
if message.channel.id == client.get_channel(886095797375074375):
await tc.send("ok")
else:
await member.move_to(channel = None)
elif before.channel is not None and after.channel is None:
role = discord.utils.get(member.guild.roles, id=886983232829141022)
await member.remove_roles(role)
It isnt sending ok when i send a message in that channel
ohh.. how do we fix it ?
guys, my music commands were working perfectly fine, but then replit, said they killed my program, and now the music commands give error: NoneType Object is non-subscriptable
on_message is a different event
hmm.. so how we make the bot to send ok when i send some message in that channel and if i dont send it would disconnect me
What is the maximum file size for a bot to send?
Hmm, u can use a bot var and set it to True or False if the person replies or not (u can make a dict)
!botvar
Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:
bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"
@bot.command()
async def get(ctx: commands.Context):
"""A command to get the current value of `test`."""
# Send what the test attribute is currently set to
await ctx.send(ctx.bot.test)
@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
"""A command to set a new value of `test`."""
# Here we change the attribute to what was specified in new_text
bot.test = new_text
This all applies to cogs as well! You can set attributes to self as you wish.
Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!
for more information ^^^
!d help
Guys?
It's for my question?
could you send the code please ๐
no
okay
bot.responses = {}
if message.channel == your channel:
if message.content == "whatever":
# update bot.responses with message.author.id as the key and True as the value
# Then in an on_voice_state_update check for each member's value from the dict.. I would prefer using a tasks.loop tho
!d discord.ext.tasks.Loop BTW
class discord.ext.tasks.Loop```
A background task helper that abstracts the loop and reconnection logic for you.
The main interface to create this is through [`loop()`](https://discordpy.readthedocs.io/en/stable/ext/tasks/index.html#discord.ext.tasks.loop "discord.ext.tasks.loop").
oh ok
thanks a lot
(:
^
SyntaxError: invalid syntax
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 17, in load
bot.load_extension(f'cogs.{extention}')
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 678, in load_extension
self._load_from_module_spec(spec, name)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 609, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.embeds' raised an error: SyntaxError: invalid syntax (embeds.py, line 95)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/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: ExtensionFailed: Extension 'cogs.embeds' raised an error: SyntaxError: invalid syntax (embeds.py, line 95)```
Hi
i trying make Missing Permission comman and evry try error
Mhm
if isinstance(error, commands.MissingPermissions):
. . . .
aaaaaaand
isinstance(object, classinfo)```
Return `True` if the *object* argument is an instance of the *classinfo* argument, or of a (direct, indirect, or [virtual](https://docs.python.org/3.10/glossary.html#term-abstract-base-class)) subclass thereof. If *object* is not an object of the given type, the function always returns `False`. If *classinfo* is a tuple of type objects (or recursively, other such tuples) or a [Union Type](https://docs.python.org/3.10/library/stdtypes.html#types-union) of multiple types, return `True` if *object* is an instance of any of the types. If *classinfo* is not a type or tuple of types and such tuples, a [`TypeError`](https://docs.python.org/3.10/library/exceptions.html#TypeError "TypeError") exception is raised.
Changed in version 3.10: *classinfo* can be a [Union Type](https://docs.python.org/3.10/library/stdtypes.html#types-union).
naaah
hm lemme get it
what
(:
?
Helpp
with?
this how see code?
with youtube_dl.YouTubeDL(YDL_OPTIONS) as ydl:
info = ydl.extract_info(url, download=Flase)
url2 = info['formats'][0]['url']
source = await discord.FFmpegOpusAudio.from_probe(url2,
**FFMPEG_OPTIONS)
vc.play(source)
Bro That is coming error
what should i do?
?
!ytdl
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTubeโs robots.txt file; (b) with YouTubeโs prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
i can't find the page can you help me?
What does that mean?
@maiden fable
against ToS
which page bro?
that is the page...
yessssssss
can u tell me in DM
if its against ToS
you give me this link
sorry
see this man pfp
look like he is so cute ๐
that is what it should show
Thank you
oooooo goddddddd
Bruh yesterday I also asked someone
but they also said against ToS
What SHOULD I DO?
don't use it
Bro I just did...
ok but How can i solve my error cause I wanted to fix this error pls?
well u gotta make yr function async. that is what I can tell u. Nothing more, nothing less
czz u gotta code yourself......
FUCK OFF
lmao bruh
chill
Yo!!
Remember me?
hi
you told me that and last time now you won't help me
may i dm u pls?
(permission :<)
why
cause its againt Tos in this server
so...
what the hell
pls don't host on repl
Can anyone say what's wrong
why not
whats up with that console
^
and client.say isnt a thing anymore
and because it's garbage for bot hosting
oh
hlo
pls
oki
what do you want help with
someone know how do i get rid of this
NOBODY IS HELPING ME
Dude chill out people will help you when they want to
you aren't obligated for help
Give me a sec
oh ok
here @crimson cliff
hello how to install discord.py (voice) on windows
No
I doesn't mean that
Well People saying its against ToS given in rule 5
So Thats why nobody heling
Too ๐ญ
pip install discord.py[voice]
thanks
what do you need help with?
I told you to provide context
thats not that

music command
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
!ytdl
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTubeโs robots.txt file; (b) with YouTubeโs prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
read it
How many times will u send me this
as many times as you'd like
ok
Until it gets through your head that we won't help you.
k

not funny bro
I am sad ๐ฆ
so. You wanna break the tos

Did i say that?
ofc you breaking it
well no from now on
Just skid off of GitHub lol
good
that's what most of us do for music systems anyhow
lmao

Ima dump replit 
you should

LOL
and I am trying to draw that cutie cat from ur pfp lol
You host on repl?
not anymore
i suggest against this
btw can u send me link for code (music bot)
I amma try
Don't use repl or heroku.
Look on โจ GitHub โจ
that's what I'm sayin

It's not that hard to follow ToS rules.
fix what
click Alt+F4 to get fix this ๐
bro codes?
also if that's a selfbot we can't help lol
its not a selfbot
๐
its discord bot
purge dm?
purge
didn't know bots could purge dms
?
yeah They could
Clear msg
They can purge messages in channels
- is sketch how it says "discord-purge-dm-main\purgedm.py"
but what's the problem
he didnt reply yet lol
fix what
yeah exactly
what is the issue
bro ur code?
UwU (Hello Again)
bot=False, not a self bot bro totally
selfbot
?
"?"
I told you guys lmfaoooo
i mean it seemed kinda suspicious at the beginning
๐ GENIUS MAN
I know, that's why I questioned it
good my boi !
we cant help with selfbots
u guys are making everything lame bitching over a selfbot
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
there's rules in this server
what the hell is self bot
ur bitching over a selfbot
maybe you should read the rules and ToS
keep bitching over a selfbot on discord
sure
dont mention me (in advance)
go ask ur friends, they prob have a skidded script
good one lulw
lel
ok now lets stop
tryna be funnny?
Hey, Dont Say anything to her
Say to me, kiddo ๐
what place do you guys recommend for hosting discord bots, lets say its kinda friendly to use
nothing here is funny "axl" ๐คก
lmaoo u wanna simp over discord
he wanna simp over a female he doesnt knows irl
Heheh I AM FAKE SIMP ๐
huh
guys just stop
fake simp ur already downbad
can someone just mute this skid or sum
skid?
contact modmail
"axl" not sus at all
did u know the facts ur mom made a mistake in giving u to the adoption center?
<@&831776746206265384>
i bet shes regretting it rn
of?
hello
of what?
@copper quartz Sir Can u pls mute @brazen fractal
I am really sorry for mentioning u
Next time I won't do that
PLS SEE MSG HISTORY FOR PROFF
?
this chat went from discord bot to adoption center
instead of making a huge problem come to my dms
hi this 19 guy being rude because we didnt help with his selfbot
ok
blanket is the one bitching about something over a sb
No
it's against the rules
@tight obsidian also its against ToS
mute him for 1 month
if u can
or pls explain him
!ban 805856858564329557 3d You came here just to get help with a selfbot, and when told about our rules, started making inappropriate comments. Goodbye.
:incoming_envelope: :ok_hand: applied ban to @brazen fractal until <t:1631812657:f> (2 days and 23 hours).
thanks
which place is recommended to host a bot?
THANKS MAN
I AM PROUD OF U
We appreciate you bringing them to our attention, but please don't make demands of the moderators.
thanks
Ok Sir
Next time
We will be in respect
Can anyone explain me this?
There are ways in which you can use a VPS to host your bot 24/7 without downtime, it's basically bot hosting
OH I understand
In 1 second I thought its VPN link hehe
It'll be running on a private server, so you don't have to locally host the bot on your device
ohk
VPN = Virtual Private Network
VPS = Virtual Private Server
thanks
Different things
yes bro I know
I just said in 1 second
ok thanks bro
๐
ruh roh
do these places support stuff like json files to store data
nun big he didnโt say nun , i didnโt want it to get br a huge problem in the server
If it is being hosted on the cloud, yes, databases and JSON's will work
bro May i tell u something
dont tell anyone shhh
Sure
that eivl's pfp look scary
I agree
Everytime I come to this server his name is in top and its make me scary
also He look like Demon
You rite
Lol
same issue tho, imma repost it
def get_emojis(self, s_query):
#here are some codes that will maka a list
return final_list
@commands.command()
@commands.has_permissions(manage_emojis = True)
@commands.bot_has_permissions(manage_emojis = True)
async def search(self, ctx, *,name: str):
name.replace(" ", "+")
el = get_emojis(name)
await ctx.send(el)```
so when i invoke the command it says `get_emojis` is not defined. why am i getting this error
self.get_emojis
Inside a script which uses concurrency, yeah a bad idea, in your case too
it causes blocking
what is an alt to this
aiohttp
i just tried it with requests and it worked but i guess if any exception is raised it will cause the bot to shutdown , r8?
No, but it will block the event loop until the operation is complete, so yeah chances of a shutdown exist, more read here
!blocking
Why do we need asynchronous programming?
Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you do not use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming.
What is asynchronous programming?
An asynchronous program utilises the async and await keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. Any code within an async context manager or function marked with the await keyword indicates to Python, that whilst this operation is being completed, it can do something else. For example:
import discord
# Bunch of bot code
async def ping(ctx):
await ctx.send("Pong!")
What does the term "blocking" mean?
A blocking operation is wherever you do something without awaiting it. This tells Python that this step must be completed before it can do anything else. Common examples of blocking operations, as simple as they may seem, include: outputting text, adding two numbers and appending an item onto a list. Most common Python libraries have an asynchronous version available to use in asynchronous contexts.
async libraries
The standard async library - asyncio
Asynchronous web requests - aiohttp
Talking to PostgreSQL asynchronously - asyncpg
MongoDB interactions asynchronously - motor
Check out this list for even more!
from discord.ext import comands
bot = commands.Bot(command_prefix="!")
@bot.command(name="hello")
async def hello_world(ctx: commands.Context):
await ctx.send("hello world")``` so this is my first lines of code but its showing error in the bot = commands., line
and in the ctx: commands.context line
from discord.ext import commands
thanks a lot, man
Decorators
A decorator is a function that modifies another function.
Consider the following example of a timer decorator:
>>> import time
>>> def timer(f):
... def inner(*args, **kwargs):
... start = time.time()
... result = f(*args, **kwargs)
... print('Time elapsed:', time.time() - start)
... return result
... return inner
...
>>> @timer
... def slow(delay=1):
... time.sleep(delay)
... return 'Finished!'
...
>>> print(slow())
Time elapsed: 1.0011568069458008
Finished!
>>> print(slow(3))
Time elapsed: 3.000307321548462
Finished!
More information:
โข Corey Schafer's video on decorators
โข Real python article
so uhh do i store my token in a .env file or .json?
:O i saw corey shafer's oop videos but only till # 2
whichever format you want, just don't share this file publicly
mkay
what do i call my .env file
token.env?
people mostly jus call it .env
ohh so no name?
Yeah
so if i like do from dotenv import .env should i do this?
!dotenv
Using .env files in Python
.env (dotenv) files are a type of file commonly used for storing application secrets and variables, for example API tokens and URLs, although they may also be used for storing other configurable values. While they are commonly used for storing secrets, at a high level their purpose is to load environment variables into a program.
Dotenv files are especially suited for storing secrets as they are a key-value store in a file, which can be easily loaded in most programming languages and ignored by version control systems like Git with a single entry in a .gitignore file.
In python you can use dotenv files with the python-dotenv module from PyPI, which can be installed with pip install python-dotenv. To use dotenv files you'll first need a file called .env, with content such as the following:
TOKEN=a00418c85bff087b49f23923efe40aa5
Next, in your main Python file, you need to load the environment variables from the dotenv file you just created:
from dotenv import load_dotenv()
load_dotenv(".env")
The variables from the file have now been loaded into your programs environment, and you can access them using os.getenv() anywhere in your program, like this:
from os import getenv
my_token = getenv("TOKEN")
For further reading about tokens and secrets, please read this explanation.
Yes
i have to type them on the import part am i right?
Not sure what you are trying to say
like should i type where the imports are or in the alst
last in the code
Follow the style guide, import in the top lines
No
Read this
alr
What lib is @unkempt canyon going to use after April 2022?
i followed it but to run the bot what do i type?
Sit back, relax, wait and see
i have a json file filed with user ids how do i dm them all ?
bot.run(TOKEN) or bot.run(my_token)?
Do what you have named your variable
okay
If it's TOKEN = getenv(...) then bot.run(TOKEN) and same for any other var name
alr
get all the ids, use map for getting a User obj from every id then just use a loop
for ID in work.json:
#stuff
``` smh like this right ?
i get this error File "bot.py", line 14, in <module> bot.run(my_token) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 723, in run return future.result() File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 702, in runner await self.start(*args, **kwargs) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 665, in start await self.login(*args, bot=bot) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 511, in login await self.http.static_login(token.strip(), bot=bot) AttributeError: 'NoneType' object has no attribute 'strip'
Something like this
seq = map(lambda u: Bot.get_user(u), your ids here)
then use a for loop and send
idk about map sry
from discord.ext import commands
from dotenv import load_dotenv
load_dotenv(".env")
from os import getenv
my_token = getenv("TOKEN")
bot = commands.Bot(command_prefix="!")
@bot.command(name="hello")
async def hello_world(ctx: commands.Context):
await ctx.send("hello world")
bot.run(my_token)``` this is my code
Time to know ;)

Sry didn't see
same error
yeah, I didn't see that there
so it should be load_dotenv(".env")?
Yeah
Guys, why does this say, 'request takes 2 positional argument but three were given
@client.command()
async def lyrics(ctx,*,name=None):
try:
if name is None:
player = music.get_player(guild_id=ctx.guild.id)
name1 = player.now_playing()
name = name1.name
async with aiohttp.request("GET", LYRICS_URL, name, headers={}) as r:
if not 200 <= r.status <= 299:
await ctx.send("No Lyrics Found")
data = await r.json()
What do i change in this ;-;
what do i do then
ig * aint needed
its a problem with aiohttp not for the *
Forgot, sry, wait
no, it's for request
because of the aiohttp.request part
yeah
it takes 2 arguements, you gave 3
which one should i remove, i was watching a tutorial ;-;
@stuck flare uhh are you sure the name of variable in env file is TOKEN?
tbh u simply gave me back the error i gave ๐
but thanx
yeah
i am in replit and i am new to the enviroment thingy so i made a .env file in that
what isnt working?
u cant
they disabled it
u have to make env variables now
wdym?
.env files dont work anymore on replit
I keep getting this error
AttributeError: module 'discord' has no attribute 'ui'
simple error, but I don't know why it shows up since my dpy is up to the latest version
breh then what do i do? json?
yes breh
๐ฉ
json?
The build on github?
or just installed from pypi
Yeah no, thats not 2.0
do you know how to download the 2.0 version? if you mind telling me tho
are you using poetry or something? you will have to modify the pyproject.toml or just in normal python -m pip install -U git+https://github.com/Rapptz/discord.py.git
No idea what is the use of poetry
Hmm just run that command
np
what is your code?
can we not edit a sent image?
!d discord.Guild.description
The guildโs description.
CAN WE NOT EDIT A SENT MESSAGE?
We can
!d discord.Message.edit
await edit(**fields)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the message.
The content must be able to be transformed into a string via `str(content)`.
Changed in version 1.3: The `suppress` keyword-only parameter was added.
But can't edit an image
ig we cant for image..
yea
Nope
can i use more than 1 event in bot.wait_for func?
(In every case)
Message.edit(embed=newembed)
kdsfksdm didnt work
You awaited it?
@frosty prairie
Why when i using minimum 1 or, this if all the time is true?
cuz "kurwo" Is True
How can i make my bot react to its own embed?
I want it to put a check and a x on the embed i just cant figure it out
@commands.command(name="ssuvote")
async def ssuvote(self,ctx):
embed = discord.Embed(title = f"SSU VOTE", description =f"Vote With the โ
mark if you plan on attending." "\n" "\n" " Vote with a โ if you can not join." "\n" "\n" "If you vote with the check you must join when ssu opens if not you will be warned!" "\n" "\n" "** If you get warned and join the Sesh then you can dm a admin to get it taken away!**")
embed.set_thumbnail(url = 'https://images-ext-2.discordapp.net/external/jftnVFITYRGaMwbf6aY7Qutqp6Q_2gA4v72nXBbpALg/%3Fsize%3D512/https/cdn.discordapp.com/icons/857793161370533938/c38dde5d462235e12a3e10a2dc789dc6.png?width=461&height=461')
await ctx.send(embed=embed)
await ctx.message.delete()
You should use any(word in message.content for word in ["kurwo", "test", "testtt"])
but is not true
hmm
Non-empty iterables are true-ish.
why?
!d discord.Message.add_reaction
await add_reaction(emoji)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Add a reaction to the message.
The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Emoji "discord.Emoji").
You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission to use this. If nobody else has reacted to the message using this emoji, the [`add_reactions`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission is required.
Thx
send() returns the Message object, just assign a var to it and await Message.add_reaction()
Because that's how this language defines truthness for iterables.
so how i can do if if not true then code not go next
im getting a add reaction is not defined?
You can think of it as the length of the iterable isn't 0 (which is False), everything non-zero is True, therefore non empty iterables are True.
I believe I already spoonfed you.
can you show me how it should look in code?
I did.
wait how
So i take the send() and add Message to it?
yes you explained for me this but i don't know how i can use it ;c
An example
msg = await ctx.send(...)
await msg.add_reaction(...)
OK so put that under ctx.send embed k
Replace it with the entire condition you wrote.
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50006): Cannot send an empty message
im guessing i out the msg= in the wrong spot
@commands.command(name="ssuvote")
async def ssuvote(self,ctx):
embed = discord.Embed(title = f"SSU VOTE", description =f"Vote With the โ
mark if you plan on attending." "\n" "\n" " Vote with a โ if you can not join." "\n" "\n" "If you vote with the check you must join when ssu opens if not you will be warned!" "\n" "\n" "** If you get warned and join the Sesh then you can dm a admin to get it taken away!**")
embed.set_thumbnail(url = 'https://images-ext-2.discordapp.net/external/jftnVFITYRGaMwbf6aY7Qutqp6Q_2gA4v72nXBbpALg/%3Fsize%3D512/https/cdn.discordapp.com/icons/857793161370533938/c38dde5d462235e12a3e10a2dc789dc6.png?width=461&height=461')
await ctx.send(embed=embed)
msg = await ctx.send()
await msg.add_reaction("โ
")
await ctx.message.delete()
yeah, you did
So put it up top with my imports?
assign it to the send() above where it is at the moment
ok so change the await ctx.send(embed=embed) to
msg = await ctx.send(embed=embed)
?
Yes
ok let me try that
Remove the one below it
@brazen raft it is good?
That's the same screenshot.
how do i get logs from audit log like in a embed with full details???
That's not what I instructed you to do...
so how i should do it? Sorry but my english is not good
!d discord.AuditLogEntry
class discord.AuditLogEntry(*, users, data, guild)```
Represents an Audit Log entry.
You retrieve these via [`Guild.audit_logs()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Guild.audit_logs "discord.Guild.audit_logs").
`x == y` Checks if two entries are equal.
`x != y` Checks if two entries are not equal.
`hash(x)` Returns the entryโs hash.
Changed in version 1.7: Audit log entries are now comparable and hashable.
if any(word in message.content for word in ["kurwo", "test", "testtt"]):
okay, thank you - i check this
example?
!d discord.Guild.audit_logs
async for ... in audit_logs(*, limit=100, before=None, after=None, oldest_first=None, user=None, action=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/stable/api.html#discord.AsyncIterator "discord.AsyncIterator") that enables receiving the guildโs audit logs.
You must have the [`view_audit_log`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.view_audit_log "discord.Permissions.view_audit_log") permission to use this.
Examples
Getting the first 100 entries:
```py
async for entry in guild.audit_logs(limit=100):
print('{0.user} did {0.action} to {0.target}'.format(entry))
```...
There
whats the difference
Guild.audit_logs() returns that object
hello,
async def sendSingleRole(ctx, role: discord.Guild.role):
is this right?
no
No
its discord.Role
discord.Role
oh okok thx, and it get the ID or the Name?
Id, name, mention
its gets with the name or id or mention
oh nice, so i can use what i prefer
Yes
thx a lot ^^
๐ ๐
Why is it NoneType, if i clearly made development channel objekt?
It's nonetype when i run the code on my raspberry
but if i run it on pc, it works
It's probably not cached
entire code:
try doing await self.client.fetch_channel(...)
oh okay
Where should I do it then?
you can use tasks
please-
!d discord.ext.tasks.loop
discord.ext.tasks.loop(*, seconds=0, minutes=0, hours=0, count=None, reconnect=True, loop=None)```
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/stable/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
?
so task, which runs only 1 time?
yes
because it can be called more than once
i want to particular id of particular name.
that stores in json like
"data": [{
"object": "egg",
"attributes": {
"id": 1,
"name": "mewo"
}
},
"object": "egg",
"attributes": {
"id": 2,
"name": "bhao"
}
}
]
i want id where name is meow. How can i do this in python?
how?
.
what do you mean "how"?
bruh
thatโs just how the discord gateway works
on_ready gets called whenever discord sends the READY event
which can happen multiple times, due to reconnections or other things
Guys, i want to make a blacklisting words command
but when i open my txt file using readlines, why does it show \n, and can i remove it?
why are you using a .txt files to save words
should i use a database?
yea duh
umm kk, thenx
Hello, someone knox how do I get a guild objet by the id ?
i want to do something like this
for i in data["data"]:
f = i["attributes"]["name"]
if f == "discord.py generic":
m = ["attributes"]["id"]
print(m)
client.get_guild(int(id here))
ok thanks
@upbeat otterhey can u help me?
ask sir
this.
i want to get id of particular name that are store in json.
umm.......i dont really much know how to use json files, am sorry
ah i see
k
how to make the name field empty in embeds?
\u200b
With my embed is there a way to change the size of the font
So that my discord invite dose not go onto the next line?
no
No
damn cus it looks bad
tysm
how to get the message content without the command?
example
test hello
bot: you said "hello"
make Embed all lowercase
you're missing a closing bracket on the line with size =
the variable name should be lowercase as per convention
Is it possible to set_image of embed in the embed constructor?
hi! so if I have this code
user = client.get_user(int(key))
and "key" is a Variable with the ID of a user, why does user = None
for role in member.roles:
await member.remove_roles(role, reason=f"{ctx.author} (ID: {ctx.author.id})")``` would this work for removing all roles from someone?
You can just await member.edit(roles=None)
One api call instead of n
can i really do that
Its probably None
It means the user isn't in the cache. You'll have to do fetch_user instead
Why have i never tried doing that.. That would clean up so much of my code
what does it mean that the user isn't in the cache
can you add a reason to it?
!d discord.Member.edit
await edit(*, reason=None, **fields)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the memberโs data.
Depending on the parameter passed, this requires different permissions listed below...
so member.edit(roles=[muted_role], reason="")
Yep
ah you can, noice
If you have perms set correctly you don't need to remove any roles
I know i know but people are dumb
is there a way to store someones previous roles asynchronously? (i dont wanna make a db table for it)
i know it wont be reboot persistent
The correct approach would be a database
or.. store their roles then remove all of them then call them back again
I knoow but my db guy isnt here rn
im still learning how to do it
Well, the correct approach would be to just make people do permissions correctly
You shouldn't be removing any roles in the first place
@bitter depot I hate to pester you but are you able to explain or is this something that I would have to research on my own
Is it possible to edit a module with a python program by converting it to txt, adding lines of code then closing it and converting it back to .py
I don't have the time to go into it, sorry
all good
But you can just fetch_user which doesn't rely on cache
That's your solution
user = bot.get_user(id) or await bot.fetch_user(id)
fetch_user not fetch
And you have to await it
so
how could I use an await
if i wanted to the username = a variable
what does the fetch method actually do
bruh he meant do await client.fetch_user(...)
after that user.name will return the username
you just use an await
do whatever you want with that
there is no special behaviour or anything
i told you
im fetching a channel and mentioning it in an embed, but if i click on it, it does not teleport me to the channel. why?
i might be using get_channel idr
hm
just stop using discord, easy fix
Any recommendation on how to make a task loop run at a specific time each day?
Ok thanks
it takes in a datetime object
so this 2021-09-13 20:54:18.761287 and 2021-09-13 20:54:12.761287 would work?
or only utc
first one is utc
if thatโs a datetime object then yeah
ok
Is it possible to update my bot code without shutting it down. And how Big bots do that?
Using git maybe?
Hey, weโre in #dev-contrib, it would be off topic for this channel
so if i do
await client.fetch_user(int(key))
then
how to i assign the username to
variable named "user"
hi, how can I detect when an image is sent & then do things with it (like post it in another channel or download it)
or maybe get the link of it
How do you access the member ID of the user that used a slash command? The solutions i've found on stack overflow are just giving me the member ID of the bot's response to the slash command.
you dont have a starter or an on_ready event i think
on_ready is not needed
on_ready is just an event that fires somewhere just before the bot is actually ready to send/receive API calls
and has a chance to be called multiple times


