#discord-bots
1 messages · Page 355 of 1
async def send_message(username):
embed = discord.Embed(
title="asd",
description="Description",
color=discord.Color.blue()
)
await webhook.send(username=username, avatar_url="https://media.discordapp.net/attachments/1201232387896512636/1232335459297001553/reaper.gif?ex=66291555&is=6627c3d5&hm=5583c74af19e2af31888f9c92b1ee9711369065b4f5b595ac1b00477c9cb8e42&=", embed=embed)
did i do it right?
oh wait man but this isn't ran by a command?
it's ran by an exe file
i want it to send embed after i run my python file, i dont want to send it after i type command in my chat
you can just do title=roblox
will it mather tho this code is for discord command, i forgot to mention i need it to send embed after running file
!d discord.Webhook.from_url
classmethod from_url(url, *, session=..., client=..., bot_token=None)```
Creates a partial [`Webhook`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Webhook) from a webhook URL.
Changed in version 2.0: This function will now raise [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError) instead of `InvalidArgument`.
Hello do you help me?
no errors and only the first 2 prints are getting printed
No, there are commands, they just don't come when I type them, it gives this error.
so you havent loaded the extensions the commands are in
how do i install
wdym
commands are in the Scrim folder
how come total seconds doesnt get printed
so you want to load extensions
hmm, might’ve already told you then 
i know pretty werid
thats only thing:
reminder-create command called
User: fantasyyonfire#0
So how do I solve the error now?
@limpid marsh
follow my instructions
properly this time
I didn't understand there
Where should I write the code you mentioned, I solved the error in the fln main, only the commands are not coming.
wdym “fln main”
show me what you wrote
What does wdym mean?
Oke
put the load extensions into a @bot.event called setup_hook
how do i do it?
you made a recursive function btw and never called it
me when:
@bot.event
async def event_name_here():
whatever to happen in event
basic dpy bro 😭
How do I call??
Shall I write this code in main.py?
infinite loop?
nah mate put it in the microwave for 45 seconds and if its still cold, mix it and put in for another 30
should heat correctly 
fuck the recursive loop, who the hell uses 2 spaces? 
I need to get it out of the infinite loop, how do I do that?
I do 
change them damn spaces 🗣

dont use the loop?
alr told you what to do broski
No
alr told you what to do broski
more concerning thing is that indentation 8 exists 🦆
😢
why are you using a main func when i told you what to do already
Is that replit
vscode
me when:
for i in range(5):
for j in range(5):
print(i + j)
İ not understand
Hellish 💀
that looks normal in standard text ngl
use setup_hook
Your iphone ain't normal
⬆️ ⬆️⬆️⬆️
chill bruh, my broke ass got a 7 😭🙏🏽
await setup_hook()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A coroutine to be called to setup the bot, by default this is blank.
To perform asynchronous setup after the bot is logged in but before it has connected to the Websocket, overwrite this coroutine.
This is only called once, in [`login()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.login), and will be called before any events are dispatched, making it a better solution than doing such setup in the [`on_ready()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_ready) event.
Warning
Since this is called *before* the websocket connection is made therefore anything that waits for the websocket will deadlock, this includes things like [`wait_for()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.wait_for) and [`wait_until_ready()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.wait_until_ready)...
Where do I write this?
using client is a sin
Is that even your money then 😭
in your microwave main file
commands Bot inheritates from Client and BotBase 
no 😭😭
Bro sorry i don't understand
commands.Bot is just the cute outcome of two ugly parents
Samsung tv fridge is the best place to code 💀
“write it in your main file” 🗣🗣🗣🗣🗣🗣
Oke
nah bro real ones code on the chicken wing cell phone 😭🙏🏽
Error
so whats the error
mf you gotta be more specific on your problems
you cant just say "error" and expect a followup answer
anyone know why note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for aiohttp
ERROR: Could not build wheels for aiohttp, which is required to install pyproject.toml-based projects?
i have pip updated. just started using PyCharm and it gives this error.
happens when i try to install any package on pycharm
not for here. try #python-discussion you’ll get better answers
oh yeah forgot
Hello i was asking if anyone can make for me a announcements command for slash I tried to make it but when i run the command it say error so i want anyone to make for me or give me
just made the switch over to py charm, and fixed everything that pycharm was having a problem with. i have cogs setup (works fine on my server and in vs code) but when i try to on pycharm i just get no commands found with no errrors or anything
you have two on_ready handlers in there, so the last one will overwrite your other handler
3*
oh lol i missed the top one
But, so with dyno, dyno has an AFK system right, and it edits your nickname to have [AFK]whateveryourgoofynameis, but if you are a role above or the owner, dyno still does it.. how does dyno do that?
Unless I am wrong and dyno can't do that. Because from personal experience I am pretty sure it can.. but I have not used that bot in many years.
dunno, as far as i can tell, it seems to be limited by role/ownership
Hm, so it just, edits based on its permission? If it doesn't have permission it just continues and skips nickname edit?
https://docs.dyno.gg/en/modules/afk
Due to how Discord permissions work, Dyno can never change the owner’s nickname. As long as his role is above the role of any other using the command and he has the
Manage Nicknamespermission, he will change their nicknames.
Alright then, well thank you lol
yep. ive seen “owners” use it and it doesn’t change their name
Just was a lil confused, because I thought he did but then I was confused cuz it wasn't possible
Pipe down


why are there so many 😭
oh btw did you know you can do setup_hook in a @bot.event handler

stuff's getting heated in the nerds department
all bot.event does is setattr(client, func.__name__, func)
im not sure if its cogs or what but everything looks fine in cogs and main.
for this code snippet, nothing's calling your load function
try using setup_hook to handle your startup stuff
e.g. py @bot.event async def setup_hook(): await bot.load_extension("path.to.ext")
alright ll try that
can someone help me out im trying to add jishaku to my bots code but im kinda confused idk why 😭
all you have to do is load the extension via await bot.load_extension('jishaku')
yo can i get some help here?
i tried use this {member.avatar_url} to set someone profile pic in the welcome message embed and i got an error , didnt use discord.py for a long time did they changed it?
I"m having an issue where when I try import requests
it just underlines requests saying I dont have the module
but I actually do and reinstalled it twice already
!d discord.Member.display_avatar
property display_avatar```
Returns the member’s display avatar.
For regular members this is just their avatar, but if they have a guild specific avatar then that is returned instead.
New in version 2.0.
use that instead to get asset
then .url to get the url
o i guess just str also gives u the url so kinda redundant
can a button timeout if i put timeout=None?
nope
okay thanks
:D
So like flowery said, you can use .url personally, I would not recommend .url.
so you can do member.avatar.url is what flowery is saying, but sometimes you can get an error if there is no url to the avatar/profile, so what you can do is just do member.avatar and you won't ever run into that issue.
No problem!
you got member.avatar.url, member.avatar, member.display_avatar
and if you are using user, you can also replace these
and also, inside of the display avatar, you can also do .url at the end, to do the url, but I still don't recommend that.
But I think this error only happens with discord.Member if you use discord.User then you should be fine with using user.avatar.url or member.avatar.url how ever you labeled it. I think discord.Member is a little different from discord.User and I kinda have no clue why, but that would be a question for @hushed galleon.
i mean i specifically said display_avatar so you dont get attr error
Well yeah, my bad.
But ive noticed when you use discord.User you won't get the attr error.. but when you use discord.Member and use .url you will get the error. So I know it has to be something related to discord.Member I am assuming?
unless im stupid and just tweaking lmao
how do i fill the completions for a command parameter
like if i have /command <string>
You would use Auto fill
ty
np
Also related to this error I think is because member is for server vs user is global. So maybe thats why. So better off using User if you are wanting to use .url but either way im moving past this lmao
@bot.tree.command(name="admin-give-coin", description="Admin commands")
async def givecoin(interaction: discord.Interaction, player: discord.Member, coin: str, amount: int):
print('g')
@givecoin.autocomplete('coin')
async def givecoin_autocomplete(
interaction: discord.Interaction,
current: str,
) -> List[app_commands.Choice[str]]:
options = ['Robert Coin']
return [
app_commands.Choice(name=option, value=option)
for option in options if current.lower() in option.lower()
]```
im getting app_commands and List not found
am i being dumb
So make sure to do
from typing import List
oh mb mb
i think its
from discord.ext import app_commands
or
from discord import app_commands
one of the 2, can't remember which one lol
@torn solar also make sure to add
@app_commands.autocomplete(coin=givecoin_autocomplete)
where?
above the autocomplete function?
bro
my bot keeps getting blocked from accesing the api
i didn't send that much requests
the code is a slash command example copied from stack overflow
i don't know why this is happening.
if you're using repl.it, that happens because other people are trying to host bots on the same datacenters
No, im not using repl.it
also the guild argument ill remove it
However, im using a bot hosting service 24/7, may there be a problem with that?
!d discord.Guild.get_member_named
get_member_named(name, /)```
Returns the first member found that matches the name provided.
The name is looked up in the following order...
:3
if you're getting 429s, its probably a bad service, the server needs its own IP address that other bots won't run on
Traceback (most recent call last):
File "/home/codespace/.python/current/lib/python3.10/site-packages/discord/app_commands/tree.py", line 1248, in _call
await command._invoke_with_namespace(interaction, namespace)
File "/home/codespace/.python/current/lib/python3.10/site-packages/discord/app_commands/commands.py", line 853, in _invoke_with_namespace
return await self._do_call(interaction, transformed_values)
File "/home/codespace/.python/current/lib/python3.10/site-packages/discord/app_commands/commands.py", line 846, in _do_call
raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'close' raised an exception: AttributeError: 'Bot' object has no attribute 'get_member_named'
deamm
xd
it's guild.get_member_named
using discord.py 2.0 what do i use for slash commands? i see a bunch of stuff but im confused what to use. im using discordpy 2.3.2 the latest
its called AppCommand, general info and examples
yikes my brain is fucked
flip yeah thanks
welcome
Can someone @ me and point me in the right direction I’m looking to have a discord bot made & bought.
what does thia mean?
File "C:\Users\xz0v\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 441, in _run_event
await coro(*args, **kwargs)
File "C:\Users\xz0v\Desktop\jealousy_discord_bot\main.py", line 22, in on_ready
await bot.load_extension("cogs.ping")
File "C:\Users\xz0v\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands\bot.py", line 1013, in load_extension
await self._load_from_module_spec(spec, name)
File "C:\Users\xz0v\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands\bot.py", line 938, in load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.ping' raised an error: ImportError: cannot import name 'Option' from 'discord.app_commands' (C:\Users\xz0v\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands_init.py)
Option doesnt exist, what are you trying to do?
Option is deprecated
discord.py now supports all app components
do the equivalent of importing a select menu or smth
!rule 9 
we dont do that here
# cogs/fun.py
import discord
from discord.ext import commands
class Fun(commands.Cog):
# typehint is useful for writing code
def __init__(self, bot: commands.Bot):
self.bot = bot
@commands.command(name = 'hello')
async def hello(self, ctx):
await ctx.reply(f"Hello, {ctx.author.mention}")
# -------- cut the cog there, other commands can be added ---------
# this is very important. your code won't run otherwise
async def setup(bot): # requires a bot arg
await bot.add_cog(Fun(bot)) # add the cog with the bot param
Can anybody figure out how to change this example one I using to work with client instead of bot? Please?
client = commands.Bot(command_prefix = '?', intents = discord.Intents.all())
That is like the biggest wall I have right now.
just change the class attribute
in your case, client is literally just a name
so just replace “bot” and “self.bot” in those cases with “client” andself.client”
Alrighty. I appreciate you tremendously by the way.
AttributeError: loop attribute cannot be accessed in non-async contexts. Consider using either an asynchronous main function and passing it to asyncio.run or using asynchronous initialisation hooks such as Client.setup_hook
import discord
import random
import asyncio
import datetime
from discord.ext import commands
client = commands.Bot(command_prefix = '?', intents = discord.Intents.all())
class DealGame(commands.Cog):
def __init__(self, client: commands.Bot):
self.client = client
#DEAL GAME UPDATED
@commands.command(name = "dond", aliases=["deal"])
async def dond(self, ctx):
#At the end of the Deal program
async def setup(bot):
await bot.add_cog(DealGame(bot))
Well, that didn't work.
I guess it IMPOSSIBLE to have it as client unless the MAIN file needs to be changed up to.
import discord
import random
import asyncio
import datetime
import aiohttp
from discord.ui import Button, View
from discord.ext import commands
#client = commands.Bot(command_prefix = '?', intents = discord.Intents.all())
class DiscordBot(commands.Bot):
def __init__(self):
super().__init__(
command_prefix = '?',
intents = discord.Intents.all()
)
async def setup_hook(self): # this replaces on_ready
await self.load_extension('cogs.Fun')
await self.load_extension('cogs.Weather')
await self.load_extension('cogs.Fraction')
await self.load_extension('cogs.DealGame') # loads the fun cog
client = DiscordBot()
That is what the main file cog looks like.
and how are u running the bot?
I just open the file and it runs.
no i mean what does your run func looks like
I just want to use a cog that uses "client" instead of "bot" in the cog file I think it called.
like you run it like client.run('Token') or something else
ok then can you show the whole traceback for error
Yes. Let me remake it.
and you don't need to define client in here after the imports
Gonna run it again without the client = this on the Deal file and see what error shows up.

pickcase = await client.wait_for('message', timeout=300, check=check)
NameError: name 'client' is not defined
use self.client if its a cog instead of just client
Alright, lets see if that works.
how do i get the active dev badge?
create a bot with one app command and have someone use it
you will get a mail with in 24hr to claim your badge and to keep the badge u will need the command to be used once every 30 days to keep the badge
I wish there was a way to just select all "client" showing up instead of just typing and trying to find everyone.
which ide are you using?
in vsc its ctrl + F2 to select all occurences
I use visual studio code.
.
Whoa that is shockingly convienent.
Time for the test. Also there was 12 of those to changed and that was a new thing you taught me.
No errors... yet.
Nope, it works.
Thank you @viscid hornet very much! 🍪🍪🍪🍪🍪🍪🍪
Thank you @turbid condor very much! 🍪🍪🍪🍪🍪🍪🍪
oh awesome

thanks for the cookies asw
also i dont know if its important but im using danbothosting
im not sure it has it's own ip addres tho
may be they use shared ip
Oh yea good point
confusing
whats “Option” supposed to be?
the old deprecated shit i didnt remove it 
no like what was it
buttons? selects?
for slash but its old
it was the list of values for command param imo
ohh like autocomplete?
Wdym
oh so like typehinting an arg to a literal
its like autocomplete but static so the options dont change
yes
slash commands confuse me lmfao
they are pretty easy
they’re easy when you get to know them 
💀so that's like.... Choices?
mhm
not much different from normal prefix
yes
So why not use choices
he is
idk for some reason its the only thing i cant do
keep tryin tho
its like the ancient version of choices
u can use hybrid as an alt
and just don't process_commands in on_message
Then why do we have Options
options is out of the picture
yeah but miss out some functionality of app_commands
ill keep looking into geting slash command working without hybrid then, will be a last resort
Why not use hybrid
gl
where can i find more about hybird?
options is the old version of choices
learn slash first and then go to hybrid
like a car with just the rims and no back two wheels lmao
Yeah that's one way of saying that 💀
whats your issue with slash cmds?
well i tried making a basic echo command but i get an error and im not sure what it means, let me send screenshot
confused at this part
can you type the full line
yeah that would help more eh
bot.tree.command(name="echo", description="Echoes a message.") @app_commands.describe(message="The message to echo.") async def echo(interaction: discord.Interaction, message: str) -> None: await interaction.response.send_message(message)
yeah no issue it seems might be the linter
!d discord.InteractionResponse.send_message
await send_message(content=None, *, embed=..., embeds=..., file=..., files=..., view=..., tts=False, ephemeral=False, allowed_mentions=..., suppress_embeds=False, silent=False, delete_after=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Responds to this interaction by sending a message.
are you sure you don't have multiple discord libs installed
which might cause naming conflicts
ive been doing a lot of installing.. so i probably do
if that's replit then i'm sure its discord instead of discord.py
replit?
nvm
no shot that exists still ahah
try doing pip freeze in terminal and show what it prints
oh cant do that oopsies
i have some i need to uninstall
like salsh and interactions 😭
discord-ext-forms==3.0.3 discord-py-interactions==5.11.0 discord-py-slash-command==4.2.1 discord-typings==0.8.0 discord.py==2.3.2
just run this script ```py
import os
import sys
py_exec = sys.executable
uninstall_list = " -m pip uninstall nextcord py-cord interactions.py disnake dislash discord-py-slash-command discord.py-message-components enhanced-discord.py novus hata discord-interactions discord.py-self discord.py-self.embed discord2 python-discord reactionmenu discord_py_buttons discord_slash discord.py discord discord-ext-forms discord-ext-alternatives dpy-appcommands discord-ext-slash"
os.system(py_exec + uninstall_list)
os.system(py_exec + " -m pip install discord.py --no-cache-dir")
remove these and then reinstall just discord.py
Anyone have any idea how I can attach a csv file as a hyperlink inside the embed?
forgot this exists too
im using discord.py
where is the CSV file stored
Its generated as a part of the slash command
Like transaction records associated with a user
you need to upload it somewhere and link it to the button
upload the csv on a host and share the link to it
u can use some cloud file store like firestore or s3
How can I achieve that? I want it all to happen when this slash command is used
or just upload it to a dump channel on discord and give a link to the attachment now
alrighty uninstalled that then re installed discord py
This makes more sense
How to program a dc bot
yeah all of this would go inside your slash command body
to do what?
To timeout someone buy custom command
still getting this though, not sure
just run the code
u synced the commands?
oh that's a weird goal but ok, u need to know the following
- python upto classes and instances
- asynchronous programming
- bit about apis help
ill do that
add SQL too to store the timeout duration
if u synced commands and still don't see it then close and reopen ur discord app
can you do it like
synced = await bot.tree.sync()
print(f'Number of Synced Commands: {len(synced)}')
```at the place where you syncing
and see what it prints
it somewhat- worked? .. im nots sure
import sys; print('Python %s on %s' % (sys.version, sys.platform))
if that was your message yes then it did
not sure.
unless you changed the code
codes the same. just synced my commands
is syncing a command instant?
have 2 synced commands. all my other commands are cog
yes
ok
try the command again
alrighty
but u will need to refresh your client
My discord client?
re-open the app or refresh webpage
Ok, also one more question, if i have defined bot as commands.Bot, does defining client as discord.Client have a use?e
nope
yes have echo and ping, just none work
so i can just delete it?
stick to Bot it's better
Ik
yes
k
it's working right there the bot is replying to you
tho idk why it replies with bot not found
im a lucky man
If i have a bot that uses commands , slash commands, can i get the active developer badge?
i think you can easily get it
Alr
without that
yup slash commands are needed only
ohh
Ik
so how do i get it exactly
it doesn't matter if it has prefix command or not it just needs one app_command that is used
this happened before.. when i tried using buttons
here
wait so it says that when using button?
it has before. i dont think i ever tried buttons again because i couldnt bother i could try to make a button and see?
I try to get active developer badge but it says i have no apps that use app_command.
im running it on a server- but its off so its not like that can be a problem
even if i do
wait 24 hrs
Ohhh makes sense.,
nope shouldn't be unless the server is also online
but then again you should receive two responses
or an error
Can anyone help me with running raspberry pi camera
wait maybe it is on
u might want to create a post in #1035199133436354600 forum for that
hmm its very creepy now it shouldn't do that unless you are overwriting your message
in the code
it might be me being dumb not sure
!longtext
no clue what the things called
i guess i broke my normal commands as well
🙂
fixed my cogs- had my shit setup wrong
no luck on slash though
Is there a way I can move the attachment below the embed instead of this?
nope. it's a csv file so python displays it like that
i recommend either a link, discord attachment (idk if taht counts as an attachment) or just not attach that file
do you know how interaction works?
whats your code?
the name 😭
🗣️ 🔥
but do you know how slash commands work
thats important to know as well
fuck nah 🙊
from discord import Interaction # easier import
@app_commands.command() # for a cog, uses self
@bot.tree.command() # for a main file
async def your_command(self, interaction: Interaction):
await interaction.response.send_message("Hello!") # sends a message as a response```
this is as basic as it gets
See asher's guide to slash commands
there's different types of .responses, like:
interaction.response.defer()interaction.response.edit_message()
@slate swan (but the dpy examples make more sense imo)
do you have a link for those?
A hands-on guide to Discord.py
Bro spent a lot of his life making every single page of this guide 😭
w mans
They should unpin my gist and pin this up tbh this is more helpful 💀
I hate to ask this, but how do you get the user name shown on screen?
ctx.author.display_name = tailstellstales
ctx.author = tailstellstales#0
ctx.author.name = "tailstellstales
ctx.author.id = ID Number of Name
??? = TailsTellsTales
I even looked up discord py doc thing and nothing.
class Ticket(ezcord.Cog, emoji="🎫"):
def __init__(self, bot):
self.bot = bot
self.ticket_owner = None
@ezcord.Cog.listener()
async def on_ready(self):
self.bot.add_view(TicketRole(self.channel_name, self.logs_channel_name, self.ticket_feedback))
self.bot.add_view(TicketView())
self.bot.add_view(CreateTicketSelect())
self.bot.add_view(QuestionsButton(self.ticket_owner))
``` ```py
[ERROR] Error while sending error report to webhook. Please check if the URL is correct.
[ERROR] Error in event on_ready
Traceback (most recent call last):
File "C:\Users\Dark_Angel\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 400, in _run_event
await coro(*args, **kwargs)
File "C:\Users\Dark_Angel\Desktop\Jinx-Bot\cogs\ticket.py", line 94, in on_ready
self.bot.add_view(TicketRole(self.channel_name, self.logs_channel_name, self.ticket_feedback))
AttributeError: 'Ticket' object has no attribute 'channel_name'```
It should be display_name if that's your "Username" in a guild, otherwise it returns your discord username which is TailsTellsTales
why are you adding views to the bot??
is that your bot? i cant find any that let you use jsk yourself
yeah it's mine
yes
mf got a verified app, thats crazy 😭
😅
that doesnt answer my question
wtf did you do to get a verified app 💀
because I need it because of the ticket system
make a very cool bot related to something for which not many exist already

why are you adding views to the BOT instead of the MESSAGE
What do you think ?
INPUT: What I want. TailsTellsTales
@client.command()
async def testing(ctx):
await ctx.send(ctx.author.display_name)
await ctx.send(ctx.author)
await ctx.send(ctx.author.name)
await ctx.send(ctx.author.id)
OUTPUT: What I get.
tailstellstales
tailstellstales#0
tailstellstales
I removed name ID.
Because he needs it because of the of the ticket system
shut up 😭
Do ctx.author.display_name
Lmao
isnt there a nickname for this sort of thing?
!d discord.Member.display_name
property display_name```
Returns the user’s display name.
For regular users this is just their global name or their username, but if they have a guild specific nickname then that is returned instead.
@quick gust
Example 2 with your user name.
Infernum = Doesn't exist.
infernum.. = author.display_name or author.name
infernum..#0 = author
There seems to not be one that can show your actual user name.
😭
I'm telling you the code I keep running shows it as I mentioned above.
I have no idea, but I been trying to figure it out for months.
Like this should be pretty straight forward, but surpringly nobody knows.
it probably just doesnt let you
!d discord.Member
class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild).
This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User).
x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User) instances too.
x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User) instances too.
hash(x) Returns the member’s hash.
str(x) Returns the member’s handle (e.g. `name` or `name#discriminator`).
Is there any other ones I can test?
wdym?
@client.command()
async def testing(ctx):
await ctx.send(ctx.author.display_name)
await ctx.send(ctx.author)
await ctx.send(ctx.author.name)
await ctx.send(ctx.author.id)
await ctx.send(ctx.author.mention) #Try these two out
await ctx.send(ctx.member.user)
Like anymore names to test to see if it might show the correct user name I want?
lemme experiment w it
To my shocking surprise, the author.mention actually did something. I was just making stuff up lol.
Obviously the mention pings you.
Yes
Now I am curious if "author.mention" would work in an embed of discord.
Do you want the global nickname Or the the username?
Yes it does but it does not ping
I honestly don't know which is why I gave detailed list above.
The user’s global nickname, taking precedence over the username in display.
New in version 2.3.
Use this
no way that works
It's clearly written in the docs
INPUT: What I want. TailsTellsTales
@client.command()
async def testing(ctx):
await ctx.send(ctx.author.display_name)
await ctx.send(ctx.author)
await ctx.send(ctx.author.name)
await ctx.send(ctx.author.id)
await ctx.send(ctx.author.mention)
OUTPUT: What I get.
tailstellstales
tailstellstales#0
tailstellstales
I removed name ID
@ebon ocean
Oooh, that's good.
So I guess that would be ctx.send(ctx.global_name).
@viscid hornet
what
Ctx.author.global_name
!d discord.ext.commands.Bot.guilds
property guilds```
The guilds that the connected client is a member of.
ooh
You could have done discord.Client.guilds to save effort 💀
Using author.mention in an embed causes it to turn into an @ id number.
You can only use it in description and field values
how do you set a bot status

!d discord.Client.status
property status```
[`Status`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Status): The status being used upon logging on to Discord.
woah
@ebon ocean does this work though?
You can't change the status with that
yeah it's change_presence but it's raising this
Alright, gonna try ctx.author.global_name that.
AttributeError: 'NoneType' object has no attribute 'change_presence'```
class DiscordBot(commands.Bot):
...
async def setup_hook(self):
await self.change_presence(status = discord.Status.offline)```
It's because you can't change the presence before you run your bot
@client.event
async def on_ready():
await client.change_presence(status=discord.Status.online) #activity=discord.Game("Friday Night Funkin'")) (type=discord.ActivityType.watching, name=""))
print("Bot is ready.")
Use a task or a text command

Dont do it in on_ready
That is my status thing I have.
"um, on_ready() can be called multiple times, making it a less effective solution for this problem ☝️🤓"
No I just don't like the on_ready event
That reason is secondary
same 
That been on the on_ready thing for a long time now from a youtube video long ago.

Got this error.
await ctx.send(ctx.author.global_name)
AttributeError: 'Member' object has no attribute 'global_name'

Yeah, basically. At least I learned how to mention a name.
!d discord.Member.global_name
property global_name```
Equivalent to [`User.global_name`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User.global_name)

It weird how our ACTUAL display names can not be used in the bot.
Unless you get pinged.
what is your dpy version? @ebon ocean
Update your discord.py
pip install -U discord.py
Been so long since I checked on that.
Do that then ig
Yeah I have no idea how to check discord python version and just gonna update it.
you could check it like this
import discord
print(discord.__version__)
I had 2.2.2 it says on updating.
Alright let it update
[notice] A new release of pip is available: 23.0.1 -> 24.0
I guess will update that too.
yea
Sigh! How do I run the thing?
-m pip install --upgrade pip
Screw it, I'll show my dang files. Don't hack me.
[notice] To update, run: C:\Users\removeduser\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe -m pip install --upgrade pip
After the discord update, the names are still the same lol.
But seriously, do you know how to run that? Forgive me, I'm not good with computers.
Too late... I think just guessed and I already ran the program and it the same usernames as before.
author
so done with roles man
how do you edit a role
oh im dumb
!d discord.Role.edit
await edit(*, name=..., permissions=..., colour=..., color=..., hoist=..., display_icon=..., mentionable=..., position=..., reason=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the role.
You must have [`manage_roles`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_roles) to do this.
All fields are optional.
Changed in version 1.4: Can now pass `int` to `colour` keyword-only parameter.
Changed in version 2.0: Edits are no longer in-place, the newly edited role is returned instead...
I am gonna slap myself.
what did you fuck up now 😭🙏
I didn't catch the user should be author part.
await ctx.send(ctx.author.global_name)
AttributeError: 'Member' object has no attribute 'global_name'
*INPUT
@client.command()
async def testing(ctx):
await ctx.send(ctx.author.display_name)
await ctx.send(ctx.author)
await ctx.send(ctx.author.name)
await ctx.send(ctx.author.id)
await ctx.send(ctx.author.mention)
await ctx.send(ctx.author.global_name)
OUTPUT
await ctx.send(ctx.author.global_name)
AttributeError: 'Member' object has no attribute 'global_name'
Anyway, y'all let me know if you ever can figure that out.
They already did that earlier and couldn't find anything.
if member.global_name is giving you an attr error, it means your dpy isn't 2.3 above
But I just updated it.
well the error says otherwise, did you update on the wrong environment?
I don't see it, but somebody gave me download thing.
Here we go. pip install -U discord.py
I just use that again.
It says installed already.
can you do print(discord.__version__) in your code and see what it says
a means alpha, its before release version
currently its 2.3.2
can you do pip --version
Yeah it shows pip 24.0
well i need to know the path as well
pip 24.0 from C:\Users\nameremoved\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pip (python 3.9)
and what do you use to run the bot? py or python, i.e py main.py or python main.py
Oh... it's filename.py
no im asking the command itself not the filename
I don't use a command. I just open the file and it runs.
with what text editor? vscode? those also uses a command when you click on the play button
I use visual studio code.
I only use idle shell to run a program if in a text editor thing.
Otherwise I just open the file in a regular file folder.
Is this NOT what everyone gets when they run this?
INPUT
@client.command()
async def testing(ctx):
await ctx.send(ctx.author.display_name)
await ctx.send(ctx.author)
await ctx.send(ctx.author.name)
await ctx.send(ctx.author.id)
await ctx.send(ctx.author.mention)
await ctx.send(ctx.author.global_name)
OUTPUT
tailstellstales
tailstellstales#0
tailstellstales
241629325223395329
@ebon ocean
await ctx.send(ctx.author.global_name)
AttributeError: 'Member' object has no attribute 'global_name'
I am 100% certain it's IMPOSSIBLE to get your username to show.
As in my user name being TailsTellsTales for example.
you're looking for global_name, that is set when you set the User Profile
which is why its important to debug why your discord.py isn't 2.3.2
Well global name causes error.
i know, because it's not the latest its an alpha release for your discord.py
Oh yeah, forgot to mention, that confused the alpha release.
Is it not ready yet?
Like why did it not load the normal one?
no, im saying your discord.py version is in alpha release of 2.3.0, when the current version is already at 2.3.2
so you probably updated discordpy on the wrong environment
when you press the run button, this should appear, that would be your python path
need to know that
Oh. Yeah, I will admit I am really bad with computers. I just opened command prompt and added that pip install thing somebody posted.
dw just show me what path appears when you run it
I am officially confused. Do you mean type run into search or run in command prompt? What am I even running?
this, how did you run the bot
I go to file explorer and click the file to run it.
It pops up in a command prompt.
C:\Windows\py.exe
so i guess your os already set the python path on that file
I have no idea.
so if this is true then just do C:\Windows\py.exe -m pip install -U discord.py
Alright. I was just reading what it said on the top of the command prompt screen.
Okay it did something.
@golden portal What the fudge biscuits?! It actually shows my actual username now?!
Twice!
nice finally works
yea display_name would include global_name as well
so it would appear twice based on your code
yo quick question
how do i run two async funcs at the same time?
The great thing is all my code uses author.display_name which works out.
use asyncio.create_task/asyncio.gather
Anyway let me get you your cookies.
so like ```py
async def func1():
# do something
async def func2():
# do something else
await asyncio.gather(func1(), func2()) # like this?
i guess its all due to the discord.py version mismatch, also i would recommend reading about python environement and virtual environment, most people uses virtual environments to manage python libs
yes
Thank you @golden portal for getting that figured out and yeah I will be looking into that here! 🍪🍪🍪🍪🍪🍪🍪
welcome

if a task gets destroyed due to an error? how must I re-start it without having to re-run the bot?
are you using cogs?
yes
yeah, through the code (whenever it errors)
whats the exception?
it can be anything
another thing
main chat is dead so how would i do this ```py
await asyncio.gather(
task1(),
task2(),
task3()
)
only after the gather task has finished
print("All done!")```
nvm alr got an answer
maybe an option would be to use TaskGroup 
oh alr
!d asyncio.TaskGroup
class asyncio.TaskGroup```
An [asynchronous context manager](https://docs.python.org/3/reference/datamodel.html#async-context-managers) holding a group of tasks. Tasks can be added to the group using [`create_task()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.create_task). All tasks are awaited when the context manager exits.
New in version 3.11.
nah i'd win
💀
wait TaskGroup wouldnt actually work
Im curious now 
this would question would belong more to #async-and-concurrency
fr
Lmao
Is it just me or discord is really slow today? My commands take forever to sync. I literally have to kick my bot and re-invite it for the commands to appear
perhaps you're hitting the sync ratelimit
How do I check that?
or how long do I wait?
if you see a warning you would know the time
No warnings
I'll take a break anyways. I've been doing bot stuff all day.
I enter a wormhole when I do bot stuff where time just warps by lol
applesauce or choco pudding?
i didn't gat it what wrong
Do you have an error handler?
is this AI gen code
No
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
done
How can i make a slash command only available to admins
Or only runnable by admins
why is it all in one file
cogs exist for a reason
check if interaction.user is an admin
but having a 470 line file is cooler clearly
How can i check ?
not manageable in the slightest
its cool if i have a rolls royce but whats the point of it if it has no engine
cant use it to go anywhere
initialise a role object for your admins, eg. py guild = ... # use bot to get guild special_role = ... # admin role gotten from the guild
then in your code, check if interaction.user has that role, eg. py @your_slash_command() async def admin_only(self, interaction: Interaction): if special_role not in interaction.user.roles: # they dont have the role return # abort the func
theres probably a deco for this
from typing import Type
import discord
import sys
import asyncio
import random
from discord.ext.commands.bot import _default
from discord.ui import Button, View
import time as pyTime
import json, random
import json
from discord import app_commands
from discord.ext import commands
import time
import configparser
from discord.ui import button, Button, view```
what the hell are these imports
Hello, I am quite new into coding and I have been making a timezone bot that would put the time in the voice channel but I have no idea on how I would update the time every 10 or so minutes, I looked into tasks.loop but I have no clue on what I can do to look for the channel and edit the time.
I have been stuck here for a while now and I think I already hit the wall in what I know so I might need an external help. Thank you. I will put the code in a sec.
async def only_for_admins():
async def check(interaction):
return interaction.user.guild_permissions.administrator
return app_commands.check(check)```
this checks if the user is an admin (perms)
uhh that does'nt work
theres also @app_commands.has_role() if admins are defined by a role
wdym?
make it a decor peice
Like whenever i check interaction.user.guild_penrissions.traitor it doesn't do anything. I made it to check if it has and if it does it will run and else it will say no perms, but when i run it nothin happen
the one i use is something that goes like:
if not interaction.user.guild_permission.administrator:
return await interaction.response.send_message('Admin priv only')
Ig this works
I also tried the decorator for the role but nothing happens too
use @tasks.loop() and get the voice channel object py @tasks.loop(...) async def loop(self): guild = bot.get_guild(...) vc = guild.get_channel(...) await vc.edit(name = ...)
.traitor?
||(literally said that exact thing earlier)||
fudge biscuits 😭
is there a way to automatically find the said channel (in this instance the voice channel that was made by the bot) like in a category?
or maybe a way to manually input the channel ID for it to start updating. I tried putting tasks.loop in app_commands.command and it seems that it doesnt work too.
you can either:
- use the ID and call
guild.get_channel()with the ID - use the name and call
discord.utils.get(guild.channels, name = vc_name)
both need aguildwhich you can get by doingbot.get_guild(guild_id)
I was thinking of making a slash command to input the ID and it would start updating.
i recommend just getting the channel
just get the channel
it doesnt count as an API call because it's loaded into cache
I see, okay I will try this out thank you.
It's better to getch it tbh
no like its automatically cached so you dont need to fetch it
Sometimes it may return None
sorry for the delay, it did return a none type
AttributeError: 'NoneType' object has no attribute 'get_channel'
your guild is None
by returning a NoneType, it means this: py def func(): return None
(you had to use this in a private message with the bot)
use this in an actual guild (server)
Forecast API returns alerts and warnings issued by government agencies (USA, UK, Europe and Rest of the World) as an array if available for the location provided through the Forecast API.
By default alerts are not returned. To get alerts back in the response from Forecast API, pass the parameter alerts=yes.
I have no idea how to "pass the parameter". Not a super big deal, just curious.
This is a discord bots help channel
Don't tell me "It's for a discord bot" 💀
.
It's very hard to understand API things, though the weather one is the one I understand the most. No problem if that too complicated.
Alright lets believe him
I assume this "parameter" is an "query parameter" and you would pass it like this
https://example.com?parameter=value
thats fine
Wait a second... I just noticed there already is a "param" thing in the start of the weather bot code. I wonder if I can just copy/paste it to match alert thing? Gonna find out.
in the url?
Bro writes everything he does
No idea. It works.
WAIT! Here we go. "http://api.weatherapi.com/v1/forecast.json"
alright I checked it and you will most likely need more than 1 query parameters
follow this pattern to correctly pass them
https://example.com?parameter1=value1¶meter2=value2
assuming that parameter1 is an API token and parameter2 is the alert
I just realized something. Even if I "pass the parameter" I would still have no idea how to even get the alerts figured out cause it doesn't say where it belongs in the API doc thing.
Again, it's not a big deal. It was just a curiosity for me.
you would have to access the value of alert in the response
when getting the JSON Response its in dict format I believe
so you can either use .get() function or [] (getitem) syntax on it
from dotenv import load_env; import requests; import os
load_env()
protocols = ('https', 'http',)
secure = True
params = {
'api_key': '1234',
'alert': 'yes',
}
if secure is True:
response = requests.get(f'{protocols[0]}/:/weather.com/params.json(&)')
text = response.words

💀
That is something. It all good.
-text = response.words
+data = response.json()
Which looks better to y'all?
Are we actually trying to fix that I wrote cancer
yeah :kekw:
first one
The temps are color coded by the way.
I trying to make it where can look nice on mobile too.
LOL.
the first one would be the one to go for then I guess
since discord messed a bit with codeblocks so it looks a bit off
and the text hops to the next line
is there a python course like duolingo?
im trying to learn python with anyway
Learn python from duolingo 😳
There was an app on mobile "mimu" or something
The weather icon is making it where only 21 characters on mobile for me can fit on a single line.
I started with it
I prefer the first one too.
no i dont mean like that
Anyways this is a discord bot help channel
I am so done with the bot today.
i want to store a bunch of numbers like this: py 43623536647361
to represent a connect 4 board game position. whats the best way to put this into a database?
whats wrong with it now 😭
Nothing. I finished the weather bot update.
db abuse detected
thats a thing? 
if you could cache it, yeah :lol:
im tryna migrate 6000 strings like that over to an sqlite db and its not looking good
"python int too big for sqlite integer"
Migrating to sqlite db ,😭😭😭
should i just put it in as strings and call int() on them?
Use BIGINTEGER
its from a text file 😭
Bigint
W bro 🙏
I never had that problem though 😭
?
What shit are you using 😭😭
use sqlite3 :noice:
i put one of the numbers iunto binary and i got this 💀 py 0b1001111010110011100101011001111101110011000001
sqlite3 db browser
i am 
😭
alr 😭
What the hell dude how do you even come up with that 😭😭😭
Also this belongs in #databases no offence
import sqlite3
connection = sqlite3.connect("data.db")
cursor = connection.cursor()
query = "CREATE TABLE IF NOT EXISTS smth (number BIGINT)"
cursor.execute(query)
connection.commit()
its literally normal 💀
oh yeah mbb. i basically live here
I think I'm underinformed
definitely are
You forgot to close the cursor 👁️👁️
I hope it does
just like pointers in cpp 😔
Just like your problems irl 😔
fucking liar py self.conn.execute('INSERT INTO connect4 VALUES (?, ?)', (moves, evaluation)) OverflowError: Python int too large to convert to SQLite INTEGER


You can get banned for cursing others
wait i'll get it to print whatever it failed and keep going

Use a BIGINT
if bigint doesnt work the only possible thing i'd see would be making it TEXT
what do you think i just did 😭
Use sqlite3 browser
in sqlite, all integer types are signed bigints already
# last 3
Failed to upload board moves 32364511663516535572337576216.
(Evaluation: -2)
Failed to upload board moves 14711164625315265231526226375765447437733.
(Evaluation: 0)
Failed to upload board moves 2275634273633217117526375347415.
(Evaluation: -4)```
hmm why wont my db store these? 
Wth 💀sqlite is weird
ints won't be suitable for this purpose then, you'll want to serialize it to a byte stream / BLOB
time to move to #databases tbh

Shorten your integers 😳
kick has raidrd an exception Member obj has no atribute "guild_permission"
well there you go
guild_permissions
!d discord.Member.guild_permissions
property guild_permissions```
Returns the member’s guild permissions.
This only takes into consideration the guild permissions and not most of the implied permissions or any of the channel permission overwrites. For 100% accurate permission calculation, please use [`abc.GuildChannel.permissions_for()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.GuildChannel.permissions_for).
This does take into consideration guild ownership, the administrator implication, and whether the member is timed out.
Changed in version 2.0: Member timeouts are taken into consideration.
see?
minor spelling mistake 😔
thats when i try to use:
if not interaction.user.guild_permissions.administrator:
await interaction.response.send_message("You can't run this")```
What's the error
you spelt it wrong
now the spelling is fixed
im dumb

this the same mf with like 30 commands in his main file “because it looks cooler”
stop calling everyone you see a mf 😭 🙏
its like having a person with no limbs in a dope outfit
they have to begin somewhere
does it look good? yes
do they look like a pillow? yes
is it practical? no
can they stand? no
can they walk? i dont think so
they need to begin on the right path
I don't know how i make commands in file and connected to the start file
That why
learn cogs 🗣🗣
and recommending to read the docs & official guides
and extensions 🗣🗣 (same thing but not same thing)
ray i dont wanna be that guy but likeee #1232755927380262922
😭 😭
did i spend them all on that db question
Why is visual studio code showing this as errors?!
import (discord)
import random
import asyncio
import datetime
import (aiohttp)
from (discord.ui) import Button, View
from (discord.ext) import commands
Is it because the extensions in V S C need to be updated?
why you are putting parenthesis in the imports?
that's invalid syntax
That's to show where it thinks there are errors at.
have you installed discord.py?
Forgot to mention that. Added parenthesis to show VSC thinks those are errors or "problems".
Yes, I updated it earlier today.
do you have multiple python versions installed in your pc?
I have no idea how I would even know.
you're not using a Virtual environment correct?
What is virtual environment?
...so you're not using it
it's probably this
are you in Windows?
Yes, I use windows 10 I believe.
run this command
py --list
it'll show the installed python versions
Installed Pythons found by py Launcher for Windows
-3.9-64 *
mh, did you put your python interpreter path in the PATH environment variable?
I have no idea.
Honestly no idea what that means.
If this was 1999 when computers were much easier to use, then I might know some things.
search on Google how to add python on PATH, if you don't remember if you selected the box to add the interpreter to PATH when installing python
is that python v3.9 
the issue that Vs code is showing is that it's unable to locate the packages, as if they are not installed, this suggest that you have some issues with your IDE or with your interpreter

I swear computers are hell to figure out.
Let's look.
That's the latest version right?
https://www.geeksforgeeks.org/how-to-add-python-to-windows-path/
I'm using that.
no...
this is the latest version
😭
guys python version is 3 and a half years old
But I literally updated both discord py and python earlier?!
Also NONE of these google searches is helping.
uhm, are you sure that you didn't update pip instead?
this guide is correct
no, pip is the default python package manager
with pip you install (update, etc...) libraries, pip is just a script written in python to install third party software and make it usable in your python files
I'm gonna be honest, I am very overwhelmed.
I suggest starting from the basics then
with python we refer to the interpreter, to update it you need to head to the python website, choose a python version, repeat the installation process (selecting the option to add the interpreter path to the PATH) and possibly deleting python 3.9 or at least knowing how to choose the correct python version when running commands
anyway this seems off topic for this channel
Yeah, okay.
I'll just let my self esteem drop to 0 here, but I'll try.
There are 500 different python to choose from?!
How am I supposed to know which one to download for windows?
THIS WHY I always stay at home to myself and never try to do anything, beccause I CAN'T EVER DO ANYTHING!
You should be fine downloading what it suggests in the homepage
Tbf I don't remember whether that button links to the page of all downloads or immediately downloads the latest version of Python to your system
In any case the latest stable version is 3.12.3 if memory serves right
Do you know what your operating system is and what processor you have?
Windows 10 and no idea the processor. I am really bad with computers.
I'm installing the python thing now.
A very slow and long download.
Make sure to add Python to path and allow administrator privileges if it wants to install the py.exe launcher under C:\Windows\System32
Oh you went ahead
I just guessed and hit install.
https://docs.python.org/3/tutorial have fun reading some






