#discord-bots

1 messages · Page 1108 of 1

heady sluice
#

bru

slate swan
#

how can everything be a var

heady sluice
#

okay I didn't mean irl

slim spoke
#

can someone come to my bot testing server and tell me which permissions does my bot need? xd tried few different options but it didn't work

heady sluice
#

on line 21, you used a # which commented out an important part

#

I think what you meant is colour=0xb7ff02)

#

and in the end (in code, in case you'd ask), member.display_avatar.url could just be written as x

#

cuz you dunno what it is

uncut jacinth
#
class Buttons(discord.ui.View):
    def __init__(self, *, timeout=180):
        super().__init__(timeout=timeout)
    @discord.ui.button(label="Blurple Button",style=discord.ButtonStyle.blurple,emoji="🎁") # or .primary
    async def blurple_button(self,button:discord.ui.Button,interaction:discord.Interaction):
        button.disabled=True
        await interaction.response.edit_message(view=self)

@client.command()
async def button(ctx):
    view=Buttons()
    await ctx.send("This message has buttons!",view=view)

And i got this error

Ignoring exception in view <Buttons timeout=180 children=2> for item <Button style=<ButtonStyle.primary: 1> url=None disabled=False label='Blurple Button' emoji=<PartialEmoji animated=False name='🎁' id=None> row=None>:
Traceback (most recent call last):
  File "C:\Users\lequi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ui\view.py", line 414, in _scheduled_task
    await item.callback(interaction)
  File "C:\Users\lequi\Desktop\Hint Bot\hinttest.py", line 35, in blurple_button
    button.disabled=True
AttributeError: 'Interaction' object has no attribute 'disabled'

Any body any idea?

slate swan
heady sluice
#

no, not discord.Color

slate swan
heady sluice
#

you use discord.Color or discord.Colour when you want to access a colour that Danny has hardcoded for you already

#

you want the specific colour 0xb7ff02

#

so you only pass that to colour=

slate swan
heady sluice
#

no...

#

color=0xb7ff02)

#

I also noticed you made client a commands.Bot, then reassigned it to be a discord.Client

#

and changed presence on_ready

#

so I suggest just removing line 5

slate swan
#

just remove line 5 ?

heady sluice
#

and I got a tag from the dpy server:

Don't change_presence (or make API calls) in on_ready within your Bot or Client.
Discord has a high chance to completely disconnect you during the READY or GUILD_CREATE events (1006 close code) and there is nothing you can do to prevent it.

Instead set the activity and status kwargs in the constructor of these Classes.

bot = commands.Bot(command_prefix="!", activity=..., status=...)

As noted in the docs, on_ready is also triggered multiple times, not just once.

Basically: don't 👏 do 👏 shit 👏 in 👏 on_ready.

heady sluice
heady sluice
#

yes

slate swan
heady sluice
#

oh, you don't need a bot

#

you can do this within your client

#

you have

client = discord.Client()
```, so you could change that to

client = discord.Client(activity=discord.Game(name="++introduction"))

dense swallow
#

how can i see button press counts?

heady sluice
#

and delete line 11 with the change_presence stuff

#

and your code is already much better on startup

dense swallow
slate swan
dense swallow
#
    @commands.command()
    @commands.cooldown(1, 10, commands.BucketType.user)
    async def suggest(self, ctx, *, suggestion):
        """Suggest some commands that should be included in bot."""

        await ctx.send(f"{self.bot.yes} {ctx.author.mention}, your suggestion has been recorded!")

        upvotes = 0
        downvotes = 0
        channel = self.bot.get_channel(798259756803817545)
        view = View()

        b1 = ButtonCreation(
            style=discord.ButtonStyle.grey,
            emoji=self.bot.yes
        )
        b2 = ButtonCreation(
            style=discord.ButtonStyle.grey,
            emoji=self.bot.no
        )

        view.add_item(b1).add_item(b2)

        async def b1_callback(interaction: discord.Interaction):
            nonlocal upvotes
            upvotes += 1
            await interaction.response.edit_message(embed=em)

        b1.callback = b1_callback

        async def b2_callback(interaction: discord.Interaction):
            nonlocal downvotes
            downvotes += 1
            await interaction.response.edit_message(embed=em)
        
        b2.callback = b2_callback

        em = discord.Embed(color=self.bot.color)

        em.add_field(name="Suggestion", value=f"> {suggestion}", inline=False)
        em.add_field(name="Upvotes", value=f"{upvotes} Votes", inline=True)
        em.add_field(name="Downvotes", value=f"{downvotes} Votes", inline=True)

        em.set_author(name=ctx.author, icon_url=ctx.author.avatar.url)
        em.set_thumbnail(url=ctx.author.avatar.url)
        em.set_footer(text=f"Guild: {ctx.guild} ({ctx.guild.id})")

        await channel.send(embed=em, view=view)
``` this is my code, but it does not update it, shows 0 (both upvotes and downvotes)
heady sluice
#

just store something like b1.count, set it to 0

wicked atlas
heady sluice
#

add 1 to it in the callback

slate swan
#

better subclass the View

dense swallow
#

im doing that, setting upvotes and downvotes = 0 then +1 it in async func

slate swan
heady sluice
wicked atlas
heady sluice
#

interesting indentation

dense swallow
heady sluice
#

huh

#

missing a bit of python here

wicked atlas
slate swan
#
class UpDownVoteView(discord.ui.View):
  def __init__(self):
    super().__init__(timeout=60)
    self.up = 0
    self.down = 0
    self.users = []
  
  async def interaction_check(self, inter: discord.Interaction):
    if inter.user in self.users:
      return await inter.response.send_message("NO", ephemeral=True)
  @discord.ui.button(label="upvote")
  async def upv(self, button: discord.ui.Button, inter: discord.Interaction):
    self.up += 1
    await inter.response.send_message("Upovted", ephemeral=True)  

  @discord.ui.button(label="downvote")
  async def downv(self, button: discord.ui.Button, inter: discord.Interaction):
    self.down += 1
    await inter.response.send_message("Downvoted", ephemeral=True)  
heady sluice
#

noob

slate swan
#

better append the users to a list so that they dont get to up/downvote again

dense swallow
#

yeah

slate swan
slate swan
#

just i want help to correct my first script

slate swan
#

we don't talk about that

heady sluice
#

nah you're trippin

slate swan
#

also, what did I do, that was just an example

wicked atlas
# slate swan im begginer, sorry .

Just a heads up, discord.py isn’t a beginner thing despite it being what draws people to python. It’s a more intermediate thing, much easier once you’ve taken the time to learn the basics of the language

heady sluice
slate swan
slate swan
heady sluice
slate swan
#

no comments

#
            interaction.response.send_message(content="123", ephemeral=True)

Dear tell me what is the problem?

slate swan
#

😅 oh

heady sluice
slate swan
heady sluice
#

!indents

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
heady sluice
#

ew

warped mirage
#

can someone help me make a slash command dpy 2.0 , i need certain stuff on it

full lily
#

if i'm making a web panel for my discord bot in flask, how easy is it to exchange information between the bot and the site?

warped mirage
warped mirage
# slate swan yeah?

so , i need /send category1: category2: then it says your category has been sent to the owner and the bot dms u the category1 category2

slate swan
full lily
slate swan
full lily
#

okay cool

warped mirage
#

and in the dm the bot will legit say , the information is category1 category 2

#

easy enough for sum ppl

#

So can someone help me with that

slate swan
warped mirage
#

i forgot

potent spear
#

in dpy v2?

warped mirage
#

ye

potent spear
#

there are existing examples in gh

warped mirage
#

can u send a link

#

i cant find anything

warped mirage
#
@app_commands.rename(text_to_send='text')
@app_commands.describe(text_to_send='Text to send in the current channel')
async def send(interaction: discord.Interaction, text_to_send: str):
    """Sends the text into the current channel."""
    await interaction.response.send_message(text_to_send)
``` ok i have this
#

anyways so can someone help me

#

make the code

#

@slate swan

#

someone lol

potent spear
#

well, you need to define the bot and intents correctly too ofc

warped mirage
#

i need /send category1: category2: then it says your category has been sent to the owner and the bot dms u the category1 category2

potent spear
warped mirage
#

can u help me make the command if its simple please

potent spear
#

well, I've seen you here before, so you must know how to do it in v1.7.3, right?

warped mirage
#

sort of

#

but im v2.0

potent spear
#

well, have you read the migration guide first of all?
for example, you need message_content intents, since they are required, as well as in the discord dev portal, you'll need to enable app commands

potent spear
#

well, then where's your issue?

warped mirage
#

...

#

/send category1: category2: then it says your category has been sent to the owner and the bot dms u the category1 category2

#

i need help making this?

potent spear
#

well, you should know that that command will take 2 args
with typehint discord.CategoryChannel

warped mirage
#

ok if u guys dont know its alr

potent spear
#

we won't write it for you, that's all we're saying

warped mirage
#

no one asked for that

dense swallow
warped mirage
#
@slash.slash()
async def send(ctx, user: discord.Member, *, message=None):
    message = message or "txt",
    await user.send(message)``` done i made a slash command @potent spear now i need help making the rest
dense swallow
#

pretty sure slash commands take in interaction, not ctx

warped mirage
#

this is v1.7.3

#

i need help making the rest

#

for 2.0

dense swallow
#

i think u should update to 2.0

potent spear
#

well, no idea what that @slash.slash() lib is, but it surely isn't v2

warped mirage
#

i have

warped mirage
potent spear
#

what lib is that?

warped mirage
#

its old in 1.7.3

#

i need to make it 2.0

dense swallow
#

1.7.x does not have slash
is it discord-components?

warped mirage
#

discord-slash-commands

#

i think

#

but i made it as a template , now i need help converting this into 2.0

dense swallow
#

if u want slash d.py defines it as app_commands

warped mirage
#

ye , can u help me make that?

dense swallow
#

i havent made any slash cmds with dpy

warped mirage
#

ye but i need 2.0 bruh

#

nah

vale sierra
slate swan
#

ehm what did i do wrong

#

i want the pfp of 2 people

uncut jacinth
#
class Buttons(discord.ui.View):
    def __init__(self, *, timeout=180):
        super().__init__(timeout=timeout)
    @discord.ui.button(label="Blurple Button",style=discord.ButtonStyle.blurple,emoji="🎁") # or .primary
    async def blurple_button(self,button:discord.ui.Button,interaction:discord.Interaction):
        button.disabled=True
        await interaction.response.edit_message(view=self)

@client.command()
async def button(ctx):
    view=Buttons()
    await ctx.send("This message has buttons!",view=view)

And i got this error

Ignoring exception in view <Buttons timeout=180 children=2> for item <Button style=<ButtonStyle.primary: 1> url=None disabled=False label='Blurple Button' emoji=<PartialEmoji animated=False name='🎁' id=None> row=None>:
Traceback (most recent call last):
  File "C:\Users\lequi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ui\view.py", line 414, in _scheduled_task
    await item.callback(interaction)
  File "C:\Users\lequi\Desktop\Hint Bot\hinttest.py", line 35, in blurple_button
    button.disabled=True
AttributeError: 'Interaction' object has no attribute 'disabled'

Anybody any idea?

vale sierra
#

element is probably outside the function

warped mirage
#

Can someone help me

slate swan
#

maybe i can

warped mirage
vale sierra
warped mirage
#

i need /send category1: category2: then it says your category has been sent to the owner and the bot dms u the category1 category2 this

slate swan
#

and whats the proble

sage otter
#

You're separating with a comma for some reason

balmy bobcat
#

hi! Can I ask for help here or should I create a thread so I don't flood?

sage otter
#

await ctx.send(f"{memberAvatar1}{memberAvatar2}")

#

@slate swan ^

slate swan
#

thank you 🙂

sage otter
#

interaction comes first not button

uncut jacinth
#

Thanks man

sage otter
#

Should be
(self, inter, button)

slate swan
#

tyler now it gives a atributeerror

vale sierra
warped mirage
sage otter
slate swan
sage otter
#

That doesn’t normally exist for cogs. Did you make one yourself?

slate swan
#

i made it myself yeyCat

sage otter
#

And honestly just save yourself time.

#

Consider literally just
member1.display_avatar.url

slate swan
#

ehhmmm

#

wait in what waty

#

do i replace the member avatar 1 adn 2

#

sorry for typos

sage otter
#

memberAvatar1 = member1.display_avatar.url

slate swan
#

oooh

#

oh wait ofc i have it in my other command

sage otter
#

Oh you're on 1.7 dpy

#

You don’t have display_avatar

slate swan
#

my what

sage otter
#

nvm what I said about display_avatar

#

Do member1.avatar_url likewise for member2

slate swan
sage otter
#

So what’s the problem then?

slate swan
#

but also i keep getting that this is not importing

sage otter
#

Did you install the package?

slate swan
#

i did

#

wait ill try again

cloud dawn
slate swan
#

oh

sage otter
#

I honestly forgot about that.

slate swan
#

sorry for asking

#

lul i didnt know Hehe

cloud dawn
slate swan
#

oh ofc

#

srry

sage otter
#

element is only in the scope of your check function. You can’t use it outside.

#

What you can do is

#

assign the self.bot.wait_for to a variable and that variable will be that message you expect it to be.

#

And you can use that instead

slate swan
#

again attribute error crybaby

sage otter
#

Show your errors

slate swan
sage otter
#

Yeah I literally said you don’t have that

slate swan
#

i did

sage otter
#

The error literally says you used display_avatar so you obviously didn’t

slate swan
#

yes sorry wait im channging code

sage otter
#

Wtf no

vale sierra
sage otter
#

I said assign it to a variable and that will be the message object you want

neat lynx
#

So, I want to get interactions/slash commands working with discord.py, but I have yet to found comprehensive documentation.

#

Can anyone point me in the right direction?

slate swan
neat lynx
#

You need to indent everything after line 13.

#

The error tells you.

#

You have the function and the if on the same intendation.

slate swan
neat lynx
#

By...adding a tab to everything that belongs into the function.

slate swan
#

wait

#

and now ?

neat lynx
#

What's different.

#

From line 37 to all other ifs.

slate swan
#

i add tab ( if) and tab await message

#

IF
await

neat lynx
#

The error message is pointing you to the space that is missing something.

#

What does an if end with?

slate swan
#

hello, could someone help me out. I've been trying this for ages. I'm trying to make a whitelisted command that my bot can have so only users with the certian ids can use the command. I'm wanting to save the users infomation and id into a config.json file but I can't get it to work, here's my code:

neat lynx
#

Async editing files will lead to tears.

#

Might I suggest sqlite.

#

Or any lite db of your choice.

slate swan
#

how can i use that?

#

have you got the docs?

uncut jacinth
#
    @discord.ui.button(label="Button",style=discord.ButtonStyle.gray)
    async def gray1_button(self,interaction:discord.Interaction,button:discord.ui.Button):
        await interaction.response.edit_message(content=f"This is an edited button response 2! {member.name}")

@client.command()
async def button(ctx, member: discord.Member):
    await ctx.send("This message has buttons!",view=Buttons())

I got this but how i get the member argument in the button function?

#

[2022-06-19 00:15:47] [ERROR ] discord.ext.commands.bot: Ignoring exception in command button
Traceback (most recent call last):
File "C:\Users\lequi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\bot.py", line 1330, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\lequi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\core.py", line 987, in invoke
await self.prepare(ctx)
File "C:\Users\lequi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\core.py", line 904, in prepare
await self._parse_arguments(ctx)
File "C:\Users\lequi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\core.py", line 811, in _parse_arguments
transformed = await self.transform(ctx, param, attachments)
File "C:\Users\lequi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\core.py", line 663, in transform
raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: member is a required argument that is missing.

#

Error

slate swan
torn sail
neat lynx
#

A :

uncut jacinth
neat lynx
#

You're missing a : at the end of your ifs.

uncut jacinth
#

ansform
raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: member is a required argument that is missing.
Ignoring exception in view <Buttons timeout=180 children=2> for item <Button style=<ButtonStyle.secondary: 2> url=None disabled=False label='Button' emoji=None row=None>:
Traceback (most recent call last):
File "C:\Users\lequi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ui\view.py", line 414, in _scheduled_task
await item.callback(interaction)
File "C:\Users\lequi\Desktop\Hint Bot\hinttest.py", line 31, in gray1_button
await interaction.response.edit_message(content=f"This is an edited button response 2! {member.name}")
NameError: name 'member' is not defined

#

Thats the one i want the for example display the user name of the member in the button function

#

after a button is clicked

#
class Buttons(discord.ui.View):
    def __init__(self, *, timeout=180):
        super().__init__(timeout=timeout)
    @discord.ui.button(label="Button",style=discord.ButtonStyle.gray)
    async def gray_button(self,interaction:discord.Interaction,button:discord.ui.Button):
        await interaction.response.edit_message(content=f"This is an edited button response!")
    @discord.ui.button(label="Button",style=discord.ButtonStyle.gray)
    async def gray1_button(self,interaction:discord.Interaction,button:discord.ui.Button):
        await interaction.response.edit_message(content=f"This is an edited button response 2! {member.name}")

@client.command()
async def button(ctx, member: discord.Member):
    await ctx.send("This message has buttons!",view=Buttons())
slate swan
#

@neat lynx

torn sail
#

you should add a member argument into Buttons __init__ and assign it self.member = member and then you can access it in ur functions with self.member

uncut jacinth
#

I tried but it outputs a error if i write it in init

torn sail
#
class Buttons(discord.ui.View):
    def __init__(self, member):
        self.member = member
uncut jacinth
# torn sail ```py class Buttons(discord.ui.View): def __init__(self, member): se...
Traceback (most recent call last):
  File "C:\Users\lequi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\core.py", line 200, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\lequi\Desktop\Hint Bot\hinttest.py", line 35, in button
    await ctx.send("This message has buttons!",view=Buttons())
TypeError: __init__() missing 1 required positional argument: 'member'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\lequi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\bot.py", line 1330, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\lequi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\core.py", line 995, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "C:\Users\lequi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\core.py", line 209, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: __init__() missing 1 required positional argument: 'member'
torn sail
#

view=Buttons(member)

uncut jacinth
#
Ignoring exception in view <Buttons timeout=180 children=2> for item <Button style=<ButtonStyle.secondary: 2> url=None disabled=False label='Button' emoji=None row=None>:
Traceback (most recent call last):
  File "C:\Users\lequi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ui\view.py", line 414, in _scheduled_task
    await item.callback(interaction)
  File "C:\Users\lequi\Desktop\Hint Bot\hinttest.py", line 31, in gray1_button
    await interaction.response.edit_message(content=f"This is an edited button response 2! {self.member.name}")
AttributeError: 'Buttons' object has no attribute 'member'
uncut jacinth
#
class Buttons(discord.ui.View):
    def __init__(self,member, *, timeout=180):
        super().__init__(timeout=timeout)
    @discord.ui.button(label="Button",style=discord.ButtonStyle.gray)
    async def gray_button(self,interaction:discord.Interaction,button:discord.ui.Button):
        await interaction.response.edit_message(content=f"This is an edited button response!")
    @discord.ui.button(label="Button",style=discord.ButtonStyle.gray)
    async def gray1_button(self,interaction:discord.Interaction,button:discord.ui.Button):
        await interaction.response.edit_message(content=f"This is an edited button response 2! {self.member.name}")

@client.command()
async def button(ctx, member: discord.Member):
    await ctx.send("This message has buttons!",view=Buttons(member))
torn sail
uncut jacinth
autumn shuttle
#

Not like that

#

Inside the init function

uncut jacinth
#

What inside the init function

autumn shuttle
#

dude in the function

uncut jacinth
#

Never had anything with __init_

autumn shuttle
#

You define self.member to the member argument

balmy bobcat
#

you should read object oriented programming docs

autumn shuttle
#

It's a normal function

#

But special

#

Normal function syntax thi

#

Tho

balmy bobcat
#

Hi, I'm trying to create a function that allows the user to create a custom role with a custom colour

@client.command()
async def role_perso(message,name,color):
    guild = message.guild
    await message.send(f"{color}")
    await guild.create_role(name=name, color=discord.Color(int(color)))
    await message.add_reaction(working_emote)

color is an hex color, but I don't know why, its class is str and I can't convert it to int
"Expected int parameter, received str instead."
"ValueError: invalid literal for int() with base 10: '0x45ba80'"

autumn shuttle
#

Cos it's not an int

#

Can't u just define color to that hex

uncut jacinth
#

Ok

balmy bobcat
autumn shuttle
#

I'm on mobile rn

balmy bobcat
#

I don't understand why I can"t convert my hex number to int yet this is an int

autumn shuttle
#

But try checking what they convert to color

balmy bobcat
#

discord.Color wants an int as a parameter

autumn shuttle
#

Yes but does color in create role only accept a discord.Color object?

balmy bobcat
#

let me check this

#

AttributeError: 'str' object has no attribute 'value'

slate swan
#

hello, im using a database to make a whitelisted command but how can i check to see if a user already exists within the database using the users id as a input?

autumn shuttle
#

Dude I've been telling you

#

Apparently you can just pass in the hex

#

You don't need discord.Color

balmy bobcat
#

the problem is that they want the hex as an int

#

should I try to convert the hex to a base 16 int?

#

int(my_hex,16)

autumn shuttle
#

I just don't see how that's necessary

balmy bobcat
#

my hex is a str and they refuse str

full lily
full lily
#

your question is quite broad. Which part are you havbing trouble with

slate swan
#

SELECT id FROM users WHERE id = {userid} @full lily like that rigt im trying to compare the given user id say its 131313131313 and i want to check to see if that exists in my databae if it does i want my bot to state that it exsits if not i want it to add that user if that made sense

#

MY BOT is work thank but i have embed problem bot dont typing my embed. i think i have bad embed text?

autumn shuttle
#

I cant see shit

balmy bobcat
# autumn shuttle Is it
@client.command()
async def role_perso(message,name,color):
    guild = message.guild
    await message.send(f"{color}")
    await guild.create_role(name=name, color=color)
    await message.add_reaction(working_emote)

This is my actual code and it doesnt work
"AttributeError: 'str' object has no attribute 'value' "

full lily
#

if it's empty, you know the person isn't in your database and you should add them

#

I wonder if there's a sql command to all of that in one go. "Check if this row exists, and if not, add it"

slate swan
#

maybe so do i try to select the users id from my database and if it equals nothing then to add them right?

autumn shuttle
#

There probably is

slate swan
#

My embed message, not work

client = discord.Client(activity=discord.Game(name="++introduction"))

@client.event
async def on_ready():
    print('HackingTraining is ready.')
  
@client.event
async def on_message(message):

    if message.content.startswith('++introduction'):
        embed = discord.Embed(
        title='Commands',
        description='**__IMPAT13NTS - HACKING TRAINING__**\n**!შესავალი** :pushpin:\n**!ლინკები** :link:\n**!math instruction** :scroll:\n**!math** :pushpin:\n**!gamefield instruction** :scroll:',
        color=0xb7ff02)
        embed.set_image(url="https://media.discordapp.net/attachments/974804087893815326/982721780110209084/IMPAT13NTS__5_-removebg-preview.png")
        embed.set_thumbnail(url=message.author.display_avatar.url)
        embed.timestamp = datetime.datetime.now()
        await message.channel.send(embed=embed)```
autumn shuttle
#

Anything in the console?

autumn shuttle
#

Then ig try converting it

balmy bobcat
#

that's what I did 😹 can't convert it

#

ValueError: invalid literal for int() with base 10: '0x45ba80'

autumn shuttle
#

But type returns int right

slate swan
slate swan
#

?

balmy bobcat
#

I added a print(type(color))

slate swan
autumn shuttle
#

It's just avatar_url

heady sluice
#

stuck in 1.7

slate swan
potent spear
#

If you’re not on dpy v2, yes

slate swan
#

fuck my embed ..

sick birch
#

Did you import it?

slate swan
#

my bot is ready but

#

my embed not work

sick birch
#

Also you should probably be using the commands extension

slate swan
#
@client.event
async def on_ready():
    print('HackingTraining is ready.')
  
@client.event
async def on_message(message):

    if message.content.startswith('++introduction'):
        embed = discord.Embed(
        title='Commands',
        description='**__IMPAT13NTS - HACKING TRAINING__**\n**!შესავალი** :pushpin:\n**!ლინკები** :link:\n**!math instruction** :scroll:\n**!math** :pushpin:\n**!gamefield instruction** :scroll:',
        color=0xb7ff02)
        embed.set_image(url="https://media.discordapp.net/attachments/974804087893815326/982721780110209084/IMPAT13NTS__5_-removebg-preview.png")
        embed.set_thumbnail(url=message.author.avatar_url)
        embed.timestamp = datetime.datetime.now()
        await message.channel.send(embed=embed)```
#

this is my embed code bot not work

potent spear
#

You should read the error

slate swan
potent spear
#

Yeah, read it

slate swan
#

yea but i dont understand. .

autumn shuttle
#

Literally just import the library

potent spear
#

You didn’t import datetime

#

Good IDE’s would even suggest this

slate swan
#

if i remove date?

autumn shuttle
#

What's ur favorite ide

waxen python
#

How do most bots go about permission systems? I was wanting to allow the user to set permissions that roles are allowed to do, but I have no idea how this would feasibly work from a database....
How would I check that the user has a role with that permission without iterating through all their roles every time? Maybe I've set about this the complete wrong way. thanks

autumn shuttle
#

Don't remove anything just import datetime

slate swan
#

how?

waxen python
#

🗿

autumn shuttle
#

Import datetime

slate swan
#

example?

waxen python
#

import datetime at the top of your file.

autumn shuttle
#

IMPORT DATETIME

slate swan
#

🥲

waxen python
#

you are meant to know the basics of python before starting to use dpy :P

slate swan
#

what is this called? like embed.add what

potent spear
slate swan
#

or set

#

Why are you blaming me

#

i just help. 🙂

potent spear
slate swan
#

sorry. : )

#

ahhh tnaks

#

thanks

autumn shuttle
#

I prefer tnaks tbh

waxen python
potent spear
#

You want to copy a member’s exact permissions & make a role out of it?

waxen python
#

do I? my current idea was to assign vaules to a role id in my database, but I hadn't thought through how I would end up checking that efficiently

potent spear
#

Yeah, you’re implementing this the wrong way

#

There’s a decorator called “has_permissions”

waxen python
#

No, I know that. But that's for default discord permissions, not custom vaules

autumn shuttle
#

If statements

waxen python
#

Again, yes. I'm aware how discord permissions work. That's not what I'm trying to do

autumn shuttle
#

Just check if any of the members roles is in the database with custom perms

waxen python
#

Yes, I thought that. But that doesn't sound efficient for every command

#

some users could have 100s of roles

potent spear
#

Yeah, and one of those roles should have a specific permission?

autumn shuttle
#

If it has a perm then it would be really specific and probably the top role

slate swan
#

i imported

waxen python
slate swan
#

but again, my embed not work : /

autumn shuttle
#

It's not like I'm an admin and only my mod role gives me the ability to ban

waxen python
potent spear
waxen python
#

you somehow managed to do what we told you incorrectly

slate swan
#

wtf

autumn shuttle
#

import datetime

waxen python
#

that's how importing things work 🤔

slate swan
#

xD

waxen python
#

in your code

autumn shuttle
#

IVE SAID EXACTLY THOSE WORDS LIKE 66000 TIMES

waxen python
#

you can EITHER change to import datetime or do what I did

potent spear
autumn shuttle
#

Resuming where we left off

waxen python
#

yeah..

#

if you have admin it would override it

autumn shuttle
#

Ig but it wouldn't override view warnings

waxen python
#

I'm going to have multiple checks, if had admin then I won't need to check my permissions dB. doesn't solve the issue though

slate swan
potent spear
#

Anyways, storing “custom role names” as unique identifier isn’t a good idea, you should reference to a config table

slate swan
waxen python
slate swan
#

ha?

waxen python
slate swan
waxen python
#

the timezone

potent spear
waxen python
slate swan
waxen python
potent spear
#

Still not really an idea of what you’re trying to achieve

slate swan
#

remove

waxen python
#

remove indeed

slate swan
#

import datetime and add import UTC. ?

waxen python
waxen python
slate swan
waxen python
#

🗿

waxen python
#

yes that's what you coded it to do

slate swan
#

now

waxen python
#

yes now that's what you did

waxen python
potent spear
waxen python
#

It's role specific, settable like this:

#

sorry for sending that again I just think that image explains it better than me :P

potent spear
#

I think I see what you want

#

You want to give an existing role in a Guild to a member with the specified permissions?

slate swan
potent spear
#

Here we go again

waxen python
#

omg tf are you doing lmao

#

you had it working before

waxen python
slate swan
waxen python
potent spear
waxen python
#

What do you mean?

potent spear
slate swan
#

: /

potent spear
slate swan
#

i want correct time bro

potent spear
waxen python
waxen python
#

like have the role called Warnings

#

I guess that's a way of doing it, less clean imo but idk.

potent spear
#

Depends on how many “moderation” roles you might need

waxen python
slate swan
#
async def on_member_join(member):
   await client.get_channel(971319830064017458).send(f"{member.name} has joined", delete_after=30)```

not working, how to fix?
waxen python
#

Sorry to bother you with this lol, I'll do some more thinking

slate swan
waxen python
#

You need the members intents from the discord developers portal and you need to enable them in your code

potent spear
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 Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

intents = Intents.default()
intents.members = True

bot = commands.Bot(command_prefix="!", intents=intents)

For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.

slate swan
#

alr

#

is my code correct though?

potent spear
#

Yup, a bit of a redundant oneliner, but sure

uncut jacinth
#
class Buttons(discord.ui.View):
    def __init__(self, member, *, timeout=180):
        super().__init__(timeout=timeout)
        self.member = member
    @discord.ui.button(label="0",style=discord.ButtonStyle.green)
    async def gray_button(self,interaction:discord.Interaction,button:discord.ui.Button):
        label = int(button.label)
        label += 1
        button.label = label
        await interaction.response.edit_message(view = self)

    @discord.ui.button(label="0",style=discord.ButtonStyle.red)
    async def gray1_button(self,interaction:discord.Interaction,button:discord.ui.Button):
        label = int(button.label)
        label += 1
        button.label = label
        await interaction.response.edit_message(view = self)
        #await self.member.kick(reason="Test")

@client.command()
async def button(ctx, member: discord.Member):
    await ctx.send("This message has buttons!",view=Buttons(member))

Anybody know how i add a check to it that only the author can use the buttons?

scarlet aurora
#
    @commands.command()
    async def whomedia(self, ctx):

        check_role = discord.utils.get(user.guild.roles, name='Media Perms')

        for user in ctx.guild.users:
            if check_role in user.roles:
                await ctx.send(user.name)``` ```user is referenced before``` can someone tell me why this is happening?
slate swan
uncut jacinth
uncut jacinth
scarlet aurora
#

I'm trying to check if per user has media perms

uncut jacinth
#

Yes its the code

cerulean folio
scarlet aurora
#

so it goes through each user, then check if it has media perms

uncut jacinth
#

But i changed the media

#

You can change the role back

cerulean folio
#

i.e your variable isn't declare/doesn't exist

scarlet aurora
#

thanks

uncut jacinth
#

Then everyone in the server with the role gets listed

cerulean folio
#

for example if it's a dict, just add user = dict() before

scarlet aurora
#

still don't work

cerulean folio
scarlet aurora
#

ok ty

uncut jacinth
#

isnt it self, user, ctx?

cerulean folio
#

so the function knows that user you're talking about

uncut jacinth
#

Because it will timeout your bot fast

#

Try this

scarlet aurora
#

i don't want any arguments

uncut jacinth
#
    temporary = ""
    for user in ctx.guild.members:
        if check_role in user.roles:
           temporary += user.name+"\n"
sick birch
#

!d discord.ui.View.interaction_check

unkempt canyonBOT
#

await interaction_check(interaction)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

A callback that is called when an interaction happens within the view that checks whether the view should process item callbacks for the interaction.

This is useful to override if, for example, you want to ensure that the interaction author is a given user.

The default implementation of this returns `True`.

Note

If an exception occurs within the body then the check is considered a failure and [`on_error()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.View.on_error "discord.ui.View.on_error") is called.
scarlet aurora
uncut jacinth
#

so your bot doesn't send too many messages if you have many members with that permission

#

so it doesnt timeout

scarlet aurora
#

ok ty

#

but the error is still there

uncut jacinth
#

right?

scarlet aurora
#

local variable 'user' referenced before assignment

uncut jacinth
#
@commands.command()
async def whomedia(ctx):

    check_role = discord.utils.get(ctx.guild.roles, name='Media Perms')

    temporary = ""
    for user in ctx.guild.members:
        if check_role in user.roles:
           temporary += user.name+"\n"
    await ctx.send(temporary)
#

Try this

#

There was no error for me

scarlet aurora
#

local variable 'user' referenced before assignment

uncut jacinth
cerulean folio
# scarlet aurora but the error is still there

you're using the variable user as it was an object. But the variable user does not exist.
here's a simple example:

def send_message():
    print(message.user.id)
    return

async def on_message(message):
   send_message():
uncut jacinth
sick birch
scarlet aurora
#

yers

sick birch
#

You might also wanna pass in the member object into the view

cerulean folio
#

in my example, you're using message BEFORE it exists

scarlet aurora
#

i don't want an argument though

cerulean folio
#

then put it inside the main function?

scarlet aurora
#

wdym

#

bot.command(user) ?

uncut jacinth
#

Interactions.user?

sick birch
#

ctx.author, the person to run the command

#

Compare that with interaction.user, and return a boolean depending on that

uncut jacinth
#
@client.command()
async def button(ctx, member: discord.Member):
    await ctx.send("This message has buttons!",view=Buttons(member))
#

Where exactly?

#

await ctx.send("This message has buttons!",view=Buttons(member), interaction_check=ctx.author)

sick birch
#

No, override the function in the view

cerulean folio
scarlet aurora
#

oh nvm I got it

cerulean folio
sick birch
#
async def myView(discord.ui.View):
  def __init__(self, member: discord.Member, ...):
    ...
    self.member = member

  async def interaction_check(self, interaction: discord.Interaction):
    # optionally add a message to people who can't use the interaction
    if interaction.user != self.member:
      await interaction.response.send_message("You can't use that :(")
      return False
    
    # The return is the most important part
    return True

  ... # other view components here
scarlet aurora
#
    @commands.command()
    async def whomedia(self, ctx):
        user = ctx.guild.members
        check_role = discord.utils.get(user.guild.roles, name='Media Perms')

        temporary = ""
        for user in ctx.guild.members:
            if check_role in user.roles:
                temporary += user.name + "\n"

        await ctx.send(temporary)```
#

@cerulean folio ^^

cerulean folio
#

I solved my problem

#

But in a different way since I'm not using @command decorators :(

#
 async def my_callback(interaction):
          if interaction.user == interaction.user:
            await interaction.response.edit_message(content="whatever", view = None)
            data['15'] = 0
            await select_game(data)
            return True
scarlet aurora
#

@cerulean folio I sent the code

cerulean folio
cerulean folio
#

nice :D

scarlet aurora
#

it don't work

cerulean folio
#

huh?

#

oh wait ofc it doesn't

#

what are you trying to do exactly please?

scarlet aurora
#

When command is run, it checks every user in the guild and returns the user names that have the rank (media perms)

uncut jacinth
#

I need it to be used by author

sick birch
#

Well you just need to pass in a member object, so the exact implementation shouldn't matter

uncut jacinth
#

So i should like use the author id

#

but how i get it in the class

sick birch
#

Pass it in like you're already doing

uncut jacinth
#

Ok

sick birch
#

it should be a field in __init__

uncut jacinth
#

So i gonna pass in ctx?

sick birch
#

If you want to, but I'd only pass in the member object/id of the person who should be able to use the view

uncut jacinth
#

Okey thank you

sick birch
#

no prob

scarlet aurora
#

@cerulean folio

uncut jacinth
#
class Buttons(discord.ui.View):
    def __init__(self, author, member, *, timeout=180):
        super().__init__(timeout=timeout)
        self.member = member

    async def interaction_check(self, interaction: discord.Interaction):
      if interaction.user != self.author:
        await interaction.response.send_message("You can't use that", ephemeral=True)
        return False
      return True

    @discord.ui.button(label="0",style=discord.ButtonStyle.green)
    async def gray_button(self,interaction:discord.Interaction,button:discord.ui.Button):
        label = int(button.label)
        label += 1
        button.label = label
        await interaction.response.edit_message(view = self)

    @discord.ui.button(label="0",style=discord.ButtonStyle.red)
    async def gray1_button(self,interaction:discord.Interaction,button:discord.ui.Button):
        label = int(button.label)
        label += 1
        button.label = label
        await interaction.response.edit_message(view = self)
        #await self.member.kick(reason="Test")

@client.command()
async def button(ctx, member: discord.Member):
    await ctx.send("This message has buttons!",view=Buttons(ctx.author, member))

So i passed it in like that but i get that error

Traceback (most recent call last):
  File "C:\Users\lequi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ui\view.py", line 410, in _scheduled_task
    allow = await self.interaction_check(interaction)
  File "C:\Users\lequi\Desktop\Hint Bot\hinttest.py", line 28, in interaction_check
    if interaction.user != self.author:
AttributeError: 'Buttons' object has no attribute 'author'
cerulean folio
uncut jacinth
sick birch
#

Are you looking for users with a specific role or a specific permission? @scarlet aurora

cerulean folio
#

sorry I edited it

sick birch
#

Also may I put in we don't spoonfeed others in the future? thanks

cerulean folio
uncut jacinth
#

I think sending ready code

sick birch
#

Yes, sending fully completed code without anything to support it

cerulean folio
#

I won't do that again but I'd like to know why that rule is set please

sick birch
#

Not really a rule, more of a courtesy

uncut jacinth
#

not just copy and pasting i guess

sick birch
#

It's because spoonfeeding doesn't help anyone learn, and only serves to shut someone up (albeit temporarily)

#

They'll come back later with a similar question because there's no learning value in pressing CTRL+C and CTRL+V

sick birch
#

What, copy pasting?

uncut jacinth
#

Not to spoonfeed someone

sick birch
#

Right, not a hard rule, but again a courtesy I'd prefer we followed as it does everyone a favour in the long run

cerulean folio
#

Well, I don't agree that it's always the case. Some people struggle for so much time, sending them the right answer sometimes helps not lose motivation to keep learning. Because some might just abandon.

Although I totally agree that most people just come for a ready to use code just to feel some achievement. Not a good way to teach indeed

sick birch
#

I agree, very dependent on the person. It's too much effort to figure out if it's worth spoonfeeding someone or not, so in general we'd like to stay away from it

uncut jacinth
#

I mostly struggle too because lacks of knowledge (Might it be in Python or in English), And sometimes it helps me more to get some code that i can analyse for the next time

#

Im try me in python since now activly around 3 weeks and i understand much because people sent me code that i could analyse, But there are always new things that brings me into struggle (Like these buttons)

cerulean folio
# scarlet aurora ```py @commands.command() async def whomedia(self, ctx): user = ...
    @commands.command()
    async def whomedia(self, ctx): #defining the command to search users that have media perms
        user = ctx.guild.members # storing all server members in 'user' variable
        check_role = discord.utils.get(user.guild.roles, name='Media Perms') # here you're trying to send a list of users to be checked by a function that's supposed to check an individual user.

        temporary = "" # declaring an empty string
        for user in ctx.guild.members: # iterating through guild members (with a variable you defined above as all guild member which is kind of weird)
            if check_role in user.roles: # checking if None is in user.roles (i think this is always True or always False)
                temporary += user.name + "\n" concatenating your string

        await ctx.send(temporary) #sending string

I would suggest that you do something like:

@commands.command()
    async def whomedia(self, ctx): #defining function
        users = ctx.guild.members # storing users in a var
        result = list() # declaring result variable
        for user in users: # iterating through users
          if discord.utils.get(user.guild.roles, name='Media Perms'): # checking if role exists in user.guild.roles
            result.append(user?name) # adding user name to list
        await ctx.send('\n'.join(result)) # transforming list into string and sending it
shrewd apex
cerulean folio
#

In python there are "inline loops" that basically shortens code and makes it more readable.
Thus, this part of the code:

  for user in users: # iterating through users
          if discord.utils.get(user.guild.roles, name='Media Perms'): # checking if role exists in user.guild.roles
            result.append(user) # adding user to list

could become:

result = [x for x in users if discord.utils.get(x.guild.roles, name='Media Perms')
shrewd apex
cerulean folio
uncut jacinth
cerulean folio
balmy bobcat
#

Hi, how can I check if a role has the default colour?

#

I want to code a command that allows the bot to delete only roles with a custom colour

slate swan
paper sluice
cerulean folio
#

I have a question here guys please.
So since I didn't learn with good sources, what I usually do is something like this:

@client.event
async def on_message(message):
  prefix = message.content.split(' ')[0]
  msg = ' '.join(message.content.split(' ')[1:])
  if prefix == '!greet':
    await message.channel.send(f'Hi <@{message.mentions[0]}> !\n
    <@{message.author}> told you this:\n
    `\n{msg}\n`)

client.run(token)

But now that I looked for a way to limit simultaneous command uses per user to 1, I've been told I should use bot decators.
Can someone send me a nice course/lesson/tutorial/video/guide about how should I reshape my bot?

All functions are ready and split in files, so what's remaining in my main.py is just the message parser with all the if statements to filters commands.

cerulean folio
paper sluice
cerulean folio
#

Oh I don't know, I asked the dude to test it. Since I don't know the function I just explain what they generally has to do to fix it, so they can adapt with their knowledge 😊

slate swan
#

If u dont name the command in the Deco it will auto name with the func name

cerulean folio
#

Oh also for my question:
what's the difference between client and bot
i.e between client.run(token) and bot.run(token)

cerulean folio
slate swan
#

Yes

cerulean folio
#

ugh I been parsing all commands XD

slate swan
#

and ur bot var be like
bot = commands.Bot(command_prefix="ur prefix")

#

!d discord.ext.commands.Bot

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, intents, **options)```
Represents a discord bot.

This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") you can do with this bot.

This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.

Unlike [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client"), This class does not require manually setting a [`CommandTree`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CommandTree "discord.app_commands.CommandTree") and is automatically set upon instantiating the class.

async with x Asynchronously initialises the bot and automatically cleans up.

New in version 2.0.
cerulean folio
#

alright...

#

thanks a lot !

#

I'll make the appropriate changes to all my code then

slate swan
#

👍

#

Get familiar to commands then u can switch to cogs

#

So u don't need to put all ur code stuff in 1 file

#

So u can separate them

cerulean folio
#

I already did... XD

slate swan
#

Oh cool

cerulean folio
#

My previous main.py was like 1200 lines so... I ended up splitting it. It was a nightmare to reconnect everything 😭

#

especially importing stuff...

slate swan
#

Haha lol

cerulean folio
#

i'm still struggling with some parts

slate swan
#

U are free to ask

cerulean folio
#

thank you ! will do later

slate swan
#

Hey, does anyone know to add permission lock to a command using hikari-lightbulb?

slate swan
#

Like only people with administrator permission can do the command

slate swan
# slate swan Yea
@lightbulb.add_checks(lightbulb.has_guild_permissions(hikari.Permissions.ADMINISTRATOR))
``` this should work
slate swan
#

fix?

paper sluice
#

what is wrong?

slate swan
#

when doing the command, the point doesn't type any text

paper sluice
#

well then, authrole is not in the roles of the invoker

slate swan
#

Even if i remove Auth role

#

the bot doesnt say anything once command is written

paper sluice
#

did u run the bot?

cerulean folio
#

I just dropped discord.client() to start using commands.Bot() and was wondering how to do client.fetch_user(arg) now

slate swan
#

bot.fetch_user(id)

cerulean folio
#

aw okie thank you !

cerulean folio
#

like does ctx.bot.fetch_user(arg) works?

slate swan
#

No

cerulean folio
#

alrightie

slate swan
stone palm
#

guys

#

how do i get the last message sent by the bot

#

in a server

slate swan
#

arg should be an ID and you need to await this

paper sluice
#

yo sarth, does hikari have oop / decorator like button things, like dpy

slate swan
#

!pip hikari-miru

unkempt canyonBOT
paper sluice
#

ah nice

cerulean folio
#

So I read in dpy docs that client can be replaced by bot in nearly any circumstances... nearly XD

I just got this error:

msg = await ctx.wait_for('message', check=check)
AttributeError: 'Context' object has no attribute 'wait_for'
#

ohhhh

#

I'm stupid nevermind

slate swan
#

its a sublass of Client

cerulean folio
#

yeah I apologize i put ctx instead of bot i'm just being stupid sometimes

magic pond
#
    async def buy_this(user, item_name, amount):
      item_name = item_name.lower()
      name_ = None
      for item in mainshop:
        name = item["name"].lower()
        if name == item_name:
          name_ = name
          price = item["price"]
          break
          if name_ == None:
            return [False, 1]
            cost = price * amount
            users = await get_bank_data()
            bal = await update_bank(user)
            if bal[0] < cost:
              return [False, 2]
              try:
                index = 0
                t = None
                for thing in users[str(user.id)]["bag"]:
                  n = thing["item"]
                  if n == item_name:
                    old_amt = thing["amount"]
                    new_amt = old_amt + amount
                    users[str(user.id)]["bag"][index]["amount"] = new_amt
                    t = 1
                    break
                    index+=1 
                    if t == None:
                      obj = {"item":item_name, "amount" : amount}
                      users[str(user.id)]["bag"].append(obj)
                      except:
                      obj = {"item":item_name, "amount" : amount}
                      users[str(user.id)]["bag"] = [obj]        
                      
                      with open("bank.json", "w") as f:
                        json.dump(users, f)
                        
                        await update_bank(user, cost*-1, "wallet")
                        return [True, "Worked"]
    raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.Economy' raised an error: SyntaxError: invalid syntax (Economy.py, line 237)
hushed galleon
#

looks like your indentation is super messed up

magic pond
#

ok

#

uhhh why is the bot not responding to the cmnd. tht cog is loaded still it doesnot respond to the commands in tht cog

cerulean folio
#

I have a little problem I can't identify in this bit of code:

async def other_callback(interaction):
      async def show_proofs(arg):
        embeds = list()
        embeds.append(add_embed(arg, users))
        for index, proof in enumerate(arg['proofs'].split(',')):
          embeds.append(discord.Embed(color = arg['tag_color']))
          embeds[index].set_image(url = proof, description=EMPTY)
        return embeds
      await interaction.response.edit_message(embeds=await show_proofs(arg), view=None)
      return True
  show_proofs.callback = other_callback
  view = View() 
  view.add_item(show_proofs)
  await message.channel.send(embed=add_embed(arg, users), view =view)

Here's the traceback:

    await interaction.response.edit_message(embeds=await show_proofs(arg), view=None)
  File "/interactions.py", line 791, in edit_message
    await adapter.create_interaction_response(
  File "/async_.py", line 219, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embeds.1.description: This field is required

Someone came across this?

paper sluice
#

ur embed needs to have a description

slate swan
#

How to send a cog help?

cerulean folio
#

it's confusing :o

cobalt jacinth
#

you can make 25 apps per account. any way to increase it ?

supple thorn
cobalt jacinth
#

okay thx

jagged adder
#

is there a way for a bot to send a user to a specific channel, rather than just pinging them in said channel?

#

as with my bot it would be kinda convenient to be able to type x command to 'start game' and it takes u directly there, esp if you're in a server with alot of channels (like one of my main servers has :p)

slate swan
slate swan
slate swan
jagged adder
#

alright, i wouldve sworn i had come across that before. alg

slate swan
jagged adder
#

yep

abstract kindle
#

Hey, can anyone help me with editing the thumbnail of an embed

#

Whenever I edit the message with a new embed, the old image just gets detached from the embed

slate swan
#

hi there, I'm using the <:name:id> format to use emojis in other servers but it just gives me this

and yeah I made sure it has the perms

jagged adder
#

how can i strip down a dict to just one of its keys when referencing it?

abstract kindle
#

The initial thumbnail

#

I'm trying something with Message.add_files() and Message.remove_attachments()

slate swan
#

if you are editing the thumbnail, the older one will get removed obviously

abstract kindle
#

I got it working, except it's a little sluggish

#

Like the old image gets removed and then the new image gets edited in as an attachment and then it pops on to the embed

slate swan
abstract kindle
#

I'm using set thumbnail

slate swan
#

weird

jagged adder
#

i have

Knife = {name: 'Knife', category: 'dagger', cond: 'used', dmg: 3, value: 25}

in Items.py

class NewGameState:
    def __init__(self):
        self.Inventory_Start = ['Backpack', Items.Knife]

in my class, and

 inv_string = ('__**Starter Gear**__', '\n'.join([f'- {obj}' for obj in state.Inventory_Start]))

in my inv check command

what i want to do is when i check the inv, only take the name attribute from the knife

slate swan
#

¯\_(ツ)_/¯

final geyser
#

I know this is pretty basic but I made a discord bot that scrapes images from the web. I’m pretty proud of it.

vocal snow
slate swan
slate swan
vocal snow
slate swan
jagged adder
#

in the basic sense ye, tho i dont know everything fr

#

still learning

vocal snow
#

Ok ignore me then

slate swan
#

lmaooo

#

but why use classes if you don't know how to use them.....

#

there are alternatives....(which are messier ofc)

#

buy the hacker plan, and nobody would steal the code, you know many big bots are open-sourced ¯\_(ツ)_/¯

#

So I have member: discord.Member
How do I get the member’s id and name?

unkempt canyonBOT
#

property name```
Equivalent to [`User.name`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User.name "discord.User.name")
slate swan
#

search the docs instead

slate swan
slate swan
#

create a license?

slate swan
slate swan
#

not really

#

depends on which vps and plans you buy and the vps's specs

#

max 10$ dollars i would pay for

#

see the pins

slate swan
#

im not richlemon_raised_eyebrow

jagged adder
# slate swan `Knife.get("name")`

the thing is im not tryin to only get one name, i want to be able to have a bunch of items that are later added to inv have the same thing done to them when i use the inv command. ie, i need a way of filtering out only the name for any item under one of my 'inv' categories

slate swan
#

10 dollars aint much though, so I take my words back

#

10 bucks a month max for me tbh

#

no

#

under powered machines

#

(copied from dpy)

  • Bots are not what the platform is designed for. Heroku is designed to provide web servers (like Django, Flask, etc). This is why they give you a domain name and open a port on their local emulator.

  • Heroku's environment is heavily containerized, making it significantly underpowered for a standard use case.

  • Heroku's environment is volatile. In order to handle the insane amount of users trying to use it for their own applications, Heroku will dispose your environment every time your application dies unless you pay.

  • Heroku has minimal system dependency control. If any of your Python requirements need C bindings (such as PyNaCl binding to libsodium, or lxml binding to libxml), they are unlikely to function properly, if at all, in a native environment. As such, you often need to resort to adding third-party buildpacks to facilitate otherwise normal CPython extension functionality. (This is the reason why voice doesn't work natively on heroku.)

  • Heroku only offers a limited amount of time on their free programme for your applications. If you exceed this limit, which you probably will, they'll shut down your application until your free credit resets.

#

😔 imagine having volatile storage

slate swan
#

Possible to do like
If the user uses ,daily today he gets 1500
If he uses ,daily tomorrow again he gets 3000
In simple words increasing 500 coins per ,daily
But if the user fails to use it for the next day reset the amount

slate swan
waxen ruin
#

hello..is there a way i can make my bot read commands from a webhook? Thanks

#

and ik we can do something with on_message, but i want to incorporate it with discord.ext commands

vocal snow
#

Are webhooks able to read messages? I thought they could only send

pliant gulch
vocal snow
#

Oh read commands from a webhook as in read commands... From a webhook

lyric apex
#

How to make embed image none?

slate swan
magic pond
#

why is it comming like this

dusky pine
#

i'd like to buy bathwater

magic pond
#
    @commands.command()
    async def shop(self,ctx):
      em = discord.Embed(title=f"Shop Items",colour=0x2f3136)
      for item in mainshop:
        name = item["name"]
        price = item["price"]
        desc = item["description"]
        em.add_field(
          name=name,
          value=f" :mw_reply: ` ${price} ` —  {desc}  ",inline=False)
        em.set_footer(text='Page (0/1)')
        await ctx.send(embed=em)

dusky pine
#

is it belle delphine's bath water

slate swan
#

How to make the bot send the numbers likes this 25,000 rather than 25000?

#

print("25,000")

#

ez

#

💀 ** **

#

I wouldn’t ask if it was that easy

#

..

#
users[str(ctx.author.id)]["bank"]
``` for this ^
#

its output is 25000

#

not 25,000

#

uh

#

wait

#

k*

visual island
#

!e
print(f"{20000:,}")

unkempt canyonBOT
#

@visual island :white_check_mark: Your eval job has completed with return code 0.

20,000
vale wing
slate swan
vale wing
#

And I made a whole function to write those things like that

#

Lmao

slate swan
visual island
slate swan
#

oh

#

["bank"]:, would work?

visual island
#

yes, if it's inside f-string expression, otherwise it won't

weak widget
#

Know anyone why the connection failure?

slate swan
#
Traceback (most recent call last):
  File "C:\Users\DEBARKA NASKAR\Desktop\Dank Frost\main.py", line 19, in <module>
    class HighLowView(discord.ui.View):
  File "C:\Users\DEBARKA NASKAR\Desktop\Dank Frost\main.py", line 61, in HighLowView
    async def Lower(self, interaction, button):
TypeError: 'Button' object is not callable```
#

why am i getting this error

slate swan
#

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

slate swan
#

@slate swan help

slate swan
slate swan
shrewd apex
#

also what's the global for?

tough anvil
#

hello... tried this code here, but getting this error. any idea what have i done wrong?

slate swan
#

the error quite says it all you need a colon

slate swan
#

and he needs to pass the token as a string lol

#
Traceback (most recent call last):
  File "C:\Users\DEBARKA NASKAR\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 200, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\DEBARKA NASKAR\Desktop\Dank Frost\main.py", line 82, in highlow
    users = await get_bank_data()
  File "C:\Users\DEBARKA NASKAR\Desktop\Dank Frost\main.py", line 106, in get_bank_data
    user = json.load(f)
  File "C:\Users\DEBARKA NASKAR\AppData\Local\Programs\Python\Python310\lib\json\__init__.py", line 293, in load
    return loads(fp.read(),
  File "C:\Users\DEBARKA NASKAR\AppData\Local\Programs\Python\Python310\lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "C:\Users\DEBARKA NASKAR\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\DEBARKA NASKAR\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\DEBARKA NASKAR\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1330, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\DEBARKA NASKAR\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 995, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "C:\Users\DEBARKA NASKAR\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 209, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: JSONDecodeError: Expecting value: line 1 column 1 (char 0)

why am i getting this

slate swan
slate swan
waxen ruin
slate swan
#

wl?

#

and why are you using that async iterator

#

you dont require it

slate swan
#

no

#

not about you...

#

somebody asked a question and deleted it wtf 😭

#

ash

#

have you tried rust?

#
Traceback (most recent call last):
  File "C:\Users\DEBARKA NASKAR\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 200, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\DEBARKA NASKAR\Desktop\Dank Frost\main.py", line 82, in highlow
    users = await get_bank_data()
  File "C:\Users\DEBARKA NASKAR\Desktop\Dank Frost\main.py", line 106, in get_bank_data
    user = json.load(f)
  File "C:\Users\DEBARKA NASKAR\AppData\Local\Programs\Python\Python310\lib\json\__init__.py", line 293, in load
    return loads(fp.read(),
  File "C:\Users\DEBARKA NASKAR\AppData\Local\Programs\Python\Python310\lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "C:\Users\DEBARKA NASKAR\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\DEBARKA NASKAR\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\DEBARKA NASKAR\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1330, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\DEBARKA NASKAR\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 995, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "C:\Users\DEBARKA NASKAR\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 209, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: JSONDecodeError: Expecting value: line 1 column 1 (char 0)

why am i getting this

#

what is f?

#

wut

#

in line 106

#
async def get_bank_data():
    with open("bank.json", "r") as f:
        user = json.load(f)

    return user
#

dis

#

well iirc the error raises when it tries to load invalid json

#

!e

import json
json.loads('')
unkempt canyonBOT
#

@slate swan :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 2, in <module>
003 |   File "/usr/local/lib/python3.10/json/__init__.py", line 346, in loads
004 |     return _default_decoder.decode(s)
005 |   File "/usr/local/lib/python3.10/json/decoder.py", line 337, in decode
006 |     obj, end = self.raw_decode(s, idx=_w(s, 0).end())
007 |   File "/usr/local/lib/python3.10/json/decoder.py", line 355, in raw_decode
008 |     raise JSONDecodeError("Expecting value", s, err.value) from None
009 | json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
slate swan
#

yep

#

oh k

#
async def create_account(user):

    users = await get_bank_data()

    if str(user.id) in users:
        return False
    else:
        users[str(user.id)] = {}
        users[str(user.id)]["wallet"] = 150000
        users[str(user.id)]["bank"] = 0

    return True

async def get_bank_data():
    with open("bank.json", "r") as f:
        user = json.load(f)

    return user

#

i have this tho

pure crypt
#

hi, how can i make that teh bot reply to the user’s message where he call 5he command?

slate swan
unkempt canyonBOT
#

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

A shortcut method to [`send()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context.send "discord.ext.commands.Context.send") to reply to the [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message") referenced by this context.

For interaction based contexts, this is the same as [`send()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context.send "discord.ext.commands.Context.send").

New in version 1.6.

Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") or [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError "(in Python v3.10)") instead of `InvalidArgument`.
slate swan
#

I was trying brainfuck though

slate swan
#

nice

#

yes

pure crypt
#

content=embed=embed doesn’t work

slate swan
#

just embed=embed

pure crypt
#

Ok

slate swan
slate swan
#

i dont like troll langs really

#

nice

pure crypt
#

How can i make that the bot add an emoji to his message and if the user clicks it it delets the message? I can’t find it in the docs

spring flax
#

!d discord.Message.add_reaction

unkempt canyonBOT
#

await add_reaction(emoji, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Adds a reaction to the message.

The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Emoji "discord.Emoji").

You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/latest/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/latest/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission is required.

Changed in version 2.0: `emoji` parameter is now positional-only.

Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") instead of `InvalidArgument`.
spring flax
#

!d discord.Message.delete

unkempt canyonBOT
#

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

Deletes the message.

Your own messages could be deleted without any proper permissions. However to delete other people’s messages, you need the [`manage_messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission.

Changed in version 1.1: Added the new `delay` keyword-only parameter.
slate swan
slate swan
heady sluice
shrewd apex
#

idk why is it that tough to make a dbpithink

slate swan
#

sql dbs are ezier than json

dusky pine
#

SQL is closer to english than... dictionaries.

#

INSERT INTO users VALUES ('sz_skill', 'password123'); looks better than db["users"].append(["sz_skill", "password123"])

dusky pine
lament mesa
#

admin abooz

dusky pine
#

i meant people could make alts and give their main money

swift pumice
#
async def mute(ctx):
    if ctx.author.guild_permissions.administrator == True:
        mute = ctx.guild.get_role (985475444981764106)
        await ctx.add_roles(mute)
        await ctx.send(f"{ctx.user.name} has been muted.")
    else:    
         await ctx.send("you are not adminstrator, noob")
``` why isnt this working ? it doesnt give an error
warped mirage
#

can u help me now?

slate swan
slate swan
swift pumice
#

ok wait

#
async def on_message(message):
    if message.author == bot.user:
            return    
    if message.channel.id == 987651665492586568 and message.content.lower() != "!verify":
        await message.delete()
        await message.channel.send(f'{message.author.mention}please only write !verify and not something other', delete_after=3)
    else:
        await bot.process_commands(message)```
slate swan
#

remove the await bot.process thing and change .event to .listen()

swift pumice
#

no all my other commands work, its not bot event problem its my code problem @slate swan

#

pls ping me if you answer cuz i wont see it if you dont

warped mirage
swift pumice
heady sluice
#

you can't add a role to a Context

#

you can add a role to a Member

#

ctx.user is also not a thing iirc

#

do you mean
!mute <ping someone>
and the pinged person is muted?

swift pumice
heady sluice
#

you want to take a Member as an argument

swift pumice
heady sluice
#

like this

#
async def mute(ctx, member):
#

then you can use
await member.add_roles(mute)

swift pumice
#
async def mute(ctx,member):
    if member.author.guild_permissions.administrator == True:
        mute = member.guild.get_role (985475444981764106)
        await member.add_roles(mute)
        await ctx.send(f"{ctx.user.name} has been muted.")
    else:    
         await ctx.send("you are not adminstrator, noob", delete_after=3)``` like this right?
heady sluice
#

it's good

swift pumice
#

thanks

heady sluice
#

but you might wanna send that the member was muted

#

not the person who used the command

swift pumice
#

thx

heady sluice
#

👍

#

oh wait @swift pumice lmao

swift pumice
#

huh?

#
async def mute(ctx,member):
    if member.author.guild_permissions.administrator == True:
        mute = member.guild.get_role (985475444981764106)
        await member.add_roles(mute)
        await ctx.send(f"{member.name} has been muted.")
    else:    
         await ctx.send("you are not adminstrator, noob", delete_after=3)
```like this?
heady sluice
#

you still have to use if ctx.author.guild_permissions.administrator == True:

heady sluice
#

ctx.author is the person who used the command

swift pumice
#

okay

heady sluice
#

member is the person who you pinged

swift pumice
#

thanks

#
async def mute(ctx,member):
    if ctx.author.guild_permissions.administrator == True:
        mute = member.guild.get_role (985475444981764106)
        await member.add_roles(mute)
        await ctx.send(f"{member.name} has been muted.")
    else:    
         await ctx.send("you are not adminstrator, noob", delete_after=3)
``` it still doesnt work? no error in console? like nothing happens @heady sluice
heady sluice
#

on_command_error event?

#

actually, do you have members intent?

swift pumice
swift pumice
heady sluice
#

!intents might just answer like this

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 Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

intents = Intents.default()
intents.members = True

bot = commands.Bot(command_prefix="!", intents=intents)

For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.

swift pumice
heady sluice
heady sluice
#
@bot.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.CommandNotFound):
        await ctx.send("**Invalid command. Try using** `help` **to figure out commands!**")
    elif isinstance(error, commands.MissingRequiredArgument):
        await ctx.send('**Please pass in all requirements.**')
    elif isinstance(error, commands.MissingPermissions):
        await ctx.send("**You dont have all the requirements or permissions for using this command :angry:**")
#

this is an example of a bad error handler

#

cuz it's missing else: raise error

swift pumice
#

oh ok

heady sluice
#

do you have smth like this

swift pumice
#

no

heady sluice
#

damn it moment

swift pumice
heady sluice
#

do other commands work

swift pumice
#

yes

#

@heady sluice

heady sluice
#

can you show another command

slate swan
heady sluice
swift pumice
heady sluice
#

yes

swift pumice
# heady sluice yes
async def userinfo(ctx,member: nextcord.Member = None):
    if member is None:
        member = ctx.author
    embedVar = nextcord.Embed(title="Information", description="Shows information of the user", color=0x00ff00)
    embedVar.add_field(name=f"{member.name}", value=f"{member.discriminator}", inline=False)
    embedVar.set_thumbnail(url=f"{member.avatar}")
    #embedVar.add_field(name=f"{member.joined_at}"),value=f"{"%b %d,%Y, %T"}", inline=False)
    embedVar.add_field(name=f"{'Discord account creation date'}", value=f'{member.created_at.strftime("%d %b %Y %H:%M")}', inline=False)
    await ctx.send(embed=embedVar)
heady sluice
#

weird

#

I wonder what would happen if you'd put an error in the userinfo command

swift pumice
#

can you maybe just tell me the problem or do you dont know it either?

heady sluice
#

absolutely no idea

swift pumice
#

damn

slate swan
heady sluice
#

more complicated

slate swan
heady sluice
#

yeah there's no other option for that

slate swan
#

?

#

Why are you telling me 💀

heady sluice
#

but please tell me you use a global error handler

swift pumice
slate swan
slate swan
#

Not you

swift pumice
#

oh ok

warped mirage
#

I need help someone

Making a slash command

slate swan
swift pumice
slate swan
swift pumice
slate swan
#

try it

shrewd apex
#

y?

#

i did tho...

swift pumice
cloud cairn
#

I cant figure out how to make a command like this "!image <Image.png>"

shrewd apex
#

what's this?

cloud cairn
#

So when i do like !image meme.png it will send the image from my ./image folder

swift pumice
#

ok

warped mirage
slate swan
#

@swift pumice wait

swift pumice
#

Im frustrated.

slate swan
#

Wait wait

swift pumice
#

I wanna kms

slate swan
#
@client.command()
async def mute(ctx,member: discord.Member):
    if member.guild_permissions.administrator == True:
        mute = member.guild.get_role(988041989406740551)
        await member.add_roles(mute)
        await ctx.send(f"{member.name} has been muted.")
    else:    
         await ctx.send("you are not adminstrator, noob", delete_after=3)
``` try this ^
#

change the role id btw

swift pumice
slate swan
slate swan
swift pumice
slate swan
#

np

cloud cairn
#

Why wont this work?

@client.event
async def on_message(msg):
    channel = msg.channel

    if msg.content == ('!image ', image):
        await channel.send(file=discord.File('./images/'+image)) 
#

Pretty new to Python :/

#

Wut?

heady sluice
#

to me the only logical thing would be if msg.content.startswith("!image") and msg.content.split(" ")[1]:

#

well no cuz he doesn't know what it could be

#

maybe he has a list of what the options are

heady sluice
#

I suppose the image folder has images, so he might wanna check the names of the images and check if msg.content.split(" ")[1] is one of those names

heady sluice
#

I hate the fact you don't use commands PurpleSkull

slate swan
#

why not use commands instead of an on_message event

cloud cairn
#

Doesn't want to work, or i might just imported it wrong :/

heady sluice
#

there's also the option someone just writes !image and doesn't get a response

cloud cairn
#

And after that?

await channel.send(file=discord.File('./images/'+image))
#

or am i just stupid

#

probably stupid

slate swan
#

image is not defined, is it?

heady sluice
#

msg.content.split()[1]

#

does split automatically split by spaces

cloud cairn
slate swan