#discord-bots
1 messages ยท Page 860 of 1
well I get that, that was just an example. What I am doing is checking if a tag is valid, if its not I want it to repeat until it is.
and what is that tag?
its randomized
so its making a random tag, then its passing through my checker, if valid it passes if not it repeats until it is
doesn't this do what you want it to do?
well not exactly, the result wil be different each time
can you give an example of what you are trying to do?
sure, one second.
mind if I dm it?
ye go ahead
Hey
We did it boys, moderator commands are no more!
lmao wtf is discord on, they want us to migrate to slash commands and now they making slash commands itself?
ok
at this point let discord host your bots
๐๏ธ ๐๏ธ
lmfao fr, make them host our discord bots
im having #discord-bots related jokes
smh ๐ฟ
it's like artistic inspiration, (idk what's that) it just comes and goes (mostly goes)
ok, why this not send any message, even when i dont hav any CD
@bot.command()
@commands.cooldown(1, 15, commands.BucketType.user)
async def chop(ctx):
name = ctx.author.id
energy = database.check_energy(name)
level = database.check_level(name)
no_energy = database.check_no_energy(name)
q = database.check_sleep(name)
if q == 0:
s = database.check_duel(name)
if s == 0:
if no_energy > 0:
req = 0
else:
req = math.ceil(15 * ((2 / level)))
if energy > req:
if req == 0:
database.no_energy_decrease(name, 1)
resource = random.randint(1, 3)
exp = random.randint(1, 10)
database.add_item(name, int(resource), "log")
level = database.check_level(name)
database.add_exp(name, int(exp*level))
bot.last_level = database.check_level(name)
database.check(name)
bot.level = database.check_level(name)
database.energy_decrease(name, req)
if random.randint(1, 3) == 2:
database.add_item(name, 1, "apple")
await ctx.send(f"{ctx.author.mention} is getting {resource} log:log:, 1 :apple: apple, and getting {exp*level}XP!")
else:
await ctx.send(
f"{ctx.author.mention} is getting {resource} log:log:!, and getting {exp*level}XP!")
if bot.last_level != bot.level:
bot.last_level = bot.level
await ctx.send(f"GG, {ctx.author.mention} is getting a level")
else:
await ctx.send("HEH u already tired, go sleep first (or u can use :meal: meal if u have one)")
chop.reset_cooldown(ctx)```
!paste way too big fr
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.
๐ฟ ??
ok https://paste.pythondiscord.com/sevuzuxeva not send any message and no error and no CD
I have like 50 commands on my bot, and about 4 different servers that use it. For every command I do:
if ctx.channel.id == lobby_channel:
l_channel = lobby_channel
b_role = banjo_role
d_channel = draft_channel
elif ctx.channel.id == lobby_channel_ap:
l_channel = lobby_channel_ap
b_role = banjo_role
d_channel = draft_channel_ap
elif ctx.channel.id == lobby_channel_ru:
l_channel = lobby_channel_ru
b_role = banjo_role_ru
d_channel = draft_channel_ru
elif ctx.channel.id == lobby_channel_zh:
l_channel = lobby_channel_zh
b_role = banjo_role
d_channel = draft_channel_zh```
is there an easier way of checking this?
i feel like if i have to add another server I have to add more code to every command
is there like a function i can create that checks it
well, there is but you will have to use the commands extension instead of on_nessage commands
can you show me how?
what are you trying to check?
๐ฟ
guild ids?
im basically saying only these guild IDS can access these channels
and im also defining roles and stuff
so you want store things per guild ids?
so I do this rn
# Channels RU
guild_id_ru = 632584547078373377
general_channel_ru = 834846983625637939
activity_channel_ru = 874393053920632862
games_channel_ru = 800619130947895356
draft_channel_ru = 828239321773506571
lobby_channel_ru = 828239289653002241
leaderboard_channel_ru = 828239395667574814
admin_channel_ru = 828239459417718804
test_channel_ru = 837113269487009802
banjo_role_id_ru = 828633154675671075
# Channels AP
guild_id_ap = 757759815685767250
activity_channel_ap = 757791469145948220
games_channel_ap = 893696041965199450
draft_channel_ap = 757791515593408623
lobby_channel_ap = 757791360450429068
leaderboard_channel_ap = 757791527253835837
admin_channel_ap = 893696281980071946
test_channel_ap = 893696309817651220
ap_role_id_ap = 757798722561114132
# Channels ZH
guild_id_zh = 924526874523217960
general_channel_zh = 924526993826017348
activity_channel_zh = 924527600058118154
games_channel_zh = 924527947631693885
draft_channel_zh = 924527851301138442
lobby_channel_zh = 924527891692269668
leaderboard_channel_zh = 924527810477965375
admin_channel_zh = 924528040971735070
test_channel_zh = 924528104641269760
banjo_role_id_zh = 924528737695981568```
what the-
i get all the channels here
wdym?
holy cow, da haec
LOL!
E
database, you can store ids per guilds
meanies
and way easier
imagine using decorator checks on commands ๐
Why are you storing ids/
hmm
then why not do that?
help
channel IDs
yea, so make a seperate table with guild id and channel id as columns and store it in that?
Ok I can do that
Check the value of q
but how does that help me
Fastest way I can think if is to just run a print() statement right before your if statements
The if statements are probably returning false somehow
fking 0
you dont have messy code, you can access them anytime and anywhere depending on how you are making the connection to the db and its easier
now i see, ok ggty
okay, so in my situation rn for example, I have commands and to seperate certain things in the command I use different channels can I create something to make this easier
like a function?
db function
when they use the command get all the channel ids and stuff you need from the db using the guild id
yeah but my problem is having alot of commands and then using the same kind of code
Yep and Fira code
accessing role names, channel IDs
i dont think you get my point
Nice nice
ok, you said you had 50 cmds, how are they the same?
just use Commands ๐ with check decos
that wont work in his case
store all things I need in DB and create a function that retrieves everything that I need from role names and channel IDs and sort them by guildID
yes
i just mean i have to do this for every command
and its annoying... so I think the function will help
I will call it at the beginning of every command
yea works
good idea thnx
np.
How would i react to the message that is sent by the bot with the reaction of โ
!d discord.ext.commands.Bot.wait_for
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
This?
how'd i do this better ๐ค
!d discord.Message.add_reaction
await add_reaction(emoji)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Add a reaction to the message.
The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji").
You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission to use this. If nobody else has reacted to the message using this emoji, the [`add_reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission is required.
bro read that again
He worded it weirdly okay?
How would i react to the message that is sent by the bot with the reaction of white_check_mark
๐๏ธ ๐๏ธ
brighter image
def guildInfo(ctx):
conn = sqlite3.connect(db_path, uri=True)
c = conn.cursor()
c.execute(f"SELECT guildID, lobby_channel, games_channel, draft_channel, activity_channel, admin_channel, leaderboard_channel, games_table, player_role_id, player_role, admin_role, muted_role, banned_role, captain_role, rank_one_role FROM guilds WHERE guildID = {ctx.guild.id}")
sql = c.fetchone()
return sql```
how do I get this info from this function to a command that called this function?
return sql should send back a tuple with all the info in it
uhhh i dont see anything ๐ฎ
oh have you done sql = guildInfo(ctx)
where?
where you call it
you gotta define what you're storing the return in
๐
- Function names should be written in
snake_case, camelCase is never used in python - sqlite3 is blocking. Use aiosqlite instead
!pypi aiosqlite
I read in pep8 that camelcase should be used for class names with multiple words
idk where the hell you're reading that
This is the official documentation so there's really no way to dispute it
I see
# Pascal Case (the proper way)
class MyLongClassName:
pass
# camelCase (the wrong way (pep8 wise))
class myLongClassName:
pass
alright so the place i read just doesn't know what camel case is
I only learnt a bit of js so I don't know a lot about camelCase
But what is shown on that website is PascalCase
What website is it?
Can I have the link?
wrong camelcase
camel case is like this โmyLongClassNameโ
ah
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
Yeah this is 100% an error on their part
What Rasberry pi do yโall recommend me to get for hosting
Try asking in #microcontrollers
Oh alright
what does the 0 mean in message.embeds[0].title:
indexing the list, basically returns the title of the first embed
do i need it?
youre indexing the first element
yeah
what would happen if i didnt have it?
because embeds returns a list of embeds
i tried if 'title' == message.embed.title: but it didnt work
!e
my_list = ["Let's", "show", "indexing"]
print(my_list[0])
print(my_list[1])
print(my_list[2])
@final iron :white_check_mark: Your eval job has completed with return code 0.
001 | Let's
002 | show
003 | indexing
embed is not a thing
do if message.embeds[0].title == 'title':
@rotund frigate is it the problem about finding if there's a certain phrase in the title of an embed?
yes
If so, map each embed to a list of title strings, then check if its in it
well i want to do this, if embed has certain image url, send message
if "some string" in map(lambda emb: emb.title, message.embeds):
# found it
await message.channel.send('message')```
"Certain image URL", thumbnail or image? is it the icon in the header or the footer?
lambda ๐
oops just image
if "url" in map(lambda emb: emb.image.url, message.embeds):
# found it
i dont want to use lambda
i want to use it this way if "Name of the Pokemon" in message.embeds[0].title:
!e if "Name of the Pokemon" in message.embeds[0].title:
@rotund frigate :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | if "Name of the Pokemon" in message.embeds[0].title:
003 | ^
004 | IndentationError: expected an indented block after 'if' statement on line 1
wdym first embed?
Messages can have multiple embeds
For example, a message may have 2 embeds, and the URL might be in the 2nd one
in which case your if statement wouldn't pick it up
It would also error out if someone sends a normal message w/o an embed
so if i type if "Name of the Pokemon" in message.embeds[3].title: it would do 3 embeds?
It would get the 4th embed
if it exists, if it doesn't and you don't have a good error handler it'll crash
that's why if you use map + lambda it would work no matter how many embeds a message has
(or a regular function if you don't like lambdas)
def someFunc(emb: discord.Embed):
return emb.image.url
if "url" in map(someFunc, message.embeds):
# found it
i am trying to make a name bot with the info i have so far, can someone help me?
instead of the name.ai its the pokemon name
You are not allowed to use that command here. Please use the #bot-commands channel instead.
remove the * param
!d disnake.UserFlags.hypesquad
The user is a HypeSquad Events member.
here is the link to everything that contains hypesquad in its name - https://docs.disnake.dev/en/latest/search.html?q=hypesquad#
search for anything that fits your purpose
lemme see
make sure u have members intent enabled
are you sure you're sending stuffs instead of printing them 
!intents
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 the Members and Presences intents, which are needed for events such as on_member 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.
and that ^
ctx, wont work, the event only takes a member argument discord.Member, you need to get the channel object and use the send method on that object
bot.get_channel is also there ๐
will only work for one server - kinda misleading, just use bot.get_channel
sure, either let the server members with perms configure the channel or either iterate through them to find a channel

but then, type checkers to brrrr since its typehinted as Union[DMChannel, TextChannel, VoiceChannel, None]
.
!d discord.ext.commands.Bot.get_channel
get_channel(id, /)```
Returns a channel or thread with the given ID.
don't think you can
typing is beautiful yet painful sometimes
hmm
!d disnake.PublicUserFlags
class disnake.PublicUserFlags```
Wraps up the Discord User Public flags.
x == y Checks if two PublicUserFlags are equal.
x != y Checks if two PublicUserFlags are not equal.
hash(x) Return the flagโs hash.
iter(x) Returns an iterator of `(name, value)` pairs. This allows it to be, for example, constructed as a dict or a list of pairs. Note that aliases are not shown.
New in version 1.4.
See your type hints looking like mumbojumo
Ah, that is done manually
indeed
Told u ๐
hunter knows everything 
Meh, I have made those commands in the past so I know about them
uh
disnake.ext.commands.errors.ExtensionFailed: Extension 'save' raised an error: JSONDecodeError: Expecting value: line 1 column 1 (char 0)
what the
Add {} to the JSON file
do you know what args are?
ok
of course it didn't
send huh?
use bot.get_channel in the function, not in it's parameters
replace it with client
why are u adding it in the param then
remove it from the param
!d discord.on_member_join
discord.on_member_join(member)``````py
discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") leaves or joins a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
see it takes only one member arg
assign the client.get_channel to a variable then variable.send
client.get_channel returns a channel obj, send the message to that by doing```py
channel = ...
await channel.send(...)
Define it then? ```py
channel = client.get_channel(...)
getprefix
!d discord.ext.commands.Bot.get_prefix
await get_prefix(message)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves the prefix the bot is listening to with the message as a context.
bro, assign client.get_channel(id) to a variable, it can't be empty
im using json for storing
get_channel takes a valid channel id
json is not a db
can u not ping me
what to do if we get login failure but I copied the token correctly
ok.
yes
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 the Members and Presences intents, which are needed for events such as on_member 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.
Show the full error, maybe you're rate-limited
make sure to do both of these (add in your code and enable in dev portal)
discdb? ๐
any error?

wha, thats a different thing
i dont see anything wrong tbh, try printing the channel and member
@slate swan u got intents?
print(channel)
print(member)
show
just importing doesnt work
why'd you wanna print the member?
in the bot constructor
ok
copy paste that literally? =D
add intents=intents in your client = commands.Bot()
yeah, and their bot var is client
oh nice
๐
wc
intents, not indents
huh
nice
1 st i know nothing about json
with open("logs.json") as f:
logs = json.load(f)
``` json object
for items in logs:
TypeError: 'CogMeta' object is not iterable
show code
for items in logs:
for guildid, logsid in items.items():
seems like logs is an instance of commands.Cog
why did you import it tho lol
trying to create a suggest command, bot is listening to everything but sending it in the correct channel
incorrect channel*
"is listening to everything but sending in the CORRECT channel"
I mean, then what is the issue
im stating that it's listening to everything other than sending it in the correct channel
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'send'
the channel id is wrong
how could it be wrong?
Czzz u copied it wrong...?
Try typing in <#id-here> replacing the id-here with the ID u input in the code and see if it shows the current channel
self.client?
?
i did
they are in a cog and they are using client.get_channel
fucking christ i just noticed that
i assume they redefined client in the cog
Ah that way
Its fine
thanks
Weird it didn't raise an error tho
sorry if i seem like a grinch hunter, just hella tired
Show yr error handler bruv
yeah odd how it didn't
Its fine, I can understand it
u got an error handler?
i don't got error handling up yet. that was on my list just now
ah i had it to print "error not caught"
Haha instead do print(error) then
Its fine
hi๏ผwhen run bot with pycharm for first time, an error happened, anyone can help? ImportError: cannot import name 'api' from partially initialized module 'bot' (most likely due to a circular import) (F:\vvvbb_2022\bot\bot\bot\bot.py)
python.exe F:\vvvbb_2022\bot\bot\bot
Traceback (most recent call last):
File "E:\installed\py39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "E:\installed\py39\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "F:\vvvbb_2022\bot\bot\bot_main.py", line 3, in <module>
import bot
File "F:\vvvbb_2022\bot\bot\bot\bot.py", line 14, in <module>
from bot import api, constants
bot\bot\bot\bot.py
thats one hell of a directory
with open("logs.json") as f:
logss = json.load(f)
{"926129108696580186": 927407150651834448, "874949321089511475": 935097577261633546}
the first one is working
but the second json id is not working
@maiden fable
{'926129108696580186': 927407150651834448, '874949321089511475': 935097577261633546}
@maiden fable ^
@slate swan join back
if I iterate through channel.pins and unpin all of them, would it be bad for ratelimits if the channel has like 20-25 pinned messages?
why do u say it doesn't work then
yes
its not checking the second one
so should i iterate through and unpin and asyncio.sleep(1), I guess this would be a solution right
yea
.
try printing guildid
???
guild id
what about logsid
874949321089511475
935097577261633546
json file
{"926129108696580186": 927407150651834448, "874949321089511475": 935097577261633546}
So they both print the same thing?
Show the separate prints then bruv
seprate?
Like what does guildid print and what does does logsid print
for guildid, logsid in logss.items():
print(guildid)
print(logsid)
if int(guildid) == message.guild.id:
tell separately
1 i said guildid and then logsid
and what is message.guild.id
@commands.Cog.listener()
async def on_message_delete(self, message):
for guildid, logsid in logss.items():
print(guildid)
print(logsid)
if int(guildid) == message.guild.id:
no, what's the message.guild.id
guild id
logs
I will just go and study for exam cya
bruh?
I got an exam on monday bruv
@quick gust mind helping him?
Imagine randomly pinging anyone ๐ฟ
no he hurts my brain i don't understand what he says
u forgot ash?
its logs for bots
Smh @nimble plume mind printing message.guild.id?
server logs
Yes No
listen the first json is working
there are 2 different server id there
the 1 id is working fine but 2 nd not working
because the message.guild.is is the first id not the second one
yes the first id has 2 serve
{"926129108696580186": 927407150651834448, "874949321089511475": 935097577261633546}
1 combo working "926129108696580186": 927407150651834448
Okay?
2 nd combo not checking "874949321089511475": 935097577261633546
use a database
huh?
then i can help u
discdb =D
dont know nothing
?
about discdb
Was jk
huh?
asqlite :D
Meh I ain't hiding it anyways
ill copy paste i ll not learn
I have already been trolled and bullied cz I made that so idrc
woah what i was trooling u until i realize its really u
Lol that is my GitHub only
Cool thanks (also ot)
u also invite my bot
I don't really own any servers ๐คท
ok..
i also dont own i created a server for inviting nvmd
off-topic
now go study all byeeeee
hi can u help me
use try and except
it's giving error that avatar doesn't have url property
๐
2 possible reasons:
- The user doesn't have avatar
- You're not using v2.0
it's the bot itself
how do I restart a loop exactly
kill it and make a new loop
f it doesn't have avatar
Ah i thought u were talking about asyncio.loop
tysm
no worries
you can use display_avatar 
the function
"self.client.user"
I tried that, it says function is not defined where function is the function decorated with tasks.loop
@tasks.loop(...)
async def foo():
...
# to restart
foo.restart()
I wonder if you could restart it from within the loop iteslf though 
I'm pretty sure you could
!d discord.ext.tasks.Loop.restart does exist
restart(*args, **kwargs)```
A convenience method to restart the internal task.
Note
Due to the way this function works, the task is not returned like [`start()`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop.start "discord.ext.tasks.Loop.start").
oh well

let's see if this siht works 
what's the best way to start a loop in a cog 
start it in __init__ function
ur learning for exam?
Having lunch
def setup(bot):
cog = Cog(bot)
bot.add_cog(cog)
cog.task.start()
=D
btw my problem is solved ๐
that... also works
why/is one better than the other
they're basically similar
also realized it doesn't stop if I jsk unload the cog 
?
can I not sleep in peace 
dont ping me randomly please
How
He means the Akeno server
let's not discuss it here then 
lol
it's locked 
locked what?
pineapple channel, you closed it, what did you want the help with
no he asked how problem solved so i give him channel so he can read how it i s fixed
Ah that way
ik, else u gonna bother @unkempt canyon by running those commands again
hey peeps,
I was wondering if a bot could check if a particular user replied to the bot's message
The message that this message references. This is only applicable to messages of type MessageType.pins_add, crossposted messages created by a followed channel integration, or message replies.
New in version 1.5.
!d discord.MessageType.reply
The system message denoting that the author is replying to a message.
New in version 2.0.
@bot.command()
async def foo(ctx, arg):
await ctx.send(arg)```
How do I make different arguments separating with : like !foo test:cal:lol
aight tysm
Its fine, have fun
u can do arg.split(":")
!e
arg = "1:2:3:4"
print(arg.split(":"))
@maiden fable :white_check_mark: Your eval job has completed with return code 0.
['1', '2', '3', '4']
But I basically wanna set as Variable
If that makes sense
use flags, ig?
Like the code asks length
I wanna do like !foo 12 and it inputs the length for 12 ect
!d discord.ext.commands.FlagConverter
class discord.ext.commands.FlagConverter```
A converter that allows for a user-friendly flag syntax.
The flags are defined using [**PEP 526**](https://www.python.org/dev/peps/pep-0526) type annotations similar to the [`dataclasses`](https://docs.python.org/3/library/dataclasses.html#module-dataclasses "(in Python v3.9)") Python module. For more information on how this converter works, check the appropriate [documentation](https://discordpy.readthedocs.io/en/master/ext/commands/commands.html#ext-commands-flag-converter).
iter(x) Returns an iterator of `(flag_name, flag_value)` pairs. This allows it to be, for example, constructed as a dict or a list of pairs. Note that aliases are not shown.
New in version 2.0.
No
Iโll get an example
@maiden fable py```
@bot.command()
async def obamasend (ctx, arg):
usernameclaimed, user = reason.split(':') ```
Like this
Yea so jusyt use my way bruv
Could you replace reason with arg
Wym
@maiden fable
yea soooo?
(ctx, *, reason=None):
Can I replace this from original
To the one I updated
Arg looks better then reason=none
Sure, ig?
Iโll try it
File "main.py", line 68
await reply_lol.add.reaction("โฐ")
^
IndentationError: expected an indented block
help
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
Have you learn discord docs
Well not discord docs but python
!indent
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
Indentation is one off errors explained there
ok
@cosmic agate
๐๐ผ
The best way to explain is there is too many or too less spaces before await
hmm how to you know, know that there is a lot of spaces?
Remove/add space and run code
Show command before that
ok
Show whole command code
@bot.command()
async def timer(ctx, seconds):
try:
secondint = int(seconds)
if secondint > 600:
await ctx.reply(embed=discord.Embed(title="Timer", description="I dont think I'm allowed to do go above 600 seconds/10 minutes.",colour=discord.Colour.random()))
raise BaseException
if secondint <= 0:
await ctx.reply(embed=discord.Embed(title="Timer", description="I dont think I'm allowed to do negatives.",colour=discord.Colour.random()))
raise BaseException
embed4 = discord.Embed(title="Timer", description="Timer has ended!",colour=discord.Colour.random())
embed4.set_footer(text="Use $timerhelp to see seconds to minutes.")
while True:
secondint -= 1
if secondint == 0:
await reply_lol.add.reaction("โฐ")
users = await reply_lol.reactions[0].users().flatten()
reply_lol = await message.edit(embed=embed4)
await message.edit(embed=embed5)
await asyncio.sleep(1)
reply = await ctx.reply(embed=discord.Embed(title="Timer", description=f"{users.mention}Your countdown Has ended!",colour=discord.Colour.random()))
except ValueError:
await ctx.reply(embed=discord.Embed(title="Timer", description="Must be a number!",colour=discord.Colour.random()))
?
Itโs fixed there
Lol
XD
you're still stuck here 
Huh
No Iโm helping him with indentation error
yeah 3 days ago I was helping with the same indents
lol
@cosmic agate did it work?
I love ur about me btw
its depressing you know 
Know what?
O
Lmfao man has been stuck on indentation error for 3 days
No hate to you my friend
nvm 
I mind

@bot.command()
async def alex(ctx, arg):
name, leng, amnt = arg.split(':')
users = 0
for i in range(int(amnt)):
content = '\n'.join(sample(ascii_lowercase+digits, int(leng)))
buffer = BytesIO(content.encode('utf-8'))
file = discord.File(buffer, filename= name)
users += 1
print(f"{user} | {users}")
await ctx.send(file=file)``` await outside function
yes it did
you didn't indent the for loop block
lag
Not my problem
The await is outside function is my problem
it is the problem
your for loop is outside the function, thus everything after it, is also outside
O
Hi, is there any design pattern I can follow building my Discord bot?
design pattern? 
Like MVC
MVC? 
STFW is an option here
idk what you're trying to state, out of my understanding 
What
But you're making my question invisible to other members, who probably have better understanding about my question, by questioning aimless questions
Your asking very unrelated topics to discord bots
Whats MVC
Do you mean the layout of code like in order?
Not like that but kinda ye, also I hope you guys have connection to any browser, so remember that you can search things on the internet
Well yes
But you donโt have to resort to browser when you donโt know something
@slate swan yes discord.py has certain layout for each thing
Like commands have to start with bot.command()
async def alexlol(ctx)
await ctx.send(โtestโ)
Not like that
You misunderstand me because design pattern is not something framework or API specific syntax
so I am wanting to make the help command for my bot and I have a code but the reactions aren't the emojis i want.
Code:
from discord.ext import commands
from pretty_help import DefaultMenu, PrettyHelp
menu = DefaultMenu(page_left="", page_right="", remove="", active_time=5)
ending_note = "The ending note from {ctx.bot.user.name}\nFor command {help.clean_prefix}{help.invoked_with}"
bot = commands.Bot(command_prefix="gd ")
bot.help_command = PrettyHelp(menu=menu, ending_note=ending_note)```
Output:
The emojis should be as follows:
Page Left: 
Page Right: 
Remove Embed: 
then just change the emoji
its changed in the code but it doesn't react with the right emoji
use PartialEmoji's
If i were to create a bot that would do speech recognition, and it were to be deployed on an active server, would it be possible to listen to separate voice channels? As I don't assume it would be able to catch individual voice channels from independent users, or is this possible to isolate if multiple people were to talk at once?
Please smack me in a ping if you are replying, or i might lose it ๐
bots cannot join 'separate' VCs, they can only join one VC at a time
Okay, in that case, are they able to isolate each person's speech?
or will they receive it as a mixed up shoutfest
no, they meant that the bot can only join one voice channel per server
I know
and my question is, if there's like 10 people in the VC with that bot, would the bot be able to distinguish eachs user's voice, or will they not be able to
Does a bot receive each user's speech on a separate channel, or is it a single channel with all speech joined
Nope
Voice Receive isn't implemented in most of the wrappers
So it'll be a shoutfest it receives?
It won't receive any voice
what
What
I've seen bots do voice commands
mee6 does that somehow 
true
discord.js, py-cord has it though
I know receiving voice is possible
most
discord.js already has voice receive, as kayle specified
I only have the question whether it can isolate a single user voice, or whether multiple people talking will be complete randomness
I mean, discord does allow it, just the endpoint isn't documented
Nope
Not until u use pycord, also I never looked into their implementation so idrk
py-cord
I've never used py-cord 
Again, i'm just asking IF it is possible, not with what library, language, day of year, flavour of tea
because it just sucks
then which one u use? nextcord? idk i am confused
It should be, but as I said I never looked into it or how it works so cannot really help u, sorry. Try asking in their server
you sitll can't
why would I use, I dont wanna do nothing with random people's voices 
right okay thanks, can you pm me their discord? or do you ont have it
I am talking about the module itself, not voice receive
disnake 
!pypi py-cord
Gracias

imagine using disnake and not using fusion
imagine not sending raw requests to the api yourself
mee6 does that iirc
Its fun tbh
smh
Many big bots do, they make their own wrappers suiting their need
MEE6 is coded in Python iirc and they have their own wrapper
waste of time 
It saves them resources
idts

I mean, my bot only uses on_message trigger and send method. If I use raw aiohttp requests with it, I can decrease the RAM usage even more
hunter make dsc api wrapper 
Meh there are already loads of them
huncord 
I already hate that name
w h a t
I mean, I am writing Python programs already (see #ot0-psvmโs-eternal-disapproval I posted a pic)
how do I make the respond in a block of message?
the response in dm comes like this
1st message link1
2nd message link2
how do I make
1st message:
link1
link2
@bot.slash_command()
async def search(ctx, search):
await ctx.defer()
page = requests.get(f'https://')
tree = html.fromstring(page.content)
xpaths = ["/html/body/div[2]/div[2]/div[1]/a/@href","/html/body/div[2]/div[2]/div[2]/a/@href", "/html/body/div[2]/div[2]/div[3]/a/@href","/html/body/div[2]/div[2]/div[4]/a/@href","/html/body/div[2]/div[2]/div[5]/a/@href",
"/html/body/div[2]/div[2]/div[6]/a/@href","/html/body/div[2]/div[2]/div[7]/a/@href", "/html/body/div[2]/div[2]/div[8]/a/@href",
"/html/body/div[2]/div[2]/div[9]/a/@href", "/html/body/div[2]/div[2]/div[10]/a/@href"]
for pth in xpaths:
links = []
links.append("https://nhentai.net" + tree.xpath(pth)[0])
user = ctx.author
await user.send(f'blahbah\n'+'\n'.join(links))
await ctx.respond('Please check your DM', ephemeral=True)
you know a reply pings a person if the mentions are on right
!d discord.PartialEmoji try using this instead of strings for the emojis
class discord.PartialEmoji```
Represents a โpartialโ emoji.
This model will be given in two scenarios:
โข โRawโ data events such as [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add")
โข Custom emoji that the bot cannot see from e.g. [`Message.reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message.reactions "discord.Message.reactions")...
Instead of writing all the columns, you can just do * to get all the columns, and using f-strings in sql is bad, use placeholders instead.
Can the bot add reactions to a interaction
regarding pycord how do I make sure the tasks.loop doesn't restart until it's completely finished?
Buttons are called interactions, right?
Buttons are called buttons 
LMao
Well, depends in which way u want to take it, the PoV
What do you think interaction means?
any ui related response from a user on the frontend
Well I'm just trying to find the correct word for issue I'm about to open to @unkempt canyon. "Limit user interaction of help embed pagination"
Yea u can say that
great, thx
Does anyone know why I am getting unknown webhook error?
https://paste.pythondiscord.com/raw/awunuwakec
you do know that you can send the part where you're creating webhooks 
I literally ctrl+fed the page and cant see a single webhook written anywhere
No I dont

Wdym
Should I show the real command
Where it all started?
U do know that interactions are webhooks, right?
My time to leave 
@rotund creek mind showing the full traceback?
That error comes when u interact with a component
Imagine not knowing it
Just show a screenshot if u can then
K
imagine not working with buttons, totally me
I dont have a single button in my bot 
I know u r joking...... right? 
||no||
Smh
On which button click does it happen?
I mean, I dont require them so 
Smh
On the first choice
Oh hi there fridays!
anyone have any good tutorials on were to start with making bots(i alr have a bit of python knowledge)
So it will be
hello thanks for showing me this channel
In rpsConfirmView
All cool!
It takes place in rpsMultiConfirmView class and in confirmButton function
Oh, sorry bruv. I cannot see it rn, got a class
Also why does timeout go off even though someone responded
Ypu cannot
https://vcokltfre.dev/ best one ig
!d disnake.Member.timeout
await timeout(*, duration=..., until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Times out the member from the guild; until then, the member will not be able to interact with the guild.
Exactly one of `duration` or `until` must be provided. To remove a timeout, set one of the parameters to `None`.
You must have the [`Permissions.moderate_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.moderate_members "disnake.Permissions.moderate_members") permission to do this.
New in version 2.3.
huh
ty!
huh huh
i don't wanna use a fork
@boreal ravine
thanks
(:
whats wrong with this code?
@clien
typo on_message decorator
ohhh lmaooo
!indents
tysm yall
indents
and why is everything underlined
indents 
messege, authro

lmao
and it's always the
We have logged in as, format method
happy freecodecamp noises
respect f-sfrings already
oh everything turns red if you wwait outside of the function?
even
import os
yeahhh they tutorial seems a bit outdated since this is like the 5th error ive gotten
speaking offff
Yo guys so I wanna put a big part of meh code into another file for easier management, but idk how do I do that? that you create another file like p.py and then create a class and put ur code there, but it never seems to work for meh
replit ew
your fault
didnt i give you a tutorial link?
idk what else to use
use a code editor/ide to code..
You should use bot
yeah i think imma just switch to that one freecodecamp is a bit outdated
I normally use vs but idk it can do the online stuff
bot = commands.Bot(command_prefix="pls ", help_command=None)
Try this
Switch things to like @bot.command()
Or
unhappy subclassed helpcommand noises
it can do that, you just gotta run the file with an internet connection
U donโt need client
also, the tutorial you are using seems very bad
i just found this-
https://vcokltfre.dev/ use this
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
you dont have a ctx in on_message
please, dont, follow, freecodecamp
yeah thats the one imma do sasuke said it was best to
commands
freecodecamp should delete their tutorial already
Oh wait just read the code

class DropDownMenu(Select):
def __init__(self):
options = [
SelectOption(label="Red", value="red"),
SelectOption(label="Green", value="green"),
SelectOption(label="Blue", value="blue"),
SelectOption(label="Yellow", value="yellow"),
SelectOption(label="Orange", value="orange"),
SelectOption(label="Pink", value="pink")
]
super().__init__(placeholder="Select your choice.", min_values=1, max_values=1, options=options)
async def callback(self, interaction: Interaction):
await interaction.response.send_message(f"Your choice is {self.values[0]}.")
self.disabled = True
Trying to disable the Select object. Setting attribute disabled to True isn't working. Any workaround?
maybe edit the View after setting the disabled value to True
^
ohhh alr
How to do it?
you have to edit it
imagine editing
Ash, it's time for u to stop
I wasnt making fun of anybody
I really meant something else while it came out wrong
discord.Message.edit(view=newView)

Ah okay.
no
something like this

wrong reply
yeah, call it, put the new dropdown in it
class DropDownMenu(Select):
def __init__(self):
options = [
SelectOption(label="Red", value="red"),
SelectOption(label="Green", value="green"),
SelectOption(label="Blue", value="blue"),
SelectOption(label="Yellow", value="yellow"),
SelectOption(label="Orange", value="orange"),
SelectOption(label="Pink", value="pink")
]
super().__init__(placeholder="Select your choice.", min_values=1, max_values=1, options=options)
async def callback(self, interaction: Interaction):
await interaction.response.send_message(f"Your choice is {self.values[0]}.")
self.disabled = True
class DropDownView(View):
def __init__(self):
super().__init__()
self.add_item(DropDownMenu())
class Dropdown(commands.Cog):
def __init__(self, client: Bot):
self.client = client
@commands.slash_command(name="dropdown", description="Test the dropdown feature.", guild_ids=get_guilds())
async def dropdown(self, ctx):
await ctx.respond(view=DropDownView())

Full Code. Now temme. 
maybe edit in your callback
set the default value of user to None
a: Option(discord.Member, description="Set the user", required=True)
a will never be None
it's complicated already
anyways, gotta go
interaction.responce.edit_message(view=self) put this under self.disabled = True
makes much more sense.
async def slap(self, ctx, a: discord.Member=None): '''do stuff''
Nah Ash don't send wrong code.
no?
nope
thats right 
You should try a input
What
@stray carbon
@commands.command(name='slap')
async def slap(self, ctx, a:discord.Option(discord.Member, "The member to slap!", required=true)):
"""Slap the user!!!"""
await ctx.send(f'Slapped {a}')
Fixed.
????
rip my skills
Can you stop spoonfeeding?
I always forget about sum() 
Btw, use ctx.respond()
no?
dud just use =None
^
Do you know how to do discord.py inputs
nobody listens to me
i literally even gave an example
command is working but when we dont mention a user bot doesnt send message 'mention a user to slap'
They're trying to make sure a member is mentioned. Why not just use the required=True so that it can't be invoked without it?
Lemme gimme u example
@stray carbonyour solution, Senor
lol wtf
discord.commands.Option
then what they had before was corrent, they just need to remove the if statement where it checks if user is none
hi guys, how can i make this command send the top 3 not send the oll of in
@client.command(name="servers")
async def _sero(ctx):
servers = client.guilds
servers.sort(key=lambda x: x.member_count, reverse=True)
for x in servers[:3]:
y = 0
for x in client.guilds:
y += x.member_count
embed=discord.Embed(title="Server infos")
embed.add_field(name="\u200b",value='**{}**, **{}** Members, {} region, Owned by <@{}>, Created at {}\n{}'.format(x.name, x.member_count, x.region, x.owner_id, x.created_at, x.icon_url_as(format='png',size=32)))
embed.add_field(name="\u200b", value='**Total members::** **{}**!\n**Number of servers:** **{}**!'.format(y, len(client.guilds)))
await ctx.send(embed=embed)
They're goal is to inform the user to mention a member.
omg
use list slicing on client.guilds
how
!e print([1,2,3,4,5][:2])
then make an if statement if member is none
@slate swan :white_check_mark: Your eval job has completed with return code 0.
[1, 2]
discord.ext??
why discord.command then?
from discord.ext import commands
istg the inconsistency between the forks
that was an example of list slicing, dont just copy paste it.
nah, he got false information guys
Any professional game developers dm me please
are you using this as a database
its just pycord. for all others its just <library>.Option
TypeError: list indices must be integers or slices, not tuple
do you even read the other parts of the messages other than the code?
async def slap(self, ctx, a:discord.User=None):
ImportError: cannot import name 'Embed' from 'discord.embeds' (/home/runner/rewardbot/venv/lib/python3.8/site-packages/discord/embeds.py)
what do i import/install to fix this
yes?
async def slap(self, ctx, a: discord.Member=None):
if a is None:
return await ctx.reply("Slapped the air for ya")
tf is discord.embeds
discord.Embed
!d discord.embeds.Embed 
class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, 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.
Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
reinstall discord.py
huh spoonfed
it was better than applying too much brain
oh he already had the if
if you wanna do-
jk jk
!ot
Off-topic channel: #ot2-never-nesterโs-nightmare
Please read our off-topic etiquette before participating in conversations.
!rule 7
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
:)

poor guy
not working,wait i will give full code
!resource
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
torture
omegalul
you control your lights with a discord bot?
i stopped doing this
you're the coolest person here

!pypi hikari-lightbulb ๐โโ๏ธ
nvm
lmao
does that even matter?
you're not cool
"A simple to use"
what?
meh got jokes
!pip hikari-tanjun
when compared to this

there are more command handlers but i dont like any other than these
so how can i put this to top 3 ? i dont use database its just send the servers (the bot in 8 server and send the all)
@client.command(name="serversek")
async def _sero(ctx):
servers = client.guilds
servers.sort(key=lambda x: x.member_count, reverse=True)
for x in servers[:5]:
y = 0
for x in client.guilds:
y += x.member_count
embed=discord.Embed(title="Server infos")
embed.add_field(name="\u200b",value='**{}**, **{}** Members, {} region, Owned by <@{}>, Created at {}\n{}'.format(x.name, x.member_count, x.region, x.owner_id, x.created_at, x.icon_url_as(format='png',size=32)))
embed.add_field(name="\u200b", value='**Total members::** **{}**!\n**Number of servers:** **{}**!'.format(y, len(client.guilds)))
await ctx.send(embed=embed)
!f-strings
Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.
>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."
Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.
ok and if +1 server?
The description of the embed. This can be set during initialisation.
just send("text", embed=embed)
how to attach a img url as attachment?
and whats the end
?
ya done
!d discord.Member.color
property color: discord.colour.Colour```
A property that returns a color denoting the rendered color for the member. If the default color is the one rendered then an instance of [`Colour.default()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Colour.default "discord.Colour.default") is returned.
There is an alias for this named [`colour`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member.colour "discord.Member.colour").
can anyone guide me on how to make a bot notify when a streamer goes live on, say, Youtube/twitch
I tried to make bot.event on_message, its working but my command didnt, i put await bot.process_commands(message) but its still not working
How can i fix that ?
remove process_commands and change bot.event to bot.listen()
permissions of the author or the user that is mentioned?
why user or member?
Traceback (most recent call last):
File "main.py", line 20, in <module>
from cogs.help import HelpCommand
File "/home/runner//cogs/help.py", line 20, in <module>
from core.Contexts import Context
File "/home/runner//core/Contexts.py", line 6, in <module>
from core import buttons
File "/home/runner//core/buttons.py", line 591
async with aiohttp.ClientSession() as session:
^
async with aiohttp.ClientSession() as session:
async with session.get(url, params=params) as r:
if r.status == 200:
res = await r.json()
else:
return
```help????
I remove the full line ? await bot.process_commands(message)
ok
You cut off the error
Send the full traceback
huuh
thats the full
guess not




