#discord-bots

1 messages ยท Page 860 of 1

kindred epoch
#

yea ^^

winged crane
#

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.

kindred epoch
#

and what is that tag?

winged crane
#

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

kindred epoch
#

doesn't this do what you want it to do?

winged crane
kindred epoch
#

can you give an example of what you are trying to do?

winged crane
#

sure, one second.

winged crane
kindred epoch
#

ye go ahead

nimble plume
#

Hey

quaint epoch
#

We did it boys, moderator commands are no more!

kindred epoch
#

lmao wtf is discord on, they want us to migrate to slash commands and now they making slash commands itself?

royal turret
#

ok

quaint epoch
#

bot = disnake.ext.commands.Bot(command_prefix='/')

#

ez

slate swan
#

at this point let discord host your botsyert

slate swan
kindred epoch
quaint epoch
slate swan
quaint epoch
#

it's like artistic inspiration, (idk what's that) it just comes and goes (mostly goes)

small igloo
#

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)```
unkempt canyonBOT
#

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.

small igloo
rose hazel
#

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

slate swan
rose hazel
#

can you show me how?

kindred epoch
slate swan
#

guild ids?

rose hazel
#

im basically saying only these guild IDS can access these channels

stone beacon
#

what theme is that if I may ask?

#

One dark?

rose hazel
#

and im also defining roles and stuff

kindred epoch
rose hazel
#

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```
slate swan
#

what the-

rose hazel
#

i get all the channels here

kindred epoch
#

wtf

#

dud just use a db

rose hazel
#

wdym?

rose hazel
#

LOL!

small igloo
kindred epoch
rose hazel
#

meanies

kindred epoch
#

and way easier

rose hazel
#

i already do that for the plyaers

#

players*

slate swan
#

imagine using decorator checks on commands ๐Ÿ˜”

rose hazel
stone beacon
kindred epoch
#

then why not do that?

rose hazel
#

these are just channels

#

for each guild

rose hazel
#

channel IDs

kindred epoch
#

yea, so make a seperate table with guild id and channel id as columns and store it in that?

rose hazel
#

Ok I can do that

stone beacon
rose hazel
#

but how does that help me

stone beacon
#

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

small igloo
kindred epoch
stone beacon
#

I'll assume you're sure s is zero as well

#

If so then idk I

small igloo
rose hazel
#

like a function?

#

db function

kindred epoch
#

when they use the command get all the channel ids and stuff you need from the db using the guild id

rose hazel
#

yeah but my problem is having alot of commands and then using the same kind of code

sick birch
rose hazel
#

accessing role names, channel IDs

kindred epoch
#

i dont think you get my point

rose hazel
#

yes i do

#

i definitely get it

stone beacon
kindred epoch
slate swan
kindred epoch
rose hazel
kindred epoch
#

yes

rose hazel
#

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

kindred epoch
#

yea works

rose hazel
#

good idea thnx

kindred epoch
#

np.

frigid pendant
#

How would i react to the message that is sent by the bot with the reaction of โœ…

final iron
unkempt canyonBOT
#

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**...
final iron
#

This?

dull terrace
#

how'd i do this better ๐Ÿค”

unkempt canyonBOT
#

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.
slate swan
final iron
slate swan
#

๐Ÿ‘๏ธ ๐Ÿ‘๏ธ

dull terrace
#

brighter image

rose hazel
# kindred epoch np.
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?

dull terrace
#

return sql should send back a tuple with all the info in it

rose hazel
#

uhhh i dont see anything ๐Ÿ˜ฎ

dull terrace
#

oh have you done sql = guildInfo(ctx)

rose hazel
#

where?

dull terrace
#

where you call it

rose hazel
#

in the command

#

nope let me try

dull terrace
#

you gotta define what you're storing the return in

rose hazel
#

yeah it works

#

nice man, thanks ๐Ÿ˜ฎ

dull terrace
#

๐Ÿ‘

final iron
#

!pypi aiosqlite

unkempt canyonBOT
dull terrace
final iron
#

This is the official documentation so there's really no way to dispute it

dull terrace
#

๐Ÿค”

final iron
#

I see

final iron
# dull terrace
# Pascal Case (the proper way)
class MyLongClassName:
    pass

# camelCase (the wrong way (pep8 wise))
class myLongClassName:
    pass
dull terrace
#

alright so the place i read just doesn't know what camel case is

final iron
#

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?

dull terrace
final iron
tacit storm
#

camel case is like this โ€œmyLongClassNameโ€

final iron
#

ah

dull terrace
unkempt canyonBOT
#

7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.

final iron
slate swan
#

What Rasberry pi do yโ€™all recommend me to get for hosting

slate swan
#

Oh alright

rotund frigate
#

what does the 0 mean in message.embeds[0].title:

spring flax
rotund frigate
#

do i need it?

slate swan
spring flax
#

yeah

rotund frigate
#

what would happen if i didnt have it?

spring flax
#

because embeds returns a list of embeds

rotund frigate
#

i tried if 'title' == message.embed.title: but it didnt work

final iron
unkempt canyonBOT
#

@final iron :white_check_mark: Your eval job has completed with return code 0.

001 | Let's
002 | show
003 | indexing
spring flax
rotund frigate
#

!e if 'title' == message.embed.title:

#

what do i use then?

spring flax
#

do if message.embeds[0].title == 'title':

sick birch
#

@rotund frigate is it the problem about finding if there's a certain phrase in the title of an embed?

sick birch
#

If so, map each embed to a list of title strings, then check if its in it

rotund frigate
#

well i want to do this, if embed has certain image url, send message

sick birch
#
if "some string" in map(lambda emb: emb.title, message.embeds):
  # found it
rotund frigate
#

await message.channel.send('message')```
sick birch
#

"Certain image URL", thumbnail or image? is it the icon in the header or the footer?

sick birch
rotund frigate
#

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:

unkempt canyonBOT
#

@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
sick birch
#

That only works on the first embed

#

If that's alright then sure

rotund frigate
#

wdym first embed?

sick birch
#

Messages can have multiple embeds

rotund frigate
#

like i can only do 1 image

#

and 1 title?

sick birch
#

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

rotund frigate
#

so if i type if "Name of the Pokemon" in message.embeds[3].title: it would do 3 embeds?

sick birch
#

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
rotund frigate
#

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

unkempt canyonBOT
#

You are not allowed to use that command here. Please use the #bot-commands channel instead.

quick gust
#

remove the * param

slate swan
#

!d disnake.UserFlags.hypesquad

unkempt canyonBOT
slate swan
#

peephappy search for anything that fits your purpose

#

lemme see

quick gust
#

make sure u have members intent enabled

slate swan
#

are you sure you're sending stuffs instead of printing them catstare

quick gust
#

!intents

unkempt canyonBOT
#

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.

slate swan
#

send something to that channel?

quick gust
#

that wont work...

#

get or fetch a channel object then send

slate swan
#

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

maiden fable
#

bot.get_channel is also there ๐Ÿ‘€

quick gust
#

will only work for one server - kinda misleading, just use bot.get_channel

slate swan
#

sure, either let the server members with perms configure the channel or either iterate through them to find a channel

maiden fable
#

but then, type checkers to brrrr since its typehinted as Union[DMChannel, TextChannel, VoiceChannel, None]

quick gust
#

!d discord.ext.commands.Bot.get_channel

unkempt canyonBOT
maiden fable
#

Ikrrrrrrr

#

# type: ignore goes brrr

quick gust
#

don't think you can

stone beacon
#

typing is beautiful yet painful sometimes

quick gust
#

hmm

maiden fable
#

!d disnake.PublicUserFlags

unkempt canyonBOT
#

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.
stone beacon
#

See your type hints looking like mumbojumo

maiden fable
#

Ah, that is done manually

quick gust
#

indeed

maiden fable
#

Told u ๐Ÿ‘€

slate swan
maiden fable
#

Meh, I have made those commands in the past so I know about them

quick gust
#

uh

nimble plume
#

disnake.ext.commands.errors.ExtensionFailed: Extension 'save' raised an error: JSONDecodeError: Expecting value: line 1 column 1 (char 0)

quick gust
#

what the

nimble plume
#

wtf

#

async def on_member_join(member : discord.Member, bot.get_channel):
huyh???

quick gust
#

do you know what args are?

nimble plume
quick gust
#

of course it didn't

nimble plume
#

send huh?

boreal ravine
#

use bot.get_channel in the function, not in it's parameters

quick gust
#

and also give it an ID

#

bot.get_channel(channel_id)

#

dont see that anywhere here

boreal ravine
#

replace it with client

quick gust
#

why are u adding it in the param then

#

remove it from the param

#

!d discord.on_member_join

unkempt canyonBOT
#

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.
quick gust
#

see it takes only one member arg

#

assign the client.get_channel to a variable then variable.send

boreal ravine
#

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(...)

quick gust
#

so you're just gonna ignore what I said pithink

#

np lol

nimble plume
#

getprefix

maiden fable
#

!d discord.ext.commands.Bot.get_prefix

unkempt canyonBOT
#

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.
quick gust
#

bro, assign client.get_channel(id) to a variable, it can't be empty

nimble plume
#

im using json for storing

boreal ravine
#

get_channel takes a valid channel id

quick gust
nimble plume
#

but im using

nimble plume
#

so i use

quick gust
#

can u not ping me

gilded grotto
#

what to do if we get login failure but I copied the token correctly

nimble plume
#

ok.

boreal ravine
#

yes

quick gust
#

seems right

#

make sure u have enabled intents

#

!intents

unkempt canyonBOT
#

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.

boreal ravine
quick gust
#

make sure to do both of these (add in your code and enable in dev portal)

maiden fable
quick gust
#

any error?

quick gust
#

wha, thats a different thing

#

i dont see anything wrong tbh, try printing the channel and member

maiden fable
#

@slate swan u got intents?

quick gust
#

print(channel)
print(member)

maiden fable
#

show

quick gust
#

just importing doesnt work

boreal ravine
maiden fable
#

in the bot constructor

quick gust
#

yeah

#

uh wait

#

i know what ure gonna do

nimble plume
#

ok

maiden fable
quick gust
#

add intents=intents in your client = commands.Bot()

quick gust
#

oh nice

maiden fable
#

๐Ÿ‘€

nimble plume
#

wc

boreal ravine
#

intents, not indents

maiden fable
#

l o l

#

its fine

nimble plume
#

huh

maiden fable
#

Why did I misread it as hun What happened

#

Lol

quick gust
#

nice

nimble plume
#

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

maiden fable
#

show code

nimble plume
#
for items in logs:
            for guildid, logsid in items.items():

maiden fable
#

seems like logs is an instance of commands.Cog

nimble plume
#

oh yea

#

ya i just see its targeting the cog

slate swan
#

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

maiden fable
#

incorrect channel*

slate swan
#

"is listening to everything but sending in the CORRECT channel"

maiden fable
#

I mean, then what is the issue

slate swan
#

im stating that it's listening to everything other than sending it in the correct channel

maiden fable
#

message = await channel.send

#

Instead of ctx.channel.send

slate swan
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'send'

maiden fable
#

the channel id is wrong

slate swan
#

how could it be wrong?

maiden fable
#

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

slate swan
maiden fable
#

No I mean on the discord client

#

Type that in discord

slate swan
#

self.client?

maiden fable
#

?

slate swan
#

i did

slate swan
slate swan
#

i assume they redefined client in the cog

maiden fable
slate swan
#

christ man

#

im not use to working in cogs, that was the fix

maiden fable
#

Its fine

slate swan
#

thanks

maiden fable
#

Weird it didn't raise an error tho

slate swan
#

sorry if i seem like a grinch hunter, just hella tired

maiden fable
#

Show yr error handler bruv

slate swan
#

yeah odd how it didn't

maiden fable
maiden fable
slate swan
#

i don't got error handling up yet. that was on my list just now

maiden fable
#

Weirddd

#

So u don't have an on_command_error event?

#

or on_error event

slate swan
#

oh yeah i did

#

i do ** my fault

maiden fable
#

add an else block

#
else:
    raise error
#

That will raise the error automatically

slate swan
#

ah i had it to print "error not caught"

maiden fable
#

Haha instead do print(error) then

slate swan
#

yeah just did,

#

thanks chief

maiden fable
#

Its fine

slate swan
#

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

quick gust
#

bot\bot\bot\bot.py

thats one hell of a directory

slate swan
#

What lib you suggest to deal with images?

#

!pip pillow

unkempt canyonBOT
nimble plume
#
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

maiden fable
#

Lemme see

#

Try printing logss

nimble plume
#
{'926129108696580186': 927407150651834448, '874949321089511475': 935097577261633546}
#

@maiden fable ^

boreal ravine
#

@slate swan join back

spring flax
#

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?

maiden fable
nimble plume
spring flax
# maiden fable yes

so should i iterate through and unpin and asyncio.sleep(1), I guess this would be a solution right

nimble plume
maiden fable
nimble plume
#

ok

#

926129108696580186
874949321089511475

maiden fable
#

???

nimble plume
#

guild id

maiden fable
#

what about logsid

nimble plume
#

874949321089511475
935097577261633546

#

json file

{"926129108696580186": 927407150651834448, "874949321089511475": 935097577261633546}
maiden fable
#

So they both print the same thing?

nimble plume
#

no

#

guildid and logsid have different print

maiden fable
#

Show the separate prints then bruv

nimble plume
#

seprate?

maiden fable
#

Like what does guildid print and what does does logsid print

nimble plume
#
for guildid, logsid in logss.items():
               print(guildid)
               print(logsid)
               if int(guildid) == message.guild.id:
maiden fable
#

tell separately

nimble plume
#

1 i said guildid and then logsid

maiden fable
nimble plume
#
    @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:
quick gust
nimble plume
#

guild id

quick gust
#

bro

#

What is it?

nimble plume
#

logs

maiden fable
#

I will just go and study for exam cya

nimble plume
#

bruh?

maiden fable
#

I got an exam on monday bruv

nimble plume
#

ok il get another one

#

@slate swan hey

maiden fable
#

@quick gust mind helping him?

maiden fable
quick gust
#

no he hurts my brain i don't understand what he says

nimble plume
nimble plume
maiden fable
nimble plume
#

server logs

maiden fable
nimble plume
#

there are 2 different server id there

#

the 1 id is working fine but 2 nd not working

maiden fable
nimble plume
#

yes the first id has 2 serve

#

{"926129108696580186": 927407150651834448, "874949321089511475": 935097577261633546}

#

1 combo working "926129108696580186": 927407150651834448

maiden fable
#

Okay?

nimble plume
#

2 nd combo not checking "874949321089511475": 935097577261633546

quick gust
nimble plume
#

huh?

quick gust
#

then i can help u

maiden fable
#

discdb =D

nimble plume
maiden fable
#

?

nimble plume
#

about discdb

maiden fable
#

Was jk

nimble plume
#

huh?

heavy folio
#

asqlite :D

nimble plume
#

hunter exposed

#

@maiden fable

maiden fable
#

Meh I ain't hiding it anyways

nimble plume
maiden fable
#

I have already been trolled and bullied cz I made that so idrc

nimble plume
#

woah what i was trooling u until i realize its really u

maiden fable
nimble plume
#

hahah

maiden fable
#

Meh

#

No one uses it anyways

nimble plume
#

lol

#

im also going for exam learning

#

@maiden fable i invited ur bot

maiden fable
#

Cool thanks (also ot)

nimble plume
nimble plume
maiden fable
#

I don't really own any servers ๐Ÿคท

nimble plume
nimble plume
heavy folio
#

off-topic

nimble plume
#

now go study all byeeeee

nimble plume
heavy folio
#

um

#

i dont use json alot

nimble plume
#

ok

#

so

#

lets claim a help channel

visual island
#

use try and except

frozen elk
#

it's giving error that avatar doesn't have url property

maiden fable
#

๐Ÿ‘€

visual island
#

2 possible reasons:

  1. The user doesn't have avatar
  2. You're not using v2.0
maiden fable
#

it's the bot itself

slate swan
#

how do I restart a loop exactly

maiden fable
#

kill it and make a new loop

slate swan
#

@tasks.loop loop ofc

#

I know loop.restart exists, but what is loop exactly

maiden fable
#

Ah i thought u were talking about asyncio.loop

frozen elk
#

tysm

slate swan
#

no worries

slate swan
visual island
visual island
maiden fable
slate swan
#

I tried that, it says function is not defined where function is the function decorated with tasks.loop

visual island
#
@tasks.loop(...)
async def foo():
  ...

# to restart
foo.restart()
slate swan
#

I wonder if you could restart it from within the loop iteslf though m_eyesleft

slate swan
#

OH I'M IN A COG

#

smh self go brr

maiden fable
#

!d discord.ext.tasks.Loop.restart does exist

unkempt canyonBOT
#

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").
slate swan
#

oh well

slate swan
#

let's see if this siht works shrug_SS

#

what's the best way to start a loop in a cog whatstheteaspillit

visual island
#

start it in __init__ function

nimble plume
maiden fable
maiden fable
nimble plume
#

btw my problem is solved ๐Ÿ™‚

slate swan
#

why/is one better than the other

visual island
#

they're basically similar

slate swan
#

also realized it doesn't stop if I jsk unload the cog whatstheteaspillit

slate swan
slate swan
maiden fable
maiden fable
slate swan
nimble plume
slate swan
nimble plume
slate swan
nimble plume
#

no he asked how problem solved so i give him channel so he can read how it i s fixed

maiden fable
#

Ah that way

maiden fable
urban shell
#

hey peeps,
I was wondering if a bot could check if a particular user replied to the bot's message

maiden fable
#

Sure

#

!d discord.Message.reference

unkempt canyonBOT
#

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.

maiden fable
#

!d discord.MessageType.reply

unkempt canyonBOT
slate swan
#

@bot.command()
async def foo(ctx, arg):
    await ctx.send(arg)```
How do I make different arguments separating with : like !foo test:cal:lol
urban shell
maiden fable
#

Its fine, have fun

maiden fable
#

!e

arg = "1:2:3:4"
print(arg.split(":"))
unkempt canyonBOT
#

@maiden fable :white_check_mark: Your eval job has completed with return code 0.

['1', '2', '3', '4']
slate swan
#

If that makes sense

maiden fable
#

use flags, ig?

slate swan
#

Like the code asks length
I wanna do like !foo 12 and it inputs the length for 12 ect

maiden fable
#

!d discord.ext.commands.FlagConverter

unkempt canyonBOT
#

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.
slate swan
#

No

#

Iโ€™ll get an example

#

@maiden fable py```

@bot.command()
async def obamasend (ctx, arg):
usernameclaimed, user = reason.split(':') ```

#

Like this

maiden fable
#

Yea so jusyt use my way bruv

slate swan
maiden fable
#

Wym

maiden fable
#

yea soooo?

slate swan
#

(ctx, *, reason=None):

#

Can I replace this from original

#

To the one I updated

#

Arg looks better then reason=none

maiden fable
#

Sure, ig?

slate swan
#

Iโ€™ll try it

cosmic agate
#

File "main.py", line 68
await reply_lol.add.reaction("โฐ")
^
IndentationError: expected an indented block

#

help

slate swan
#

!resources

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

slate swan
#

Well not discord docs but python

unkempt canyonBOT
#

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

slate swan
#

Indentation is one off errors explained there

slate swan
cosmic agate
#

๐Ÿ‘๐Ÿผ

slate swan
cosmic agate
#

hmm how to you know, know that there is a lot of spaces?

slate swan
cosmic agate
#

await reply_lol.add.reaction("โฐ")

#

wait sorry wrong

#

this much spaces

slate swan
#

Show command before that

cosmic agate
#

ok

slate swan
#

Show whole command code

cosmic agate
#

this is my code @slate swan

slate swan
# cosmic agate this is my code <@456226577798135808>

@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()))

cosmic agate
#

?

slate swan
#

Itโ€™s fixed there

slate swan
#

Lol

cosmic agate
#

XD

slate swan
slate swan
#

No Iโ€™m helping him with indentation error

slate swan
#

lol

#

@cosmic agate did it work?

#

I love ur about me btw

slate swan
slate swan
#

O

#

Lmfao man has been stuck on indentation error for 3 days

#

No hate to you my friend

slate swan
slate swan
slate swan
slate swan
#

@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
cosmic agate
cosmic agate
#

thanks

visual island
#

lag

slate swan
#

The await is outside function is my problem

visual island
#

your for loop is outside the function, thus everything after it, is also outside

slate swan
#

Hi, is there any design pattern I can follow building my Discord bot?

slate swan
slate swan
#

STFW is an option here

#

idk what you're trying to state, out of my understanding PepeWalkAwkward

slate swan
#

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

boreal ravine
slate swan
#

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

slate swan
#

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

unkempt yacht
#

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="![left](https://cdn.discordapp.com/emojis/947082764887396373.webp?size=128 "left")", page_right="![right](https://cdn.discordapp.com/emojis/947082731886633022.webp?size=128 "right")", remove="![cross](https://cdn.discordapp.com/emojis/947083013521563648.webp?size=128 "cross")", 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: left
Page Right: right
Remove Embed: cross

hoary cargo
#

MR_uncanny_10 then just change the emoji

unkempt yacht
#

its changed in the code but it doesn't react with the right emoji

glossy epoch
#

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 ๐Ÿ™‚

boreal ravine
glossy epoch
#

Okay, in that case, are they able to isolate each person's speech?

#

or will they receive it as a mixed up shoutfest

slate swan
glossy epoch
#

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

maiden fable
#

Voice Receive isn't implemented in most of the wrappers

glossy epoch
#

So it'll be a shoutfest it receives?

maiden fable
#

It won't receive any voice

glossy epoch
#

what

maiden fable
#

What

glossy epoch
#

I've seen bots do voice commands

slate swan
boreal ravine
#

discord.js, py-cord has it though

glossy epoch
#

I know receiving voice is possible

maiden fable
#

discord.js already has voice receive, as kayle specified

glossy epoch
#

I only have the question whether it can isolate a single user voice, or whether multiple people talking will be complete randomness

maiden fable
#

I mean, discord does allow it, just the endpoint isn't documented

maiden fable
#

Not until u use pycord, also I never looked into their implementation so idrk

glossy epoch
#

then i'll use pycord

#

will that be able to do so?

slate swan
#

awkward py-cord

maiden fable
#

Ash gonna help u with voice receive then ๐Ÿ‘€

#

Since I never used that module

slate swan
glossy epoch
#

Again, i'm just asking IF it is possible, not with what library, language, day of year, flavour of tea

slate swan
maiden fable
maiden fable
slate swan
glossy epoch
#

right okay thanks, can you pm me their discord? or do you ont have it

maiden fable
unkempt canyonBOT
glossy epoch
#

Gracias

maiden fable
#

this has it

#

๐Ÿ‘€ I sense something else

slate swan
boreal ravine
#

imagine using disnake and not using fusion

slate swan
#

imagine not sending raw requests to the api yourself

boreal ravine
#

mee6 does that iirc

maiden fable
#

Its fun tbh

slate swan
#

smh

maiden fable
#

MEE6 is coded in Python iirc and they have their own wrapper

maiden fable
#

It saves them resources

boreal ravine
slate swan
slate swan
#

pithink still imagine

maiden fable
#

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

maiden fable
#

Meh there are already loads of them

slate swan
maiden fable
#

I already hate that name

slate swan
#

even I dislike it now pithink

maiden fable
#

ยฏ_(ใƒ„)_/ยฏ

#

Should I try writing a discord bot in my notebook? ๐Ÿ‘€

maiden fable
slate swan
#

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)
unkempt yacht
#

@boreal ravine

boreal ravine
#

you know a reply pings a person if the mentions are on right

boreal ravine
# unkempt yacht ?

!d discord.PartialEmoji try using this instead of strings for the emojis

unkempt canyonBOT
#

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")...
kindred epoch
rotund creek
#

Does anyone know why I am getting unknown webhook error?

tidal hawk
#

Can the bot add reactions to a interaction

steel void
#

regarding pycord how do I make sure the tasks.loop doesn't restart until it's completely finished?

tawdry perch
#

Buttons are called interactions, right?

kindred epoch
#

Buttons are called buttons pithink

maiden fable
#

LMao

maiden fable
kindred epoch
slate swan
#

any ui related response from a user on the frontend

tawdry perch
maiden fable
#

Yea u can say that

tawdry perch
#

great, thx

rotund creek
slate swan
slate swan
#

I literally ctrl+fed the page and cant see a single webhook written anywhere

rotund creek
#

No I dont

slate swan
rotund creek
#

Should I show the real command

#

Where it all started?

maiden fable
slate swan
maiden fable
#

@rotund creek mind showing the full traceback?

#

That error comes when u interact with a component

maiden fable
rotund creek
#

Replit dont allow copying on mobile

#

Copying the traceback at least

maiden fable
#

Just show a screenshot if u can then

rotund creek
#

K

slate swan
#

I dont have a single button in my bot anime_shrug

maiden fable
maiden fable
#

Smh

rotund creek
maiden fable
#

On which button click does it happen?

slate swan
maiden fable
#

Smh

rotund creek
#

On the first choice

maiden fable
#

Oh hi there fridays!

safe herald
#

anyone have any good tutorials on were to start with making bots(i alr have a bit of python knowledge)

rotund creek
#

So it will be

safe herald
rotund creek
#

In rpsConfirmView

maiden fable
#

All cool!

rotund creek
#

It takes place in rpsMultiConfirmView class and in confirmButton function

maiden fable
#

Oh, sorry bruv. I cannot see it rn, got a class

rotund creek
#

Also why does timeout go off even though someone responded

boreal ravine
#

How do I timeout someone in d.py?

maiden fable
#

Ypu cannot

maiden fable
#

!d disnake.Member.timeout

unkempt canyonBOT
#

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.
boreal ravine
safe herald
maiden fable
boreal ravine
#

doesn't d.py have an httpclient

#

can't I use that

boreal ravine
maiden fable
maiden fable
#

(:

boreal ravine
#

thanks hunter lol

safe herald
#

whats wrong with this code?

slate swan
cold sonnet
#

typo on_message decorator

safe herald
#

ohhh lmaooo

kindred epoch
safe herald
#

tysm yall

slate swan
#

indents

cold sonnet
#

and why is everything underlined

slate swan
cold sonnet
#

messege, authro

slate swan
kindred epoch
cold sonnet
#

and it's always the
We have logged in as, format method

slate swan
cold sonnet
#

respect f-sfrings already

#

oh everything turns red if you wwait outside of the function?

#

even
import os

safe herald
#

speaking offff

buoyant igloo
#

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

slate swan
#

replit ew

cold sonnet
kindred epoch
safe herald
slate swan
buoyant igloo
#

You should use bot

safe herald
cold sonnet
#

innit new

#

but trash

safe herald
buoyant igloo
#

bot = commands.Bot(command_prefix="pls ", help_command=None)

#

Try this

#

Switch things to like @bot.command()
Or

cold sonnet
#

unhappy subclassed helpcommand noises

slate swan
buoyant igloo
#

U donโ€™t need client

slate swan
#

also, the tutorial you are using seems very bad

safe herald
slate swan
buoyant igloo
#

Also use await ctx.send(โ€œwhateverโ€)

#

You are using outdated version

slate swan
slate swan
safe herald
cold sonnet
slate swan
#

sadcat freecodecamp should delete their tutorial already

buoyant igloo
#

Oh wait just read the code

slate swan
#
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?

cold sonnet
#

maybe edit the View after setting the disabled value to True

kindred epoch
#

^

kindred epoch
#

you have to edit it

slate swan
#

thisisfine imagine editing

cold sonnet
#

Ash, it's time for u to stop

slate swan
#

I really meant something else while it came out wrong

cold sonnet
slate swan
slate swan
kindred epoch
cold sonnet
slate swan
kindred epoch
cold sonnet
slate swan
#
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())
slate swan
slate swan
cold sonnet
slate swan
#

set the default value of user to None

#

a: Option(discord.Member, description="Set the user", required=True)

final iron
#

a will never be None

cold sonnet
#

it's complicated already

cold sonnet
#

anyways, gotta go

kindred epoch
slate swan
#
async def slap(self, ctx, a: discord.Member=None): '''do stuff''
slate swan
#

no?

#

nope

#

thats right cringe

buoyant igloo
#

You should try a input

kindred epoch
#

???

final iron
#

What

slate swan
#

@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.

buoyant igloo
#

????

slate swan
#

rip my skills

slate swan
#

I always forget about sum() peepocry

slate swan
kindred epoch
#

dud just use =None

slate swan
#

^

buoyant igloo
slate swan
slate swan
# kindred epoch dud just use `=None`

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?

buoyant igloo
#

Lemme gimme u example

slate swan
#

lol wtf
discord.commands.Option

kindred epoch
tacit token
#

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)
slate swan
kindred epoch
#

omg

slate swan
tacit token
#

how

slate swan
#

!e print([1,2,3,4,5][:2])

cold sonnet
unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

[1, 2]
slate swan
#

like this

#

are you using pycord?

cold sonnet
#

discord.ext??

tacit token
slate swan
#

why discord.command then?

buoyant igloo
#

from discord.ext import commands

slate swan
#

istg the inconsistency between the forks

slate swan
# tacit token

that was an example of list slicing, dont just copy paste it.

cold sonnet
#

nah, he got false information guys

next widget
#

Any professional game developers dm me please

slim ibex
slate swan
tacit token
#

TypeError: list indices must be integers or slices, not tuple

slate swan
#

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

tacit token
#

yes?

slate swan
#
async def slap(self, ctx, a: discord.Member=None):
  if a is None: 
    return await ctx.reply("Slapped the air for ya")
buoyant igloo
#

tf is discord.embeds

slate swan
#

!d discord.embeds.Embed bestthisiisfine

unkempt canyonBOT
#

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.
slate swan
#

embeds is a module inside discord folder.

#

Embed is a class inside it

slate swan
cold sonnet
#

oh he already had the if

slate swan
#

just had to add None as the default value anime_shrug

cold sonnet
#

you don't define an embed like
em = discord.embeds.Embed
do you

slate swan
#

album cover on spotify activity looks weird

#

idk if its just me

slate swan
#

kek jk jk

quick gust
unkempt canyonBOT
slate swan
unkempt canyonBOT
#

7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.

quick gust
#

:)

slate swan
cold sonnet
#

poor guy

stray carbon
kindred epoch
#

!resource

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

cold sonnet
kindred epoch
slate swan
#

thats nothing when you compare it to my imports

#

totally not cursed

cold sonnet
#

you control your lights with a discord bot?

boreal ravine
cold sonnet
#

you're the coolest person here

slate swan
#

!pypi hikari-lightbulb ๐Ÿƒโ€โ™‚๏ธ

unkempt canyonBOT
cold sonnet
#

nvm

kindred epoch
#

lmao

slate swan
cold sonnet
#

you're not cool

slate swan
#

"A simple to use"
what?

kindred epoch
#

meh got jokes

slate swan
unkempt canyonBOT
slate swan
#

when compared to this

slate swan
#

there are more command handlers but i dont like any other than these

tacit token
#

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)
unkempt canyonBOT
#

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.

tacit token
#

ok and if +1 server?

honest vessel
#

for x in servers[:5]:
y = 0

#

this does absolute nothing it just makes y = 0

unkempt canyonBOT
honest vessel
#

just send("text", embed=embed)

stiff nexus
#

how to attach a img url as attachment?

tacit token
honest vessel
#

?

stiff nexus
#

ya done

slate swan
#

!d discord.Member.color

unkempt canyonBOT
#

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").
slate swan
#

if you are using Context, Context.author.color

#

yep

spring flax
#

can anyone guide me on how to make a bot notify when a streamer goes live on, say, Youtube/twitch

slate swan
#

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 ?

kindred epoch
#

permissions of the author or the user that is mentioned?

slim ibex
#

why user or member?

stiff nexus
#
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????
slate swan
#

I remove the full line ? await bot.process_commands(message)

slim ibex
#

ok

final iron
#

Send the full traceback

cold sonnet
#

huuh

stiff nexus
cold sonnet
#

guess not