#discord-bots

1 messages · Page 941 of 1

sick birch
#

I'm doing that on my host

final iron
#

tbh a really nice and simple explanation

silent ermine
spice adder
#

Repl is actually being blocked by uptime robot

sick birch
#

For a website you'll have to bind a port so a docker port is re-routed to your host port

cloud dawn
#

To be fair tough docker is overcomplicated. Could have been made a lot easier.

sick birch
#

With overcomplication comes extensive customizability which is suited in a professional environment

silent ermine
cloud dawn
#

Thus, not recommended for beginners.

sick birch
#

But I'm not privy to using a database within a docker container

#

I'm just running a postgresql database on my host machine

silent ermine
sick birch
#

Don't know if a docker container can access an external postgres, since it's meant to be isolated

sick birch
#

Docker actually has a postgres image

silent ermine
sick birch
#

So maybe I'm mistaken

silent ermine
#

Alright imma go, ty robin :)

sick birch
#

Cool, nice talking to you 👋

silent ermine
cloud dawn
#

Better if i go sleep as well ducky_drawing

sick birch
#

Night

cloud dawn
#

👋

boreal ravine
#

Why is this pinned?

austere vale
#

#help-bagel message @undone halo i used this code and i did this. is there a way to get it so that the embed updates with how much time is left?

undone halo
austere vale
#

oh how do i use timestamps?

boreal ravine
#

<t:unix timestamp> <t:999999>

buoyant zodiac
#

when i go 2 load my cog it says "Enable tracemalloc 2 get the object allocation trace back"

#

anyone know why

sick birch
buoyant zodiac
#

yea i j realized, thank you

#

no because it's not in a function it's j in the open

nova bear
#

im trying to see how many servers my bot is in by going
,servers
and i dont know where to start

buoyant zodiac
#

{len(bot.guilds)}

sick birch
#

Hint: bot.guilds returns a list of guilds your bot is in

nova bear
#

but where would i put that

buoyant zodiac
sick birch
#

Depends where you want to display it

buoyant zodiac
#

robin a pro i'll let him do the talking

nova bear
#

i want it to say how many it is in when i run the command

sick birch
#

For example:

@bot.command()
async def my_command(...):
  print(f"Bot is in {len(bot.guilds)} servers!")
#

I'll let you use that as an example to adapt it to your needs because printing to console isn't very helpful

nova bear
#

so if i replace my command with servers and ... with ctx and ctx instead of print would it do that

sick birch
#

I'm not quite following

nova bear
#

let me get an example

buoyant zodiac
#

await ctx.send(f"{len(bot.guilds)}

sick birch
#

That would be great

buoyant zodiac
#

the f string is very ugly

sick birch
buoyant zodiac
#

missing?

nova bear
#
@bot.command()
async def servers(ctx):
  await ctx.send(f"Bot is in {len(bot.guilds)} servers!")
buoyant zodiac
#

that would work

supple thorn
nova bear
#

there we go

#

thanks!

supple thorn
#

missing a " and misplaced the ending parenthesis

buoyant zodiac
#

oh yea 😭😭

#

but can anyone help me

#

how am i supposed 2 await bot.load_extension if it's not in a function?

#

do i HAVE 2 put it in one

sick birch
#

There are better places to load your extensions than your top-level

buoyant zodiac
#
  if filename.endswith(".py") and not filename.startswith("_"):
    bot.load_extension("cogs.{filename[:-3]")
buoyant zodiac
sick birch
#

I'm going to assume you're on d.py 2.0 because you mentioned load_extension needing to be awaited. In 2.0, you have a setup_hook you can run it in

buoyant zodiac
#

ye i'm on 2.0

sick birch
#

You can overwrite the default setup hook

#
async def MyBot(commands.Bot):
  def __init__(self, ...):
    # This is where we used to load_extension
  async def setup_hook(self):
    # This is where we want to load_extensions now. Keep in mind you can await it
    await do_something()
bot = MyBot(...)
hushed galleon
#

also another alternative is loading extensions in a main, async function and starting your bot from there

sick birch
#

Both are viable options, you pick which you feel to be easier

spice adder
#
    if message.author == client.user:
        return
    if str(message.channel.type) == "private":
        await add.reaction("✅")
``` Tried this as `message.add.reaction` and `client.add.reaction` with both had no "add" attributes, and as it is it says that "add is not defined"
sick birch
#

I prefer the main async function method becuase for the aforementioned fine-grained control, and also I like having a defined entry point into all my asynchronous programs

buoyant zodiac
proven birch
#

Why this is not working there is no errors

supple thorn
sick birch
spice adder
#

No shot I'veb [onqjwdiu[danwjk

supple thorn
#

!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/master/api.html#discord.Emoji "discord.Emoji").

You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission to use this. If nobody else has reacted to the message using this emoji, the [`add_reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission is required.

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`.
spice adder
#

God.

sick birch
# buoyant zodiac my main.py looks nothing like this, is that an issue?

Not an issue. I'm guessing this is how you do it:

bot = commands.Bot(...)

Most people do it that way, it's simpler. It also provides you with less control over your bot. Transitioning to a bot subclass isn't very difficult, in fact @spring flax (sorry for ping) is writing a guide on that to put up on the pydis site :)

spice adder
#

I need sleep, thank you

supple thorn
proven birch
#
py
@client.command()
async def syncofficials(ctx):
  if ctx.author.id == 771252695667310623:
    await ctx.send("Sorry")
  else: 
    return
  await ctx.send("Syncnorizing officials.")
  for user in ctx.guild.members:
    if "™️" in user.name:
      role = ctx.guild.get_role(958411325082591272)
      await user.add_roles(role)
sick birch
#

Define "not working"

proven birch
#

Actually I want to replace author with role id

spice adder
#

Also, this may be a good time to ask about this, but is there a way to sort of "slice out" a mention from a string of message.content?

sick birch
#

Just, remove it?

spice adder
#

One moment

proven birch
#

who is helping me

sick birch
#

Aha, I love it when this happens. You're looking for exactly discord.utils.escape_mentions(text)

spice adder
#

No way

sick birch
supple thorn
#

yeah still waiting for your answer

proven birch
#

The author id ones not working

#

When I send the cmd

sick birch
#

Again, what does "not working" mean

proven birch
#

It's not sending sorry

sick birch
#

What's it not sending?

#

"Sorry"?

proven birch
#

Yes

sick birch
#

Whose using the command? You?

proven birch
sick birch
#

That's why

#

It only sends "sorry" if you send the message

proven birch
#

But id there is not mine

#

Oh it's mine

sick birch
#

771252695667310623 is the ID there is it not?

#

And that's your ID yeah

proven birch
#

It's not sending sorry messagr

sick birch
#

Then there's a problem somewhere else

#

Try printing to see if the command gets picked up

proven birch
sick birch
#
@client.command()
async def syncofficials(ctx):
  print("command was called")
  ...
sick birch
#

Okay, now try printing this:

print(ctx.author.id == 771252695667310623)
sick birch
#

It prints "true"?

proven birch
#

Yes

sick birch
#

Can you show how your code looks like right now?

proven birch
#

Wait

#

Let me open dc on my laptop

proven birch
# sick birch Can you show how your code looks like right now?
@client.command()
async def syncofficials(ctx):
  print("Command Was Called")
  print(ctx.author.id == 771252695667310623)
  if ctx.author.id == 958421003921403995:
    await ctx.send("Sorry")
  else: 
    return
  await ctx.send("Syncnorizing officials.")
  for user in ctx.guild.members:
    if "™" in user.name:
      role = ctx.guild.get_role(958411325082591272)
      await user.add_roles(role)```
sick birch
#

Can you also add

await ctx.send("Command was called")

at the top?

#

It might be an issue where the bot's not able to send messages

spice adder
#

I have a feeling that I'm going about this the wrong way, so is there a good way to get a user object from a user ID in a message?

sick birch
#

Hmm something's not right

spice adder
#

Not quite, just starts with $

sick birch
#

If so, you can typehint it and discord.py will provide you with the appropriate object

#
@bot.command()
async def my_command(ctx, member: discord.Member):
  # member is a member object
  print(member.name)
spice adder
#

Oh wow, I was doing that in a very roundabout way

proven birch
#

bruh

sick birch
proven birch
sick birch
#

There we go

proven birch
sick birch
#

Now it's printing it isn't it

#

Or, rather, sending a message

proven birch
#

it said sorry but also performed the action

sick birch
#

Well yes

proven birch
#

actually it should not sync

sick birch
#

That's what your code is telling it to do

#

If you want that, your code should look like this:

proven birch
#

but i don't want it to be like this

sick birch
#
if ctx.author.id = someid:
  # say sorry
  return 
sick birch
#

What?

proven birch
#

how i will fix

#

i think there is mistake in return and else

sick birch
#

Don't use an else: return

proven birch
sick birch
#

Send the sorry message, then return immediately after

#
if ctx.author.id == 123:
  # say sorry
  return
# other stuff
spice adder
sick birch
#

So you want to check if a message starts with "$" and is in a certain channel?

proven birch
#

Thanks

spice adder
#

*under an on_message event

sick birch
#

Well you can leave out if it starts with "$" becuase command handlers won't be called anyway

#

And it's best to compare IDs rather than names

sterile imp
#
Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\impre\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\impre\OneDrive\Desktop\Vouch\main.py", line 85, in on_message
    await userCommands.vouch(message.author,
  File "C:\Users\impre\OneDrive\Desktop\Vouch\userCommands.py", line 24, in vouch
    vouchNum: int = d['VouchCount'] + 1
TypeError: can only concatenate list (not "int") to list```
sick birch
#

d['VouchCount'] is a list

proven birch
#

@sick birch btw

#

I did it wrong

spice adder
#

Mm, the last thing I tried was a \d{17,19} regex, and then used get_user on it, but that didn't seem to work petruccayy

sick birch
#

You're overcomplicating it

#

What do you want your bot to do if a message was sent in a certain channel?

sterile imp
#

@sick birch how do i fix it

sick birch
#

I'm gonna need a lot more information on that

spice adder
#

Here, I'll send the full code

sick birch
#

For example, what is d, where does it come from, what's it's defined structure, if any, etc

sick birch
#

yours is a relatively simple problem

spice adder
#

Gotchu

sick birch
#

But I need to know what you're doing if the message is sent in a certain channel

#
elif str(message.channel) == "channelname":
  # what here?
sterile imp
#
d = data.loadJSON(data.DATABASE_FILENAME)
    vouchNum: int = d['VouchCount'] + 1
    vouch = {
        'ID': vouchNum,
        'Giver': user.id,
        'Receiver': targetUser.id,
        'IsPositive': isPositive,
        'Message': message,
    }
    pendingVouches: list = d['PendingVouches']
    pendingVouches.append(vouch)
    data.updateJson(data.DATABASE_FILENAME, {
        'PendingVouches': pendingVouches,
        'VouchCount': vouchNum,
    })```
#

@sick birch ^

sick birch
#

I'm guessing VouchCount is a list

#

For some reason

spice adder
#
    elif str(message.channel) == "💌┃modmail" and message.content.startswith(
            "$ "):
        await message.add_reaction("✅")
        userids = re.findall("\d{17,19}", message.content())
        finaluserid = client.get_user(userids)
        member_object = message.mentions[0] or finaluserid
``` What I currently have
#

The upper part is the on_message handler for DMs

sick birch
#

So basically any message in a modmail channel?

spice adder
#

Well, messages starting with $ yes

sick birch
#

Starting with $ of course

sterile imp
sick birch
#

And what do you expect it to contain?

sick birch
spice adder
#

$ (mention/ID)

#

Which becomes the member object

sick birch
#

Why not use a command for that instead and save yourself some time

#

And get rid of that entire on_message

sterile imp
#

remove int?

sick birch
#
@bot.command()
async def modmail(ctx, member: discord.Member):
  # stuff
sick birch
#

And you need to make sure you're not dumping a list into it

proven birch
#

what i did ?

sick birch
proven birch
# sick birch Code?
@client.command()
async def syncofficials(ctx):
  await ctx.send("Command was called")
  print("Command Was Called")
  print(ctx.author.id == 771252695667310623)
  if ctx.role.id == 958572191681744898:
    await ctx.send("Syncnorizing officials.")
  for user in ctx.guild.members:
    if "™" in user.name:
      role = ctx.guild.get_role(958411325082591272)
      await user.add_roles(role)
      return
      await ctx.send("Sorry, This Command Is Only For Server Mods")```
sterile imp
#

rip im just gonna delete this bot idea/project :(

sick birch
#

ctx.role what are you trying to do?

#

Get all the roles of a user?

proven birch
sick birch
#

Which role?

proven birch
#

the role id

#

i have written after it

sick birch
#

So you want to check if a role is equal to itself?

spice adder
#

So on a command, if I put startswith (" ") will it require $ regardless?

sick birch
#

Commands will only be invoked if they start with your command prefix, yes

proven birch
#

i wannna check the user roles if he have role of the id i have wirtten then perfrom sync otherwise if he does not have the role then send sorry

sick birch
#

You don't have to check it yourself

sick birch
sterile imp
#

@sick birch my brother said to change int into list?

sick birch
#

The typehint?

#

That doesn't really matter. Python ignores typehints

proven birch
#

if role in ctx.author.roles: == 958572191681744898:

buoyant zodiac
#

does bot.users bring up a list of all the users inside the servers the bot is in?

proven birch
#

like this

sick birch
buoyant zodiac
#

okay thank you

sick birch
#

You need to check if a discord.Role object is in ctx.author.roles

proven birch
#

bruh

proven birch
#

wait listen carefully

sick birch
#

I know what you want to do, I've provided a solution

buoyant zodiac
#

if role in ctx.author.roles: ??

proven birch
#

i want that the cmd only can be executed by the server mod role and if the user is not having the mod role simply send sorry if it has the mod role then sync the officials

sick birch
#

So just use the has_role check?

proven birch
#

yaaa

proven birch
#

ok

buoyant zodiac
#

@unkempt canyon

proven birch
#

@commands.has_any_role('Library Devs', 'Moderators', 492212595072434186)

#

this will work for me?

#

commands.has

buoyant zodiac
#

the id

sick birch
#

Assuming your server has all of those roles yes

proven birch
buoyant zodiac
#

what the

proven birch
#

syntax error

buoyant zodiac
#

you did that

#

all wrong

austere solstice
buoyant zodiac
#
@client.command()
@commands.has_role(...)

is how it should be formatted if i'm not wrong

buoyant zodiac
austere solstice
#

must type name not id

wanton pebble
#

how can i check if a message is nsfw?

proven birch
#

it should send sorry

#

when i don't have mods role

buoyant zodiac
#

else:?

#

may you send the code so i can edit it?

austere solstice
#

try putting name

proven birch
#
@client.command()
@commands.has_any_role(958572191681744898)
async def syncofficials(ctx):
  await ctx.send("Syncnorizing officials.")
  for user in ctx.guild.members:
    if "™" in user.name:
      role = ctx.guild.get_role(958411325082591272)
      await user.add_roles(role)
      return
      await ctx.send("Sorry, This Command Is Only For Server Mods")```
buoyant zodiac
#
@client.command()
@commands.has_any_role(958572191681744898)
async def syncofficials(ctx):
  await ctx.send("Syncnorizing officials.")
  for user in ctx.guild.members:
    if "™" in user.name:
      role = ctx.guild.get_role(958411325082591272)
      await user.add_roles(role)
  else:   
      await ctx.send("Sorry, This Command Is Only For Server Mods")```
#

that is probably indented very wrong

austere solstice
austere solstice
#

not id

austere solstice
proven birch
austere solstice
austere solstice
#

its thinking that role id is role name

proven birch
#

if i have mod role

austere solstice
proven birch
austere solstice
#

hmm

proven birch
#

bruh id is not there

proven birch
austere solstice
austere solstice
proven birch
#

i only want by the role or id

snow ibex
#

return

#

if statement

#

i think it is doing what it is supposed to do

austere solstice
snow ibex
#

raise and error when the user doesnt have role

proven birch
#

it should send this

snow ibex
proven birch
#

if user is not having the mod role

hasty bison
#

Whats the command to message a user

austere solstice
#

it may work

proven birch
#

bruh

#

now i again need to go up and check for that code

hasty bison
austere solstice
austere solstice
hasty bison
#

Yeah

torn sail
#

!d discord.User.send

unkempt canyonBOT
#
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
austere solstice
# hasty bison Yeah

ok then

@client.command()
async def dm(ctx, user:discord.Member, *, msg):
     await user.send(msg)
hasty bison
#

How do i use

proven birch
#


@client.command()
async def syncofficials(ctx):
  for user in ctx.guild.members:
    if "mod" in user.role:
      await ctx.send("Syncnorizing officials.")
  for user in ctx.guild.members:
    if ":tm:" in user.name:
      role = ctx.guild.get_role(958411325082591272)
      await user.add_roles(role)
  else:  
    await ctx.send("Sorry, This Command Is Only For Server Mods")```
austere solstice
hasty bison
#

Yea

cyan aspen
#

Me also

proven birch
#

Member' object has no attribute 'role'

austere solstice
cyan aspen
#

hi

torn sail
austere solstice
torn sail
#

And you would need a role object not a string

austere solstice
torn sail
#

Or you could do [role.name for role in user.roles]

proven birch
#

after 10h one command is done

#

wow

torn sail
#

Nice

proven birch
#

works

austere solstice
#

with user.roles

proven birch
#

yes

torn sail
#

Yes

proven birch
#

any docs

#

pls

torn sail
#

!d discord.Member.timeout

unkempt canyonBOT
#

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

Applies a time out to a member until the specified date time or for the given [`datetime.timedelta`](https://docs.python.org/3/library/datetime.html#datetime.timedelta "(in Python v3.10)").

You must have the [`moderate_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.moderate_members "discord.Permissions.moderate_members") permission to use this.

This raises the same exceptions as [`edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member.edit "discord.Member.edit").
austere solstice
proven birch
#

ok thanks

#

i need datetime

boreal ravine
proven birch
boreal ravine
#

replit installs d.py 1.7.3 by default which is the stable branch

proven birch
#

so what should i do then

boreal ravine
#

install master branch inside the shell

#
pip install -U git+https://github.com/Rapptz/discord.py/
proven birch
#

like what command

#

ok

steep gulch
#

Is it possible to build a bot that can fetch answer to questions from the Web, e.g Website like, Stackoverflow e.t.c?

proven birch
#
async def timeout_user(*, user_id: int, guild_id: int, until):
    headers = {"Authorization": f"Bot {bot.http.token}"}
    url = f"https://discord.com/api/v9/guilds/{guild_id}/members/{user_id}"
    timeout = (datetime.datetime.utcnow() + datetime.timedelta(minutes=until)).isoformat()
    json = {'communication_disabled_until': timeout}
    async with bot.session.patch(url, json=json, headers=headers) as session:
        if session.status in range(200, 299):
           return True
        return False


@bot.command()
async def timeout(ctx: commands.Context, member: discord.Member, until: int):
    handshake = await timeout_user(user_id=member.id, guild_id=ctx.guild.id, until=until)
    if handshake:
         return await ctx.send(f"Successfully timed out user for {until} minutes.")
    await ctx.send("Something went wrong")```
boreal ravine
#

use v10 api

proven birch
#

it there v10 api in discord

proven birch
#

literally

#

v10

steep gulch
#

Thanks

spice adder
#
# unban logs
@client.event()
async def on_member_unban(guild, user):
  username = (str member.string)
  userid = (str member.id)
  unbanreason = (str reason)
  unbanembed = discord.Embed(title=(str "User " + memberid + "unbanned"))
  modlog = client.get_channel()
  await modlog.send()
```Not sure what I'm doing wrong, but I definitely know that I'm doing it wrong. (guild is predefined)
proven birch
#

any way to make a anti webhooks command

#

there is no version for discord

boreal ravine
torn sail
torn sail
#

And member.string isn’t a thing

kindred topaz
#

hello, need help with integrating spotify with my discord bot yo

boreal ravine
proven birch
spice adder
steep gulch
proven birch
proven birch
torn sail
#

Ur not closing the (

spice adder
proven birch
torn sail
torn sail
proven birch
torn sail
spice adder
#

And then for modlog = client.get_channel(881835799547609109) I'm getting invalid syntax

proven birch
torn sail
proven birch
#

where it is wrong tell me that

#

where ( is missing?

torn sail
#

No no sorry I looked at it wrong

proven birch
#

someone tell me what to do then

torn sail
#

What’s the problem

proven birch
#

but i have imported datetime

torn sail
#

Show the import

proven birch
torn sail
#

When u run it does it work

proven birch
torn sail
#

That’s not related to the code you sent

slate swan
#

for some reason my python discord bot can't send an emoji
I've trying to get it to send Haunt_Gift but it just won't no matter how I format it

can anyone help me?

proven birch
#

after install git dpy 2.0.0

spice adder
#
# ban and unban logs
@client.event()
async def on_member_unban(guild, user):
  username =  str(user.username + "#" user.discriminator)
  userid = str(user.id)
  thereason = str(reason)
  unbanembed = discord.Embed(title=(str( "User " + userid + "unbanned"))
  modlog = client.get_channel(881835799547609109)
  await modlog.send(embed = unbanembed)``` Alright so, I couldn't find anything in the docs for unban entries, so I assume there is a different way to add that, and I also am unsure as to what I'm doing wrong with user.discriminator (invalid syntax)
torn sail
torn sail
spice adder
#

Thanks!

#

Oof, now invalid sentax on modlog =...

#

I searched back through this channel for get channel, and it looks like I've got it right

maiden fable
#

Prolly a missing closing bracket in the former lines

spice adder
#

I have to be blind because I do not see anything like that

supple thorn
#

There's 3 parenthesis on the left side while theres only 2 on the right

vale wing
#

And why are you literally str'ing everything

#
unbanembed = discord.Embed(title=f"User {user} ({user.id}) unbanned")```
Easier and more clear
spice adder
#

Fixed

vale wing
#

And uh you never used username and reason

spice adder
#

Mhm, haven't made the embed yet

#

Not sure how to define reason / get one from the unban

vale wing
#

Audit logs is the only possible way ig

spice adder
#

I saw that in the docs for ban events, but not unban events

vale wing
#

Do unbans even support reasons

spice adder
#

They do not, though I have seen bots that do take it from the command / application and use that

vale wing
#

Nvm seems like they do

spice adder
#

Interesting, so how would you define reason with that?

vale wing
#

You can get it from iterating through audit logs and fetching the correct unban entry

#

The event does not send reason

spice adder
#

Gotcha, odd

south brook
supple thorn
south brook
#

help me

spice adder
#

Can you get reason from on_member_ban or is there a different way you need to do it

boreal ravine
#

fetch the ban -> use the reason property on the BanEntry object you get

lone flax
#

I recently got a discord bot which is going to be closed soon by the developer and he gave me his github repo of source code of that bot. So now I want to use that source code in a bot made by me
So bot we can create via discord developer option. But how to add that code file with that bot ??

minor totem
#

You need to run the bot files yourself, setup to log in using the bot token on Discord.

lone flax
#

I have that cloned in my kali

boreal ravine
lone flax
#

but files adding for that bot how will it done??

#

I want it to be a bot which works itself by commanding as other bots do

#

like probot and all

minor totem
#

Those other bits run their own code on servers

#

Discord does not host any bots

lone flax
#

oh

#

so I need to run that file myself with discord token

#

in my terminal

#

everytime I use it

spice adder
# boreal ravine fetch the ban -> use the `reason` property on the `BanEntry` object you get

Tried this and on reason.reason I'm getting invalid syntax

# ban and unban logs
@client.event
async def on_member_ban(guild, user):
  username =  str(user)
  userid = str(user.id)
  reason = guild.fetch.ban(user)
  banembed = discord.Embed(title=str(username + " banned"), description=str("🔨 **User ID:** " + userid + "\n📄 **Reason:** " reason.reason))
  modlog = client.get_channel(904806027025854544)
  await modlog.send(embed = banembed)
minor totem
spice adder
#

Oh God this is going to be one of those things where I see it and feel really stupid for missing it isn't it

minor totem
#

😅

spice adder
#

Mising... .. +

#

That, and now I'm getting that Guild has no attribute fetch

hollow carbon
#

hello guys I want to write a commands about when you type a date and then the bot ctx that date event

full vector
#

what does ctx mean?

hollow carbon
#

ctx = when you type a command and the bot send some words to u in the channel

#

yes?! I am not sure

maiden fable
unkempt canyonBOT
#
class discord.ext.commands.Context(*, message, bot, view, args=..., kwargs=..., prefix=None, command=None, invoked_with=None, invoked_parents=..., invoked_subcommand=None, ...)```
Represents the context in which a command is being invoked under.

This class contains a lot of meta data to help you understand more about the invocation context. This class is not created manually and is instead passed around to commands as the first parameter.

This class implements the [`Messageable`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable "discord.abc.Messageable") ABC.
supple thorn
#

what do you mean "ctx" that date?

hollow carbon
#

that mean i type 30/3

#

and bot send 30/3 is @hollow carbon birthday !

supple thorn
hollow carbon
#

yes!

supple thorn
hollow carbon
#

Em I guess I will add some important day

hollow carbon
supple thorn
gaunt ice
south brook
gaunt ice
#

and u can do like
await cat.send(oof)

supple thorn
hollow carbon
supple thorn
supple thorn
unkempt canyonBOT
#

@supple thorn :white_check_mark: Your eval job has completed with return code 0.

2022-08-30 00:00:00
hollow carbon
#

ok

regal pulsar
#
@start.error
async def on_start_error(ctx, error):
    embed = discord.Embed(
        title="Timed Out!",
        description="You Have Taken Too Long To Reply. Closing This Session.",
        color=0xFF5733,
    )
    if isinstance(error, asyncio.TimeoutError):
        await ctx.channel.send(embed=embed)
#

this embed wont send even when the error occurs

#

i bascially have a command called start which waits for a reaction on a message

#

you have 60 seconds to react or it returns an asyncio.TimeoutError

#

but

#

the message doesnt send

placid skiff
#

First of all the context is an object which refers to a message (or an interaction in case of slash commands) so the context has a send and reply object builtin, there is no need to use ctx.channel to send a message. Now let's come to your issue. wait for raises TimeoutError, but TimeoutError is not an object of discord.py so most you are trying to call a command error but it is raised by something else. So you should check the timeout error directly in your code and not in an error handler:

num = input("add a number")
try:
  result = int(num)**2
except TypeError as e:
  print(e)
slate swan
#

hi

supple thorn
slate swan
#

?

upbeat gust
lusty arch
#
import discord
import os

client = discord.Client()

@client.event
async def on_ready():
  print('we have logged in as {0.user}'.format(client))

@client.event
async def on_message(message):
  if message.author == client.user:
    return

  if message.content.startswith('$hello'):
    await message.channel.send('Hello there!')
    
client.run(os.getenv("token"))****
#

can someone tell whats wrong with this code? its not running

upbeat gust
upbeat gust
#

At all?

lusty arch
#

like i'm getting errors(a lot)

supple thorn
upbeat gust
lusty arch
supple thorn
#

Yes

upbeat gust
lusty arch
supple thorn
upbeat gust
#

just read the error

#

it shows that token.strip doesn't work because it's None, and look where you're passing in the token

#

Must mean that whatever ur passing in is none

upbeat gust
#

Comes with arg parsing and a lot more

lusty arch
#

yeah right, i'll do that

#

thank you!

upbeat gust
# lusty arch yeah right, i'll do that

If you need commands, use the commands extension.
Docs: https://discordpy.readthedocs.io/en/latest/ext/commands/commands.html

Why should I use the commands extension?

  • Prevents spaghetti code
  • Better performance
  • Easy handling and processing of command arguments
  • Argument type converters
  • Easy sub commands
  • Command cooldowns
  • Built-in help function
  • Easy prefix management
  • Command checks, for controlling when they're to be invoked
  • Ability to add command modules via extensions/cogs
  • Still able to do everything you can do with Client
lusty arch
#

okayyyy ty

upbeat gust
hybrid mural
#
class gif_cog(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        self.every_10_min.start()

why does the self.every_10_min.start() have to be awaited?

RuntimeError: no running event loop
sys:1: RuntimeWarning: coroutine 'Loop._loop' was never awaited

In the documentation it should work like that:

class MyCog(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        self.data = []
        self.batch_update.add_exception_type(asyncpg.PostgresConnectionError)
        self.batch_update.start()

    def cog_unload(self):
        self.batch_update.cancel()

    @tasks.loop(minutes=5.0)
    async def batch_update(self):
        async with self.bot.pool.acquire() as con:
vale wing
#

Loop can't be executed until bot is ready

#

I mean it can be but shouldn't

tough lance
#

Imagine coding discord bots

maiden fable
hybrid mural
#

nah that wasnt the problem

#

but it doesnt matter now tbh i removed it since i dont actually needed that loop

inland crest
#
@bot.event
async def on_message_edit(before , after , message):
    if message.author == bot.user:
        return
    
    else: 
        em = discord.Embed(title = f"{before.author} edited a message", color = discord.Color.random())
        em.add_field(name = "Before",value = before.content )
        em.add_field(name = "After",value = after.content, )
        await after.channel.send(embed=em)```
#

why this not work

#
Traceback (most recent call last):
  File "C:\Users\JOYED\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
TypeError: on_message_edit() missing 1 required positional argument: 'message'
``` the error
slate swan
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: Forbidden: 403 Forbidden (error code: 50007): Cannot send messages to this user

inland crest
#

dms closed

slate swan
inland crest
#

which

inland crest
ripe harness
#

Is there a way for me to accept command like .com p1 p1 p1 something else p2 p2 p2 (spaces between p2 should connect it into one variable same goes for p1)

#

apart from accepting entire command as one string

inland crest
#
@bot.event
async def on_member_remove(member,after):
    leave_channel = bot.get_channel(954347624612393001)
    modchannel = bot.get_channel(933966074955833445)
    em = discord.Embed(title = f"Goodbye Message" , color = discord.Color.gold())
    em.add_field(name = "Bye", value = "{member.mention} has left the server :sob:", inline=False)
    await after.channel.send(embed=em)

    try:
        await member.send(f"Hey {member.display_name}! goodbye")
    except:
        await modchannel.send(f"{member.mention} I can't dm you, but goodbye")``` @slate swan
#

try except

supple thorn
unkempt canyonBOT
#

discord.on_message_edit(before, after)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") receives an update event. If the message is not found in the internal message cache, then these events will not be called. Messages might not be in cache if the message is too old or the client is participating in high traffic guilds.

If this occurs increase the [`max_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") parameter or use the [`on_raw_message_edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_message_edit "discord.on_raw_message_edit") event instead.

The following non-exhaustive cases trigger this event...
slate swan
#

thanks bro

inland crest
#

np

inland crest
#

its a different cmd

#

i dont think he'll need that command

supple thorn
inland crest
#

tru but.... hell still understand ig

#

now spoonfeed me

#

kek i didnt get that

inland crest
supple thorn
#

I'll just hint at it

ripe harness
#

Jorden do you know bot call for command formating

inland crest
#

nope

#

im only coding since 2 years

supple thorn
#

It's only before and after

inland crest
#

brb

slate swan
#

HI

inland crest
#
@bot.event
async def on_message_edit(before , after , self):
    if before.author == self:
        return
    
    else: 
        em = discord.Embed(title = f"{before.author} edited a message", color = discord.Color.random())
        em.add_field(name = "Before",value = before.content )
        em.add_field(name = "After",value = after.content, )
        await after.channel.send(embed=em) ``` @supple thorn this?
inland crest
#

damn

supple thorn
#

I wonder what you learned the past 2 years

slate swan
#

😑

ripe harness
# supple thorn What

I want to get 2 parameters from command with multiple spaces ie. .pizza spicy and crusty (and then another) ingredient1 ingredient2

supple thorn
#

It's only just before and after

ripe harness
#

and well some params in between

inland crest
ripe harness
#

does " " format command as single parameter

inland crest
#
        return```
#

i foud this

inland crest
#

is this the thing i need to do

supple thorn
#

No

#

I literally told you what you only need

inland crest
#

im rubyed up

#

im 13 too

supple thorn
#

So?

inland crest
#

i dont understand

#

squat

supple thorn
#

That code isn't even close to your problem

#

What

inland crest
#

its how i tacked it in my last bot

#

kek

slate swan
#

should i open my vsc now?

supple thorn
#

Yes

slate swan
#

im felling tired

#
  • bored
supple thorn
#

Why are you asking us if you should open vsc?

inland crest
#

then sleeeeeep

supple thorn
#

.pizza "pepperoni" "pineapple" "cheese"

#

Like that?

ripe harness
#

when you read comamnd in bot it's like ctx param1 param2 param3 right, I want that param1 and param2 accept multiple words

slate swan
supple thorn
ripe harness
#

in my bot he'd be blacklisted 😄

slate swan
#

🍍 + 🍕 = 💥

supple thorn
ripe harness
#

well i couldn't blacklist you since you helped me

slate swan
#

.pizza cokecane

supple thorn
ripe harness
#

sparky have u ever tried it?

slate swan
#

🥫 + 🍕 = CokeCane

#

nvmd ot

ripe harness
slate swan
#

never

ripe harness
slate swan
#

never

supple thorn
#

I haven't

ripe harness
#

then how do you know it's bad

#

I mean it isn't good good but you ll live

supple thorn
#

I only said pineapple cause it's quite popular here

#

I don't like pizza that much

slate swan
ripe harness
#

is it edible

supple thorn
#

I can eat it without puking but i won't enjoy it

slate swan
#

how u tried ice cream soup?

ripe harness
#

but yeah i know what u mean 😄 i'd love to argue but u got me 😄

#

i fold

supple thorn
slate swan
supple thorn
#

I have eaten melted ice cream

ripe harness
slate swan
supple thorn
#

I still prefer the cold version

slate swan
#

how do I delete all discord messages sent by bot

#

so like the idea is the bot deletes every messages it ever sent in DMs or servers

slate swan
supple thorn
unkempt canyonBOT
#

await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=False, bulk=True, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.

You must have the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to delete messages even if they are your own. The [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission is also needed to retrieve message history.

Changed in version 2.0: The `reason` keyword-only parameter was added.

Examples

Deleting bot’s messages...
slate swan
#

how can i send this to a specific channel using the channel = bot.get_channel() ? I'm using the modal feature

    async def callback(self, interaction: discord.Interaction):
        embed = discord.Embed(color=discord.Color.blurple(), description=self.children[0].value)
        await interaction.response.send_message(embeds=[embed])
slate swan
supple thorn
#

There's a check kwarg

supple thorn
slate swan
#

he mean delete_after ?

supple thorn
#

All

#

Messages

slate swan
#

ban him!

#

easy

#

hmm

#

wait lemme try something

supple thorn
#

Or when it sends a message it deletes it after

slate swan
#

ok im opening vsc now

slate swan
#

some sort of self destruction

supple thorn
slate swan
#

.

supple thorn
#

With the check kwarg

slate swan
#

will try

#

channel.history()?

supple thorn
#

You can only delete 100 at a time though

slate swan
#
@bot.listen("on_message")
async def on_message(message):
    embeds = message.embeds
    if len(embeds) != 1:
        return
    
    embed = embeds[0]
    emb_dict = embed.to_dict()
    if message.author.bot:
        if emb_dict["title"] == "No new tasks.":
            Success = False
        elif emb_dict["title"] == "Task detected!":
            Success = True
        else:
            return
        channel = bot.get_channel(937661345531330590)
        if Success is False:
            delay = emb_dict["fields"][1]["value"]
            type = emb_dict["fields"][0]["value"]
            await channel.send(f"Got a task in {delay}, task is {type}")
        elif Success is True:
            delay = emb_dict["fields"][1]["value"]
            type = emb_dict["fields"][0]["value"]
            if type == "Shopping" or type == "Brushing teeth":
                await channel.send(f"![Toothbrush](https://cdn.discordapp.com/emojis/938786686622650398.webp?size=128 "Toothbrush") Got a shopping or toothbrushing task!")
            elif type == "Showering" or type == "Carwashing!":
                await channel.send(f"![Carsss](https://cdn.discordapp.com/emojis/938786686748463174.webp?size=128 "Carsss")Got a carwashing or showering task!")
            aboutuschnl = bot.get_channel(937742734339485766)
            mesg = await aboutuschnl.fetch_message(956227850191659018)
            claims = mesg.content.split("`")[1]
            aboutmemsg = f"**We've got a total of `{int(claims) + 1}` Tasks, have fun in the server!"
            await mesg.edit(content=aboutmemsg)```
When success is True, it doesn't send a message to the channel and gives me this error.
local variable 'msg' referenced before assignment
supple thorn
#

Closest variable i can find is mesg

slate swan
#

You are right that code is not the code I had when I had that error

#

I tried fixing it somehow but it still didn't work

supple thorn
#

Also did you save the new changes before running it?

slate swan
#

Yes I did that yesterday and lost access to old code

#

but there's no error now which I find weird as it doesn't send a message

#

I am currently trying to send a webhook which should give me some error

supple thorn
#

It'll only send a message to the channel if it triggers one of the if statements

slate swan
#
            elif Success is True:
            delay = emb_dict["fields"][1]["value"]
            type = emb_dict["fields"][0]["value"]
            if type == "Shopping" or type == "Brushing teeth":
                await channel.send(f"![Toothbrush](https://cdn.discordapp.com/emojis/938786686622650398.webp?size=128 "Toothbrush") Got a shopping or toothbrushing task!")
            elif type == "Showering" or type == "Carwashing!":
                await channel.send(f"![Carsss](https://cdn.discordapp.com/emojis/938786686748463174.webp?size=128 "Carsss")Got a carwashing or showering task!")
            aboutuschnl = bot.get_channel(937742734339485766)
            mesg = await aboutuschnl.fetch_message(956227850191659018)
            claims = mesg.content.split("`")[1]
            aboutmemsg = f"**We've got a total of `{int(claims) + 1}` Tasks, have fun in the server!"
            await mesg.edit(content=aboutmemsg)```
this code
supple thorn
#

Because if you aren't it won't send a message

#

It'll only edit a message

slate swan
#

Uh yeah so basically a webhook is sent with as title
Task detected!
and when that happens it should send a message to the channel

slate swan
supple thorn
slate swan
#

yes

#

the elif Success is True

supple thorn
#

Print it

slate swan
#

what do you mean with type

supple thorn
#

And tell me what it says

supple thorn
slate swan
#

Success.type() ?

supple thorn
#

No

#

Your type variable

slate swan
#

Ohhh

#

sorry damn

#

Oh bruh

#

ur so smart

supple thorn
#

It's different from what you thought it was

slate swan
#

The type variable was not
Brushing teeth
but it was
Brushing teeth

#

Something I should've thought of from the beginning 😢

supple thorn
#

I guess you can fix it now

slate swan
#

Thanks a lot!

hybrid mural
#

is there a way to change items in a view?

slate swan
#
        self.bot.add_view(view=RowButtons(self.bot)) 

#

this not working

#

i restart the bot

#

but button not working

#

!d discord.ext.commands.Bot.add_view

unkempt canyonBOT
#

add_view(view, *, message_id=None)```
Registers a [`View`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.ui.View "discord.ui.View") for persistent listening.

This method should be used for when a view is comprised of components that last longer than the lifecycle of the program.

New in version 2.0.
hybrid mural
#

@slate swan are you familiar with the tictactoe from discord py git

slate swan
#

see the arguments

spice adder
#

Is it at all possible to use the API to search how many times a specific word has been said? I.e. $search (word) - Word has been said 17 times

spice adder
slate swan
hybrid mural
#

basically im trying to implement a way of playing against a bot

#

just simple random thinking no logic

#

the only thing i have a problem with is accessing the buttons through the view

slate swan
#

hm I see

#

accessing the buttons as in?

hybrid mural
#

just simply changing some button things as style, name etc...

slate swan
#

ok

#

I'm too bad with views smh

#

i have added view but

hybrid mural
slate swan
slate swan
hybrid mural
#

I mean know python as in being a pro in python

slate swan
#

xD

#

ok can anyone help

#

:<

hybrid mural
#

you didnt even ask the question

slate swan
#

do u see my question

#

?

slate swan
#

hm?

#

and is self.bot even valid

#

plus you are not mentioning a message id

hybrid mural
#

wait

#

i dont even understand the bot.add_view()

slate swan
#
class RowButtons(disnake.ui.View):
     def __init__(self , bot: commands.Bot):
         self.bot = bot
         super().__init__(timeout=None)
     @disnake.ui.button(label="Create ticket", style=ButtonStyle.blurple)
     async def first_button(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):
#

ah i see

hybrid mural
#

You are supposed to send views

#

not add them

slate swan
slate swan
#

idk why you made it that complicated

upbeat gust
#

its not the same thing

hybrid mural
#

Yeah but if hes complaining of not seeing them then thats the issue

slate swan
#

edit the view after adding new components

slate swan
slate swan
#

what to edit

slate swan
#

how?

#

wdym??

hybrid mural
#

ctx.send(view=RowButtons)

slate swan
#

oh wait

#

nvm

slate swan
upbeat gust
#

no guys

#

adding the view is supposed to make it persistent

#

so it works after restarting

slate swan
#

yes!

#

i want my button to work after restart

upbeat gust
# slate swan yes!

so youve sent the view and stuff works, and then restart and nothing works

slate swan
#

yup

hybrid mural
#

Ah ok now i get it

slate swan
hybrid mural
#

relax i meant i get what the problem is

slate swan
#

ok whats the problem?

hybrid mural
#

no i get what your problem is

slate swan
#

bruh

hybrid mural
#

do you get an error?

slate swan
#

no

upbeat gust
slate swan
#

im using disnake

upbeat gust
#

ive never even heard of that

upbeat gust
slate swan
#

its official?

#

when you realise pycord is not the only fork

#

😑

slate swan
#

only 1.3k members ;-;

upbeat gust
upbeat gust
slate swan
#

only

slate swan
upbeat gust
slate swan
#

ok im shifting to discord 2.0

#

enhanced dpy & Disnake as an instance

#

lemee change my code

upbeat gust
slate swan
#

and then ill ask

upbeat gust
#

install link

slate swan
#

install link?

#

github i mean

upbeat gust
slate swan
upbeat gust
upbeat gust
upbeat gust
#

oop-

supple thorn
unkempt canyonBOT
#

async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.10)") that enables receiving the destination’s message history.

You must have [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.

Examples

Usage...
upbeat gust
slate swan
#

i tested it today and it didnt work

#

got it

#

lol

#

i forgot to remove it

#

i added that it in main file

#

and today i open and i continue with that i didnt see the main

#

nvmd

#

name changed hmm

#

i have done

#

that u said

#

first py

upbeat gust
#

discordpy is quite advanced so make sure you you're comfortable with py first

snow ibex
#

It's always a bad idea to jump into a library without knowing the language from personal experience it has never went well

slate swan
#

Completed my bot 👌 thanks for all the help y'all gave 👌💀

snow ibex
#

💀

jade garden
#

how to mention him?

heavy folio
#

f string

slate swan
maiden fable
#

Not supported the last time I checked iirc

tough lance
#

Danny said he would add that but who knows when

maiden fable
#

Yea

magic ore
#

You can make application commands in cogs

spring flax
#

anyone familiar with slash commands?

magic ore
#

You use the app_commands.command decorator within the cog and it will automatically get added to the bot's tree once you add the cog

jade garden
slim ibex
#

You have to import it

jade garden
slim ibex
#

Seems like you are trying to access a ui attribute on discord. Can I see your imports? It should work if discord is imported

slate swan
#
@bot.command()
@commands.has_any_role(692760082085183519, 940008547993927691, 863878825376743475, 902292952381001779, 863879069253894166, 902292952381001779, 863879304110276668, 940008547993927691)
async def пред(ctx, member: discord.Member = None, *, reason = None):
    print(45)
    cursor.execute("""CREATE TABLE IF NOT EXISTS warning(guild_id BIGINT, user_id BIGINT PRIMARY KEY NOT NULL, warns INT, count INT, moderator_id BIGINT, reasons VARCHAR)""")
    base.commit()
    print(1)
    print(name)
    
    
    warnings = cursor.execute("SELECT * FROM warning WHERE user_id = ?", (member.id,)).fetchone()
    print("работает")
    

    if member is None:
        await ctx.send("Выберите участника")
        return
        
    if reason is None:
       try:
           cursor.execute('INSERT INTO warning(guild_id, user_id, warns, count, moderator_id, reasons) VALUES(?, ?, ?, ?, ?, ?)', (ctx.guild.id,member.id,0,1,ctx.author.id,'Отсутствует'))
           base.commit()
       except Exception as e:
           print(repr(e))
       print(2222)
       cursor.execute(f'UPDATE warning SET warns = {warnings[2] + 1} WHERE user_id = ? AND guild_id = ?', (member.id, ctx.guild.id))
       base.commit()
       await ctx.send(f"**{ctx.author.name}** Выдал предупреждение # {member} (случай # )")
    else:
       cursor.execute('INSERT INTO warning (guild_id, user_id, warns, count, moderator_id, reasons) VALUES(?, ?, ?, ?, ?, ?)', (ctx.guild.id,member.id,0,1, ctx.author.id, reason))
       base.commit() 
       cursor.execute(f'UPDATE warning SET warns = {warnings[2] + 1} WHERE user_id = ? AND guild_id = ?', (member.id, ctx.guild.id))
       base.commit()
       await ctx.send(f"**{ctx.author.name}** Выдал предупреждение # {member}, причина {reason}. (случай # )")
        

error: OperationalError: no such column: user_id

slim ibex
#

error is clear

spring flax
#

i have a note main command where the user where the slash command is note create [name] [content].
Once it's made it is put into a database, and a user can only make notes for himself.
I want a show subcommand where the user can view one of his notes. The arguments would be /note show [note name] and I want to know whether its possible to make it so that when the user just types /note show and is on the argument of note name all his available notes appear in the list

slate swan
slim ibex
#

you realize that execute can be replaced with fetchone afaik

slim ibex
#

what’s this reaction menu thing

jade garden
cold sonnet
#

dpy slash commands example

jade garden
slim ibex
jade garden
slim ibex
#

no. It’s included with dpy iirc

jade garden
#

@slim ibexcan u come vc?

slim ibex
#

no unfortunately

spring flax
#

@slim ibex familiar with slash commands?

jade garden
#

@slim ibex

#

now gettings this

slim ibex
cold sonnet
jade garden
cold sonnet
#

that's not a little bit of help

cold sonnet
slim ibex
#

It also seems like you might want a slash command group

#

ah yeah you said you want a sub command 👍

spring flax
brisk zodiac
#

I am trying to make a code to change a float into an integer but when i typed !number 9.2 it didn't say anything.

@client.command()
async def number(ctx, amount: int):
    await ctx.send((int(amount)))```This is my code
spring flax
#

don't typehint to int if you're putting a float.

#

then it'll only accept int as the amount

cold sonnet
#

you return a tuple

#

well that's weird

spring flax
slate swan
jade garden
slim ibex
#

you might have to do separate queries to get specific parts of the note, if you have that

spring flax
#

is it even possible? I'm not sure

fading harness
fading harness
fading harness
jade garden
fading harness
jade garden
fading harness
jade garden
fading harness
spring flax
slate swan
jade garden
fading harness
slate swan
#

master lol

fading harness
slate swan
#

or go on github and use git

#

so no need lmao

fading harness
#

2.0 is still in beta

tough lance
#

git clone

slate swan
#

^

fading harness
tough lance
jade garden
#

how to do gitclone?

supple thorn
#

More ducks are appearing

jade garden
fading harness
#

by this iirc

pip install git+https://github.com/Rapptz/discord.py
slate swan
#

i just use disnake i mostly like its impl better than dpys

jade garden
fading harness
#

just google "how to install git on windows"

#

also are you new to coding?

boreal ravine
fading harness
#

id recommend learning some basic python before coding a discord bot

boreal ravine
# spring flax yes

Well, if you're using SQL get all of the columns that match the users ID, and then add autocomplete to the slash command I guess

cold sonnet
#

moai I got a warning for this

tough lance
#

Wat

jade garden
slate swan
#

and not very python related either

slim ibex
cold sonnet
#

don't take it word to word...

slim ibex
#

but yeah Kayle and okimii are right

#

okimii 🤖

slate swan
#

bro

#

why you capitalize kayles name but not mine am i not honorable AG_WorrySadge

slim ibex
#

it was autocorrect

cold sonnet
#

why don't you capitalize Kayle's name

slate swan
slate swan
slim ibex
#

mina 👀

daring olive
#

!mute 920688804082352198 to follow up your warning and the clarification we gave in modmail by bringing attention again to your very inappropriate message is not the behavior we expect on this server

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied mute to @cold sonnet until <t:1648647004:f> (59 minutes and 59 seconds).

slim ibex
#

o

slate swan
#

.topic

lament depotBOT
#
**What feature would you like to see added to the library? What feature in the library do you think is redundant?**

Suggest more topics here!

daring olive
daring olive
#

I still didn't try whatever resource you guys pointed me to the other day

sage otter
#

That can return an asset for either or.

#

!d discord.Member.display_avatar

unkempt canyonBOT
#

property display_avatar```
Returns the member’s display avatar.

For regular members this is just their avatar, but if they have a guild specific avatar then that is returned instead.

New in version 2.0.
daring olive
#

yeah, if a user has a different global and server pfp, i'd like a way to get both

sage otter
#

Oh yeah, there’s different properties for those

#

!d discord.Member.guild_avatar

unkempt canyonBOT
#

property guild_avatar```
Returns an [`Asset`](https://discordpy.readthedocs.io/en/master/api.html#discord.Asset "discord.Asset") for the guild avatar the member has. If unavailable, `None` is returned.

New in version 2.0.
boreal ravine
sage otter
#

And you can just use Member.avatar for global

sage otter
boreal ravine
#

imayhaveborkedit?

slate swan
#

Hi

sage otter
boreal ravine
#

I see

boreal ravine
slate swan
#

👋

hybrid mural
#

How do i check if the discord.Member is a bot?

#

bruh

sage otter
#

!d discord.Member.bot

unkempt canyonBOT
#

property bot```
Equivalent to [`User.bot`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.bot "discord.User.bot")
hybrid mural
#

ah ok i suspected

#

so tehnically if discord.Member == discord.Member.bot

#

right?

sage otter
#

no

#

You can just be like

#

if Member.bot:

hybrid mural
#

ah discord.Member.bot == True

boreal ravine
sage otter
#

That works I guess.

#

But you gotta replace discord.Member with your actual member object

hybrid mural
#

yeah i know

#

ty