#discord-bots
1 messages · Page 1003 of 1
i don't wanna start an argument here, but there's a certain attitude that was rubbing me wrong, anyone who's trying i'm very happy to help
it's not an argument, it's an instruction i expect you to follow @dull terrace going forward.
but i'll just be quiet next time i guess 
..
sparky, move on
Suggest more topics here!
Hey guys Im trying to connect my bot to heroku, but when I try connect it to my github repository I get this
help please?
owo
You can't mention members in fields titles can you?
this thing happened a few days ago
wait.. so what do I do
yeah u can't
thought so
it is suppose to be fixed or whatever
oh ok
but for now u can use heroku CLI
is heoku good?
the thing, just next to github
yeah but I dont know how to lmfao Im following a tutorial on how to do it but with github
https://www.youtube.com/watch?v=RQsAckxg9uI
In this tutorial, I'll show you how to host a Python Bot on Heroku so that it'll stay up 24/7. This works with any discord lib written in python.
Discord: https://discord.gg/xCrjUck
Install Git: https://git-scm.com/downloads
uhm.. my bot akito is still running on it.. tho i just have to switch to another account whenever my free dyno hours expire lmao
No
why not
💀if u click on it.. they show some tutorials on it
see here
mind helping pls? 😦
i agree with robin
it's NOT best, but for ppl "like me" who can't afford one.. it works :")
see, click on that "HEROKU CLI" option. and u will see the steps from there
ah ic, thanks
bru I dont understand it
click that
done
my friend use heroku and his bot is working fine
then watch youtube tutorial related to it just like how u were watching one for linking github repo with heroku :")
what next
hm
#discord-bots message lmao yes
I fell in love with this guy
https://www.youtube.com/watch?v=_WxRbxK2ClA
In this video I show you how to deploy python applications on Heroku. I deploy telegram bot on Heroku using Heroku CLI and Git. Deploying on heroku will help you to run your projects without your PC, and all users can use your bots constantly 24/7.
🍓 Get 3 months FREE of the Fastest VPN - https://www.expressvpn.com/gunther
Links:
- Heroku: h...
um is this fine for heroku
marry him :>
no, u need Procfile
is that the dockerfile of heroku?
bro wtf.. keep it in the parent folder
that procfile
😭 i don't wanna sound like a nub... but.. i've no idea about what is Docker.. tho i've heard of it a lot..
@paper sluice btw this is what we keep in our Procfile ^^
fine
ah dockerfile is similar, u just set instructions and the docker-thing will follow and do that
u can tell it to make a venv and install the req.txt for example
https://github.com/python-discord/sir-lancebot/blob/main/Dockerfile
check this out for example
help
you've to download it first lmao
no need im doing from website
thankss will check it out :>
....
uh
where how
https://dashboard.heroku.com/apps
hm
wha
there is some issues with github link that has been happeneing since past 3 days
idk xd
and that's why i suggested him to use Heroku CLI
💀 then check it
1 month*
oof
who said?
me
lol
i have tried it
i got the email when this issue happened... and it ws like 3 or 4 days ago
nah its from 1 month
I'd like help please
lmao
nvm.. it's actlaly from 9 days
ill show u proof
the bot is triggering on it's own message
the bot is detecting "sus" in its own message and sending, so the loop will continue infinitely
this will include the message sent by the bot, add a check like if message.author != bot.user
check the author of message, if it's bot -> stop
just return if the message's author is bot itself py if message.author == bot.user : return
you check if the message is sent by the bot, and return if true.
a single liner above your existing code
ngl i love single liner like.. they just look pro.. but sad thing? we can't use 'em in school exams
wait
wtf?
its sort of a convention to use that kind of syntax in other langs
like cpp
wait
💀 the thing is... if we use one liner in schools they be like.. we taught u this program to write in 5 or some lines & you're answering it in 1 line.. so no marks for u
that's what i'm tryna point out uk :")
@slate swan can u teach me how to use cli
lol i just followed the commands that it shows just next to github button in the dashboard
just copy paste it, it works lol
ya ik, same prob, our school teachers just cram cs and python for 20 years and think they know stuff :/
i used fstrings the other day and my teacher was like what is that, its not valid syntax
💀 ikr... they be having python 2 installed in their system & be.. nvm
lol
working fine no need
lol just tell me if it finally works
all set my bot is online
woahh
lemme connect my website to repo then instead of cli lmao
lol not working for me uff
heh scam 2022
...
Same
- it doesnt want to connect

Is there a free hosting like heroku 
FALIX NODES
that shit ain't working.. sparky is scamming us
ima report him :")
Ye
uh which country?
Any
its banned in some
Im from morocco so idk
u got to use vpn
ight
lets try
Gimme
wait
GIME
ill give refer link :>

Ppl in my support server asking when the bot is goinf to be online and i was like "im lookin for a good hostin service"😭😭😭 but sadly im just broke im lookin for a free one 💀😂
anyways, #965291480992321536 🙂
replying to a deleted msg
I dont think they did
they did
🤔i mean u could install the modules on heroku so
im talking about
falix nodes
Oh 💀
Well imma delete these VPN's
lmao
doesnt work for me
i sleep at 3
bru
i cant create venv help me
created virtual environment CPython3.8.10.final.0-64 in 12897ms
creator CPython3Windows(dest=C:\Users\hp\Desktop\bot\sluppybotfinal\env, clear=False, no_vcs_ignore=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\hp\AppData\Local\pypa\virtualenv)
added seed packages: pip==21.3.1, setuptools==58.3.0, wheel==0.37.0
activators BashActivator,BatchActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
idk much about envs lol
bruh
You don't use a venv?
no
What happens when you get dependency's clashing
delete one
hii
I see people use discord.ui in the videos
but I cant import such a thing
u already created
ye but
update dpy
https://learnpython.com/blog/how-to-use-virtualenv-python/
check this out if ur stuck
how can I
pip install git+https://github.com/rapptz/discord.py
that
u need to have git installed for that to work
do I need to change anything after that ?
i cant see any env folder
in my code
I mean is there any changes in other stuff
ya some minor things
f
check out the change log in the official repo, they must have the changes listed there ig
okay thanks
I hope they didnt change things that I used
@paper sluice why
Cloning into 'sluppybotfinal'...
warning: You appear to have cloned an empty repository.
empty repo?
is ur repo private or something?
idk

uh?
Is discord.py beginner friendly or i should pick something else to start in python before this?
second option
pick something else, discord.py is more definitely not beginner friendly
gn
there is my school after 4 hours
welp
gn
help pls
it worked before with normal discord.py
after I downloaded the one in github
it gives me that error
@tasks.loop(minutes=30)
async def vc_join():
await bot.wait_until_ready()
blablabla
Is there a way to timeout a user from a bot?
what ?
await timeout(until, /, *, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Applies a time out to a member until the specified date time or for the given [`datetime.timedelta`](https://docs.python.org/3/library/datetime.html#datetime.timedelta "(in Python v3.10)").
You must have the [`moderate_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.moderate_members "discord.Permissions.moderate_members") permission to use this.
This raises the same exceptions as [`edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member.edit "discord.Member.edit").
the new timeout feature on discord.... ?
How to catch Forbidden with try-except cause this doesn't catch it
how does it even relate to this!?
it doesn't work
await member.timeout(until = datetime.datetime.timedelta(hours = 3))
this doesn't work
until is positional only
what does timeout have to do with it!?
All args before / always are
so how do i fix it? @vale wing
Remove until =
I'd tell you if you needed to replace it with something
@slate swan where did you find something in my code that can be associated with timeout!?
so ```py
await member.timeout(datetime.datetime.timedelta(hours = 3))
Yes
okay
u what?
It most likely is because the SQL statement returns None.
If not then analyze your code to see where a variable is/could be None.
@slate swan @vale wing didn't work
You just confuse yourself doing it this way
Define "didn't work", did it give an error or smth
@potent light
Is there anyway to use timeout() on a member? it's in the documentation but when I try to use it it says Member doesn't have the attribute 'timeout'.
As I said, it's for discord.py 2.0 so consider updating it with the tutorial on https://github.com/Rapptz/discord.py
Because you are using old version of dpy
The one that I am currently using is 1.7.3
There's faster method
ah oki
$ pip install -U git+https://github.com/Rapptz/discord.py```
Basically the same but shorter
Note that you will need to do dome changes to your current code
Yes like making all cogs/extensions loading async
Consider talking a look at this https://discordpy.readthedocs.io/en/master/migrating.html to migrate to v2.0
Another thing I don't like about dpy 2.0
" thank you for the decision" - oh, sorry, this is sarcasm. I hope there is such a word in the English language
@commands.command(aliases = ['$', 'money', 'bank', 'банк', 'Money', 'Bank', 'Банк'])
async def __balance__ (self, ctx, * , member: discord.Member = None):
if member is None:
await ctx.send(embed = discord.Embed(
description = f"""Баланс пользователя **{ctx.author}** составляет **{cursor.execute("SELECT cash FROM users WHERE id = {}".format(ctx.author.id)).fetchone()[0]} :leaves:**"""
))
else:
await ctx.send(embed = discord.Embed(
description = f"""Баланс пользователя **{member}** составляет **{cursor.execute("SELECT cash FROM users WHERE id = {}".format(member.id)).fetchone()} :leaves:**"""
))```
Why does everything work when I check the bot's balance, and when I check the user's balance, an error is issued ???
ERROR
```Command raised an exception: TypeError: 'NoneType' object is not subscriptable```
I know it's because of [0] so I want to find out how to fix it. Please don't tell me again that it's because of [0]
It is because of those weird strings inside strings
NO
Why not do it like this
cur = cursor.execute("SELECT cash FROM users WHERE id = ?", ctx.author.id)
bal = cur.fetchone()
# and then put the bal into your string```
Idk what fetchone returns cause I haven't used sqlite for a while
Postgres wrappers have fetchval 😎
how do i remove the [] and "" from a list to just get the raw string
is there a function for it?
str.join(iterable)```
Return a string which is the concatenation of the strings in *iterable*. A [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") will be raised if there are any non-string values in *iterable*, including [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "bytes") objects. The separator between elements is the string providing this method.
@vale wing
Postgres is too difficult, there are almost no lessons on it on YouTube. And according to the documentation, it is unrealistic for a beginner to work. Since there was nothing there.
You use it like this
ls = ["stuff", "yes"]
print(", ".join(ls))```
I never told you to use postgres
I just showed how to do this with sqlite for less confusion
I said that just in case
Imho postgres is very easy besides its setup
Setup is aids for beginners that might be right
And yeah you don't get stuff like INSERT OR REPLACE that you have in sqlite
So.
@vale wing
got the same problem than 12 hours ago 😄
Command raised an exception: ValueError: parameters are of unsupported type
Hello is there possible to block link from About me section in python with a bot?
how do i make it so i dont have to put " " if i have a role with a space
https://tokyotokyotokyotokyo.tokyo/
code:
@commands.group(invoke_without_command=True)
async def role(self, ctx, role: discord.Role, member: discord.Member = None):
if member is None:
await ctx.send("missing arguments")
if member is not None:
if member.top_role >= ctx.guild.me.top_role:
await ctx.send("i can't edit roles from users above my top role")
if role in member.roles:
await member.remove_roles(role)
await ctx.send(f"**{role}** has been removed from **{member}** 👍")
else:
await member.add_roles(role)
await ctx.send(f"**{role}** has been added to **{member}** 👍")
so im using dpy 2.0
@client.event
async def on_message_delete(message):
content = message.content
for some reason the content is always blank anybody know how to fix it?
?
if yk, mention me
Did u enable message content intents
!d discord.Intents.message_content
Whether message content, attachments, embeds and components will be available in messages which do not meet the following criteria:
• The message was sent by the client
• The message was sent in direct messages
• The message mentions the client
This applies to the following events...
how do i enable it on my script
huh?
the content off the message is blank it isnt suppoused to
Message intents
intents = discord.Intents()
intents.message_content = True
bot = Bot(..., intents=intents)
can i add two intents
yes
what param?
ctx.guild.region
AttributeError: 'Guild' object has no attribute 'region'
i just switched to dpy 2 its getting a few errors here and there
deprecated
Its deprecated
how to give a role to the author of a bad word ??
elaborate
await message.channel.add_roles(guild.roles, name = 'МУТ')```
not work
??
message.channel.add_roles: tries to add a role to a channel, obviously will not work
message.author.add_roles: hm maybe this will work
I have an event that reacts to bad words and issues a warn . and on 3 warn he should give out the role of mut
await message.channel.add_roles(mute_role)
AttributeError: 'TextChannel' object has no attribute 'add_roles'```
@reef trail I've already read it and I did it that's my mistake
await message.channel.add_roles(mute_role)
AttributeError: 'TextChannel' object has no attribute 'add_roles'```
okay so why are you sending an irrelevant error
Why does my member join work but my member leave doesn't?
@client.event
async def on_member_join(member):
print("Member Join")
@client.event
async def on_member_leave(member):
print("Member Left")
its on_member_remove, not leave
Oh ok thank you
you can copy the keys in your check_up_times dict and iterate through that so the for-loop doesnt prevent attention_message from deleting the user key, e.g. py for user_id in list(self.bot.check_up_times): ... # any changes to the dict won't affect this list
^ this approach relies on send_attention_message() always completing before the attention loop ends, which right now it does, but if you somehow change it so the attention loop is able to re-run while there are pending reactions, you need to make sure it doesnt send a second message to the same user
also your wait_for check should compare the reaction's message so it doesnt accidentally trigger when someone else reacts with ✅ on a different message
oh and for simultaneous checkups you can use asyncio.create_task(self.send_attention_message(...)) to have them run in the background
i think a dictionary keeping track of currently active checkups would be fine
class MyHelp(commands.MinimalHelpCommand):
def get_command_signature(self, command):
return '{0.clean_prefix}{1.qualified_name} {1.signature}'.format(self, command)
async def HelpEmbed(self, mapping: [dict] = None):
e = Embed(
color=0x8e65b3,
description=f'**questions @ woke#7396**\n'
f'{len()} commands in total\n'
f'')
if mapping:
for cog, command_set in mapping.items():
filtered = await self.filter_commands(command_set, sort=True)
if not filtered:
continue
name = cog.qualified_name if cog else "no category"
command_list = ', '.join(
command.name for command in filtered
)
value = (
f'{cog.description}\n{command_list}'
if cog and cog.description
else command_list
)
e.add_field(name=name, value=value, inline=False)
return e
how do i get the total amount of commands in a cog file when bot hasn't been defined yet?
it's this line to be exact:
description=f'**questions @ woke#7396**\n'
f'{len()} commands in total\n'
f'\u200b\n')
where are you using HelpEmbed?
because i named it that...?
Does any one know to where the bot would show the users age profile? Like this
what
wdym what, what in the world is not clear about that sentence man
Like have it have to where itll say the user age and the user verification from your server
where are you using that method inside the class?
because of:
async def send_bot_help(self, mapping: dict):
e = await self.HelpEmbed(
mapping=mapping
)
await self.get_destination().send(embed=e)
async def send_command_help(self, command: commands.Command):
pass
async def send_cog_help(self, cog: commands.Cog):
pass
send_group_help = send_command_help
literally all inside the same class
the MyHelp class
typically the bot will be accessible when the help command is invoked since the context attribute should be filled, but this depends on how you're using that method - in your case it is accessible using self.context.bot
add another parameter to HelpEmbed and then do ctx.bot.commands
Yes?
thank you
self.context is only accessible in send_ methods.
it works tho lol
exactly, they're invoking HelpEmbed from a send method
yes
@slate swan do the same thing i mentioned here, i.e. compare the msg sent with the reaction.message you're listening for
This may be a really dumb question but why type of bytes of does attachment.read() return? I need to load it into PIL.Image, and it needs to be one of ['1', 'CMYK', 'F', 'HSV', 'I', 'L', 'LAB', 'P', 'RGB', 'RGBA', 'RGBX', 'YCbCr'] Using discord.py.
well the image data is arranged according to the image attachment's format (e.g. png / jpeg), which i believe pillow should autodetect for you when you pass the bytes
Does any one know how to get the bot would show the users age profile? Like this
what do you mean by where?
^?
how do i get the overal amount of people who use the bot (https://tokyotokyotokyotokyo.tokyo/)
!d discord.Client.users
property users```
Returns a list of all the users the bot can see.
does this also apply for all the guilds the bot is in?
yes, it needs member intents enabled
just typehint that argument as discord.User ....
you could just handle the discord.NotFound exception of guild.unban
???
if you don't know how to handle exceptions: https://docs.python.org/3/tutorial/errors.html#handling-exceptions
you know what a typehint means right?
if not, you need to learn python.
unfortunately no and sure how would i learn "python"
i have done many courses
but they have functions lists and dictionarys
nothing about typehints
i have been trying to find a good course if you could find me one thatd be amazing
could you mention the course you used?
codeacademy w3schools
anyone got time atm?
https://docs.python.org/3/library/typing.html this is what typing means
you basically mention the class of data type the argument is
liwe this?
im talking about the argument, not the function itself
im clueless
just replace the member_id's typehint to discord.User
you already typehinted it with str just replace str
also typehinting
i have no fucking clue tbh i didn't read what your problem was
Is it normal that it takes sometimes till the bot with slash commands get his new options (name & value)
why so complicated? u just want to unban ppl right?
for updating global commands yes, those take up to an hour to get synchronized
damn that's one sus avatar and banner
🙂
okay okay I thought I did something wrong.
I hate slash commands yet and just started
but still....
working 😄
to check
if user is not found i hate errors
or not error handled code
so yeh
@hushed galleon how do I send embeds in choices?
@slash.slash(
name="Hilfe",
description="Die Hilfe für dich!",
options=[
create_option(
name="option",
description="Wähle deine Hilfe Kathegorie",
required=True,
option_type=3,
choices=[
create_choice(
name="Hilfe Clear",
value="Clear Commands.. Comming soon.."
),
create_choice(
name="Hilfe Admin",
value="Admin Commands.. Comming soon"
)
]
)
]
)```
Like in here... how do I put a embed in it
tried a few things but im flipping out when I always need to kick and re-invite the bot all the time xD
💀 oh man
you cant directly tell discord to give you back an embed to send, that you would just write in your command to check what choice they selected
why not use newest
discord.py v2

theres a normal way like that too
why is everyone telling some other things in this dc 
everyone is saying something else, so funny
So when I ask how I build a embed in this command I want to know how to build it in there, if u dont know pls shut up 
dont tell them to shut up, they're only just recommending you use a maintained implementation of slash commands
because that Library is extremely outdated, and using 3rd party plugins is always bad
^ ive only figured out just now that discord_slash became the "legacy" version of what is now interactions.py, no wonder i couldnt find the documentation before
u know I changed everything yesterday with the others
^ that’s what I use
idk about the codebase, but nice library in terms of syntax and classnamings etc
good @slate swan trying it now and it works but got a spam problem all the time:
everytime when a message got send on my dc this happens
should I try to re invite him?
I mean it works but my console is full of it.
im really confused rn
You cant await an async function
but you cant call an asynchronous function then
how would i call an asynchronous function without being able to await it
or is there another way
!d asyncio.run
asyncio.run(coro, *, debug=False)```
Execute the [coroutine](https://docs.python.org/3/glossary.html#term-coroutine) *coro* and return the result.
This function runs the passed coroutine, taking care of managing the asyncio event loop, *finalizing asynchronous generators*, and closing the threadpool.
This function cannot be called when another asyncio event loop is running in the same thread.
If *debug* is `True`, the event loop will be run in debug mode.
This function always creates a new event loop and closes it at the end. It should be used as a main entry point for asyncio programs, and should ideally only be called once.
Example...
usually you have one place that starts the event loop, e.g. your main.py file, so in there you could have an async main function and then use asyncio.run() to run it: ```py
async def main():
bot = commands.Bot(...)
# Connect to database here and add as a bot var
async with aiosqlite.connect('xyz.db') as conn:
bot.conn = conn
await bot.start(TOKEN)
asyncio.run(main())```
or you can use setup_hook if you are on 2.x
the hack is that ? -> line 22 but theres nothing
Show code
button = interactions.Button(
style=interactions.ButtonStyle.PRIMARY,
label="Hilfe Admin",
custom_id="/clear um den Chat zu clearen\r\n",
"/mute um einen Spieler zu Stummen\r\n"
)
button2 = interactions.Button(
style=interactions.ButtonStyle.DANGER,
label="bye bye!",
custom_id="bye!",
)
row = interactions.ActionRow(
components=[button, button2]
)
@bot.command(...)
async def test(ctx):
await ctx.send("rows!", components=row)
Did it like on the website
everything worked but not that
if your decorator isnt on line 22 it means the running code is different from what you have
I cp it from the website
you still have the ... left there
How can I add a masked link?
masked?
ye and what should be there then?
Im confused bc I just did what the side said...
You can’t just copy paste it
hyperlink
^ +1
no shit rly? I thought I could 🙂
lmaos orry for ping lmOAO
Anyone know what _MissingSentinal is? Is it like the same thing as None or something?
Ignoring exception in view <View timeout=180.0 children=1> for item <Navigator placeholder='Select a module/cog to view.' min_values=1 max_values=1 options=[<SelectOption label='Meta' value='Meta' description='' emoji=None default=False>] disabled=False>:
Traceback (most recent call last):
File "C:\Users\dgile\Documents\Projects\Asahi\venv\lib\site-packages\discord\ui\view.py", line 413, in _scheduled_task
await item.callback(interaction)
File "C:\Users\dgile\Documents\Projects\Asahi\src\cogs\help.py", line 61, in callback
await self.ctx.bot.help_command.send_cog_help(self.ctx.bot.get_cog(self.values[0]))
File "C:\Users\dgile\Documents\Projects\Asahi\src\cogs\help.py", line 24, in send_cog_help
await self.context.send(
AttributeError: '_MissingSentinel' object has no attribute 'send'
Production Code:
async def send_cog_help(self, cog: commands.Cog):
await self.context.send(
embed=discord.Embed(
title=f"Help for {cog.qualified_name.replace('_', ' ')}",
description=cog.description or "No Description",
color=self.context.bot.info_color
).add_field(
name="Commands",
value="\n".join([f"`{i.qualified_name}`" for i in cog.get_commands()])
).set_footer(
text=f"This cog currently has {len(cog.get_commands())} commands",
icon_url=self.context.bot.user.avatar.url
)
)
copy pasta from websites aren't always good.. and they not gonna teach u until u learn/understnd it :>
it's the context for a help command
you'd pass whatever kwargs you want to the command decorator according to their documentation
https://discord-interactions.readthedocs.io/en/latest/client.html
and?
[text lmao](https://google.com)
pityesports 🤔
That wasnt my question. Im asking what a _MissingSentinal is and why its being propagated.
what's self?
Usually context would be there. _MissingSentinal basically it like None
HelpCommand class
hm
and this is usable for title aswell?
Embed title?
😭 as long as it is used in embeds, yes.. but yeah, it won't work in name of embed field(s)
you cant directly use send_cog_help from the help_command attribute of bot as the HelpCommand was designed to be invoked from a regular command
Do you know why its being propagated in that instance where context should be implied.
is there any way to make it work as the title?
In an embed?
yes.
use the url kwarg in the embed object
anything important in there? its annoying.
i said that it DOES work in title
What do you recommend me doing instead. I tried to think of workarounds but that was the only thing i thought would work in the moment
It didn't work for me.
!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`.
discord.Embed.url @slate swan
If it helps. Heres the current implementation. https://paste.pythondiscord.com/eyivegijil
!d discord.ext.commands.Context.send_help
await send_help(entity=<bot>)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Shows the help command for the specified entity if given.
The entity can be a command or a cog.
If no entity is given, then it’ll show help for the
entire bot...
invalid for some reason
Thanks!
bro?
Depends
sqlite3
can't be invalid.. show your code bruh
!pypi aiosqlite
that's blocking in an asynchronous context.. use aiosqlite3 instead
^ +1
yes ik but i cant figure how to to do asyncio.run in defining client
cause im trying to get prefix but asyncio.run just gives an error
someone helped you before..
masked_link_embed=discord.Embed.url(title='[**Hi**](https://nono.ns/)', colour = discord.Colour.green())
await ctx.send(embed=masked_link_embed)
💀 oh gawd wtf..
just this
😭
no.. title='Hi', url='https://nono.ns/'
^ @slate swan
Oh that actually makes sense
!d discord.Embed 😭 it was here already..
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`.
shit
can I add 2 titles?
command_prefix=get_prefix @green bluff
💀
no
No
send_help could work, although it comes with the caveat of having to create another HelpCommand instance; the alternative is passing the help command object to your navigator and using send_cog_help from that: ```py
class Navigator(discord.ui.Select):
def init(self, ctx: AsahiContext, help_command: AsahiHelp):
...
async def callback(self, interaction: discord.Interaction):
await self.help_command.send_cog_help(...)```
Hi
Make it bold
💀 description is always bigger than title.. and it has more character limit that title
font I mean
oh lmao he meant that in terms of thickness? lol
my bad :>
Why not await self.ctx.bot.help_command.send_cog_help(...)?
how would I do it then?
the help command object thats actually calling send_bot_help is a deep copy of the one stored on the bot; bot.help_command by itself isnt associated with any context (there's a note about why it does a deep copy in the HelpCommand documentation)
hey, what does async def riddle(self, ctx, *, question): what is the "*" in the paramaters mean
You can take a look at it here https://discordpy.readthedocs.io/en/stable/ext/commands/commands.html#keyword-only-arguments
It is explained along with other types of parameters
makes sense, thanks!
Can someone explain in layman's terms how bots work. Do they pull from a list of acceptable responses? Do they build their own sentences. I'm going to try and learn python again and I think a chatbot would be fun but don't want to get in over my head on the first one! 😅
idk where I missed it...
@bot.command(
name="Erster Befehl",
description="Test UI",
options=[
interactions.Option(
name="Command1",
description="Beschreibung1",
type=interactions.OptionType.SUB_COMMAND,
options=[
interactions.Option(
name="option",
description="Beschreibung2",
type=interactions.OptionType.INTEGER,
required=False,
),
interactions.Option(
name="Command2",
description="Beschreibung3",
type=interactions.OptionType.SUB_COMMAND,
options=[
interactions.Option(
name="option2",
description="Beschreibung4",
type=interactions.OptionType.STRING,
required=True,
),
],
),
],
)```
Am I blind or what
It is?
or which one ur talking about, but they should be closed, if not it would show another error
should be
but Idk how to close the options on top.
if I put it another ] it closes something else
you passed in the options kwarg twice
huhg
why isn't loading cogs on 2.0?
client = bot
for filename in os.listdir('./cogs'):
if filename.endswith('.py') and not filename.startswith('_'):
client.load_extension(f'cogs.{filename[:-3]}')
no thats how they implement subcommands
speaking of which that is a copy paste of their example which has the syntax error
my problem is that it does not close
anyone know how to how to string parse math for a math command
Load extension and add cogs need to be awaited so load extensions in the setup hook
in 2.0 they made load_extension and add_cog async methods, so you have to await them
oops
so that means that you don't use that anymore on 2.0?
You do. You just await them now
im finding this really difficult to do, and noone knows a simple enough way to
@commands.command()
async def math(self, ctx, *, args): #todo```
bot.load_extension('cogs.utility')
await bot.load_extension('cogs.utility')
like that?
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/master/api.html#discord.Client.login "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/master/api.html#discord.on_ready "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/master/api.html#discord.Client.wait_for "discord.Client.wait_for") and [`wait_until_ready()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.wait_until_ready "discord.Client.wait_until_ready")...
what-
...
ive never used that and my cogs load just fine
It’s new in 2.0
you can set it to a transparent colour i think
how?
not sure what it is
o i see ty tho ill try look it up
its not a transparent embed color, its just the same color as Discord background
no?
because i tried that and u can see colour when highlited
change your theme to light theme and see it yourself 🙂
ok
the hex for that color is 0x36393F
oh lmao and ow my eyes hurt
but his embeds look the same when highlighted
not the same in lightmode tho
cause discord provides no option for transparent embeds
ik but how does his one
look the same while highlighted
thats just the same colour as the discord dark background
like the colour u gave me looks different when i hover over the message
Nope - peuple tend to keep the embed look and have color the same as the embed dark gray color.
Inspecting the embed element will give you that color as background, more specifically the background-secondary variable. Which is --background-secondary: #2f3136;
Wow
thanks
Because that's how Discord's CSS works and you can't change it
thanks too
i mean background secondary
They don't provide real support for transparent color as already said so the closest you can get is to have the same color as the background.
looks just like background
isnt that the colour when you hover on the embed?
No
if answer.lower() == "toothbrush":
ctx.send("Correct Answer")
Is there a way I can make it so after someone guesses the right answer, the answer isn't claimable anymore? For example, the user guesses the right answer and gives them a role but nobody else after they guess it can put the answer in and get the role?
Works fine
Just return, no?
wdym?
As we don't know how you've implemented the command/feature so far we can't help but just guess on solutions.
I need it so lets say you guess the answer and then I see you guess the answer, I just take it and put it in for the same reward you got. I want it so where its a "one-time" answer kinda thing
oh my bad, i meant the embed's bg color, and i got that hex from disnake's Color.dark_theme
which seems to do the same
Not really - you don't keep the embed "layout"
It won't look as "good" as with the other one which will still keep the rounded corners
good morning
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
async def send_bot_help(self, mapping: [dict] = None):
e = Embed(
color=0x8e65b3,
description=
f'**questions @ woke#7396**\n'
f'{len(self.context.bot.commands)} commands in total\n'
f'\u200b\n'
)
if mapping:
for cog, command_set in mapping.items():
filtered = await self.filter_commands(command_set, sort=True)
if not filtered:
continue
name = cog.qualified_name if cog else "no category"
command_list = ', '.join(
command.name for command in filtered
)
value = (
f'{cog.description}\n{command_list}'
if cog and cog.description
else command_list
)
e.add_field(name=name, value=value, inline=False)
await self.context.send(embed=e)
``` how do i make it so it gives me the filtered command count instead of the full command count
How do you get a category by its ID in py?
you could use discord.utils
for example
import discord
discord.utils.get(ctx.guild.channels, id=category_id)
guild.channels?
ctx.guild.channels
dont work
wdym
weird
category = discord.utils.get(ctx.guild.channels, id='968374998823755806')
channel = await ctx.guild.create_text_channel(name=f'{ctx.author.id}', category=category, overwrites=overwrites)
Get the length of filtered commands
id is string
oh
but it's defined after that, how do i do that then?
it has to be an integer
You have
icon_url=-member.display_avatar
^
Just get its length?
filter_commands returns a list, get the length of the list
gives me errors
wait sec
dont work
2 problems
Because you need to define your embed it later
It's called variable scope
nvm fixed it w this " category = discord.utils.get(ctx.guild.categories, id=968374998823755806)"
Your filtered variable is only available within the for loop and below but still in that loop scope
yeah thats what im saying
Then just save the count in an outside variable and define your embed at the end
And you probably can't make multi lines like that
multi lines like what?
description=
stuff
what makes u think i can't?
?
It's a guess based on your IDE's errors you say
oh that's im tryna get the filtered commands count
Well then you can do such horrible code 
if i have the original code, it doesnt have any problem
horrible code isn't horrible if it works
change my mind B)
Hello, I am In an blockfront minecraft server and i was wondering how do i make the welcome message unique?
my bot is hosted on aws and i used nohup to run it and now i cant see it in ps and cant turn it off
are you sure i can get the len of the filtered commands? because ive been trying and it keeps giving me problems when i try to get the length of the list
how to make time mute?
It returns a list
You can get its length
You already use the function filter_commands and save it in a variable
Simply save its length in an outer variable and then build your embed
Yeah but when I try to save it's length its giving me errors
Well I can't see your screen nor code :)
pardon the language, how can i make a similar mute?
As I can't read Russian I will make a guess..
Mute the user, then use asyncio.sleep to sleep an amount of seconds which will be given by the user, then unmute the user
oh, sorry
wait
If you want to mute a user for a specific time the explanation above is right
Although I would recommend to use the timeout feature that Discord now has
Because no versions of discord match >1.7.3,<2.0.0
and discord (1.7.3) depends on discord.py (>=1.7.3), discord (>=1.7.3,<2.0.0) requires discord.py (>=1.7.3).
Because discord.py (1.7.3) depends on aiohttp (>=3.6.0,<3.8.0)
and no versions of discord.py match >1.7.3, discord.py (>=1.7.3) requires aiohttp (>=3.6.0,<3.8.0).
Thus, discord (>=1.7.3,<2.0.0) requires aiohttp (>=3.6.0,<3.8.0).
So, because python-template depends on both aiohttp (^3.8.1) and discord (^1.7.3), version solving failed.
at venv/lib/python3.8/site-packages/poetry/puzzle/solver.py:241 in _solve
237│ packages = result.packages
238│ except OverrideNeeded as e:
239│ return self.solve_in_compatibility_mode(e.overrides, use_latest=use_latest)
240│ except SolveFailure as e:
→ 241│ raise SolverProblemError(e)
242│
243│ results = dict(
244│ depth_first_search(
245│ PackageNode(self._package, packages), aggregate_package_nodes
/home/runner/Cadmus-slash/venv/lib/python3.8/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
exit status 1
``` what did i missed in installing ?
What did you run
my bot...
The command
pip install discord.py
oh the start cmd nothing else im just getting started
replit?
Yea
@shell wing try this
$ python3 -m pip install discord.py```
And for god's sake don't use replit
👀😳
Why not use VSC
idk...
Like pycharm may be heavy but what's wrong with vsc
i think @shell wing wants hosting
i can use pycharm...
that too
alr alr 👀
that errors weird asf, back when i used to use replit, it was annoying asf and i had no idea how to solve it
@shell wing ^
ah, always on?
yea + new machine and stuff
alr
import os
try:
bot.run(os.getenv("TOKEN"))
except:
os.system("kill 1")
bot.run(os.getenv("TOKEN"))
oo
well the issue is common ip so if rate limited it wont work
even after killing it
it used to work for me tho
tho idk i stopped using it a while back
how to make a kick reason, but if it was not specified there was no reason = none?
add an argument. reason=None
Using subprocesses.run is better imho
wth is wrong with my keyboard
discord.NotFound
so uh
what would i write
ive only handled bad arguement and missing permission
exceptions so far
the exception is what i said
nowhich is?
which is?
could you give me an article of soem sort
You just said you handled 'bad arguement and missing permission'
How did you handle them
Then, do the same for NotFound
so error, discord.NotFound?
!d discord.NotFound
exception discord.NotFound(response, message)```
Exception that’s raised for when status code 404 occurs.
Subclass of [`HTTPException`](https://discordpy.readthedocs.io/en/master/api.html#discord.HTTPException "discord.HTTPException")
what error would this be
i had an increase in braincells after learning how to error handle
uhm
converting "e" to an integer?
the full traceback
return await self._callback(self.binding, interaction, **params) # type: ignore
File "c:\Users\notvi\Desktop\Opal\Opal[TESTER]\cogs\Ban_Util.py", line 99, in unban
mem = await self.client.fetch_user(int(member_id)) or self.client.get_user(int(member_id))
ValueError: invalid literal for int() with base 10: 'e'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\notvi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\app_commands\tree.py", line 1092, in call
await command._invoke_with_namespace(interaction, namespace)
File "C:\Users\notvi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\app_commands\commands.py", line 629, in _invoke_with_namespace
return await self._do_call(interaction, transformed_values)
File "C:\Users\notvi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\app_commands\commands.py", line 622, in _do_call
raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'unban' raised an exception: ValueError: invalid literal for int() with base 10: 'e'```
Anyone knows how to catch disnake.Forbidden with try-except? Cause I do have it but still getting it unhandled
instead of converting it to an integer later , you could have typehinted it to int and it would raise an commands.BadArgument if it was not an integer
nope because discord cant take their own ids as an arguement
in a slash command atleast
try:
delete()
except disnake.Forbidden:
...
``` didnt work?
This is original code
As you can see no
disnake.HTTPException doesn't work either
Ig it's about those stupid wrapped exceptions
thats not how you use try except...
cause your message sending part is inside the except itself
!e ```py
a = {"id":1}
try :
pass
except:
print(a["test"])
is what youre doing
oh wait
did you try using try except blocks inside the methods the error comes from?
pls send discord role permission can ban
!d discord.Permissions.ban_members is what you mean?
Returns True if a user can ban users from the guild.
Are you following PEP 9001 😮
but I don’t understand what’s wrong, why it works but the unban message doesn’t come
example
discord.py database mysql prefix help!
why can i
still ban
when hes not in my server
it throws an error
which i dont know
how to handle
ive tried
Try except
Man do you think I am that dumb that I don't know how to use try-except
Look at traceback and see where it's raised from
yes
how to do it?
ImportError: cannot import name 'AppCommandOptionType' from 'discord.enums' (C:\Users\xavee\AppData\Local\Programs\Python\Python310-32\lib\site-packages\discord\enums.py)
why do i keep getting this error when importing from discord import app_commands
I don't personally use dpy 2.0 but I am guessing you need to from discord.ext import app_commands
@vale wing yeah i realise that later :)
That won't change anything
When the exception is raised in inner function it goes upside until it gets caught
no its from discord
not discord.ext
K
Well have you tried something like from discord.app_commands import ...
It might be a directory and not a package so you can't import it but once again - I don't know personally so it's a guess
app_commands is a folder
but it does have an __init__.py unlike the ext folder
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`.
this I know
:wtf
i asked this and u said embed
I don't know what's wrong here
How to catch Forbidden this doesn't catch it
it works but does not send a message
"{}".format(member.mention)```
Pretty nice construction
But why tf not just use member.mention
Yes but rule 4 exists
!rule 4
4. Use English to the best of your ability. Be polite if someone speaks English imperfectly.
i know
If you want to speak russian with me you can go to dms
There is something wrong with your other code or a global error handler that overwrites it.
I just tried and for me it works fine.
Does discordpy have a way to track how long someone has been in a voice channel?
Or do I have to do that myself manually?
By yourself
Sadge
well you can use bot to track it afaik
there should be a event checking if someone joins voice channel/leaves it. but I'm not 100% sure
its work, but the message is not sent
Define "its work"
Have you tried to debug to be sure it actually works as intended?
it should unban the user after K.unban and send a message like this
And does it work?
Does it unban the user?
!d discord.on_voice_update or smth idk
No documentation found for the requested symbol.
Hi, I keep getting this error message;
Traceback (most recent call last):
File "/home/runner/ParchedExtrasmallTaskscheduling/venv/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 17, in on_message
await sendchannel.send(message.content)
File "/home/runner/ParchedExtrasmallTaskscheduling/venv/lib/python3.8/site-packages/discord/abc.py", line 1065, in send
data = await state.http.send_message(channel.id, content, tts=tts, embed=embed,
File "/home/runner/ParchedExtrasmallTaskscheduling/venv/lib/python3.8/site-packages/discord/http.py", line 254, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50006): Cannot send an empty message```
There is. But I want to track how long a user has been in a voice channel
You're sending an empty message - as the error says
well it wont work anyways, since the banned user isnt a member anymore
!d discord.on_voice_state_update # This will help you
discord.on_voice_state_update(member, before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") changes their [`VoiceState`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceState "discord.VoiceState").
The following, but not limited to, examples illustrate when this event is called...
That's my point
I am not though, like
They said
its work
which it doesn't
Yes but that doesnt tell me how long I've been in a voice channel
welp
the bot was supposed to copy & paste it onto another channel, I send the message and it says this
oh been, then no I don't know
That tells you when a user joins and leaves, get the time delta and you have it
he unbans, but the message that he did it does not come
I know. I was just hoping the thing did it for me
well, I kinda got the bot scripted for me but the dude I paid to script is ignoring me so
Without code we can't help
save the time the user joined the vc and when they left it, subtract them and you have it
Yeah - a library doesn't do everything
self_bot....?
!rule 2
2. Follow the Discord Community Guidelines and Terms Of Service.
I meant
Self bots are against the Terms of Service of Discord.
OH
We won't provide help for that
bruh, this guy
\💀
@slate swan thank u
You can use https://discordpy.readthedocs.io/en/latest/intro.html and https://discordpy.readthedocs.io/en/latest/quickstart.html as a quick start to make a bot.
Then there are tutorials around on the Internet for further help and guidance
what's wrong? it doesn't send unban message
Just as side note, you're unbanning everyone from the server and not just a single member
This unbans every member that was banned
what to do?
me need unban 1 user
Add a check
To see if the current ban_entry.user is actually the member you want to unban
what to do with the message?
And you need to type hint the member parameter to discord.User - and rename the parameter to user so that is follows naming conventions.
Otherwise it will simply never work, banned users are no longer members of the guild.
ok
how do i detect if the user who clicked the button isnt the one that ran the slash command?
compare the ctx.author and interaction.user. depends what variable your button has, but use something like this
You can
you should have a bot.wait_for()
It's must not called ctx
Instead of ctx you can name it inter or interaction which is an object of type discord.Interaction.
!d discord.Interaction
class discord.Interaction```
Represents a Discord interaction.
An interaction happens when a user does an action that needs to be notified. Current examples are slash commands and components.
New in version 2.0.
it is interaction
That’s for the button
You then have the following attributes and methods
A slash command does have ctx as argument
Just like you handle all other errors in your code
but
someone told me in another server to use interaction_check instead, they didnt give me proper information tho
@brittle bear you probably have assigned something like `SlashCommand(bot) in your code, haven’t you?
no
How does your current slash command look like
Yeah as I said - it's discord.Interaction
You can see more examples here . https://gist.github.com/AbstractUmbra/a9c188797ae194e592efe05fa129c57f
discord.py 2.0a slash command info and examples. GitHub Gist: instantly share code, notes, and snippets.
but i specified @fathom gull.error
how to make one that detects all errors
sorry for ping oopsies
@app_commands.command(name="command-1")
async def my_command(self, interaction: discord.Interaction) -> None:
""" /command-1 """
await interaction.response.send_message("Hello from command 1!", ephemeral=True)
that is not going to help me
It does, since you now have a ctx like parameter
why ur app_command is not registering
is ur app_command not shwoing up
it takes an hour to show up without assigning a guild
Use a global error handler
nah, just do it on bot's dms
example?
Well then why do all the others try-except work fine
I have on_error overwritten but it shouldn't be what is causing errors as its purpose is to do logging and nothing else
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
Somebody suggest some discord bot commands...
What kind of bot
Bot command generator
lol
Just a general couple-of-friends server bot
I literally can't think of anything after "Hello!" command
I guide others to a treasure I cannot possess.
Vc handler
Lol
Traceback (most recent call last):
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "c:\Users\thoma\OneDrive\Desktop\discord server bot\Bot2.py", line 31, in on_member_join
await member.send(embed=Myembed)
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord_components\dpy_overrides.py", line 350, in send_override
return await send(channel, *args, **kwargs)
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord_components\dpy_overrides.py", line 325, in send
data = await state.http.send_message(
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\http.py", line 248, in request
raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50007): Cannot send messages to this user``` Is something to do with dms?
yes, the user's dms are closed
ok wow glad that i something

theme?
Is that js
u can
Traceback (most recent call last):
File "C:\Users\User\Desktop\бот дс\bot.py", line 34, in <module>
async def clear(ctx, amount = 1):
what to do?
you probably have a duplicate somewhere in your code.
