await edit(*, username=..., avatar=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the current profile of the client.
Note
To upload an avatar, a [bytes-like object](https://docs.python.org/3/glossary.html#term-bytes-like-object "(in Python v3.10)") must be passed in that represents the image being uploaded. If this is done through a file then the file must be opened via `open('some_filename', 'rb')` and the [bytes-like object](https://docs.python.org/3/glossary.html#term-bytes-like-object "(in Python v3.10)") is given through the use of `fp.read()`.
The only image formats supported for uploading is JPEG and PNG.
Changed in version 2.0: The edit is no longer in-place, instead the newly edited client user is returned...
#discord-bots
1 messages · Page 1152 of 1
how is stickybot so fast 
server latency and library different don't account for how fast it is
is there a good way of creating a discord bot in python other than using discord.py
File line 28, in on_ready
await bounty_channel.send("***Resting for 5 seconds.***")
AttributeError: 'NoneType' object has no attribute 'send'
what's the problem?
Why do you have a send command in on_ready
Why not?
if the bot crashes or goes offline
and it goes back online, it does the entire thing again
yeah that's ok
Sure. Hikari, disnake, pycord, and probably more that I can't think off the top of my head
Do you have any specific errors that I can help with?
Would you recommend any of them for simple bot development (i also need voice support)
discord.py, but why did you mention anything other than that?
Traceback (most recent call last):
File "C:\Users\IT Solutions\AppData\Roaming\Python\Python37\site-packages\discord\ext\tasks\__init__.py", line 101, in _loop
await self.coro(*args, **kwargs)
File "c:/Users/IT Solutions/Desktop/myprojects/bounty/bountybot.py", line 29, in on_ready
await bounty_channel.send("***Resting for 5 seconds.***")
AttributeError: 'NoneType' object has no attribute 'send'
any known fix for this?
@client.command(aliases=["nickbot"])
@commands.has_permissions(manage_nicknames=True)
async def nicknamebot(ctx):
await discord.ClientUser.edit(username=ctx.message)
await ctx.reply("Changed username to " + ctx.message)
```It does nothing, it maybe loops on the first await but what did I index wrong?
Follow this documentation right here: https://discord.com/developers/docs/topics/oauth2 and I'll help with any errors you're having
Discord.py cannot read data from voice channels as far as i'm concerned
Ah that's what you're looking for
Well... I believe discord.js does let you read data from voice channels
The problem is it's not documented all that well even in the official API docs
and now after a long break i gotta get back to it and learn using slash commands and other new stuff
I'm not sure I understand
i don't know js so i'd have to learn a whole new language
@signal canopy if you're looking to recieve voice data, you're in a bit of a pickle
yeah i kinda noticed
Even in discord's official documentation there's almost nothing about that
too bad
yup
bounties = ["2887966607","700032621","1858461594"]
bounty_channel = client.get_channel(998183276084744232)
@tasks.loop(seconds=10.0)
async def on_ready():
for bounty in bounties:
req = requests.get(f"https://api.roblox.com//users/{bounty}").text
list = json.loads(req)
username = list["Username"]
print(username)
r = requests.get(f"https://api.roblox.com/users/{bounty}/onlinestatus/").text
check = json.loads(r)
status = check["LastLocation"]
if status == "Playing":
embed=discord.Embed(title="User Profile", url=f"https://roblox.com/users/{bounty}/profile", description=f"{username} is playing a game go check if it's da hood or not", color=0x7410b7)
embed.set_author(name=f"{username}", url=f"https://www.roblox.com/headshot-thumbnail/image?userId={bounty}&width=60&height=60&format=png", icon_url=f"https://www.roblox.com/headshot-thumbnail/image?userId={bounty}&width=60&height=60&format=png")
embed.set_thumbnail(url=f"https://www.roblox.com/headshot-thumbnail/image?userId={bounty}&width=60&height=60&format=png")
await bounty_channel.send(embed=embed)
await bounty_channel.send("***Resting for 5 seconds.***")
on_ready.start()
error :
fireisawfreind
FancySpirits
FDJDFHJIGJD
Unhandled exception in internal background task 'on_ready'.
Traceback (most recent call last):
File "C:\Users\IT Solutions\AppData\Roaming\Python\Python37\site-packages\discord\ext\tasks\__init__.py", line 101, in _loop
await self.coro(*args, **kwargs)
File "c:/Users/IT Solutions/Desktop/myprojects/bounty/bountybot.py", line 29, in on_ready
await bounty_channel.send("***Resting for 5 seconds.***")
AttributeError: 'NoneType' object has no attribute 'send'
Finishes all the tables and when it gets to the time were it sends to the "bounty_channel" it breaks
sorry for the flood.
Yay! Found something! https://guide.pycord.dev/voice/receiving
Pycord tries to keep the recording of audio as simple and easy as possible, to keep making Discord
thanks a lot
@sick birch
Anyone able to help?
The first step is to set up a route handler that can get the code, which you'll exchange for the user's access token
Great, didn't know pycord supported that
that channel is not the bot's cache, so get_channel returns None
so put that part of code in an async function and use fetch_channel which is a coro so you will have to await it
Hard to tell without knowing what technologies you're using
I can't make it for you
I can tell you generally what to do, and help out with any specific errors you're having
and im gonna be learning python and i went to discord.py and it said to put this command: py -3 -m pip install -U discord.py to download the discord language and when i do it, it gives me all sort of errors what should i do
That still doesn't really tell me anything. HTML, CSS, and JS files on their own are only good for static content, which is not good enough for making a log in with discord functionality
@tasks.loop(seconds=10.0)
async def on_ready():
bounty_channel = client.fetch_channel(998183276084744232)
? like that
what errors are you getting?
await client.fetch...
We can help fix the errors, but as a side note getting started with discord.py while being new to coding is probably not the best of ideas
What should i do to start, what would be a way to learn
The task callback name can be anything but maybe let's call it something other than on_ready just so we don't confuse ourselves
!resources - hopefully you'll find something in here helpful
Resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
can I put that in a variable?
yes you can
thanks it works fine now
its recommened you first try to use get_channel then check if it is None, if it is then you fetch_channel
They host their bot in discord data center's basement 100%
!Pip hikari
- You need to close file after writing stuff to it, use
with open(...) as fconstruction - Try specifying encoding when opening file with
encodingkwarg:
open("file.txt", "a", encoding="utf-8")```
Pfp 😳
So i just started coding and it is giving me this error Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
#python-discussion good for you
thx
ok i check it
the error seems self explanatory?
ermmm dont understand 😅
I mean it literally tells you lol
go into your windows settings > manage app execution aliases and disable the python shortcut
fixed it
# imports:
from math import perm
import random
import discord
from discord.ext import commands
from discord.utils import get
@client.command()
@commands.has_permissions(manage_messages=True)
async def mute(ctx, member: discord.Member):
perms = discord.Permissions(permissions=65536) # permissions level for muted members
if get(ctx.guild.roles, name="Muted | OhMan Bot"):
print("Mute role exists")
else:
await ctx.guild.create_role(name="Muted | OhMan Bot", permissions=perms, colour=discord.Colour(0x0062ff))
user = ctx.message.author
role = get(user.server.roles, name="Muted | OhMan Bot")
await member.add_roles(role)
```How would I assign a role to a user thats mentioned?
@bot.command()
async def test(ctx,*,text):
emojis = []
for s in text.lower:
if s.isdemical():
num2emo = {'0':'zero','1':'one','2':'two',
'3':'three','4':'four','5':'five',
'6':'six','7':'seven','8':'eight','9':'nine'}
emojis.append(f':{num2emo.get(s)}:')
elif s.isalpha():
emojis.append(f':regionalindicator{s}:')
else:
emojis.append(s)
await ctx.send(''.join(emojis))
i have this problem
i tried to recreate the emojify command and i get this message
File "main.py", line 190
elif s.isalpha():
^
SyntaxError: invalid syntax
trying it:
@bot.command()
async def test(ctx,*,text):
emojis = []
for s in text.lower:
if s.isdemical():
num2emo = {'0':'zero','1':'one','2':'two',
'3':'three','4':'four','5':'five',
'6':'six','7':'seven','8':'eight','9':'nine'}
emojis.append(f':{num2emo.get(s)}:')
elif s.isalpha():
emojis.append(f':regionalindicator{s}:')
else:
emojis.append(s)
await ctx.send(''.join(emojis))```
There is a problem with the lines of code, I have fixed it.
There is a erorr
strftime, I have no idea why.
thank you so much
if i were u just make advantage of discord timeout feature anyways i gtg
I forgot that that exists. thanks
wait now it says this
from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'builtin_function_or_method' object is not iterable
hey
how to get a user mention in a specific channel?
for example when someone sends: "hello @rapid falcon"
i want the bot to get the mention @rapid falcon from the message
is there a way to do this? ping when replying
text.lower()
text.lower(): or text.lower()
@bot.command()
async def test(ctx,*,text):
emojis = []
for s in text.lower:
if s.isdemical():
num2emo = {'0':'zero','1':'one','2':'two',
'3':'three','4':'four','5':'five',
'6':'six','7':'seven','8':'eight','9':'nine'}
emojis.append(f':{num2emo.get(s)}:')
elif s.isalpha():
emojis.append(f':regionalindicator{s}:')
else:
emojis.append(s)
await ctx.send(''.join(emojis))```
Trying its working.
await ctx.send(''.join(emojis)) was in the wrong row.
the lower is still wrong
!e print("AAAA".lower) # wrong
print("AAAA".lower()) # correct
@slate swan :white_check_mark: Your eval job has completed with return code 0.
001 | <built-in method lower of str object at 0x7f73946ab2b0>
002 | aaaa
im new to coding sorry
Yes, but also what I wrote down
indeed
it doesnt work
If you write the text in capital letters it will not work,
You need to specify if text.isupper(): text = text.lower()
from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'str' object has no attribute 'isdemical'
its isnumeric
so i replace isdemical with isnumeric?
yes
Maybe, but I made a command in the style you prepare and there is no need to replace.
!e ```py
print("69".isdecimal())
what python version you are on?
run python -V -V in your terminal
😅 you/or they actually mis-spelt decimal with demical
b o t are not numbers...
im using replit
its working with numbers but i want to do this work with letters too
I think it's regional_indicator_x and not regionalindicatorx
Uhh okay so not bots related but discord, how do discord authenticates the users while they log in from typical login page? Like is it a type of grant from oauth just like for bots or they just give jwt tokens to user?
emojis.append(f':regional_indicator_x :') i did this
oh ok leme try this again
And you probably want to remove the x and put the actual letter instead
yea
And I would check the length of the final message before sending, can easily get over the character limit
Everyone is confusing your mind, it's an easy thing and does not need everything they have written for you.
emojis = []
for s in text.lower():
if s.isdecimal():
num2emo = {"0": "zero", "1":"one", "2": "two", "3":"three", "4": "four", "5":"five", "6":"six", "7":"seven", "8":"eight", "9":"nine"}
emojis.append(f":{num2emo.get(s)}:")
elif s.isalpha():
emojis.append(f":regional_indicator_{s}:")
else:
emojis.append(s)
await ctx.send(' '.join(emojis))```
try
um ok
Delete last 100 messages from a specific channel ?
emojis.append(f":{num2emo.get(s)}:")
emojis.append(f":regional_indicator_{num2emo.get(s)}:")
No bro.
!d discord.TextChannel.purge
await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=None, bulk=True, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.
You must have the [`manage_messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to delete messages even if they are your own. The [`read_message_history`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission is also needed to retrieve message history.
Changed in version 2.0: The `reason` keyword-only parameter was added.
Examples
Deleting bot’s messages...
f":{num2emo.get(s)}:" will get you :one: like this, is that the emoji?
nvm, youre correct
Is there a way to make voice channel private with command which channel has been created on another event?
await voice.set_permissions(ctx.guild.default_role, view_channel=False, connect=False)
if voice != None:``` `AttributeError: 'VoiceState' object has no attribute 'set_permissions'`
voice.channel.set_permissions
also you should be checking if the voice is not None before changing perms
thank you so much it worked
would be a blessing if someone could help me
you need to update to 2.0
poetry add git+https://github.com/Rapptz/discord.py
sorry me again if i sent a simple message it will work like the command !say how do i remove that
same thing happens in the bot dank memer example: if you say pls emojify - it will sent -
There is no emoji for the text you wrote
can anyone make a bot that converts youtube to mp4s through discord 😭
or sent a code that works for that command
yea.
eh it's not that hard to download a youtube video
there are literally librairies for it
i know but its faster
though might be against rule 5 as it's similar to music bots
not really
How to install discord.py from github using pip ?
behind the scenes, yes.
i mean could you please help me? 😭
what server is this?
there is cmd command if you can post it
pip --- ?
Just look at it yourself?
look @ dms
oh ok
so you don't know it
It's literally on the link
Take the 5 seconds to look at it yourself
You don't get everything given in life
I know, just kidding with you
overwrite = ctx.channel.overwrites_for(member)
AttributeError: 'NoneType' object has no attribute 'id'
i dont understand why i get this error
i think there is more detail than this
member is None
they probably use some API or some kind of mapping which gets matching letters from other fonts
!e ```py
m = {
"a": "𝓪",
"b": "𝓫",
"c": "𝓬"
}
user_input = "bac"
do replacement stuff
loop through the *, arg the user inputted
check the userinput against the dictionary
replace characters with the dict value
could anyone help me make a youtube to discord mp4 converter command?
Using dict is gonna make it very very big, you could just make a full string representing the alphabet, but in that font, E.g ```py
replacement = "".join(["𝓪𝓫𝓬"[ord(char) % 32 - 1] for char in user_input])
Although, you would probably need to secure the index part more, incase of index error
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)
Not exactly YTDL but the point applies
!src d
Command: docs
Look up documentation for Python symbols.
Source Code
bot/exts/info/doc/_cog.py:307
go look at it yourself 🙂
They did web scraping ig
yep they did web scraping
https://github.com/python-discord/bot/tree/main/bot/exts/info/doc
there's uh, html, markdown, parser
Hello, no errors but when I send the command !sregler the bot just removes the command but does not send anything
import discord
from discord.ext import commands
import asyncio
import random
TOKEN = "Token"
client = commands.Bot(command_prefix ="!")
@client.command()
@commands.has_role("regleraccess")
async def sregler(ctx,):
await ctx.message.delete()
embed = discord.Embed(title = "Gene's Regler", description = "Server Regler", color = 0x00FFFF)
embed.add_field(name="§1 Man må ikke tigge om ting")
embed.add_field(name="§2 Auto Clikker/Autosell er ikke tilladt")
embed.add_field(name="§3 Racisme/nazisme tolerere vi ikke")
embed.add_field(name="§4 Scamming er ikkee tilladt")
embed.add_field(name="§5 Raiding er ikke tilladt")
embed.add_field(name="§6 Reklame om andre servers er strengt forbudt")
embed.add_field(name="§7 Max 2 account per ip")
embed.add_field(name="§8 Alle former af hack er ikke tilladt")
embed.add_field(name="§9 Kun Labymod, Lunar, Feather og badlion er tilladt")
embed.add_field(name="§10 Staff ord er lov")
embed.add_field(name="§11 Man må kun vinde 1 af baltop pladserne selvom man er i et team eller sig selv")
embed.add_field(name="§12 Man må ikke booste andre udenfor sit team op på baltop")
embed.add_field(name="§13 Støvsugning er ikke tilladt")
embed.add_field(name="§14 Bots er ikke tilladt")
embed.add_field(name="§15 Greif er ikke tilladt")
embed.add_field(name="§16 Finder man en bug skal man oprette en ticket")
embed.add_field(name="§17 Man må ikke sælge ting på serveren for emeralder")
embed.add_field(name="§18 Brug dit sunde fornuft")
embed.add_field(name="")
embed.add_field(name="Vi skriver ud i #dev-log hvis det kommer nye regler")
embed.add_field(name="")
embed.add_field(name="© Superawesome")
client.run(TOKEN)```
All embed fields need a non empty name and value
Sorry I don't understand what you mean with value
embed.add_field(name="...", value="...")
!d discord.Embed
class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") for you.
Changed in version 2.0: `Embed.Empty` has been removed in favour of `None`.
Okey thanks but what should I write in value?
Okey thanks
@commands.has_role("mod")
async def addrole(ctx):
user = ctx.message.author
role = discord.utils.get(user.server.roles, name="Test")
await bot.add_roles(user, role)```
Anyone know the issue I cant use proper indentation due to my device.
What?
Your server needs 2 discord py bots?
I want to linking the other file to main
like all in 1
so is it 2 bots or 1 bot plsu an extension?
yes like that
i want to make music and moderator in 1 bot
sry iam newbie
Use cogs
can i get that code
what ver of dpy are u using
3.9
1.7.3
ok
make a new folder in the same directory called cogs
and put the extension into it
now in the main file, somewhere under your on_ready function, do bot.load_extension('cogs.filename without the .py at the end')
then in your cog file, setup a class: class className(commands.Cog):
then with each command instead of the @bot.commands decorator, use @commands.command
at the bottom of the file, do py def setup(bot): bot.add_cog(className(bot))
classname = file name right
no
oh
I wouldn't recommend doing that in on_ready
it can be anything, but usually something like commands
true
ok
yeah that works too
for example: ```py
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix ='>', help_command=None, case_insensitive=True, intents=intents)
load_dotenv()
TOKEN = os.getenv("UNSEEBOT_TOKEN")
bot.load_extension("cogs.meme")
bot.load_extension("cogs.tts")
bot.load_extension("cogs.tictactoe")
and in each command, there should be a self parameter before the ctx
if i use client=command.Bot should i change it?
rename client to bot
yeah that is incorrect variable nameing but it won't break the bot
so i rename bot to client right?
for example: py @commands.command async def commandName(self, ctx)
no client to bot
not bot to client
keep it ?
change the client to bot
but otherwisw keep it
!paste
here is an example of a cog
tysm
Hi I was wondering if anyone can help me. I am trying to make my discord bot send the contents of a .txt file. Can someone please help
this is for discord.py
class discord.File(fp, filename=None, *, spoiler=..., description=None)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/latest/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/latest/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")s.
can someone help me to do a inventory bot? or tell me how i can do
How do I load all of my extensions at once in 2.0?
me when for loop exists
Anyone know how you send messages in threads w/ pycord
you cant do that....?
that would be cool ig a method that takes a list of paths that are strings ofc, it would be kinda redundant but i can see the usage of it
You can. I figured out how
you cant load them all at once afaik, you would have a for loop which that isnt instant thats one after the other
reasons why I love hikari
even disnake has it but I dont like disnake cause no
imagine still making bots🤨
totally not me
i moved on to networking
I moved on to overworking
anyways im going to read my course now bye
bye kid
dont call me a kid
if im a child i dont want to know what my grandma classifies as
tweenager
guess youre a child like me
no im older
doesnt look like it🧍
ok.
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.

class Main(commands.Bot):
def __init__(self):
super().__init__(
command_prefix = ".",
intents = discord.Intents.all(),
application_id=996142024430452826) # Client ID
async def on_ready(self):
await bot.change_presence(activity=discord.Activity(
type=discord.ActivityType.watching,
name="the Nebula Network"))
print(f'{self.user} has initialized.')
async def setup_hook(self):
self.initial_extensions = [
'cogs.core',
'cogs.suggestion',
'cogs.invite',
'cogs.group',
'cogs.ping',]
for ext in self.initial_extensions:
await self.load_extension(ext)
print('Works')
# Guild ID
await bot.tree.sync(guild=discord.Object(id=848367847670284298))
My extensions aren't loading anymore for some reason if anyone knows why
on_ready works tho
setup_hook doesnt even tho it worked before?
what is even bot? its pretty messy code ngl
well I aint a professional so
idk what you mean what is bot
bot = Main()
i thought it was pretty clean 🥲
whats messy about it
why would you call your subclass Main? and where is it defined in the class???
Well your bots name?
import discord
from discord.ext import commands
class Main(commands.Bot):
def __init__(self):
super().__init__(
command_prefix = ".",
intents = discord.Intents.all(),
application_id=996142024430452826) # Client ID
async def on_ready(self):
await bot.change_presence(activity=discord.Activity(
type=discord.ActivityType.watching,
name="the Nebula Network"))
print(f'{self.user} has initialized.')
async def setup_hook(self):
self.initial_extensions = [
'cogs.core',
'cogs.suggestion',
'cogs.invite',
'cogs.group',
'cogs.ping',]
for ext in self.initial_extensions:
await self.load_extension(ext)
print('Works')
# Guild ID
await bot.tree.sync(guild=discord.Object(id=848367847670284298))
bot = Main()
#bot.run(os.environ["DISCORD_TOKEN"])
is how I have it setup
if that extra bit adds anything
inside your class remove bot and pass self
you want me to remove commands.Bot?
oh me oh my, why so complicated
is it that complicated? 😭
self would be your instance of your class which is a subclass of commands.Bot so self would be the only thing that has the change_presence method no?
more like messy and unreadable

I read this as basically replacing bot.change_presence to self.change_presence instead
yes
it makes it work
because bot is undefined in your class
oooh
oh and the method to syncing your slash commands if you didnt know
well I have a side question right
await bot.tree.sync(guild=discord.Object(id=848367847670284298))
What does getting this guild id actually do because I honestly am not sure and I don't know how you're suppose to do it where it sets the ID automatically so you dont have to manuallychange it for whatever server its in or if thats suppose to represent the main server or what
Okay so I shouldnt need it basically
is what im checking
I would prefer things be universal
What method are you talking about?
then dont pass any guild id
checked docs and to sync slash commands globally you would use that methkd with no guild id
What ab this though? @slate swan it still doesnt recognize slash commands
or do the setup hook
so how do I fix it
show code
class Main(commands.Bot):
def __init__(self):
super().__init__(
command_prefix = ".",
intents = discord.Intents.all(),
application_id=996142024430452826) # Client ID
async def on_ready(self):
await self.change_presence(activity=discord.Activity(
type=discord.ActivityType.watching,
name="the Nebula Network"))
print(f'{self.user} has initialized.')
async def setup_hook(self):
self.initial_extensions = [
'cogs.core',
'cogs.suggestion',
'cogs.invite',
'cogs.group',
'cogs.ping',]
for ext in self.initial_extensions:
await self.load_extension(ext)
print('Works')
bot = Main()
bot.run(os.environ["DISCORD_TOKEN"])
It doesn't print
basically so nothing loads
you need to sync your commands and print something when setup_hook gets triggered
How do you sync commands
you literally just did it here, just dont pass any arguments
did you checked if setup_hook gets fired?
it is not being fired and the have the sync cmd inside that hook
Because it has to be inside a async function
well did you put a print statement after the function signature?
and youre running your bot right?
It prints after the function if that's what you're referring to
why wouldnt it unless it's 1.7.3
It runs on_ready
thats whatim tryna figure out 
its not firing
try printing something before you define initial exts
he already did
The only thing that prints is has initialized and after
maybe your cogs dirs are incorrect and errors arent being raised?
just dont make a bot at this point 
i see no issue tbh
I have a on_command_error for each cog w/ raise error
and it doesn't give me any 🥲
actuallynvm I see what ur saying
but i wouldnt think so
but what do i know yk
remove all your command errors
and just have one in your class you dont really need multiples btw
and what is self.tree?
shouldnt you define it? or something
oh theres a self.sync_commands method
shouldnt you define it or something idk if it gets set idk havent worked with dpy2.0
how do i find it 😭
hex?
find what?
arent hexcodes 8 chars for colors?
uh yeah it should be 8 chars
use 0x as the prefix
you need to add the 0x prefix
it converts it to a hexcode, but its actually a int type😳
different bases is the different between numbers and hexcodes right?
IM SO CONFUSED SORRY
add 0x to the start
0xF3A5F4 it should be
ohh
def check(m: discord.Message):
return m.author.id == ctx.author.id and m.channel.id == ctx.channel.id
msg2 = await self.bot.wait_for('message', check=check, timeout = 60.0)
await ctx.send(msg2.content)```
I have this simple code and I was wondering how I could get a memberObject from a user that is mentioned inside of the message content, I remember there was some way but I cannot seem to find it on google or stack to help me
Ohhh its the msg2 var with a .mentions[] i'm slow asf
?
hii can someone help me find where to put the embed color
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
can you use pip freeze in your command line and paste the output in https://mystb.in
add me real quick 😭

Sorry I just turned it off for the night I’ll do that tomorrow
notice that embed = discord.Embed(... line's indentation did not match with the other lines
And you should change embed.color instead of creating a new Embed instance
could you add me by chance
^
uhm idk what ur doing but id just put color in the original place u defined ur embed
its already in the constructor?
the picture is hurting my eyes i have problems
yeah the indents are going brrrrrr
fr
how do I load Jishaku with slashbot?
bot.load_extension('jishaku') is not working
and how do I mention aliases in @bot.hybrid_command(...,with_app_command=True)?
Because the function doesn't seem to take aliases as a parameter
load_extension now needs to be awaited
so await bot.load_extension('jishaku')?
!pip jishaku it's a library
A discord.py extension including useful tools for bot development and debugging.
but how does that even work
yess
can I put it under setup_hook?
Yeah sure
nice. that problem is now solved
@slate swan do you know about this one?
I think you can use the aliases kwarg in hybrid_commands decorator
!d discord.ext.commands.Bot.hybrid_command
hybrid_command(name=..., with_app_command=True, *args, **kwargs)```
A shortcut decorator that invokes [`hybrid_command()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.hybrid_command "discord.ext.commands.hybrid_command") and adds it to the internal command list via [`add_command()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.add_command "discord.ext.commands.Bot.add_command").
Yeah it should work ( but only for prefix commands )
so even if I mention aliases, it wont work for slash commands
slash commands don't have aliases so
did they change member.avatar_url to something else?
member.avatar.url
bruh
member.avatar returns a discord.Asset object which has a url property
oh
AttributeError: module 'discord' has no attribute 'ui'
on_message function
async def on_message(self,message):
view = discord.ui.View()
style = discord.ButtonStyle.gray
item = discord.ui.Button(style=style, label="Atest", url="https://docs.google.com/")
view.add_item(item=item)
```
install 2.0 dpy
no
pip install --upgrade discord.py i tried this
can you help @slate swan
RuntimeWarning: coroutine 'BotBase.load_extension' was never awaited
client.load_extension(extension)
and await can only work inside async functions
if __name__ == '__main__':
for extension in coggs:
client.load_extension(extension)
can someone help me out, i just switched to dpy 2.0
Make a async function
can someone help me make a cmd that gives your members a role when ever they represent your server in their status
raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'Cogs.mycogg' raised an error: TypeError: object NoneType can't be used in 'await' expression``` now it's throwing me this error without line number or anything
no bruh
@robust fulcrum
make it yourself
?
.
dude please just shut up
oh
👍
Ig we can't

!d discord.Member.activity
property activity```
Returns the primary activity the user is currently doing. Could be `None` if no activity is being done.
Note
Due to a Discord API limitation, this may be `None` if the user is listening to a song on Spotify with a title longer than 128 characters. See [GH-1738](https://github.com/Rapptz/discord.py/issues/1738) for more information.
Note
A user may have multiple activities, these can be accessed under [`activities`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member.activities "discord.Member.activities").
you need presence intents for this
Do status and activity Mean same? (I just asking)
i guess discordpy 2.0 is not for me
status is the online/offline/dnd thing
Nope, status is online, offline and so goes on
what's the issue with it
activity are the background applications connected with discord
i am having troubles setting up cogs
hi
why he have staus "be right"
activity = discord.Game(name="Bloons TD battles", type=3)
await client.change_presence(status=discord.Status.idle, activity=activity)```
i fixed this issue by doing
async def setup(client):
await client.add_cog(FivemStatus(client))
``` but it still doesn't work 😦
please tag me if you find any fix
In which file you typing this?
Means in your cog or main file
in my main file there is a on_ready function which await client.loadextention all cogs and in cogs there a async def setup function
Why using setup then?
@company.sub_command(
name="create",
description="Create your company"
)
async def create(self, inter: disnake.ApplicationCommandInteraction):
await inter.response.defer()
company = db.Company(owner=inter.author)
await company.exists()
if company.exists:
print("YES")
await self.bot.send(inter, "Company already exists!", disnake.Color.red(), edit=True)
else:
print("NO")
await self.bot.send(inter, "Company created! Manage your company using /company manage", edit=True)
command
async def send(self, inter: disnake.ApplicationCommandInteraction, msg, clr=None, followup=False, edit=False):
emb = disnake.Embed(description=msg, color = clr or self.color)
if edit:
return await inter.edit_original_message(embed=emb)
elif followup:
return await inter.followup(embed=emb)
else:
return await inter.send(embed=emb)
self.bot.send
the problem is, when i run the command
it shows "Bot is thinking..." for like 1 second
then interaction failed
but it does print "YES"
and it doesn't send anything
help?i tried removing defer() no change
i also tried removing edit=True
for cog in cogs:
try:
await bot.load_extension(cog)
print(cog + " was loaded.")
Try this
@client.event
async def on_ready():
coggs = []
for filename in os.listdir('./Cogs'):
if filename.endswith('.py'):
coggs.append("Cogs." + filename[:-3])
for cog in coggs:
await client.load_extension(cog)
``` main file
```py
async def setup(client):
await client.add_cog(FivemStatus(client))``` cog
The on ready is confusing me
I really confused
it loads all the cogs in the cogs folder
.'
was there a change in bot.logout() in 2.0?
Can you show error again?
it's bot.close
it was not showing any after making it async def but before it was
raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'Cogs.mycogg' raised an error: TypeError: object NoneType can't be used in 'await' expression```
now it's not showing any error
or working
show full tb
why he have staus "be right back"
activity = discord.Game(name="Bloons TD battles", type=3)
await client.change_presence(status=discord.Status.idle, activity=activity)```
what
there's no status
uhh
u see this moon i want green circle XD
moon....?
uhhh
Show the cogs file
He mean the online status
activity = discord.Game(name="Bloons TD battles", type=3)
await client.change_presence(status=discord.Status.online, activity=activity)
for a sec i read that as i want the moon green💀
😂
Pink moon
store the number the user types and see if its the same as the previous one, you will have to store it outside the scope of the function for it to work properly
do pfp = pfp.convert('RGB') before saving it
thats one of the most dumb image manipulation in a command i have ever seen
best way would be to save as png
bro send the code as text
imagine two people using the command at the same time
pil is sync
and u are saving a file locally
then sending
first of all, have only one on_message event
then make my_variable a bot variable like bot.my_variable = 0 ( its not the best option )
then you check the message content and see if the message content is bot.my_variable + 1
def process(data):
wanted = Image.open("distract.PNG").convert('RGBA')
pfp = Image.open(data).convert('RGBA').resize((300, 285), Image.LANCZOS)
wanted.paste(pfp, (74, 190), pfp)
buffer = BytesIO()
wanted.save(buffer, "PNG", quality=95)
buffer.seek(0)
return buffer
@bot.slash_command(description="Wanted Image Manipulation")
async def distract(ctx, user: discord.Member = None):
if not user:
user = ctx.author
data = BytesIO(await user.display_avatar.read())
img = await bot.loop.run_in_executor(None, process, data)
await ctx.respond(file=discord.File(img, "profile.png"))
message.channel.id == "997957555194171462" .id returns int so this condition will always be false
remove the "
in all of the ifs not just that condition
@slate swan use this
no? why would you do that?
Hi im back from school 👋
👋
where is ur umbrella?
also do message.content != bot.my_variable instead of ==
👋
and if you have this first
if message.channel.id != 997957555194171462:
return
you dont have to check the id in every if
👋
that wont work anyway
right, copied old msg
yes sparky is helping to make this channel ot again
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
str == int is it possible?
😳 u got me
Yes
Is there any user mentioned event?
!e
str = 1
int = 1
print(str==int)
it will work, i just copied the old message 😅
@slate swan :white_check_mark: Your eval job has completed with return code 0.
True
See
eh idk just check the docs
Pls tell anyone
¯\_(ツ)_/¯
do that in ur code
👌
Is there any user mentioned event?
Don't u understand a joke 😔
pip install discord.py==1.7.3
thanks
check on message
I asked for mentukned not message
thanks
whats a trigger command?
!d discord.Member.mentioned_in
mentioned_in(message)```
Checks if the member is mentioned in the specified message.
Ye this
U can add a check in on_message else no
send ur code as text
as you wish
Like this?
if mentioned_in(message):
await ctx.send
and bot var int it will never be equal
are u writing english essay?
capital letter at start of sentence
My keyboard did
mentioned_in is a method of member class
because you did message.content is a str not int
so comparison with int returns false
wait a sec lemme rewrite it
Oh
@bot.event
async def mentioned_in(message):
No
Like member.mentioned_in(message)
raise errors.ExtensionAlreadyLoaded(name)
discord.ext.commands.errors.ExtensionAlreadyLoaded: Extension 'Cogs.fivemstatus' is already loaded.``` but it's not loaded
At event?
bot.my_variable = 275
@bot.event
async def on_message(message: discord.Message) -> None:
if message.channel.id == 997957555194171462:
if message.content != str(bot.my_variable+1):
return await message.delete()
else:
bot.my_variable += 1
please someone help
setup hook?
!e
from ctypes import*
py_object.from_address(id(False)+8).value=type('',(),{'__repr__':lambda x:'True'})
print(int == str)
print(int is str)
@paper sluice :white_check_mark: Your eval job has completed with return code 0.
001 | True
002 | True
ok wonderful
u will go down in history with newton and einstein
store it somewhere
like a json or something
search google
┬─┬ ノ( ゜-゜ノ)
or just use a txt file
#bot-commands message
(╯°□°)╯︵ ┻━┻
stop before mods flip this channel :p
You want to send a custom emoji?
it generates a GIF with the user's avatar and the "triggered" overlay
like that ^^
What's the purpose of that
making gif with pil is a headache
it should be ez to make tho
all u need to do is change the image paste position
mm yeah
eh i can give u a rough idea how to
first u paste and make the triggered image
bro do one thing u see pil docs for image manipulation
its ez if u dont understand ask
with open("count.txt") as read_file:
data = read_file.read()
bot.my_variable = int(data)
@bot.event
async def on_message(message: discord.Message) -> None:
if message.channel.id == 997957555194171462:
if message.content != str(bot.my_variable+1):
return await message.delete()
else:
bot.my_variable += 1
@bot.command()
async def save_num(ctx):
with open('count.txt', 'w') as f:
f.write(bot.my_variable)
await ctx.send("saved")
ew
might as well use a json file 
for one num? use txt only then
Is it possible to add a docstring to a discord bot discord.py event?
Also, what's the difference between an event and a command
Ok so how to retreive the docstring?
an event is triggered when a certain condition is met, a command is manually invoked
Huh-?
Could you give me an example
ashley explain in human language lmao
Yes, human language
whart
I'd dew it using function_name.__doc__ cause yes
Okay
how to get owner of a guild? ctx.guild.owner.mention doesn't work for me
Declaring Docstrings: The docstrings are declared using ”’triple single quotes”’ or “””triple double quotes””” just below the class, method or function declaration. All functions should have a docstring.
Accessing Docstrings: The docstrings can be accessed using the __doc__ method of the object or using the help function.
GeeksforGeeks
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
member intents
intents = discord.Intents.default()
bot = commands.Bot(command_prefix="-", intents=intents)
u dont
and also in dev portal
intents.member = True
ok
i'll try
Traceback (most recent call last):
File "/Users/sgolis/PycharmProjects/Discord_Bot/main.py", line 12, in <module>
intents.member = True
AttributeError: 'Intents' object has no attribute 'member'
error
oh
intents.members
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix=prefix, intents=intents)
import discord
from discord.ext import commands
intents = discord.Intents.default()
intents.message_content = True
client = commands.Bot(command_prefix=".", intents=intents)
#Normal commands
@client.command()
async def f2c(ctx, fahrenheit:int):
"""This function converts Fahrenheit to Centigrade."""
await ctx.reply(f"{fahrenheit} Degrees Fahrenheit is {(fahrenheit-32)*5/9} Degrees Centigrade", mention_author = True)
@client.command()
async def c2f(ctx, celsius:int):
await ctx.reply(f"{celsius} Degrees Centigrade is {(celsius*5/9) + 32} Degrees Fahrenheit")
@client.command()
async def km2m(ctx, km:int):
await ctx.reply(f"{km} Kilometers is {km*1000} meters")
@client.command()
async def m2km(ctx, m:int):
await ctx.reply(f"{m} meters is {m/1000} kilometers")
#Docstring retrieval
@client.command()
async def help(ctx, input_doc):
await ctx.reply(input_doc.__docstring__)
PS C:\Users\HP\Desktop\Discord Bots> & C:/Users/HP/AppData/Local/Programs/Python/Python310/python.exe "c:/Users/HP/Desktop/Discord Bots/discord_bot1.py"
Traceback (most recent call last):
File "c:\Users\HP\Desktop\Discord Bots\discord_bot1.py", line 33, in <module>
async def help(ctx, input_doc):
File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 1485, in decorator
self.add_command(result)
File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 228, in add_command
super().add_command(command)
File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 1320, in add_command raise CommandRegistrationError(command.name)
discord.ext.commands.errors.CommandRegistrationError: The command help is already an existing command or alias.```
I put client.run I'm just not showing it
client = commands.Bot(command_prefix=".", intents=intents, help_command=None)
okay
working, thanks, but what does it do, though? @shrewd apex
cLieNT = commands.Bot
Traceback (most recent call last):
File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 200, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\HP\Desktop\Discord Bots\discord_bot1.py", line 34, in help
await ctx.reply(input_doc.__docstring__)
AttributeError: 'str' object has no attribute '__docstring__'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1330, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 995, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 209, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'str' object has no attribute '__docstring__'```
Uh oh
?
nvm
I can retrieve the docstring\
!e
def uwu() -> None:
''' Blvck is uwu '''
print(uwu.__doc__)
@slate swan :white_check_mark: Your eval job has completed with return code 0.
Blvck is uwu
@client.command()
async def help(ctx, input_doc):
await ctx.reply(input_doc.__docstring__)
💀
aw 
my eyes
ah doc
?
thats not how u make a help command...
str(object='') -> str
str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or
errors is specified, then the object must expose a data buffer
that will be decoded using the given encoding and error handler.
Otherwise, returns the result of object.str() (if defined)
or repr(object).
encoding defaults to sys.getdefaultencoding().
errors defaults to 'strict'.```
What?

do you know what a docstring is
commands have a description parameter 
Yeah
OH, how do I access thqat
You see I'm very inexperienced
in the command decorator
@bot.command(name="uwu", description="this command does uwu thing")
@commands.command()
async def uwu(self, ctx: commands.Context) -> None:
'''uwu Command description'''

'cause yes
or that
How do I use description parameter?
commands.Context?
class discord.ext.commands.Command(*args, **kwargs)```
A class that implements the protocol for a bot text command.
These are not created manually, instead they are created via the decorator or functional interface.
yes
Okay
yes
How to retrieve that desc tho
is it possible for a bot to get the id of a server if its given an invite link?
@slate swan
what
@slate swan
invite link?
no
I had a quick question if anyone can help.
If I have two @tasks.loops and wanted one to run after the first one is complete, how would I do that? I've tried a few methods, can't seem to get it right. Figured to ask before looking again 😄
Here are their names --
online_players.start()
status.start()
get the command using Bot.get_command("command_name") which will return a Command object, use the description property on it
@placid skiff How to retrieve the description, though
...
I couldn't understand anything 😄
bot = commmands.Bot(...)
s = bot.get_command("command_name")
s.description
Okay thanks
so for example if online_players has completed looping once or completely stopped
f
So, I'm aiming for.. If status() stops looping, then the online_players() would start.
I tried with the if not status.is_running() and couldn't get it to work. Would there be a better way?
why do people always have an issue with is_running not working 😔 and no
is it possible to make a bot read whats in an embed message
i want a bot to read the number of members in the embed of an invite
message.embeds[0].to_dict()
Here's the short version, if I did something wrong by chance.
@bot.event
async def on_ready():
if not status.is_running():
online_players.start()
it wont be accessible if it was embedded automatically from a link
on_ready 
I tried without ;-;
I think, probably not
Okay, gonna let it run the (hopefully) proper way and I'll let you know if I still struggle 
Yeah, I'm pretty sure I'm just not doing it right.
I put it at the end of my code. The status starts fine but the online_players doesn't seem to start. So, I'm assuming I'm just doing it wrong? @slate swan
status.start()
if not status.is_running():
online_players.start()
that's happening cz you probably have a wait_until_ready in the status task
might as well put the conditional inside another task
and start that task
@tasks.loop(seconds=5)
async def status_check() -> None:
await bot.wait_until_ready()
if not status.is_running():
online_players.start()
status.start()
status_check.start()
I appreciate you, thank you 😄
I'll check it and see how it works. I didn't think about making a task for tasks lol
Nor did I
welcome
what if online_players is running already
and why do y'all put if not
nqouewun same thing
what
oh cuz one will end
maybe I joined too late, I don't see where bro stops the task
little did I know the case is solved already
So, I tested it some more a few ways. The code works but it doesn't register the status as being done. Here's the code I was tweaking to see if it would log something --
@tasks.loop(seconds=5)
async def status_check() -> None:
await bot.wait_until_ready()
print("Test")
if not status.is_running():
online_players.start()
print("online_players.start()")
how do you stop status
^
... You have to stop it? 💀
what loops
I see Ashley is confusing everyone as usual
if you didn't specify the amount it's infinite
Idk, I guess my mindset was (even tho it was wrong)
The @tasks.loop(seconds=300) would stop it after the code finishes, then start it after 300s.
I shall fix, ty
how to get a user mention in a specific channel?
for example when someone sends: "hello @rapid falcon"
i want the bot to get the mention @rapid falcon from the message
!d discord.Message.mentions
A list of Member that were mentioned. If the message is in a private message then the list will be of User instead. For messages that are not of type MessageType.default, this array can be used to aid in system messages. For more information, see system_content.
Warning
The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.
if you use message.mentions, you get a list of members
Latest mentions, right?
?
I get a list with the latest mentions, right??
What are the latest mentions
a list of the members who were mentioned in THAT message
Ohhh
say you have an on_message event
the on_message takes in the message someone sent
you can check the mentions of that registered message
I'm not sure what happens if someone's pinged multiple times
if there are no mentions I assume it's just an empty list
How to mention the user back?
or if it's a response
the user who sent the message or the pinged one?
Pinged one
@bot.command()
async def avatar(ctx, *, avamember : discord.Member=None):
userAvatarUrl = avamember.avatar_url
await ctx.send(userAvatarUrl)
you get that person in the list, so you can get that Member object which has the mention property:
members = message.mentions
member = members[0]
await message.channel.send(member.mention)
assuming this is an on_message
the command avatar works for me but i want to make the command say something like this when the user doesnt tag someone !avatar and the bot says you have to mention someone for this command to work
Oh
how can i do this?
I didnt know about user.mention
Thanks @cold sonnet
You should definitely become a helper
how can i do this?
.
too many requirements
set the argument's default value to None
check if it's None
you have already set it oh
sorry idk how to do this im new to developing
it is
@bot.command()
async def avatar(ctx, *, avamember : discord.Member=None):
userAvatarUrl = avamember.avatar_url
await ctx.send(userAvatarUrl)
```this is your code, if someone doesn't ping anything, avamember is None
do you know how to check if something is None?
well that's not good but lol
if avamember is None:
in this case, you'd want to send a message
@bot.command()
async def avatar(ctx, *, avamember : discord.Member=None):
if avamember is None:
return await ctx.send("You have to mention a user to do this! ")
userAvatarUrl = avamember.avatar_url
await ctx.send(userAvatarUrl)
ok I was not sure how to not spoonfeed
wait leme try this
You should go for it
It's all up to you in the end
thanks its working
I recommend learning the basics of python before going into discord bots though
can i make this same the same but when i mention a role?
what why
it'll raise an error already
error handling is harder
ew
ok
you need to make it once and for all though, easier than checking if an argument is None in all commands
upto your own convenience anyways
but what if you want a different message for every command
why would you need that + easily configurable using a dict
I mean, you can check for the annotation of the MissingRequiredArgument to send the message you want
!d discord.ext.commands.MissingRequiredArgument
exception discord.ext.commands.MissingRequiredArgument(param)```
Exception raised when parsing a command and a parameter that is required is not encountered.
This inherits from [`UserInputError`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.UserInputError "discord.ext.commands.UserInputError")
property annotation```
The parameter’s annotation.
ofcourse you can do this
you cannot expect this from a beginner
was this added in 2.0? 
cuz MissingRequiredArgument.param returns an inspect.Parameter
idk I was quite surprised they made it easier
not anymore 😳
!d discord.ext.commands.Parameter
class discord.ext.commands.Parameter```
A class that stores information on a [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")'s parameter.
This is a subclass of [`inspect.Parameter`](https://docs.python.org/3/library/inspect.html#inspect.Parameter "(in Python v3.10)").
New in version 2.0.
ic
yes
class discord.ext.commands.Parameter
A class that stores information on a Command's parameter.
This is a subclass of inspect.Parameter.
New in version 2.0.
it was definitely a typo
I'm in confusion
thats 1.7.3 docs
oh
just go to sleep instead 
it used to be inspect.Parameter
look whos' speaking
me
little did we know discord.py is improving

tbh i like inspect.Parameter more, useless subclassing
technically discord is a module as well
but not maintained
can't you install it in 2.0?
no
just a mirror of discord.py 1.7.3
!pip discord
A mirror package for discord.py. Please install that instead.
what is this
discord 2
no shit
djs 
ill update it to 2.0 wait for it
js 🤮
ik that guy too
weirdos
hes in my friends list i think
@bot.command()
async def join(self, ctx):
if ctx.author.voice is None:
return await ctx.send("You are not connected to a voice channel")
else:
channel = ctx.author.voice.channel
await channel.connect()
await ctx.send(f"Connected to voice channel: '{channel}'")
i wanted to make a join vc command
this is becoming a music bot
and it says that im missing something
discord.ext.commands.errors.MissingRequiredArgument: ctx is a required argument that is missing.
you have self as an argument in your command
why else would it join a voice channel
remove self, you use that in classes
rickrolls
I have a text to speech bot
true
or soundboards
there's /tts
in the voice channel, not in the text channel
ok but playing copyrighted music is still illegal 🤨
you pul self only when you are inside a class
remove self and add something else or just remove self
so you mean rickrolling is illegal? 
playing rick astley songs in vc is!
if you use soundcloud you can save the sound in cache and still play it 
nice idea
I still dont get the idea why people make music bots
someone answer me pls
because they are so cool and fun!
just remove self @novel prairie
just remove slef
ok
instead just gift spotify premium to the users and tell them to start a group session
ash will gift free premium plans to all of us
I dont even buy one for myself, am poor
we should get the family plan
its not working
@bot.command()
async def join(ctx):
if ctx.author.voice is None:
return await ctx.send("You are not connected to a voice channel")
maybe ur bot is lazy
I'm sure the family will get too big by the time you buy a subscription
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: RuntimeError: PyNaCl library needed in order to use voice
!pip pynacl install this
pip install discord.py[voice]
2.0?????????
what
File "main.py", line 13
pip install discord.py[voice]
^
SyntaxError: invalid syntax
shouldn't you install it with 2.0
oh god
$ git clone https://github.com/Rapptz/discord.py
$ cd discord.py
$ python3 -m pip install -U .[voice]
``` you can do this in that case
not in the code
in the terminal
bruh idk what terminal is
like i said im new to dev



