#discord-bots

1 messages Β· Page 175 of 1

steep wedge
#

i'm currently running it on a raspberry pi underneath my desk (with visual studio open on one of my monitors)

abstract owl
#

also i agree with zippy instead of him spoonfeeding yall he's giving u docs to actually learn βœ…

cloud dawn
#

I'd use a raspberri pi.

steep wedge
#

i'm not 'hosting' it as such right now

#

because it's not finished

abstract owl
#

okay

steep wedge
#

literally just running it on visual studio with the idle interpreter xd

crimson mauve
#

@steep wedge lol, it just hit me, you are thinking I'm telling him to figure it out, ain't you?

#

lol, I was asking if they got it after linking them the docs.

slate swan
steep wedge
#

ah lol

abstract owl
#

πŸ˜Άβ€πŸŒ«οΈ

onyx rapids
steep wedge
#

i didn't read the chat so

#

did you seriously only realise i thought that now, though

crimson mauve
#

Naw, I kinda agree with ray, some coders can be just total dicks like that.

slate swan
steep wedge
#

bear in mind i had no idea back then

crimson mauve
steep wedge
#

the server has 20 members

crimson mauve
cloud dawn
steep wedge
crimson mauve
cloud dawn
#

Obviously you won't "run" it like that.

steep wedge
steep wedge
cloud dawn
crimson mauve
cloud dawn
#

Stole my joke smh

crimson mauve
#

lol

steep wedge
onyx rapids
#

I dont need a host? I can just buy a pregnancy test? Time to get a gf ig

shrewd apex
#

ASgintokishock what's happening here

steep wedge
cloud dawn
#

You don't need a gf to buy one.

fading marlin
#

Time for a TIL pithink

cloud dawn
#

Lol

slate swan
# cloud dawn I assumed you meant pi models?

Yeah, but I'm not the 20-member server person :P
(For context I have a couple bots in-the-works, I'm using the aiosqlite library and both bots will probably be making frequent database queries. One is primarily a general-purpose, quality-of-life bot for a large server. The other is a game-bot.)

cloud dawn
#

I'm coding in c# rn I've got to compensate here for the boringness.

crimson mauve
steep wedge
#

am i the only one who mixes up syntax

#

i just wrote a whole function in lua

shrewd apex
#

never mixed inter language syntax

onyx rapids
cloud dawn
#

Just stop playing Roblox or FiveM.

shrewd apex
#

βœ…

steep wedge
#

i see it as- if i'm making enough money from it, why stop?

slate swan
cloud dawn
steep wedge
#

because it's easy

steep wedge
#

it requires practically no effort, and roblox luau is even easier

#

but the military community on roblox is unable to do jack shit themselves so they pay people like myself to do it for them

#

why would i complain

crimson mauve
#

or just robux?

steep wedge
cloud dawn
#

min wage differs per country.

steep wedge
#

UK

cloud dawn
#

Ouch

steep wedge
#

yeah i agree

steep wedge
cloud dawn
#

Depends on how much time you spend on it and if you enjoy it.

lofty cedar
#

I'm trying to make it so that when a user responds to my discord bot, it stores their message in a variable, any idea how I can do that?
Here's the code:

@client.event
async def on_message(message):
    if isinstance(message.channel, discord.DMChannel):
        global tempVar
        tempVar = message.content
        return tempVar
    await client.process_commands(message)

@client.event
async def on_member_join(member):
    embed = discord.Embed(title="Verification", description="Please type your in game name:", color=discord.Color.blue())
    await member.send(embed=embed)
    inGameName = on_message(message).message.content
    print(inGameName)
    await member.send(inGameName)
fading marlin
#

bot vars!

#

though where do you get message from in your member_join event pithink

crimson mauve
#
@client.event
async def on_message(message):
    if isinstance(message.channel, discord.DMChannel):
        global tempVar
        tempVar = message.content
        return tempVar
    await client.process_commands(message)

@client.event
async def on_member_join(member):
    embed = discord.Embed(title="Verification", description="Please type your in game name:", color=discord.Color.blue())
    await member.send(embed=embed)
    inGameName = on_message(message).message.content
    print(inGameName)
    Your_Message = await member.send(inGameName)```
lofty cedar
#

I've got no clue I asked my CS teacher and he gave me a solution but it didn't work

lofty cedar
fading marlin
#

what are you trying to do? like as a whole

steep wedge
lofty cedar
fading marlin
lofty cedar
crimson mauve
fading marlin
#

they already process commands

lofty cedar
#

I've got a whole bunch of commands already, just didn't send the whole file haha

abstract owl
#

yea

crimson mauve
#

Β―_(ツ)_/Β―

fading marlin
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.11)"). 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.11)") 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.11)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/latest/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
abstract owl
#

im playing with pandas for some reason

lofty cedar
fading marlin
#

the first example in the docs my work, though you would have to change the check a bit

lofty cedar
#

Is my issue maybe that it's checking as soon as the user has joined, but there's no message the second they've joined so there's nothing to print

onyx rapids
#

does anyone have a basic code that will make my bot respond? Like the total code

crimson mauve
#
    inGameName = on_message(message).message.content

You don't call this function, it's something that happens automatically, and even if you did try to call it you don't have a message from this function to send to the other one.

lofty cedar
#

So I need to do the wait for thing to wait for a response, then run it?

fading marlin
#

you send the message in their DMs, call wait_for, then do whatever you need with the message

lofty cedar
fading marlin
#

sure thing

craggy pulsar
#

Hey I'm currently coding a discord bot that will alert me in my channel every time a stock has a 13EMA cross over/cross under the 48EMA. Ive ran the code and there are zero problems but when the stock has a cross the bot doesn't alert in the channel or send anything. Any help?

onyx rapids
craggy pulsar
# crimson mauve No errors?

Correct when I ran it on VScode there are no problems and it runs fine. It just isn't sending alerts to the discord channel when the EMA's cross

fading marlin
#

I'm gonna need glasses lol

crimson mauve
crimson mauve
lofty cedar
#

I'm back again, it's now detecting the message and storing it but I can't get on_member_join to know what the message is

fading marlin
#

show code and elaborate pelase

lofty cedar
#
@client.event
async def on_message(message):
    if isinstance(message.channel, discord.DMChannel):
        global tempVar
        tempVar = message.content
        print(tempVar + "ON MSG")
        return tempVar
    await client.process_commands(message)

@client.event
async def on_member_join(member):
    embed = discord.Embed(title="Verification", description="Please type your in game name:", color=discord.Color.blue())
    await member.send(embed=embed)
    await client.wait_for('message', check=check)
    print(tempVar + "ON MJ")
    inGameName = on_message()
    print(inGameName)
    await member.send(inGameName)
fading marlin
#

you don't need the on_message

lofty cedar
#

I'm getting tempVar + "ON MSG" but not tempVar + "ON MJ"

fading marlin
#

and you need to define a check

lofty cedar
#

I don't need inGameName = on_message()?

fading marlin
#

you don't need to call on_message

crimson mauve
#

you don't call inGameName = on_message()

lofty cedar
#

what would I put there then

fading marlin
#

just delete it

crimson mauve
#

nothing

fading marlin
#

wait_for already returns the message

#

you have to define a check though

lofty cedar
#

alright, then will inGameName know what tempVar is?

#

or yk what I mean ( I think)

fading marlin
#

wait_for returns a message object if it finds one. You can use that to define your inGameName var

lofty cedar
#

For the check function what do I do?

def check(m):
    return m.content == 'hello' and m.channel == channel
#

Do I keep it at hello? There isn't meant to be a set reply

crimson mauve
#

and in the right channel

lofty cedar
#

What about if I need their response, not them to say a set thing?

fading marlin
#

you'll have to change it to check if the message is firstly inside a DM, and if the authors match

lofty cedar
#

so

def check(m):
    return m.content and m.channel == discord.DMChannel

It's also not in a lot of use so checking author has no point

crimson mauve
#

close

fading marlin
#

you should check author

lofty cedar
fading marlin
#

and m.content will realistically never return a falsey value (assuming you've got message content enabled)

lofty cedar
#
if isinstance(message.channel, discord.DMChannel):
    ...
fading marlin
#

yeah, but do that in your check

golden birch
#

o

lofty cedar
#

Yeah

#

I've already got that in on_message btw

#
@client.event
async def on_message(message):
    if isinstance(message.channel, discord.DMChannel):
        global tempVar
        tempVar = message.content
        print(tempVar + "ON MSG")
        return tempVar
    await client.process_commands(message)
golden birch
#

im a beginner to python im failing it in school

fading marlin
#

yup, but you're not going to use on_message because that's not its intended use case

lofty cedar
#

okay

#

so is it return if isinstance . . . ?

fading marlin
#

no if

crimson mauve
lofty cedar
#

okay

fading marlin
#

you still have to check if the authors match btw

lofty cedar
#

how haha

fading marlin
#

m.author == member?

lofty cedar
#

okay

#

where do I check it?

cloud dawn
#

I'm looking forward when the bot will reply to the user..

golden birch
fading marlin
lofty cedar
#

thought so just checking

crimson mauve
lofty cedar
#

I'm testing it and it's still doing just fine with the message in on_message but on_member_join still doesn't know what the message is. I've got this now:

@client.event
async def on_message(message):
    if isinstance(message.channel, discord.DMChannel):
        global tempVar
        tempVar = message.content
        print(tempVar + "ON MSG")
        return tempVar
    await client.process_commands(message)

@client.event
async def on_member_join(member):
    embed = discord.Embed(title="Verification", description="Please type your in game name:", color=discord.Color.blue())
    await member.send(embed=embed)
    def check(m):
        if m.author.id == member.id:
            return isinstance(message.channel, discord.DMChannel)
    inGameName = await client.wait_for('message', check=check)
    print(inGameName)
    await member.send(inGameName)
golden birch
crimson mauve
upbeat otter
golden birch
#

i js get confused copying the instructions

fading marlin
lofty cedar
golden birch
#

and i also get confused on the errors

#

when i make a error idk how to fix it

lofty cedar
upbeat otter
lofty cedar
#

I hate global just prayed it would work

upbeat otter
#

(nvm I won't confuse you, Mr. Lee will help)

crimson mauve
lofty cedar
#

and what's a bot variable

fading marlin
upbeat otter
fading marlin
upbeat otter
#

πŸ›

lofty cedar
#

So I got my brother to test it and I got this response
<Message id=1062087505698111558 channel=<DMChannel id=1061463231975133204 recipient=None> type=<MessageType.default: 0> author=<User id=424623683961749515 name='OutlawElite' discriminator='0642' bot=False> flags=<MessageFlags value=0>>
his message was 'bad' lol

fading marlin
#

wait_for will return a message object

#

if you need the contents of the message use Message.content

lofty cedar
#

that's what I was using in on_message

fading marlin
#

you don't need to handle it in on_message

lofty cedar
#

so is this right?

#
@client.event
async def on_member_join(member):
    embed = discord.Embed(title="Verification", description="Please type your in game name:", color=discord.Color.blue())
    await member.send(embed=embed)
    def check(message):
        if message.author.id == member.id:
            return isinstance(message.channel, discord.DMChannel)
    await client.wait_for('message', check=check)
    inGameName = message.content
    print(inGameName)
    await member.send(inGameName)
fading marlin
#

well you're just ignoring the output of wait_for

lofty cedar
#

the output for wait_for isn't the message content though

#

so it's not what I need

fading marlin
#

no, it's a message object, and messages have a content attribute

fading marlin
lofty cedar
#

when I printed it there's no content attribute

potent spear
lofty cedar
#

<Message id=1062087505698111558 channel=<DMChannel id=1061463231975133204 recipient=None> type=<MessageType.default: 0> author=<User id=424623683961749515 name='OutlawElite' discriminator='0642' bot=False> flags=<MessageFlags value=0>>

fading marlin
#

that's the repr of a Message object

potent spear
#

it's just not printed in the repr lol

#

don't rely on the repr of an object, check the docs instead

lofty cedar
#

the heck is a repr

potent spear
#

google will tell

upbeat otter
#

and yes, searching the web helps in its own way

lofty cedar
#

alr, so how do I get message.content?

upbeat otter
#

bro

potent spear
#

that's a no-brainer

#

content is an attribute of the message object

lofty cedar
#

Yeah

crimson mauve
upbeat otter
#

aaaahhh nvm pepe_exit

lofty cedar
orchid hound
#

That was a mistake

potent spear
#

get some rest, highly suggested then

shrewd apex
#

guys what do you think is the best of way keeping track between commands for example when one command is running another different command is blocked cause first command affects the result of the second command

crimson mauve
lofty cedar
#

It's only 7:30 I'm just dead from school and monday

upbeat otter
lofty cedar
#

I'm still confused where message.content goes lol, can it go on the end of the await client.wait_for line or smth?

fading marlin
#

!d discord.discord.ext.commands.on_command perhaps? and set a custom attribute to the first one preventing the second one from being run

unkempt canyonBOT
#

discord.ext.commands.on_command(ctx)```
An event that is called when a command is found and is about to be invoked.

This event is called regardless of whether the command itself succeeds via error or completes.
shrewd apex
#

before and after invokes

potent spear
fading marlin
#

oh that exists too, right

crimson mauve
upbeat otter
lofty cedar
potent spear
lofty cedar
fading marlin
crimson mauve
lofty cedar
#

and by coding for years I mean on and off every so often

#

yes ik I'm not great at it

potent spear
#

not to worry, we all started somewhere

lofty cedar
potent spear
#

that's.. honest...

crimson mauve
#

right?

lofty cedar
#

not the code

#

the one line I sent u xD

upbeat otter
crimson mauve
#

let's get you to understanding functions first then.

potent spear
lofty cedar
#

also guys I promise I'm at least slightly literate with python

upbeat otter
lofty cedar
fading marlin
potent spear
lofty cedar
#

That's what I was doing originally

#

but that didn't work so

upbeat otter
potent spear
fading marlin
#

surely the last one has a much higher percentage

lofty cedar
potent spear
#

yeah, but I'd have to rewrite my percentages then, and that's me being lazy (productive?)

potent spear
upbeat otter
#

ok I need sleep πŸ’€ just ignore that

potent spear
lofty cedar
potent spear
lofty cedar
#

But I still got no clue where to put the message.content

lofty cedar
upbeat otter
potent spear
upbeat otter
#

I'll give you an example πŸ˜”

potent spear
lofty cedar
#

RuntimeWarning: coroutine 'wait_for' was never awaited

#

yay :(

potent spear
#

error says it all

#

even googling that can give you solutions

lofty cedar
#

yeah

#

that what I'm doing rn

crimson mauve
#

Not going to lie, just reading the traceback is more than most people learn to do.

lofty cedar
#

So I take the def check(message) function out of the on_member_join function I think

lofty cedar
upbeat otter
#
wait_for_method_in_discord_py_returns_a_message_object_which_is_contained_in_this_variable_and_discord_Message_has_a_content_attribute = await the_bot_or_the_client_you_are_using_to_create_your_bot.wait_for("message", check = lambda: message_that_you_have_been_eager_to_get: message_that_you_have_been_eager_to_get.author == the_author_you_want_to_compare_to_and_hope_this_is_a_User_or_a_Member_object)

the_message_content_you_have_been_dying_for_since_long_is_now_contained_in_this_variable = wait_for_method_in_discord_py_returns_a_message_object_which_is_contained_in_this_variable_and_discord_Message_has_a_content_attribute.content

Here's an example to accessing the content of a Message object
hope it helps you out and can solve your issue

potent spear
#

that's enough for me for today

upbeat otter
potent spear
#

you know how much newcomers hate to read long texts, right?

#

it's like it doesn't exist to them

upbeat otter
#

,

potent spear
#

especially if it's coming from a bot

upbeat otter
#

discord bot*

rare echo
#

make me scratchy

potent spear
lofty cedar
upbeat otter
golden birch
potent spear
upbeat otter
crimson mauve
lofty cedar
#

yea but for as much code as I've done I should've figured that out

potent spear
#

for sure

golden birch
crimson mauve
golden birch
crimson mauve
lofty cedar
#

I'll have a look after this, so far only thing relating to my error is all french variables or smth so that's taking a bit

upbeat otter
#

french variables?

lofty cedar
#

yea the stack overflow thing I found, the variables are all french idk

#

I think ik the issue tho but maybe not

potent spear
#

mr worldwide copy over here

lofty cedar
#

YO GUYS IT WORKS

crimson mauve
#

I think I'm going to write a little command line number guesser, then walk new people though how it works and why.

lofty cedar
#

Thanks guys :)

crimson mauve
#

Good luck with the rest.

lofty cedar
#

Rest should just be repeating this for now, but ty

potent spear
#

wait until he finds out about edge cases πŸ‘€
like his bot restarting and the new member not verifying before the restart

lofty cedar
#

Don't make me cry

crimson mauve
#

Saying should always doubles the amount of time a job will take.

slate swan
#

People honestly copy and paste code they don't understand πŸ’€

crisp pier
#

hey, which category in this help area does selenium go into in this topical chat/help area?

crisp pier
upbeat otter
crimson mauve
upbeat otter
#

apparently
everybody did/does at some point

crimson mauve
#

Don't normally get complements, do you?

upbeat otter
#

I'm a guy
what do you even expect πŸ’€

crimson mauve
#

Well I'm sure you are a good guy.

upbeat otter
#

you have a bad hunch on that one

crimson mauve
#

I tried Β―_(ツ)_/Β―

upbeat otter
#

ill jidt go to sleeppl, gn

#

and thanks πŸ˜”

crimson mauve
#

Anytime

flat marsh
#

Hello everyone

crimson mauve
#

Sup Amon?

flat marsh
#

i want to call these 3 functions BUT when i do i get errors

#

how can i divide on_message function to a bunch of smaller ones

crimson mauve
flat marsh
crimson mauve
#

Just give the entire traceback

#

You are searching though a string somewhere, you need to use numbers to do that.

#

Line 29

flat marsh
crimson mauve
#

You are passing 'rand_num' as a string, not as a variable.

#

use just rand_num

flat marsh
#

hm ok

#

but i want to pass rand num

#

see?

flat marsh
#

respect

crimson mauve
#

I see what is going on

#

command['today']['rand_num']

in order to access the lower levels of the dictionary you need to tell it level by level what path to take.

#

So command is the dict, 'today' is the key you want to access to get to 'rand_num'

flat marsh
#

ooooooooooooooooooooooooooh

#

bruh i didnt see it

#

thx for opening my eyes

crimson mauve
#

It's always the little things that you get caught on.

#

Come on back when you get caught again.

flat marsh
flat marsh
crimson mauve
#

I spent 3 days because I was forgetting to put something in a list first, so ya, if people claim to not have that problem every so often, stop lying.

shut elk
#

Hi can someone tell me why all except one slash cmd of mine are disappearing after 6 hours

#

There’s no errors and it keeps happening

#

Buttons still work

shrewd apex
crimson mauve
shut elk
#

!paste

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.

shut elk
#

sorry was on mobile couldnt send it

#

create_verify_button is the one that only works after 6 hours (before 6 hours, everything works as intended)

inner wing
#

how get all the bot guilds?
using the api it self not libs

shut elk
sick birch
unkempt canyonBOT
shut elk
#

But can anyone tell me why create_verify_button is the only one that works and also the cause of the unknown interaction for the defer msg

shrewd apex
#

also srsly the whole code base needs a re haul

shut elk
terse orchid
shut elk
#

"u need custom id for each component time out as none" so i removed the custom id for every button view?

#

"also respond to each interaction between 3 seconds if not defer it after that u can edit it with edit_original_response"
So howo do I know if it responds between 3 seconds, do I use is_done or? Like idk what I would set the contition to respond send msg

shrewd apex
shrewd apex
shrewd apex
terse orchid
# shrewd apex yes

i'm getting
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
whenever i try

shrewd apex
shut elk
shrewd apex
shut elk
shut elk
shrewd apex
#

i was telling my observations cause currently the state of code is not too optimistic plus i am on mobile

shrewd apex
terse orchid
# shrewd apex logs
  Using cached discord-2.1.0.tar.gz (1.1 kB)
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-xwqHsE/discord/setup.py'"'"'; __file__='"'"'/tmp/pip-install-xwqHsE/discord/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-33YLzi
         cwd: /tmp/pip-install-xwqHsE/discord/
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-xwqHsE/discord/setup.py", line 5, in <module>
        with open(path.join(this_directory, 'README.md'), encoding='utf-8') as f:
    TypeError: 'encoding' is an invalid keyword argument for this function
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.```
shut elk
terse orchid
shut elk
#

am a lil confused what u mean by that

shrewd apex
#

with version 3.8 or greater

terse orchid
#

pip works for other packages as well

shrewd apex
#

!d discord.Interaction.edit_original_response

unkempt canyonBOT
#

await edit_original_response(*, content=..., embeds=..., embed=..., attachments=..., view=..., allowed_mentions=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the original interaction response message.

This is a lower level interface to [`InteractionMessage.edit()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionMessage.edit "discord.InteractionMessage.edit") in case you do not want to fetch the message and save an HTTP request.

This method is also the only way to edit the original message if the message sent was ephemeral.
shrewd apex
unkempt canyonBOT
shut elk
terse orchid
shrewd apex
#

after that u have to use the interaction instance

shrewd apex
#

are u able to like write commands?

shrewd apex
#

dosent reflect in code which causes those errors

shut elk
#

that is why I had response defer, then edit original response, then followup

sick birch
terse orchid
shut elk
#

but it gave error in defer so im guessing i haev to use respond msg

sick birch
shut elk
shrewd apex
crimson mauve
#

Ah damn, I can't put discord.ui.TextInput onto a post like you could a button can I?

shrewd apex
shrewd apex
crimson mauve
shrewd apex
#

what for tho? u wanted to add it in embed or something?

crimson mauve
#

Yup.

#

Something of a game thing

shrewd apex
#

just use a button send the modal

shut elk
shrewd apex
young dagger
#

Do you guys know why I can't run my bot?

Traceback (most recent call last):
  File "blitz.py", line 11, in <module>
    from discord.ui import Button, View
ModuleNotFoundError: No module named 'discord.ui'

Requirement already satisfied: discord-ui in /usr/local/lib/python3.7/dist-packages (5.1.6)```
shrewd apex
shrewd apex
#

u need python 3.8+

young dagger
crimson mauve
fading marlin
#

The GCC 8.3.0 isn't the Python version btw

shrewd apex
young dagger
shrewd apex
#

u can dosent affect the root cause

#

ur python version and dpy lib version

#

thats the problem

fading marlin
#

You need to have discord.py 2.0+ to use components. And to have discord.py 2.0+, you also need Python 3.8+

crimson mauve
manic knoll
#

it says this

crimson mauve
manic knoll
#

i created a embed but it says that

young dagger
manic knoll
#

my command prefix is β€œ/β€œ

shrewd apex
crimson mauve
shrewd apex
manic knoll
#

heres my code

shrewd apex
#

we have tried to explain multiple times

young dagger
#

python3 is already the newest version (3.7.3-1).

#

Hmh

fading marlin
#

That's not the latest nor newest version

shrewd apex
shrewd apex
manic knoll
#

import discord
from discord.ext import commands

class MyCog(commands.Cog):
def init(self, client):
self.client = client
@commands.Cog.listener()
async def on_ready(self):
print("Mycog.py is online")

@commands.command()
async def embed(self, ctx):
    embed_message = discord.Embed(title="Axd is the move", description="Axd is gay", color=discord.Color.blue())

    embed_message.set_thumbnail(url=ctx.guild.icon)
    embed_message.set_image(url=ctx.guild.icon)
    embed_message.set_author(name=f"requested by (ctx.author.mention", icon_url="https://media.discordapp.net/attachments/1061002034364547074/1062094710224736288/IMG_3440.jpg?width=468&height=468")
    embed_message.add_field(name="field name", value="field value", inline=False)
    embed_message.set_footer(text="this is the footer", icon_url=ctx.author.avatar)

    await ctx.send(embed = embed_message)

async def setup(client):
await client.add_cog(MyCog(client))

shrewd apex
#

maybe higher idk

manic knoll
#

let me make it better for u to read

young dagger
manic knoll
#
from discord.ext import commands

class MyCog(commands.Cog):
    def __init__(self, client):
        self.client = client
        @commands.Cog.listener()
        async def on_ready(self):
                print("Mycog.py is online")

    @commands.command()
    async def embed(self, ctx):
        embed_message = discord.Embed(title="Axd is the move", description="Axd is gay", color=discord.Color.blue())

        embed_message.set_thumbnail(url=ctx.guild.icon)
        embed_message.set_image(url=ctx.guild.icon)
        embed_message.set_author(name=f"requested by (ctx.author.mention", icon_url="https://media.discordapp.net/attachments/1061002034364547074/1062094710224736288/IMG_3440.jpg?width=468&height=468")
        embed_message.add_field(name="field name", value="field value", inline=False)
        embed_message.set_footer(text="this is the footer", icon_url=ctx.author.avatar)
    
        await ctx.send(embed = embed_message)

async def setup(client):
    await client.add_cog(MyCog(client))```
#

thats my command code heres the prfix one

shrewd apex
#

follow the steps online

manic knoll
#
from discord.ext import commands

client = commands.Bot(command_prefix="=", intents=discord.Intents.all())

@client.event
async def on_ready():
    print("Success: Bot is succesfully loaded.")

@client.command()
async def ping(ctx):
    await ctx.author.send("Pong!")```
crimson mauve
fading marlin
#

You're not loading the extension

manic knoll
#

wym

shrewd apex
#

ubuntu official release is not out so u will have to get from a mirror repo ppa:deadsnakes iirc

crimson mauve
# manic knoll wym
import discord 
from discord.ext import commands

class MyCog(commands.Cog):
    def __init__(self, client):
        self.client = client
        @commands.Cog.listener()
        async def on_ready(self):
                print("Mycog.py is online")

    @commands.command()
    async def embed(self, ctx):
        embed_message = discord.Embed(title="Axd is the move", description="Axd is gay", color=discord.Color.blue())

        embed_message.set_thumbnail(url=ctx.guild.icon)
        embed_message.set_image(url=ctx.guild.icon)
        embed_message.set_author(name=f"requested by (ctx.author.mention", icon_url="https://media.discordapp.net/attachments/1061002034364547074/1062094710224736288/IMG_3440.jpg?width=468&height=468")
        embed_message.add_field(name="field name", value="field value", inline=False)
        embed_message.set_footer(text="this is the footer", icon_url=ctx.author.avatar)
    
        await ctx.send(embed = embed_message)

async def setup(client):
    await client.add_cog(MyCog(client))```
fading marlin
#

!d discord.ext.commands.Bot.load_extension you're not calling this

unkempt canyonBOT
#

await load_extension(name, *, package=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Loads an extension.

An extension is a python module that contains commands, cogs, or listeners.

An extension must have a global function, `setup` defined as the entry point on what to do when the extension is loaded. This entry point must have a single argument, the `bot`.

Changed in version 2.0: This method is now a [coroutine](https://docs.python.org/3/glossary.html#term-coroutine "(in Python v3.11)").
crimson mauve
#

```py
import discord
from discord.ext import commands

class MyCog(commands.Cog):
def init(self, client):
self.client = client
@commands.Cog.listener()
async def on_ready(self):
print("Mycog.py is online")

@commands.command()
async def embed(self, ctx):
    embed_message = discord.Embed(title="Axd is the move", description="Axd is gay", color=discord.Color.blue())

    embed_message.set_thumbnail(url=ctx.guild.icon)
    embed_message.set_image(url=ctx.guild.icon)
    embed_message.set_author(name=f"requested by (ctx.author.mention", icon_url="https://media.discordapp.net/attachments/1061002034364547074/1062094710224736288/IMG_3440.jpg?width=468&height=468")
    embed_message.add_field(name="field name", value="field value", inline=False)
    embed_message.set_footer(text="this is the footer", icon_url=ctx.author.avatar)

    await ctx.send(embed = embed_message)

async def setup(client):
await client.add_cog(MyCog(client))
```

young dagger
shrewd apex
#

u need to call it async

shrewd apex
unkempt canyonBOT
crimson mauve
manic knoll
shrewd apex
fading marlin
fading marlin
manic knoll
#

ok

crimson mauve
manic knoll
#

so can you help me call it im very very new to this

shrewd apex
#

its just name of the library tho 02Cry

crimson mauve
manic knoll
#

thank you zippy

#

goated

primal token
fading marlin
crimson mauve
# manic knoll goated

Ok, I don't expect you to understand this, but I will try and explain what it does

    if sys.platform == "win32" or sys.platform == "win64":
        for file in os.listdir(f"{FilePath}\\Cogs"):
            if file.endswith("Cog.py"):
                await Bot.load_extension(f'Cogs.{file[:-3]}')
                print(f"{file} Loaded")```
#

try being the key word

shrewd apex
#

pathlib best

fading marlin
#

Then we've got ourselves a problem

crimson mauve
#

Nevermind, starting smaller.

crimson mauve
# manic knoll no

def Function(X):
  X+=1
  return X

Y=4
NewNumber = Function(Y)
print(NewNumber)

Understand any of this?

manic knoll
#

if i say no will you get mad 😭

crimson mauve
#

Not at all, it's best if we are both on the same page

primal token
#

you also forgot 1 more line after the function definition😑

crimson mauve
manic knoll
#

ok lets get on the samepage

primal token
fast musk
#

automatic cog loaders, unless you specifically need a drop-in hot reload functionality, are a waste of brain power

#

Just put the names in a tuple and be done with it

manic knoll
shrewd apex
#
import pathlib

async def setup_hook():
    for file in pathlib.Path("Cogs").glob('*.py')
        if file.name.startswith('_'):
            continue
        await client.load_extension(f"Cogs.{file.name.split('.')[0]}")

client.setup_hook = setup_hook
shut elk
crimson mauve
shrewd apex
primal token
#

skill issue

shrewd apex
crimson mauve
shrewd apex
#

get my immunity level higher

primal token
#

He's right, if you see this whole server they like proving others wrong and love doing it

shrewd apex
fast musk
#

Everyone who drivers slower than me is an idiot, and anyone that drives faster than me is a menace

crimson mauve
primal token
shrewd apex
primal token
#

Dont start with tachyon particles though or elseπŸ”«

fast musk
#

code fixes are boring. I like talking about solving problems in abstract. Otherwise 90% of the code posted is something that is easily solved by reading the documentation

primal token
crimson mauve
#

Ya, the past can't handle those.

shrewd apex
primal token
crimson mauve
shrewd apex
#

everyone saw the talk

primal token
manic knoll
#

ok so i have all the stuff done i just dont understand this error like what did i do wrong

crimson mauve
shrewd apex
#

just like life sad

manic knoll
#

@crimson mauve

young dagger
#

Okay I'm installing python 3.9 since it's the stable version, 3.10 and 3.11 is still under bugfix, right?

shrewd apex
#

indents go brrr

primal token
shrewd apex
shrewd apex
crimson mauve
# manic knoll

Sorry, the peanut gallery has killed my teaching mood. Might ask one of them to step up and help you if they have the gumption to.

manic knoll
#

alright

primal token
#

Anya is the type of person to go to a peanut gallery

manic knoll
#

can someone help with this

shrewd apex
#

my teaching mood up there high with anya

primal token
#

Go to sleep

shrewd apex
#

3:45 am crazygamer

#

4 I'll go promise

shrewd apex
primal token
shrewd apex
young dagger
#

@shrewd apex I installed it but its still saying I have the old version. Do I have both versions now or what?

python3
Python 3.7.3 (default, Oct 31 2022, 14:04:00)
[GCC 8.3.0] on linux

python3.11 --version
Python 3.11.0```
primal token
#

After you help certified of course

shrewd apex
#

gn

#

bro

#

ur task handed over to u salute

primal token
#

no takesies backsies

crimson mauve
#

I should have put a bet on that.

crimson mauve
manic knoll
#

yep

crimson mauve
#

That site will walk you though the basics.

manic knoll
#

ok so what in that site should i click to help me remove the error

crimson mauve
#

This ain't like that

#

This site is to teach you python so you don't need to ask that question.

fast musk
#

I don't see your full code Certified, so its hard to say, but the indent on the listener is very out of place and means there could be more of an issue. The actual command overall looks fine

#

makes me wonder if the cog is even loaded

crimson mauve
fast musk
#

ah

slate swan
#

hey how could I fix this?

crimson mauve
slate swan
crimson mauve
#

no it's not

thin trout
#
@bot.command()
async def verify(ctx):

    sender = ctx.author
    image = ImageCaptcha(width=280, height=90)
    captcha_text = random.randint(100000, 999999)
    data = image.generate(captcha_text)
    role_has = discord.utils.get(ctx.guild.roles, name='User')

    if role_has in ctx.author.roles:
        await ctx.respond('You are verified!', ephemeral=True)
    else:
        await ctx.respond('Check your DMs!', ephemeral=True)
        image.write(captcha_text, 'captcha/CAPTCHA.PNG')
        await sender.send('Write what the captcha has!', file=discord.File('captcha/CAPTCHA.PNG'))
        print(captcha_text)
        
        while True:
            msg = await bot.wait_for("message", check=lambda check: check.author.id == ctx.author.id)
            if msg.guild == None:
                break

        print(msg.content)
        if msg.content == captcha_text:
            await sender.send('Correct, you should be verified!')
            role = discord.utils.get(ctx.guild.roles, name='User')
            await sender.add_roles(role)
        else:
            await sender.send('Incorrect, try again!')```
can't find the problem
slate swan
#

@crimson mauve

crimson mauve
# slate swan

Discord.py and nextcord are fighting, you can only use one or the other.

slate swan
#

Oh

thin trout
#

no error in console

#

i don't have and error logger

slate swan
crimson mauve
slate swan
#

Hey zippy still having the same problem

#

@\

crimson mauve
slate swan
#

Yep

#
@commands.Cog.listener()
    async def on_member_join(self, ctx, member: nextcord.Member):

        embed = nextcord.Embed(
            title= f"Welcome {member}",
            description=f"""> Welcome to Eagle Bird LLC
    > A quick tour around the server!
    [#1059268832956518415](/guild/267624335836053506/channel/1059268832956518415/)
    > 》 Make sure you obey those rules in order to avoid any consequences.
    [#1059268832956518416](/guild/267624335836053506/channel/1059268832956518416/)
    > 》 Stay tuned for news & updates!
    [#1059268833124298824](/guild/267624335836053506/channel/1059268833124298824/)
    > 》 Chat and engange with the community.
    [#1059268833124298828](/guild/267624335836053506/channel/1059268833124298828/)
    > 》 Take your enjoyment to the max by using our bots!
    """,
        colour = (nextcord.Color.green()))
        
        channel = ctx.bot.get_channel(1059268833124298822)
        
        embed.add_field(name="Created at:", value=datetime.strftime(member.created_at, "%A, %B, %D-, %Y"))
        embed.set_thumbnail(url=member.avatar)
        
        await member.add_roles(Member_role)
        
        await channel.send(embed=embed)
        
        Member_role = nextcord.utils.get(ctx.guild.roles, name="Members")
        
        await member.add_roles(Member_role)
        ```
crimson mauve
#

codeblock
#

Thank you

#

You uninstalled nextcord right?

slate swan
crimson mauve
#

Oh, good luck then, I don't know anything about nextcord.

slate swan
#

@crimson mauve

thin trout
slate swan
#

ΒΏDΓ³nde aparece la impresiΓ³n?

#

@thin trout

crimson mauve
thin trout
#

can't speak spanish either πŸ˜‚

calm plume
#

Does anyone know how to help with the Eof while parsing error?

crimson mauve
thin trout
#

yes

#

it print in player dms when they try to verify

crimson mauve
#

oh, you don't know what print() is, do you?

thin trout
#

i don't know nothing abount python and bots

#

just trying to learn

manic knoll
#

sigh

young dagger
manic knoll
#

i just cant figure out anything

crimson mauve
thin trout
manic knoll
#

ERROR discord.ext.commands.bot Ignoring exception in command None
discord.ext.commands.errors.CommandNotFound: Command "embed" is not found

#

there is where i am

crimson mauve
manic knoll
#

like bro how am i not done with that

thin trout
manic knoll
#

i have a command and everything

#

@commands.command()
async def embed(self, ctx):
embed_message = discord.Embed(title="Axd is the move", description="Axd is gay", color=discord.Color.blue())

    embed_message.set_thumbnail(url=ctx.guild.icon)
    embed_message.set_image(url=ctx.guild.icon)
    embed_message.set_author(name=f"requested by (ctx.author.mention", icon_url="https://media.discordapp.net/attachments/1061002034364547074/1062094710224736288/IMG_3440.jpg?width=468&height=468")
    embed_message.add_field(name="field name", value="field value", inline=False)
    embed_message.set_footer(text="this is the footer", icon_url=ctx.author.avatar)

    await ctx.send(embed = embed_message)
crimson mauve
manic knoll
#

nope

crimson mauve
#

I tried giving you what you need, we are not going to write your code for you, this place is here to get you to the point you can write it yourself. Β―_(ツ)_/Β―

crimson mauve
primal token
#

Just use RealPython which has more information and is more explicit

crimson mauve
#

I'm getting the feeling they don't want to learn, they want to already know.

young dagger
#

Did they removed _ctypes?

#

in the new python version

crimson mauve
young dagger
# crimson mauve https://docs.python.org/3/library/ctypes.html
Traceback (most recent call last):
  File "/root/blitz.py", line 1, in <module>
    import discord
  File "/usr/local/lib/python3.11/site-packages/discord/__init__.py", line 23, in <module>
    from .client import *
  File "/usr/local/lib/python3.11/site-packages/discord/client.py", line 49, in <module>
    from .user import User, ClientUser
  File "/usr/local/lib/python3.11/site-packages/discord/user.py", line 29, in <module>
    import discord.abc
  File "/usr/local/lib/python3.11/site-packages/discord/abc.py", line 59, in <module>
    from .voice_client import VoiceClient, VoiceProtocol
  File "/usr/local/lib/python3.11/site-packages/discord/voice_client.py", line 49, in <module>
    from . import opus, utils
  File "/usr/local/lib/python3.11/site-packages/discord/opus.py", line 30, in <module>
    import ctypes
  File "/usr/local/lib/python3.11/ctypes/__init__.py", line 8, in <module>
    from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'```
young dagger
crimson mauve
young dagger
#

I don't know. But do you know why my bot won't running?

crimson mauve
#

There is nothing in basic python called _ctypes

#

Look at what you are typing, now look at the example in the link I sent you.

primal token
unkempt canyonBOT
#

@primal token :warning: Your 3.11 eval job has completed with return code 0.

[No output]
crimson mauve
#

Also, what are you doing with ctypes anyway? Why do you need access to dll files on windows?

young dagger
crimson mauve
young dagger
primal token
#

Its used by dpy internally, as shown in the error its being raised internally

unkempt canyonBOT
#

discord/opus.py line 30

import ctypes```
primal token
#

Beerhunter are you on linux?

young dagger
crimson mauve
primal token
primal token
crimson mauve
#

Good eye, here I was thinking they downloaded a script that was going to mess with them

primal token
#

Never actually encountered it since i haven't used ubuntu

young dagger
primal token
#

When updating python to a version of 3.7.0 >, yes

young dagger
#

Thanks noid

primal token
#

πŸ‘

crimson mauve
#

7 months.

winged coral
#

Dodging is OP, balance changes requested

#

Well I feel like being able to dodge an attack and simultaneously hit for 5 is quite a lot

clear elm
#

how do i make it so like i do !add (value) and then it adds the amount of (value) to a different embed

#

idk if that makes sense

#

so like

!add 7 (user)

!view (user)

(in the embed it says user has 7)

and then if u do it again it adds the 2 numbers

#

.

spiral crypt
#
@client.command()
async def level(ctx):
    member = ctx.author
    xp = levels_data[str(member.id)]['xp']
    level = levels_data[str(member.id)]['level']
    await ctx.send(f'{member.mention} is level {level} with {xp} XP')
    print("Done")

question, when i run !level it doesnt do anything, it doesnt even print done in the console, any ideas why this wont work?

naive briar
#

Do you have an error handler or logging

#

You should get an error 🀷

spiral crypt
#

doesnt do anything at all, its like it doesnt even see the command

sick birch
ionic garden
#

not sure if yall need more context but-
why is this command showing up twice

slate swan
ionic garden
#

so how do i fix this?

clear elm
#

how do i make it so like i do !add (value) and then it adds the amount of (value) to a different embed

so like

!add 7 (user)

!view (user)

(in the embed it says user has 7)

and then if u do it again it adds the 2 numbers

hushed galleon
# ionic garden so how do i fix this?

make sure you dont have a guild command of the same name or used tree.copy_global_to() on that guild, then use tree.sync(guild=...) to delete the duplicated command

ionic garden
hushed galleon
hushed galleon
#

or at least have a way for your command to sync a guild without using that method

ionic garden
#

ffff

clear elm
# hushed galleon well you have two options for storing the number for each user: 1. put it in mem...

i have this code


@client.command()
async def viewlogs(ctx, member: discord.Member  = None):
    if member == None:
        member = ctx.author
    embed=discord.Embed(title=f'{member} Logging', description="_ _", color=0xBB1A24)
    embed.add_field(name="Total Shifts", value="N/A", inline=False)
    embed.add_field(name="Total Sessions", value="N/A", inline=False)
    embed.add_field(name="Weekly Logs", value="N/A", inline=False)
    embed.set_author(name = f'{member}', icon_url = member.avatar_url)
    await ctx.send(embed=embed) 

@client.command()
async def addshift(ctx, member: discord.Member  = None):
    if member == None:
        member = ctx.author
    await ctx.send(f"Added 1 shift to {member}") 

@client.command()
async def addsession(ctx, member: discord.Member  = None):
    if member == None:
        member = ctx.author
    await ctx.send(f"Added 1 session to {member}") ```

this is what i have, i have no clue how to do it. i was wondering if u could possibly help me and tell me what to put in the value area if possible?
hushed galleon
#

you need to decide how you want to store your data

#

if you want to start simple, use a python dictionary and see how you can make your commands update the values in your addshift/addsession commands and how to retrieve them in your viewlogs command

clear elm
#

do u have one?

hushed galleon
#

dictionaries are a very helpful data structure and its worth reading about them
https://realpython.com/python-dicts/
but they are simply a way to associate values to different things

thin trout
#

is there a way to make a function that always sends a message after the last message in chat?
Example:

Bot message: type !support for help
User message: !support
Bot message: type !support for help

and the first bot message get deleted

hushed galleon
#

tbh i'd just use a dictionary for that too

#

store the last support message for each channel, and delete it whenever the !support command is used

outer violet
#

you can add mentions in the title of embeds right? or is it only description

hushed galleon
#

only description and field value

clear elm
outer violet
naive briar
#

Title

hushed galleon
#

bruh no way it works for title and field name on mobile

naive briar
#

Try it with a webhook 🀷

primal token
hushed galleon
# clear elm do u think u can like give me an example code or something

consider how a dictionary can be used to track the number of donuts for different people: ```py
person_donuts = {"Luke": 4, "Andy": 7}

Add a donut for Luke:

person_donuts["Luke"] += 1

^^^^^^ ^ this is the "value"

\ this is the "key"

Add a new person, Rea, with 9 donuts

person_donuts["Rea"] = 9

Print the number of donuts for Andy:

donuts = person_donuts["Andy"]
print(donuts)

7

print(person_donuts)

{'Luke': 5, 'Andy': 7, 'Rea': 9}``` do you see how dictionaries work? and how it applies to the shift/session counter you're trying to write? instead of arbitrary people, you'd use the "member" of your command as the key, and an integer count as the value

outer violet
naive briar
#

🀷

#

I'm in alpha version, maybe that's why

slate swan
#

πŸ—Ώ title mentions hmm

outer violet
#

i forgot if it did or not

slate swan
#

works on phone

#

but not on desktop

#

@outer violet ^^^

fading marlin
#

aw man

slate swan
#

discord do be weird with designs πŸšΆβ€β™‚οΈ

outer violet
#

sadge

fading marlin
#

on_error should be a coroutine πŸ€”

crimson mauve
#

Modals are supposed to close on their own after hitting summit, right?

slate swan
thin trout
#

someone know how i can install discord components?

slate swan
#

:looli: the code is tested ofc

fading marlin
slate swan
#

!d discord.ui.View

unkempt canyonBOT
#

class discord.ui.View(*, timeout=180.0)```
Represents a UI view.

This object must be inherited to create a UI within Discord.

New in version 2.0.
fading marlin
#

thought you'd block too

crimson mauve
fading marlin
#

actually

slate swan
fading marlin
#

they close if they've got a successful interaction response, otherwise they error

fading marlin
#

this server has some... unique custom emojis

crimson mauve
#

That's the funny thing, everything under async def on_submit(self, interaction): is working just fine, the window just won't close on its own.

fading marlin
#

sounds like a Discord issue to me ducky_australia

slate swan
#

it wont close if you don't respond to the interaction properly

#

i.e. your callback is faulty

naive briar
thin trout
naive briar
#

What version is it

#

!d discord.ui.Select

unkempt canyonBOT
#

class discord.ui.Select(*, custom_id=..., placeholder=None, min_values=1, max_values=1, options=..., disabled=False, row=None)```
Represents a UI select menu with a list of custom options. This is represented to the user as a dropdown menu.

New in version 2.0.
thin trout
slate swan
#

Select is a read only class, while ui.Select ( which subclasses Select ) is the constructor

thin trout
#

oh ok

crimson mauve
real badger
#

What is a challenging command to create?

thin trout
naive briar
#

Then how would people help you if you don't even know what's wrong

#

Also why's your ticket command in on_ready listener

thin trout
#

its a cog

thin trout
naive briar
#

You need to respond to the interaction in the modal callback

crimson mauve
#

lol, knew it was going to be somthing dumb

naive briar
#

I just said it closes after you respond to it

crimson mauve
#

thanks, I'll go find out how to do a modal callback then.

#

It was interaction.response.defer() for the record.

real badger
#

how do I create something that constantly checks for messages between two users when they execute a command (tic tac toe)

fading marlin
#

I would suggest the use of buttons instead

#

They provide a better UX

slate swan
#

what is wrong

fading marlin
#

it's client.command**(), not client.commands**

slate swan
#

oh tysm

crimson mauve
manic knoll
#

could anyone help with this

#

you have to be a specific role to ping someone

#

a / command

upbeat otter
upbeat otter
upbeat otter
charred badge
#

Hello, I hope this is the right channel for this. I was wondering if there is anyone that can help me work through an issue I’m having with my discord bot code. We can do it in dm or in here, whatever is the most comfortable.

sick birch
ionic garden
charred badge
# sick birch Hello! We prefer to keep things in-server. Go ahead and ask your question

sounds good, tyvm for your time first of all.
so there isn't an error that pops up, so given my lack of experience, it kinda leaves me without much to go on. what i'm going for is a to pull a random monster from a list (the list is a bit extensive but i don't think that should effect anything) with a command and eventually after that i would like to make it pull a response from 2 different lists, but first got to get it to work. my issue comes from when i do the command nothing pops up in discord. below is the code:

import discord
import random
from discord.ext import commands

#intents for the new update for discord devs.
intents = discord.Intents.default()
intents.message_content = True

#command to talk to the bot
bot = commands.Bot(command_prefix='!', intents=intents)

@bot.event
async def on_message(message):
if message.content == "Hi".lower():
await message.channel.send("Hey, good to see ya!")

@bot.command()
async def rando(ctx):
monster = ['m1',
'm2',
'm3',
'm4',
'm5']

   await ctx.send(f'here is your target{random.choice(monster)}')
sick birch
charred badge
#

oh, ok sorry for the confusion, the issue comes to the command one

sick birch
#

Yes, but your @bot.event stops all other commands from running

charred badge
manic knoll
#

could anyone help me code something like this? okay so this is basically something where i select a user to ping and i will have a embed that says β€œYou have been offered by (author)” but i have to have a certain role to do this

charred badge
sick birch
#

I take it it worked? πŸ˜„

charred badge
#

absolutely!

sick birch
#

Awesome, glad to hear

charred badge
#

thank you so much!

sick birch
#

No worries. Have fun!

manic knoll
slate swan
#

a moment

slate swan
manic knoll
slate swan
ionic garden
#

for a slash command, i want the user to pass in a enum- basically, a str that can only take a set range of values (like apple and banana only)
is this possible? if so, how would i go about doing it?

pulsar kettle
#

I would like to code a command where a member enters a hexadecimal (e.g. FFFFFF) and the bot replies with an embed that contains just that colour. How can I go about doing this?

@bot.tree.command(name='color', description='Displays a color using a hexadecimal')
async def color(interaction: discord.Interaction, color: str):
    embed = discord.Embed(title=(f'{color} is displayed as:'), color=0xf6ff00)
    embed.set_image(url=color)
    await interaction.response.send_message(embed=embed)```
slate swan
#

but you can use an enum too

unkempt canyonBOT
#
NEGATORY.

No documentation found for the requested symbol.

slate swan
#

ooof

#

!d discord.Colour.from_str

unkempt canyonBOT
#

classmethod from_str(value)```
Constructs a [`Colour`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Colour "discord.Colour") from a string.

The following formats are accepted...
slate swan
naive briar
#

W

slate swan
#

you basically pass the user input in this classmethod to get the color for that value

slate swan
ionic garden
naive briar
ionic garden
#

oh lol, thx

slate swan
manic knoll
slate swan
#

no

#

that;s for prefix commands

manic knoll
#

ok

#

ohhh

#

ok so what im stuck on is coding the whole command

#

@slate swan

spiral crypt
spiral crypt
sick birch
#

Yeah

spiral crypt
#

pog thankies ill test it out in a bit

slate swan
manic knoll
pulsar kettle
#

How do I set the embed thumbnail to be just the colour the user provides? (e.g. if they provide ffffff the thumbnail is just pure white)

@bot.tree.command(name='color', description='Displays a colour from a hexidecimal')
async def color(interaction: discord.Interaction, color: str):
    int_color = int(color,16)
    RGB = tuple(int(color[i:i+2], 16) for i in (0, 2, 4))
    embed = discord.Embed(color = int_color)
    embed.set_thumbnail()
    embed.add_field(name='Hexadecimal', value = f'#{color}')
    embed.add_field(name='RGB', value = f'{RGB}', inline=False)
    await interaction.response.send_message(embed=embed)```
slate swan
#

you'll have to use some api or something for that

#

or pillow to create an image with your color

pulsar kettle
#

Any guides I can follow for that?

slate swan
#

if you create a request to this url, you'll find an image field

#

which has the url for an white image

#

you can do it that way

slate swan
sick birch
#

Oh I misread the question

pulsar kettle
slate swan
#

if Embed is your discord.Embed class, yes

pulsar kettle
#

I have this:

@bot.tree.command(name='color', description='Displays a colour from a hexidecimal')
async def color(interaction: discord.Interaction, color: str):
    int_color = int(color,16)
    RGB = tuple(int(color[i:i+2], 16) for i in (0, 2, 4))
    embed = discord.Embed(color = int_color)
    embed.set_thumbnail(url=f'https://singlecolorimage.com/get/{color}/100x100')
    embed.add_field(name='Hexadecimal', value = f'#{color}')
    embed.add_field(name='RGB', value = f'{RGB}', inline=False)
    await interaction.response.send_message(embed=embed)```
slate swan
#

yes it will work

pulsar kettle
#

Doesn't send thumbnail

slate swan
#

also as robin said, improvement can be made in your code! ```py
async def color(interaction: discord.Interaction, color: discord.Color):
hex_of_color = str(color)
rgb_of_color = (color.r, color.g, color.b)

slate swan
slate swan
pulsar kettle
#

Only works with white? wha

@bot.tree.command(name='color', description='Displays a colour from a hexidecimal')
async def color(interaction: discord.Interaction, color: str):
    int_color = int(color,16)
    color = color.lower()
    RGB = tuple(int(color[i:i+2], 16) for i in (0, 2, 4))
    embed = discord.Embed(color = int_color)
    embed.set_thumbnail(url=f'https://singlecolorimage.com/get/{color}/100x100')
    embed.add_field(name='Hexadecimal', value = f'#{color}')
    embed.add_field(name='RGB', value = f'{RGB}', inline=False)
    await interaction.response.send_message(embed=embed)```
slate swan
#

color.lower() ...

#

hm weird it doesnt work with lower either

slate swan
#

web request with aiohttp i.e.

desert heart
#

It works fine in the browser.

slate swan
#

yeah but not on discord

#

discord doesnt proxy it

desert heart
#

You can use pillow to create your own thumbnail then

slate swan
#

the io is not worth it when it can be done with a simple aiohttp request

#

a simple get req

desert heart
#

I disagree. The image is generated quickly, and using an API request introduces a dependency on a third party service which comes with its own set of problems

pulsar kettle
slate swan
slate swan
pulsar kettle
#
@bot.tree.command(name='color', description='Displays a colour from a hexidecimal')
async def color(interaction: discord.Interaction, color: str):
    async with aiohttp.ClientSession() as session:
        data = await session.get(f'https://singlecolorimage.com/get/{color}/400x400')
   
    await interaction.response.send_message(hk.Embed(title='color').set_thumbnail(hk.Bytes(data.content,'color.png')))```
slate swan
#

it wont work that way for you, i used a diff library

#

but yeah you;re close

pulsar kettle
#

Oh, right

slate swan
#

1 minute, ill have to see how discord.py takes bytes

#

!d discord.File

#

!local-file

#
import io

file = discord.File(io.BytesIO(data.content), filename="color.png")
embed.set_image(url="attachment://color.png")
await interaction.response.send_message(embed=embed, file=file)
#

@pulsar kettle this should do

pulsar kettle
#

file = discord.File(io.BytesIO(data.content), filename="color.png") the data in data.content "is not defined Pylance

#

Whole code:

@bot.tree.command(name='color', description='Displays a colour from a hexidecimal')
async def color(interaction: discord.Interaction, color: str):
    int_color = int(color,16)
    RGB = tuple(int(color[i:i+2], 16) for i in (0, 2, 4))
    file = discord.File(io.BytesIO(data.content), filename="color.png")

    embed = discord.Embed(color = int_color)
    embed.add_field(name='Hexadecimal', value = f'#{color}')
    embed.add_field(name='RGB', value = f'{RGB}', inline=False)
    embed.set_thumbnail(url="attachment://color.png")
    await interaction.response.send_message(embed=embed, file=file)  ```
slate swan
#

you still need that py async with aiohttp.... lines

#

just the way you send interaction changes

pulsar kettle
#

so like this?```python
@bot.tree.command(name='color', description='Displays a colour from a hexidecimal')
async def color(interaction: discord.Interaction, color: str):
int_color = int(color,16)
RGB = tuple(int(color[i:i+2], 16) for i in (0, 2, 4))
file = discord.File(io.BytesIO(data.content), filename="color.png")

async with aiohttp.ClientSession() as session:
    embed = discord.Embed(color = int_color)
    embed.add_field(name='Hexadecimal', value = f'#{color}')
    embed.add_field(name='RGB', value = f'{RGB}', inline=False)
    embed.set_thumbnail(url="attachment://color.png")
    await interaction.response.send_message(embed=embed, file=file)```
slate swan
#

um no

#
async with aiohttp.ClientSession() as session:
    data = session.get("the url")

file = discord.File(io.BytesIO(data.content), filename="color.png")
# rest of your code
# embed = discord.Embed....
naive briar
#

Also you need to await the .get to get the response object

#

And close using .close to release the connection

#

Or just use the context manager ducky_sphere

upbeat otter
#

just don't use aiohttp PU_PeepoLeaveExit

upbeat otter
clear elm
#

how do i make it so like i do !add (value) and then it adds the amount of (value) to a different embed
!add 7 (user)

!view (user)

(in the embed it says user has 7) and then if u do it again it adds the 2 numbers i have this code


@client.command()
async def viewlogs(ctx, member: discord.Member  = None):
    if member == None:
        member = ctx.author
    embed=discord.Embed(title=f'{member} Logging', description="_ _", color=0xBB1A24)
    embed.add_field(name="Total Shifts", value="N/A", inline=False)
    embed.add_field(name="Total Sessions", value="N/A", inline=False)
    embed.add_field(name="Weekly Logs", value="N/A", inline=False)
    embed.set_author(name = f'{member}', icon_url = member.avatar_url)
    await ctx.send(embed=embed) 

@client.command()
async def addshift(ctx, member: discord.Member  = None):
    if member == None:
        member = ctx.author
    await ctx.send(f"Added 1 shift to {member}") 

@client.command()
async def addsession(ctx, member: discord.Member  = None):
    if member == None:
        member = ctx.author
    await ctx.send(f"Added 1 session to {member}") ```

this is what i have, i have no clue how to do it. i was wondering if u could possibly help me and tell me what to put in the value area if possible?
loud junco
#

how can i import this class without needing to declaring bot in the file where i import it to

upbeat otter
#

you can simply load it

loud junco
#

so i dont need to do the large chunk of sql syntax

#

i just need some parameter to make the code cleaner and readable

upbeat otter
loud junco
#

wtf am i thinking

#

and btw how do i define bot

slate swan
#

you want to make a class that does database stuff for you?

upbeat otter
#

Sarth's gonna help kawaii

slate swan
#

sarth's getting away in a minute

upbeat otter
vale wing
slate swan
clear elm
upbeat otter
slate swan
#

i think someone told you about this earlier a few hrs ago?

clear elm
#

yeah but like i was super confused and also tired, i didn't understand and i lost the message

slate swan
#

!e ```py
shifts = {}
def _shifts(user_id):
print(shifts.get(user_id))

def add_shift(user_id):
shifts.setdefault(user_id, 0)
shifts[user_id]+=1

_shifts(580034015759826944) # with no shifts
add_shift(580034015759826944) # adding a shift
_shifts(580034015759826944) shift was added

#

πŸ€” wtf

#

oh

#

weird, gimme a moment

clear elm
#

what r the ids at the bottom

potent spear
#

a random user id

loud junco
#

oof

slate swan
clear elm
#

ok

slate swan
#

the implementation will be pretty much same for your code

#

but all this data will get lost when you restart the bot

loud junco
#

can i just copy paste this on top of the file to end my misery

upbeat otter
#

no

upbeat otter
#

you can't

loud junco
#

how do i define bot ;-;

upbeat otter
#

and why do you need to define bot

slate swan
loud junco
loud junco
slate swan
#

change the implementation, give me a minute

slate swan
loud junco
#

yup

vale wing
#

When the

loud junco
vale wing
#

!pypi exenenv

unkempt canyonBOT
vale wing
#

I like this so much

slate swan
#
# database.py
class Database:
    def __init__(self, bot):
        self.bot

    async def do_something(self, arg):
        return await self.bot.db.fetch(".....")
``` ```py
# bot.py
from database import Database

bot = commands.Bot(...)

@bot.event
async def setup_hook():
    bot.db = await asyncpg.create_pool(...)
    bot.database_handler = Database(bot)
vale wing
#

cause I made it

slate swan
#

and then you can use bot.database_handler.do_something anywhere you want to

clear elm
clear elm
#

ok

slate swan
#

your commands will work as those parts

clear elm
#

ok

slate swan
clear elm
slate swan
#

my __main__.py is just 3 lines πŸšΆβ€β™‚οΈ

loud junco
#

i mean like when do i do the thing in bot.py

slate swan
#

wherever your bot is located

loud junco
#

its just setup

slate swan
#

yea

clear elm
vale wing
#

This is an interesting effect fr ____

vocal snow
clear elm
#

help idk hwo to do that 😭

vocal snow
clear elm
#

yeah

vocal snow
#

so where/how are those logs being stored

#

do you have a database, maybe a json document, or something else?