#discord-bots
1 messages · Page 56 of 1
Please keep it on-topic.
Ok sorry
Do you get paid
In lemons
Do you feed off lemons
are they good?
The best.
Can I have some
No.
Is there like a secret economy of lemons
no
i recently installed latest version
venv is not a feature limited to pycharm and changing dies don't fix runtime errors
try python3.9 -m pip install pillow
*IDES, autocorrect lol
python -V
i am using asyncpraw and i installed it but when i am trying to run the code, it is showing that asyncpraw is not installed ;-;
you definately have multiple versions of python then
oh-
type ctrl+shift+p and search for "python interpreter", it will show a list of all installations
hi, my bot is offline, im hosting it on heroku, it used to work then suddenly stopped.
the bot works when i host in vs code,
i tried deploying again, heroku says no errors, but its still offline
any suggestions?
Heroku is unsuitable for hosting that's it
i have 2 installed 🤡
is it better that i use my raspberry pi for hosting it?
Definitely
ok then
any alternative website tho?
Absolutely free no
how much would it cost if i have to pay
what kind of bot is it konrad ?
There are free tiers however
multi purpose bot
does it need much data/usage
Oracle cloud, amazon aws and microsoft azure
if not i can hook you up with a docker container that can run python code
sqlite is just a local file if i remember correct ?
Yes
ok thanks,ill check the first and third, cause aws isnt suitable for individuals i think
It is
what u mean
idk what a docker is
But they all need Credit Card information
It's just not beginner friendly
Containerisation service
😭
Why cry

i know the two words
It's highly recommended to use a container for hosting discord bots
No really need to google, you'll break your brain if you're inexperienced with that. I have a guide 😉
@faint sapphire isolated environment where you can run python stuff
i have this server on 24/7
i see
You have raspberry pi don't you
yes
Then just use it
i often dont have wifi, thats why i was opting for a website
also waiting to receive a cooler
cause cpu be getting hot
i also make it run code where i use pynput
for things that cant be done through script alone
i have async praw installed and yet i am getting this error, pls help ;-;
show full traceback pls
how did you install that package?
do python --version
@silk fulcrum
hmmm
.
pip show asyncpraw
huh
install using python -m pip install library
!dashmpip
When trying to install a package via pip, it's recommended to invoke pip as a module: python -m pip install your_package.
Why would we use python -m pip instead of pip?
Invoking pip as a module ensures you know which pip you're using. This is helpful if you have multiple Python versions. You always know which Python version you're installing packages to.
Note
The exact python command you invoke can vary. It may be python3 or py, ensure it's correct for your system.
yeah thought of that
linux moment
lmao
when was the last time you updated your distro
today?
arch, manjaro, kali, ubuntu, etc all use only 3.10 or atleast 3.9 atm
a full system update?
no
2.8 and 3.8 are just saved in memory
i dont use them and my PC neither
maybe i should delete them
well not sure about my sys
probably someone out there uses 3.8
or 2.8 😳
meh i installed some apt package called python3.9-is-python or something and now python is used for 3.9
i think that is not necessarily to install some packages
did that a year ago, don't care to boot into that distro now
just sudo mv /usr/bin/python3.10 /usr/bin/python
i remember managing versions with php, there was some command where I could manage which php version will php command use, there were php 7.4, 8.0 and 8.1
idk
Cool 🤡
hey guys, i recently switched to dpy 2.0 and is currently trying to get slash commands to work
import discord
from discord import app_commands
from discord.ext import commands
class MyCog(commands.Cog):
def __init__(self, bot: commands.Bot) -> None:
self.bot = bot
@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)
@app_commands.command(name="command-2")
@app_commands.guilds(discord.Object(id=962001190558769182))
async def my_private_command(self, interaction: discord.Interaction) -> None:
""" /command-2 """
await interaction.response.send_message("Hello from private command!", ephemeral=True)
async def setup(bot: commands.Bot) -> None:
await bot.add_cog(MyCog(bot))``` i've used this code from a git rep for base understanding, but this doesn't seem to work(i have other commands that are not slash commands, can this be the reason?)
You need to sync them
!d discord.app_commands.CommandTree.sync
await sync(*, guild=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Syncs the application commands to Discord.
This also runs the translator to get the translated strings necessary for feeding back into Discord.
This must be called for the application commands to show up.
Don’t sync automatically
Make a sync command which registers as a message intent command or some kind of external listener to do it when you like
Sync when commands are modified, added, removed
or use jishaku's
Tangent
async def on_ready(self):
await self.wait_until_ready()
if not self.synced:
await app_commands.sync(guild = discord.Object(id =962001190558769182))
print('Synced')```
it's still not syncing for some reasons
dunno why but after switching to dpy 2.0 i don't get errors for things i should, like if the bot edits a message that doesn't exist it should throw an error but in 2.0 it doesn't anymore
Maybe you have a faulty error handler
NOOOO
Those cause a lot of errors
nooway there are not only lot of errors
they synced in on ready
thats so shitttttty
at least do it like this gist says https://gist.github.com/Ash-02014/b6f57065f394b54f43666037ade38d32
it says to do it in setup_hook
but at least not in on_ready
im really sorry mate just trying to get to 2.0
i think i've gotta play more minecraft
tryna upate?
this channel still shows me some shit
python -m pip install discord.py --upgrade
no, i've updated and i am now understanding the basics
mute it then
kk
await tree.load_extension(f"cogs.{filename[:-3]}")
``` What should this be?
the heck is tree.load_extensions?
where did you see that?
look
client = aclient()
tree = app_commands.CommandTree(client)
just trying to load cogs :(
client.tree is already a CommandTree
So how would I load cogs
what is tree = app_commands.CommandTree(client)
class aclient(discord.Client):
def __init__(self):
super().__init__(intents=intents, command_prefix="!")
self.synced = False
async def on_ready(self):
await self.wait_until_ready()
if not self.synced:
await tree.sync(guild=discord.Object(id=867086205182017536))
self.synced = True
print(f"Daxbot is ready")
async def setup_hook(self):
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
try:
await client.load_extension(f"cogs.{filename[:-3]}")
print(f"Loaded {filename}")
except Exception as e:
print(f"Failed to load {filename}")
print(f"[ERROR] {e}")
client = aclient()
tree = app_commands.CommandTree(client)
definitely not using the tree
Works fine with slash commands
noooooo:( dont sync in on_ready
oh
y'all guys gonna kill me
I am just trying to switch to slash commands atm
the slash commadn that I did with the tree it works fine
just trying to load cogs atm that's all
you sent tree.load_extension, now there is client.load_extension wth
and still wrong
I know..
look at this example https://gist.github.com/Master326486/6cf48c1ca0509b98e673451e356ba625#setup-hook
I should also add syncing there
dude
people are still adapting to 2.0
I don't know, trying to get used to dpy 2.0 and use slash commands
same here man
wtf is wrong with you? if you have problem just ignore it others can help
yeah lol
how to make the ticket system in a bot
bruh, now I'm getting humiliated like im toxic :blobpain:
...
@junior verge so, first of all, at least sync your tree in setup_hook like shown here https://gist.github.com/Ash-02014/b6f57065f394b54f43666037ade38d32#basic-slash-command-application-using-discordpy
that is still not the best option, but at least something
Yeah I know I am doing it now
ok
what exactly do u want
wdym joins a specific call
voice channel you mean
?
i forget the exact event
an event that checks if someone joins a talk
!d discord.on_voice_state_update
discord.on_voice_state_update(member, before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") changes their [`VoiceState`](https://discordpy.readthedocs.io/en/latest/api.html#discord.VoiceState "discord.VoiceState").
The following, but not limited to, examples illustrate when this event is called...
this?
uhh
uhh
this bot has all knowledge about py and discord.py?
yes
considering it's made in it
he has requests to docs
looks good thx
lmao
why r u reading such old msgs
you're a bad guy
:(
ImportError: can not import name ‘menus’ from ‘discord’ (/home/runner/giveaway/venv/lib/python3.8/site-packages/discord/__init__.py)
no menus in discord
you need to install them manually
discord-ext-menus
recommended from github repo
to get the newest ones
I've made a discord bot using discord.py in python and have been running it for some time. while it's running I get this message : WARNING discord.gateway Shard ID None heartbeat blocked for more than 170 seconds. Can someone tell me what does this mean?
your code is blocking for more than 170 in someway
it could be blockingio or time.sleep for example
Yes I used time sleep in my code
(blockingio is when you use something like with open to open json files that is not async so it blocks io async event loop)
that's not only cus of with open
it could be not async connection to db
Hello. Is it possible for my bot to say something on call? Like tts but the output is said on call. For example, I say .tts hello , the bot speaks Hello if connected to a vc
that is bad
@app_commands.event
``` How do you use an event with discord.py 2.0?
coroutine asyncio.sleep(delay, result=None)```
Block for *delay* seconds.
If *result* is provided, it is returned to the caller when the coroutine completes.
`sleep()` always suspends the current task, allowing other tasks to run.
Setting the delay to 0 provides an optimized path to allow other tasks to run. This can be used by long-running functions to avoid blocking the event loop for the full duration of the function call.
Deprecated since version 3.8, removed in version 3.10: The `loop` parameter. This function has been implicitly getting the current running loop since 3.7. See [What’s New in 3.10’s Removed section](https://docs.python.org/3/whatsnew/3.10.html#whatsnew310-removed) for more information.
Example of coroutine displaying the current date every second for 5 seconds:
I didn't use this in my code
the same as in 1.7.3
why
so just client.event?
yes
but client is not defined
then u have to define it
check if uve made the bot client or bot
client = commands.Bot(command_prefix='.')
Yeah I know how that works
ik
it blocks your whole code, so for example if you use it in one command like tempmute it will sleep for 10 minutes but not only for that command but for the whole code, so no commands will work till it's sleeping
make sure you have discord and discord.ext commands imported also
so consider using asyncio.sleep() to not block your code
class Daxbot(commands.Bot):
session: aiohttp.ClientSession
def __init__(self):
intents = discord.Intents.default()
intents.members = True
intents.message_content = True
super().__init__(command_prefix=["!"],intents=intents,)
# This is asynchronous!
async def setup_hook(self):
# Creating aiohttp ClientSession
self.session = aiohttp.ClientSession()
# Loading cogs
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
try:
await self.load_extension(f"cogs.{filename[:-3]}")
except Exception as e:
print(f"Failed to load {filename}")
print(f"[ERROR] {e}")
await self.tree.sync()
print("Successfully synced commands")
async def main():
client = Daxbot()
await client.start("token")
``` what would I do then as client.event?
you can do events directly in bot's subclass
Hello. Is it possible for my bot to say something on call? Like tts but the output is said on call. For example, I say .tts hello , the bot speaks Hello if connected to a vc
like this py class MyBot(Bot): async def on_message(self, message): ... @junior verge
for any event
can you still do it outside of an class
@client.event
async def on_command_error(interaction, error):
``` like what should this be now
of course it's possible
i dont exactly know how that is done
I'm sure there is an api for that
but im sure you'll need ffmpeg or smth like that
huh..which one?
in cogs
nah main
then it is not possible
well my first choice for stack overflow ofc so i got that i need to use pyttsx for it
as long as you use start to start the bot that is impossible. and do not switch back to run, start is just way better, at least cus its async
just do it in subclass or in cogs
what's the problem with that
!paste
oh yeah that is required if you want tts
@silk fulcrum https://paste.pythondiscord.com/mipazuqipe like this?
hmm alr
i cant help you anymore @waxen ruin cus im not into voice bots
gl
can someone help at #help-mushroom pleasseee
on_command_error doesn't take interaction
and you need to take self first
bot doesnt even go online I think I am running it wrong
(self, ...)
in main too?
so that stays the same?
!paste
https://paste.pythondiscord.com/uzebifukul is this right?
user.auhor :lmao:
erm
wops
actually this whole code is so... weird
a lot of ideas
could someone help at #help-chili
and first is that you need to rewrite that code
please
i have this code
adminembed = discord.Embed(title = "Administrator Commands:", description = ".kick kicks a mentioned user (could add reason at the end)\n.ban bans a mentioned user (could add reason at the end)\n.kick kicks a mentioned user (could add reason at the end)")
class MyView(discord.ui.View):
@discord.ui.select(
placeholder="What do you need help with?",
min_values=1,
max_values=1,
options=[
discord.SelectOption(label="Math Command", description="View math commands", value="value1"),
discord.SelectOption(label = "Server Info", description = "View Server Information", value = "value2"),
discord.SelectOption(label="Administrator Commands", description="View Administrator Commands", value="value3")
]
)
async def select_callback(self, interaction, select):
if select.values[0] == "value1":
await interaction.response.send_message(
"Math Commands:\n\n Addition command:\n.add adds two numbers together, eg: .add 2 2 will output 4")
if select.values[0] == "value2":
await interaction.response.send_message(
"Server Information:\n\n Member Count:\n.ServerInfo shows things about the server")
if select.values[0] == "value3":
await interaction.response.send_message(
ctx.send (embed = adminembed))
without the embed it works
but with embed it allways tells me interaction failed
any help on this??
Get an error handler
Catch the error and print it
I can’t help much without an exception
what the freaking hell is ...send_message(ctx.send(embed=...))
bro...
do you even understand what yo're doing?
im new to this
yes
to python?
That would explain it ☹️
and kind of new to python
nteraction.response.send_message(
ctx.send (embed = adminembed))
``` what is this
its been like 3 months or more
😬
probably not kind of
thats what im asking
what are you doing here then
ctx isn’t defined in this scope at all, let alone passing ctx.send to another send function
dpy is not beginner friedly
you need to rethink the logic in this section
discord.py and ✨ctx users✨
i sometimes still see people using pass_context
kill my self, why minecraft is lagging, chess.com is inaccessible and there is no other games I can play, because wine doesnt work
well that comes from stackoverflow and tutorials
How can I delete the message on btn click?
!d discord.Message.delete
await delete(*, delay=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Deletes the message.
Your own messages could be deleted without any proper permissions. However to delete other people’s messages, you need the [`manage_messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission.
Changed in version 1.1: Added the new `delay` keyword-only parameter.
imagine using pycord
For button i want not for message
You said delete a message
Hoi
depends on what message
On btn click bro
Hio
try venge.io :p
what message? where that button is placed?
What you do mean by it?
what the heck is that
The battle of polytopia
im not fun of shooters at all
Great game
can't access cus wine is broken
its a browser game ( so no installation) like krunker
im on linux, i need wine to run games like this
looks complete garbage imo
make ur own game with your discord bot kek
id better play somethng like tankionline or slither.io
i already have minesweeper and slide puzzle
My froend is cracked at slither.io
well minesweeper i have by default
go play dat and find bugs
but its boring
Though his video editing skills need work
i have a tester
there is no bugs in that commands
you can use stream on linux though
!paste
steam you mean?
Stream poggers
yeah whatever, I don't play games so
perks of being a nerd
even my dad plays games
well, actually, once a month
or even more rare but still he plays some games
i didn't find any interesting free games
ill search again
maybe i missed something
caN try brawlhalla if already haven't
and now it turns out that i cant even use steam
the same problem as with wine
:evenmorepain:
im completely gameless
i think i've gotta work on my bot and a gist
and get ready to school
and for PyWeek
go make Minecraft in python
i dont have ANY knowledge of making games in python
idk how am i gonna participate in pyweek
wth, there just was flash in my room
like someone took photo of me?
etsap!
@silk fulcrum https://paste.pythondiscord.com/zaxuyiheco this still doesn't work
I got the avatar to work
I am not surprised somehow
i'd just recommend to just... just... reqrite the code
I am sure there is not that much wrong in the code
same schema, read the docs, do things
there is THAT much wrong in the code
hm ok
i can count if you want
sure go ahead
I counted 8
which ones
response.defer and user.author
ok
member = interaction.author if not member else member
``` should be that yeah?
no
your member is not even defined
it should be user I fixed that
just do user or interaction.author!
Is it dpy?
oh wait i didnt think of that
Ursina
if that is pycord
im just gonna be completely slaughtered
that will be the most pointless rate of his code ever
oh no wait he was using app_commands
nvm im gud
..
Interaction.author is not a thing is discord.py, you can use .user there
hello
hello
how can i make it so if someone mentions the bot, the bot mentions them back
in on_message check if the bot is mentioned in the message and then send a mention of the author?
how do i check if the bot is mentioned?
!d discord.Message.mentions will give you a list of users that got mentioned in that message, and you can check if bot.user in message.mentions
A list of Member that were mentioned. If the message is in a private message then the list will be of User instead. For messages that are not of type MessageType.default, this array can be used to aid in system messages. For more information, see system_content.
Warning
The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.
you mean when replying?
you can only do that in replies
ok
you have to do .send(member.mention)
ok
if client.user.mentioned_in(message):
await message.channel.send("yes?").send(member.mention)```
something like this?
mentioned_in(message)```
Checks if the user is mentioned in the specified message.
that actually exists
but not like that
oh
it's Member.mentioned_in
what do you think you are doing .send(...).send(...)?
i want it if the user @crimson bridge the bot
I know but ClientUser is a User which is almost a Member so it makes sense that exists
what the heck does that all mean
sensemakeok
they're just all in abc.User
it doesnt work
show code
@bot.listen()
async def on_mention(message):
if client.user.mentioned_in(message):
await message.channel.send("yes?").send(member.mention)```
it was from nefore
and what do you think you are doing with .send(...).send(...) @tawdry tendon?
also why is there a client AND bot?
oof that also 
just do py @bot.listen('on_message') async def on_message(message: discord.Message): if bot.user.mentioned_in(message): print('i was mentioned!')
'on_message'
i dont want it to say "i was mentioned"
i want it to mention them back @quaint epoch
that was just an example
bruh
what?
do await message.channel.send(whatyouwant) then
!d discord.ext.commands.Bot.listen
@listen(name=None)```
A decorator that registers another function as an external event listener. Basically this allows you to listen to multiple events from different places e.g. such as [`on_ready()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_ready "discord.on_ready")
The functions being listened to must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.10)").
Example...
bruh
lemme give an example
that string is just unnecessary if you are naming function the same
@bot.listen('on_message') # looks for on_message event
async def on_message1(message):
...
@bot.listen('on_message') # also looks for on_message event
async def on_message2(message):
...```
with bot.listen you can have multiple listeners
the event type has to be specified though
yes but who ever needs that and for what reason
lots of reasons
why else would that be added
to name functions as you want
ive done it now
How do i make it so someone can only do a command every 30 minutes, with an error message
!d discord.ext.commands.cooldown
@discord.ext.commands.cooldown(rate, per, type=discord.ext.commands.BucketType.default)```
A decorator that adds a cooldown to a [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")
A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").
If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") and the local error handler.
A command can only have a single cooldown.
!d discord.ext.commands.BucketType
class discord.ext.commands.BucketType```
Specifies a type of bucket for, e.g. a cooldown.
ephemeral = True i can use onli in slash command and buttons?
How do i ues that
no, it can be used for any interaction
like shown?
so how to use in normal ctx.send
ctx is not an interaction
any "interaction"
@commands.command(pass_context=True)
@commands.has_role("Council")
async def massrole(ctx, role: discord.Role, *members: discord.Member):
guild = bot.get_guild(GUILDID)
rnames = [role.name for role in player.roles]
for member in members:
if str(role) in rnames:
await ctx.respond(f"<@{member.id}> already in {role}")
else:
await member.add_roles(discord.utils.get(ctx.guild.roles, name=str(role)))
await ctx.respond(f":white_check_mark: {role} added to <@{member.id}>")
@massrole.error
async def massrole_error(ctx, error):
if isinstance(error, commands.MissingRole):
await ctx.send("aaaa", ephemeral = True)
else:
raise error
I have a command that isn't returning any issues nor is it sending anything, it was working just fine the last time I was working on it, did I overlook something?
yes, but not always
- are you sure the command is running?
- if I were you, I'd compare role ID's, not rolenames
bot.add_command(massrole)
or change the commands.command decorator to bot.command
wym if the command is running? also
if str(role) in RoleID something like that?
if member.get_role(...) (only possible in v2)
also your code seems to be a mix of discord.py rewrite branch and pycord
wheres pycord
ctx.respond is not a discord.py thing
oh
I've only seen it in pycord's app context in all the forks
saem
why it isnt working?
I want to do something like that if you type $ say, it will send a message that I did not give you the message you want to send
text cannot be None
it's required argument
you need to make it Optional then
text: typing.Optional[str]
and import typing for that
You didn't send any value*
hello
@silk fulcrum i got voice verified :)
is there a way to add an image to an embed
vaclubary*
congrats
embed.set_image(url=)
ok
wanna go voice with me or what?
Hehe
thanks
how to do it in code?
@bot.command(name="say", description="bot wysyła wiadomość napisaną przez administratora")
@has_permissions(administrator = True)
async def say(ctx, *, text):
if text == None:
await ctx.send("U dont send value!")
else:
message = ctx.message
await message.delete()
await ctx.send(text)```
Tomorrow for sure, it's already late rn
k
How old are you btw?
i literally sent how to
Sensei
typehint the text with Optional[str]
13
Nah that's cap
nop
I am 14 btw
im actually 13
Cool
but my voice became deep at 12, and noone believed im 12 when heard it
@cerulean shale
which language is that?
lmao
What?
like this:
mathembed = discord.Embed(title = f"Math Commands:", description = "Addition command:\n.add adds two numbers together, eg: .add 2 2 will output 4\n\nMultiplication command:\n.mult multiplies two numbers together, eg: .mult 2 2 will output 4\n\nDivision command:\n.div divides two numbers, eg: .div 4 2 will output 2\n\nSubstraction command:\n.sub subtracts two numbers, eg: .sub 4 2 will output 2\n\nRandom command:\n.rand randomises a number from 1 number to the other, eg: .rand 5 9 will randomise a number from 5-9", colour = discord.Colour.magenta())
mathembed.set_image(url='https://www.sparklebox.co.uk/2361-2365/sb2363.html')```
lmao
Yes yes
why doesnt it work then
YAAAAAAY I HELPED SOMEONE
that image link seem to be something weird
where i have to paste it?
how?
.
lmao, achievement unlocked
What error are you getting?
no error
coding is not only about copy pasting btw
it says .html at the end
Only these work
okay but i dont understand u
it is a jpg file
webp*
where i have to paste it
idk why it says html
Yea yea
am i being IP grabbed or what? why isnt that link even loading
what link?
im trying
BREAKING NEWS
Master32 been kidnapped and found dead
What did you do?
oh
good news
🥲
text:str
by the way okimii was saying that he'll kidnap my cat and now he left discord
Ig that's what you should do
what if it doesnt have anything at the end of the url
doesnt that mean smth
Wha-
Very sus
😄
Type Hints
A type hint indicates what type a variable is expected to be.
def add(a: int, b: int) -> int:
return a + b
The type hints indicate that for our add function the parameters a and b should be integers, and the function should return an integer when called.
It's important to note these are just hints and are not enforced at runtime.
add("hello ", "world")
The above code won't error even though it doesn't follow the function's type hints; the two strings will be concatenated as normal.
Third party tools like mypy can validate your code to ensure it is type hinted correctly. This can help you identify potentially buggy code, for example it would error on the second example as our add function is not intended to concatenate strings.
mypy's documentation contains useful information on type hinting, and for more information check out this documentation page.
and make it optional
Bro theye are called extensions, jpeg, png, jpg, gif, webp, etc etc but only the ones i mentioned are read by the bot
So choose a pic that ends with either of them
there is even an example by dpy for that:
https://discordpy.readthedocs.io/en/latest/ext/commands/commands.html?highlight=optional#typing-optional
@silk fulcrum sensei kinda feels good helping people
nvm i got a jppg
jpg
Ight
yeah
🤡
but sometimes you can get f***ed by some very not smart guys
which for example dont know python
and annoy veryyy much
Well true tho
Btw is profanity blocked or something?
what the heck
nah, you can swear, but like... dont be toxic
rules say everything i guess
Oh lol 🤣
🦆
sometimes i can get frustrated and do some weird shit like calling someone silly and being a bit toxic...
right now already an hour my smart watches are shouting at me that they're low and battery and i just ignore them
already 0% btw
💀
Me most of time 💀
Btw you can't say others to read the manual if they ask for help in here 💀
why can't you?
if their knowledge is too low just do !resources
and if problem is solvable by docs link them by !d something
anyone have a doc to link to that explains creating slash commands with discord.py? i've been searching google and the docs but a lot of old results on google before slash commands were available and not finding much when searching slash commands on the docs
Idk the code of conduct says it 🤣
ty
I really needed that, thx brother
actually? then why not ask if you need something
Well I thought of asking tomorrow
I will sleep in like an hour or so...... That's why didn't ask about it lol
Ight
im trying my best to go sleep at 10:30 PM but still can't follow my sleep schedule
but I have like a habit or idk so I just always wake up at 6:30
nomatter if I got to bed at 3 AM
ill wake up at 6:30
Dem what's the time rn for you??
9:50 pm
no
Or Europe
russia 😭
Noice
exenfix is from there too btw
cyka
Dk who that is 💀 but ok
blyat...
try doing @exenfix and youll see in suggestions hes first
and last
you know russian or just random jouke?
materyus
Oh this guy huh
hi
hes name is exenfix in 64 bit
Cyka blyat wa gato very sexo
Hi
shto eto vse znachit
rip
my chess coach's dad died last month
And yeah
Aw is he ok?
on the road?
Yeah
i know?
He was on cycle and a truck hit him and he died on spot
this channel is never on top... oh wait im in ot3
#ot3-discord-bots
💀
That's private channel ig
no, it;s this channel
it will be renamed soon
Oh-
:lmao:
shaman
Anyways ima sleep now, peace out master
how do i use aiosqlite to delete an entry from a table? im using it for my leveling code and one of my members has a double entry
DELETE FROM statement
use primary keys
this worked thank you!
@bot.command(name="say", description="bot wysyła wiadomość napisaną przez administratora")
@has_permissions(administrator = True)
async def say(ctx, *, text = None):
if text == None:
await ctx.send("wpisz wartość")
else:
await ctx.send(text)```
when I send the $ say command without the message value, I get a message asking me to enter the value. However, when I type $ say text, it doesn't work. Will someone help me?
you can correct the code for me
try removing the else and doing return at the end of that if
so it would look like py if ...: await ctx.send(...) return await ctx.send(text)
yes
wait lets try
Hello
hi
I have this code
@has_permissions(kick_members=True)
@bot.command()
async def kick(ctx, kick_member:discord.Member, *, reason = None):
if kick_member == bot.user:
await ctx.send("You can't kick me 🤣")
elif kick_member.top_role >= ctx.author.top_role:
await ctx.send("This person's role is higher or equal to yours!")
else:
await kick_member.kick(reason = reason)
it it it is working! thanks bro ❤️
know u more then one language (python)?
How can I make it so if they don’t have the permission kick_members it sends a message saying that they don’t have the permission to
you need an error handler
Oh ok
I suppose you already get a message / traceback when the member doesn't have perms?
php and java
and u have 13yo?
yes im 13
so i know HTML, CSS, JAVASCRIPT
and i'm to 13yo
now im learning python
Bro how would he “have” a 13 year old lol
Fr?
and i will learn backend but idk what language. Maby php or node.js
@potent spear I made this, would it work
@kick.error
async def kick_error(ctx, error):
if isinstance(error, MissingPermissions):
await ctx.send("You don't have permissions to kick, you need to have the kick member permission")
else:
print(error)
Police has been contacted
well php and css are not really programming languages and PHP uses mostly HTML so I also know it, and css can be replaced with frameworks
try and see
Ok
is SCSS/SASS is language?
php -> laravel -> vue-js
no idea
vue is good
bootstrap (no well)/ tailwind
is PHP hard?
yes, tailwind
not really, it's pretty similar to JS i think, or im stupid
are u know js?
no
wait i have last question
HTML css and js are so annoying compared to python
What’s Django (I’ve heard of it but idk what it is)? Is it web framework
yes it is, it's a lib for python
!d aiohttp.web seems better
The page contains all information about aiohttp Server API:
probably, no idea, I like laravel for web
didnt get you
Yes
ok wait i send images
Assign to a var in config then import config
@torn sail hey, i remember there was something like case in python, like a replacement to py if name == "smth": ... elif name == "sfhtg": ...
do you know what it is?
or match
Yes
@silk fulcrum
import it from config and use in code and u gud?
what is that
foo = 0
match foo:
case 0:
print("foo is 0")
case 1:
print("foo is 1")
case _:
print(“foo is not 1 or 0")
!match
yeah match and case breh
8.6. The match statement
New in version 3.10.
The match statement is used for pattern matching. Syntax:
match_stmt ::= 'match' subject_expr ":" NEWLINE INDENT case_block+ DEDENT
subject_expr ::= star_named_expression "," star_named_expressions?
| named_expression
case_block ::= 'case' patterns [guard] ":" block
```...
How to do it?
from config.py import message?
from config import message*
yes?
and to get all the objects from config.py, I have to give it from config import *
i know this from css
or import config and use config.something
okay thanks
yes
but wild cards are usually discouraged
ik but i need this
you can use it
Where i can find any about inputs?
idk
Yep
Will you stay be able to use it after after message commands get removed?
With a verified bot
not without a permission for message_content
you can use message commands with message_content permission
On a verified bot too?
discord gives it
hm?
Who can say how to change this line here grole = discord.utils.get(ctx.message.guild.roles, name = ':male_sign:') if grole in ctx.author.roles and grole in member.roles: embed = discord.Embed(description = 'Вы не можете использовать данную команду на участниках с ролью :male_sign:', colour=0xF1C40F) await ctx.send(embed=embed) return in the code, so that command works without errors. The command code is below
Shouldn't it already work without errors?
Traceback (most recent call last):
File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 113, in wrapped
ret = await coro(arg)
File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 762, in _invoke
await self.callback(self.cog, ctx, **kwargs)
File "c:\Users\ToxicPenguin\Desktop\проекты на Python\disocrd bot python\cogs\fun.py", line 62, in __kiss__
role = discord.utils.get(interaction.message.guild.roles, name = '♂️')
AttributeError: 'NoneType' object has no attribute 'guild'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\bot.py", line 755, in process_application_commands
await ctx.command.invoke(ctx)
File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 312, in invoke
await injected(ctx)
File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 119, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.commands.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'NoneType' object has no attribute 'guild'```
I 'm just using it interaction: discord.Interaction not ctx. Since I have a slash command
@sick birch just replace ctx with interaction with works
ru )
@silk fulcrum yes
yes
@silk fulcrumBut here writing in other languages is generally prohibited
guild is none, probably you are using it in DMs?
scared
!d discord.Interaction.message
The message that sent this interaction.
@silk fulcrumthis error is due to the fact that I am not using ctx and this interaction
oh the message is None
not guild me dumb
actually, why can't you just use interaction.guild? @slate swan
same with ctx
@silk fulcrum OMG how do you understand this documentation
easily?
because the error
Traceback (most recent call last):
File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 113, in wrapped
ret = await coro(arg)
File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 762, in _invoke
await self.callback(self.cog, ctx, **kwargs)
File "c:\Users\ToxicPenguin\Desktop\проекты на Python\disocrd bot python\cogs\fun.py", line 62, in __kiss__
role = discord.utils.get(interaction.guild, name = '♂️')
File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\utils.py", line 461, in get
for elem in iterable:
TypeError: 'Guild' object is not iterable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\bot.py", line 755, in process_application_commands
await ctx.command.invoke(ctx)
File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 312, in invoke
await injected(ctx)
File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 119, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.commands.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: 'Guild' object is not iterable```
the heck
I have slash commands
why did you remove .roles
Yo I remember u
why dont i?
The guy that called Danny a bastard
i would remember every single russian
Toxic penguin
БОЛЬШОЕ СПАСИБО))
You pass an iterable into discord.utils.get like interaction.guild.roles or interaction.guild.members but not interaction.guild
small no problem
everyone helped me)
Oop didn’t see
@torn sailThanks. But in your case I would be confused)
👍
Hello
Hi
missing a required keyword-only argument 'logic'
@bot.commands()
async def permissionpurge(ctx, perm):
await (f"You have chosen to use {perm} as the permission to use the purge command")
@has_permissions(perm=True)
async def purge(ctx, amount = 1):
await ctx.channel.purge(limit=amount+1)
await ctx.send(f"{amount} messages have been purged!")```
thats the code
@bot.command()*
Traceback (most recent call last):
File "main.py", line 156, in <module>
@bot.commands()
TypeError: 'set' object is not callable```
no wonder thank you
perm is not a valid permission
ye
and that too 
and typehint amount as int to have no problems
how can i do that?
save in db
Well you can first store it in a database. Then create a custom check that checks the database and checks the perms
i dont know how to use sql
or json is enough if that's private bot
F
publishing a bot without database
What for has_permissions separate from bot.command ?
huh
The very basic statements are not too hard. I learned how to start it in just a few hours
he said, he wants another command to setup a permission that is required to launch that command
same
can i use basic statements for this
but noone told me about blockingio
He did not send the view
Yeah just things like SELECT or INSERT
class settings_document_admin_view(nextcord.ui.View):
def __init__(self, ctx, settings_data, *, timeout=20):
super().__init__(timeout=timeout)
self.ctx = ctx
self.settings_data = settings_data
async def unset_admin_role(self, interaction: nextcord.Interaction):
await self.bot.setiings.unset(self.settings_data)
@nextcord.ui.button(
label="Delete the Role",
style=nextcord.ButtonStyle.danger)
async def del_admin_role(self, button, interaction):
await unset_admin_role(interaction)
@nextcord.ui.button(
emoji=config.gf_delete_emoji,
style=nextcord.ButtonStyle.grey,
)
async def delete_button(self, button, interaction):
await self.handle_delete_message_and_output(self.ctx, interaction)```
so i used not async db till this summer
I would take a look at a website called sqlbolt
ye ik that website
BR, buttons. How long I remember suffering with them
Can you make no shortcuts
for databases do i have to use another file?
there are a lot of if statments i think some is false
just asking
The if statements are right he nly did not send the buttons
?
The database will create a file but all the database commands stuff will be the same file cause it’s a python lib
!pypi aiosqlite
SQLite is good to start with
ok
but use aiosqlite
why?
async
Yes
whats the difference
@silk fulcrum and where can I see how to properly export a database to a discord bot ?
no blockingio
huh?
export? migrations?
blocking io async event loops
sqlite3 module is blocking so it slows down ur bot a bit but aiosqlite is async so it won’t
!blocking
Why do we need asynchronous programming?
Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you do not use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming.
What is asynchronous programming?
An asynchronous program utilises the async and await keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. Any code within an async context manager or function marked with the await keyword indicates to Python, that whilst this operation is being completed, it can do something else. For example:
import discord
# Bunch of bot code
async def ping(ctx):
await ctx.send("Pong!")
What does the term "blocking" mean?
A blocking operation is wherever you do something without awaiting it. This tells Python that this step must be completed before it can do anything else. Common examples of blocking operations, as simple as they may seem, include: outputting text, adding two numbers and appending an item onto a list. Most common Python libraries have an asynchronous version available to use in asynchronous contexts.
async libraries
The standard async library - asyncio
Asynchronous web requests - aiohttp
Talking to PostgreSQL asynchronously - asyncpg
MongoDB interactions asynchronously - motor
Check out this list for even more!
@torn sail what sql would u recommend
SQLite
ok
WELL, in order to use the database to make a level system
i didnt get what you mean by export the database
The fact that any information is stored in the database. That's what export means
hi I wanted to make a registration system for my discord server can someone help me
what 😳
????????
maybe you mean use database in bot?
can
with what concretely
someone help me
just send the problem
yes
making a registration system for my discord server
!intentd
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default discord.py has all intents enabled except for Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
well, that's just a mean of what database you use, you will need a specific lib for it
for sqlite - aiosqlite
for mysql - aiomysq
for postgresql - asyncpg
Make sure u read what’s above
He wants to be thrown a sample code
I have
what?
And understood thanks.
you are saying too hard words for my brain
???????
Well it would be SELECT title FROM movies
The fact that I was actually about to do that
uhm, no one is going to make a whole reg sys for you
I'm just writing through a translator
you have to think how to make it your self
we can help with an error or smth like that
bruh
omg internet just crushed right now for me
i scared so much
What does this mean?
its not working
I am trying to transfer my help command from 1.7.3 to 2.0, 
It Embed.Empty was removed in dpy v2
Use None instead

code and error...
Probably outdated
oh
You could modify the code for it
Well what’s ur editor?
But just trying to transfer it to 2.0
vsc
Ok are u using venvs
don't think so no
Then open up file explorer or something then navigate to the python section then find site packages then find ur lib then modify. Or u can just fork on GitHub and install from there
I’m having trouble understanding this
monkeypatching?
I got no clue what to do
Yeah he’s using a lib meant for dpy v1
@sick birch I fixed the issue btw with the vps
I am switching to 2.0 and like editing/transferring all commands
!e
my_list = [1, 2, 3, 4]
print(3 in my_list)
print(6 not in my_list)
@sick birch :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | True
002 | True
First thing I said probably isn’t great
I would recommended forking