#discord-bots

1 messages · Page 667 of 1

full valley
#

import random
insult = random.choice(list3)

#

thats what I would do shrug

sinful pasture
#

ill try, ive already got random imported

sinful pasture
#

it works

#

les go

full valley
#

awesome :)

sinful pasture
#

ty

full valley
#

nw

#

without other libraries

gaunt wedge
full valley
#

I believe not, 1 sec

gaunt wedge
#

ok

slate swan
#

Hii

#

How to add images in a discord bot

#

Plss helpđŸ„ș

dapper cobalt
slate swan
#

What is

#

Eloborate

#

explain

#

What?

sinful pasture
#

elucidate

slate swan
#

what do you mean by "add images in a discord bot"

dapper cobalt
slate swan
#

I just need code to add images in discord bot

#

add images to what?

dapper cobalt
slate swan
#

The discord botttt

dapper cobalt
velvet tinsel
#

You mean send images?

#

Bruh

slate swan
#

Yas

#

Kkkkk

#

send?

#

Yessss

velvet tinsel
#

Finally

slate swan
#

!d discord.TextChannel.send

unkempt canyonBOT
#

await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=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.9)") 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.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
dapper cobalt
#

!d discord.abc.Messageable.send

unkempt canyonBOT
#

await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=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.9)") 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.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
slate swan
#

;-;

slate swan
velvet tinsel
#

Bruh

#

That’s what I say

weary gale
#
@bot.command()
async def userinfo(ctx, member: discord.Member):

    roles = [role for role in member.roles]

    embed = discord.Embed(colour=member.color, timestamp=ctx.message.created_at)

    embed.set_author(name=f"user info - {member}")
    embed.set_thumbnail(url=member.avatar_url)
    embed.set_footer(text=f"requested by {ctx.author}", icon_url=ctx.author.avatar_url)

    embed.add_field(name="ID:", value=member.id)
    embed.add_field(name="guild name:", value=member.display_name)

    embed.add_field(name="created at:", value=member.created_at.strftime("%a, %#d %B %Y, %I:%M %p UTC"))
    embed.add_field(name="joined at:", value=member.joined_at("%a, %#d %B %Y, %I:%M %p UTC"))

    embed.add_field(name=f"roles ({len(roles)})", value=" ".join([role.mention for role in Roles]))
    embed.add_field(name="top role:", value=member.top_role.mention)

    embed.add_field(name="bot?", value=member.bot)

    await ctx.send(embed=embed)```
can anybody think of a reason why this wouldnt work?
sinful pasture
#

damn another problem with my dadjokes bot

velvet tinsel
#

;-;

velvet tinsel
#

Just saying it won’t work doesn’t help

#

Is there an error? Is the bot sending something it shouldn’t?

slate swan
#

Hmmmm

velvet tinsel
#

Is the bot not responding?

weary gale
# slate swan error?

Ignoring exception in command userinfo:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 855, in invoke
await self.prepare(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 789, in prepare
await self._parse_arguments(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 697, in _parse_arguments
transformed = await self.transform(ctx, param)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 542, in transform
raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: member is a required argument that is missing.

slate swan
#

I am a noob at phyton idk this stuff

slate swan
sinful pasture
velvet tinsel
dapper cobalt
unkempt canyonBOT
#
Resources

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

gaunt wedge
velvet tinsel
#

Is what I try to say to beginners

weary gale
#

i didnt?

velvet tinsel
#

They don’t listen

slate swan
#

Aa

velvet tinsel
slate swan
#

I don't like to learn tho

velvet tinsel
#

it should be ctx.author I think

weary gale
#

oh

velvet tinsel
#

My mobile 😭

gaunt wedge
velvet tinsel
slate swan
velvet tinsel
#

Bruh

velvet tinsel
slate swan
#

learning is useful

velvet tinsel
sinful pasture
#

I did not write the line which returns if author is the bot itself and set 5 seconds delay, I wanted a random dadjoke every 5 seconds and I get this



@client.event
async def on_message(message):
  if message.content.startswith('ă…€'):
    await message.channel.send(dadjoke)
    time.sleep(5)```
wanton veldt
#

help?
code

@unban.error
async def unban_error(ctx, error):
   if isinstance(error, MissingPermissions):
       await ctx.send("You don't have permission to unban members.")
  if isinstance(error, MemberNotFound):
       await ctx.send("test")

Error

File "/app/main.py", line 100
if isinstance(error, MemberNotFound):                                                           ^
IndentationError: unindent does not match any outer indentation level
``` the error is after :
weary gale
velvet tinsel
#

Uh

#

Await self.transform

slate swan
#

It would be really cool if coding was easy
Like u can just tell a bot what to make and the bot will make it for u

velvet tinsel
#

You did ctx

velvet tinsel
dapper cobalt
velvet tinsel
#

Ok

slate swan
velvet tinsel
slate swan
#

same

velvet tinsel
#

Than in an entire day of school

#

Or week sometimes

gaunt wedge
velvet tinsel
#

I got kicked out of maths class because I didn’t hand in homework but that’s because I was coding

weary gale
#

bing chilling

sinful pasture
velvet tinsel
weary gale
gaunt wedge
#

how do i handle buttons?

velvet tinsel
#

you need to make an if statement

slate swan
velvet tinsel
#

And then

#

Send it

dapper cobalt
slate swan
dapper cobalt
velvet tinsel
slate swan
slate swan
velvet tinsel
#

💀

velvet tinsel
wanton veldt
#

help?

@unban.error
async def unban_error(ctx, error):
   if isinstance(error, MissingPermissions):
       await ctx.send("You don't have permission to unban members.")
  if isinstance(error, MemberNotFound):
       await ctx.send("test")
sinful pasture
gaunt wedge
velvet tinsel
#

It shouldn’t do that

#

I have mobile so idk what’s going on

slate swan
dapper cobalt
#

!indent

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

velvet tinsel
#

I hate teaching people indents tbh

#

Thanks for the command

gaunt wedge
#

bro how do i handle button clicks 😌

slate swan
#

I checked YouTube I found a video
But they showed how to make a image discord bot but idk what is class in phyton so I was looking for a easy tutorial

velvet tinsel
sinful pasture
# slate swan why dont you just use commands?

well, i want to troll my friend you see, its just, if the message starts with a hangul filler, it sends dad joke, all jokes start with hangul filler so it do be yeeting dad jokes (no self-activation prevention :))

wanton veldt
weary gale
velvet tinsel
sinful pasture
#

:C

dapper cobalt
velvet tinsel
slate swan
sinful pasture
#

is there a discord server for discord bot stuff

velvet tinsel
#

Discord py server

slate swan
#

@velvet tinsel

#

thats a ping

slate swan
velvet tinsel
#

Yeah I know what ping is

#

I didn’t realise it was supposed to pass a mention

gaunt wedge
#

....how add button click handler 😭

velvet tinsel
slate swan
#

K I will first learn what if class in phyton

sinful pasture
slate swan
velvet tinsel
velvet tinsel
#

Like above the thing

#

In the API

gaunt wedge
sinful pasture
#

ah ok

velvet tinsel
#

I don’t give a sh

#

Disnake better

slate swan
#

ppl have their own preferences

velvet tinsel
#

Goddammit acey

weary gale
gaunt wedge
#

am asking the question and i am using dpy

wanton veldt
velvet tinsel
#

Read the error

wanton veldt
#

😩

weary gale
# velvet tinsel Replace ctx with ctx.author maybe
async def userinfo(ctx, member: discord.Member):

    roles = [role for role in member.roles]

    embed = discord.Embed(colour=member.color, timestamp=ctx.message.created_at)

    embed.set_author(name=f"user info - {member}")
    embed.set_thumbnail(url=member.avatar_url)
    embed.set_footer(text=f"requested by {ctx.author}", icon_url=ctx.author.avatar_url)

    embed.add_field(name="ID:", value=member.id)
    embed.add_field(name="guild name:", value=member.display_name)

    embed.add_field(name="created at:", value=member.created_at.strftime("%a, %#d %B %Y, %I:%M %p UTC"))
    embed.add_field(name="joined at:", value=member.joined_at("%a, %#d %B %Y, %I:%M %p UTC"))

    embed.add_field(name=f"roles ({len(roles)})", value="".join([role.mention for role in Roles]))
    embed.add_field(name="top role:", value=member.top_role.mention)

    embed.add_field(name="bot?", value=member.bot)

    await ctx.send(embed=embed)```
where
velvet tinsel
#

Wherever await transform or something is

weary gale
#

that was an error i dont even know why that happened

velvet tinsel
#

Await self.transform

#

You put ctx when you were supposed to pass a member

#

Maybe you meant ctx.author yert

#

Or a mention

weary gale
#

where

#

am i stupid

velvet tinsel
#

đŸ€Šâ€â™‚ïž

#

Did you copy the code

weary gale
#

hehehe

velvet tinsel
#

Or did you make it

#

You copied it?

weary gale
#

:]

velvet tinsel
#

Oh

#

How very depressing

#

If you made it by yourself you could have solved it

weary gale
#

yeah ig

velvet tinsel
#

Read the error

#

It says await self.transform

#

Wherever it is that’s probably the error

weary gale
#

i never typed that

#

i dont even have 500+ lines

velvet tinsel
#

Oh

weary gale
#

and some reason it's saying i do

velvet tinsel
#

Show full error

weary gale
#

Ignoring exception in command userinfo:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 855, in invoke
await self.prepare(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 789, in prepare
await self._parse_arguments(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 697, in _parse_arguments
transformed = await self.transform(ctx, param)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 542, in transform
raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: member is a required argument that is missing.

velvet tinsel
#

Again

slate swan
#

also

velvet tinsel
#

Weird

weary gale
velvet tinsel
#

F it’s on dpy

boreal ravine
#

sad

slate swan
#

member is a required argument that is missing.

velvet tinsel
#

I was wondering why it was all dpy packages

slate swan
#

you have to pass a member

velvet tinsel
#

Hai kayle

weary gale
#

pass

#

a member

boreal ravine
velvet tinsel
#

yes

#

Pass

boreal ravine
velvet tinsel
#

A member

boreal ravine
#

like that

slate swan
#

yes

velvet tinsel
#

Correctimos

slate swan
#

also i basically said that half an hour ago

velvet tinsel
#

Me too

weary gale
#

nothing is happening

slate swan
#

i said it first 👀

velvet tinsel
#

It wasn’t half an hour

devout iris
velvet tinsel
velvet tinsel
slate swan
#

me first

velvet tinsel
devout iris
#

else message sends

velvet tinsel
#

😭

#

What

#

That’s illegal

boreal ravine
devout iris
slate swan
#

shows the else part

devout iris
#

@bot.command()
@commands.has_permissions(ban_members = True)
async def ban(ctx, member : discord.User = None , *, reason = None ):
  if member == None or member == ctx.author:
    await ctx.send("Kendini Mi Banlayacaksın Aptal?")
    cvp = await bot.wait_for("message", timeout = 20)
    #cvpp = cvp.upper()
    if cvp == "evet" or "ewt":
      await ctx.author.ban()
      await ctx.channel.send("Sen Kaßındın... **Banlandın Dostummmm**")
      return
    if reason == None:
      dmmsj = f"{ctx.guild.name} Sunucusundan Banlandın Geçmiß olsun\n\n Sebep = {reason}"
      await ctx.member.send(dmmsj)
      await ctx.channel.send(f"{member} Baßarılı Bir ƞekilde Banlandı")
    if isinstance(MissingPermissions):
      await ctx.channel.send(f"Bu Komutu ,Kullanmak İçin Gerekli Yetkiye Sahip Değilsin!")
  else:
      await ctx.channel.send(f"Eğer Bu Hata Mesajını Alıyorsan Muhtemelen Yetkin Yok demektir... Eğer Sorun Baßka Birßeyden Kaynaklanıyorsa LĂŒtfen {bot.is_owner} iletißime geç")

velvet tinsel
#

Stop taking the words out of my head

slate swan
#

then type faster :]

weary gale
#

how do i make it so i dont have to pass myself? so i can just run the command and it just uses me instead of having to ping myself

slate swan
#

member: discord.Member = None

#

then check if the member is None

slate swan
#

if its None then member = ctx.author

boreal ravine
#

member = member or context.author

slate swan
#

or that

weary gale
#
@bot.command()
async def userinfo(ctx, member: discord.Member):

    roles = [role for role in member.roles]

    embed = discord.Embed(colour=member.color, timestamp=ctx.message.created_at)

    embed.set_author(name=f"user info - {member}")
    embed.set_thumbnail(url=member.avatar_url)
    embed.set_footer(text=f"requested by {ctx.author}", icon_url=ctx.author.avatar_url)

    embed.add_field(name="ID:", value=member.id)
    embed.add_field(name="guild name:", value=member.display_name)

    embed.add_field(name="created at:", value=member.created_at.strftime("%a, %#d %B %Y, %I:%M %p UTC"))
    embed.add_field(name="joined at:", value=member.joined_at("%a, %#d %B %Y, %I:%M %p UTC"))

    embed.add_field(name=f"roles ({len(roles)})", value="".join([role.mention for role in Roles]))
    embed.add_field(name="top role:", value=member.top_role.mention)

    embed.add_field(name="bot?", value=member.bot)

    await ctx.send(embed=embed)```
do i have to import anything weird for this?
still not working
slate swan
#

error?

boreal ravine
#

its ur code? u should know which part isnt working and you havent given an error

weary gale
#

Ignoring exception in command userinfo:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 228, in userinfo
embed.add_field(name="joined at:", value=member.joined_at("%a, %#d %B %Y, %I:%M %p UTC"))
TypeError: 'datetime.datetime' object is not callable

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

Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'datetime.datetime' object is not callable

boreal ravine
#

ues strftime

slate swan
#

member.joined_at.strftime()

#

how do you type fast? đŸ€”

weary gale
#

YES

#

ok i need to learn more

#

its so satisfying when it works

#

thx guys

slate swan
#

your welcome

boreal ravine
#

👌

quaint epoch
boreal ravine
weary gale
#

how can i list everything underneath one another?

slate swan
#

inline = False i think

#

in the add_field

weary gale
#

all of them?

#

@slate swan

boreal ravine
#

yes

weary gale
#

can i put it before name="blablabla"

slate swan
#

yes

weary gale
#

ok thx

boreal ravine
weary gale
#

uh

#

what

boreal ravine
#

!d datetime.datetime.timestamp imagine still using strftime

unkempt canyonBOT
#

datetime.timestamp()```
Return POSIX timestamp corresponding to the [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") instance. The return value is a [`float`](https://docs.python.org/3/library/functions.html#float "float") similar to that returned by [`time.time()`](https://docs.python.org/3/library/time.html#time.time "time.time").

Naive [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") instances are assumed to represent local time and this method relies on the platform C `mktime()` function to perform the conversion. Since [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") supports wider range of values than `mktime()` on many platforms, this method may raise [`OverflowError`](https://docs.python.org/3/library/exceptions.html#OverflowError "OverflowError") for times far in the past or far in the future.

For aware [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") instances, the return value is computed as:

```py
(dt - datetime(1970, 1, 1, tzinfo=timezone.utc)).total_seconds()
```   New in version 3.3.

Changed in version 3.6: The [`timestamp()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.timestamp "datetime.datetime.timestamp") method uses the [`fold`](https://docs.python.org/3/library/datetime.html#datetime.datetime.fold "datetime.datetime.fold") attribute to disambiguate the times during a repeated interval.
boreal ravine
#

looks good because you can hover it imo

weary gale
#

how do i do that

#

lol

slate swan
#

<t:round(the datetime.datetime.timestamp thing):>

weary gale
#

i

#

dont understand

slate swan
#

something like that

#

theres different formats

#

F is my favourite

#

<t:1639148229:F> -> <t:1639148229:F>

boreal ravine
#

you used strftime

weary gale
#

i used someone elses code

boreal ravine
#

but you dont know how to use timestamp function

weary gale
#

😔

#

<t:1639148229:F>

boreal ravine
weary gale
#

teach me

boreal ravine
#

no

weary gale
#

:)

#

yes

boreal ravine
#

i already told you how to do it

weary gale
boreal ravine
#

yes

weary gale
#

so
datetime.timestamp()

full valley
peak loom
#

So I get this error

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: KeyError: 201
172.18.0.1 - - [10/Dec/2021 
``` I need to know how to fix it, it only occurs when I run !w leaderboard and this it shows, and it keeps the leaderboard from working...
boreal ravine
weary gale
#

uh

#

what do i put after discord.Member.created_at

boreal ravine
weary gale
boreal ravine
#

nice

full valley
#

damn no need to shout it

boreal ravine
#

😭

maiden fable
#

???

full valley
#

How do I get the id's of members in a vc

near sail
unkempt canyonBOT
maiden fable
#

U need to use list comp

agile shadow
#

Ok, so I have this function here,

    async def init_bot(self, bot: commands.Bot, get_locale_func: Callable[..., Coroutine[Any, Any, Any]] = None):
        self._bot = bot
        if get_locale_func is None:
            # Just use the fallback
            get_locale_func = lambda *_: self._fallback

        async def pre(ctx):
            await self.set_current_locale(await get_locale_func)

        self._bot.before_invoke(pre)```

And the issue is that i need to pass `ctx` to `await get_locale_func`, but either removing/keeping it gives me:

passing `ctx` (calling it):
```py
TypeError: 'coroutine' object is not callable```

, but removing `ctx` gives me

```py
   return preferences[ctx.author.id]
AttributeError: 'cached_property' object has no attribute 'id'```
full valley
#

is that member objects tho

#

or id's

maiden fable
#

Yea member objects

near sail
#

A list of member objects

agile shadow
maiden fable
#

Why

agile shadow
#

TypeError: 'coroutine' object is not callable

maiden fable
#

Yea

#

cz u r doing await func instead of await func()

honest shoal
#

do we need to import something for ctx.purge?

agile shadow
peak loom
#

Am I allowed to ping my help channel in this chat??

agile shadow
#

because get_locale_func requires ctx but I can't pass ctx for some reason

maiden fable
#

what is the error

maiden fable
#

Weird

lament mesa
honest shoal
#

ohh oke

full valley
#
members_ids = []
for x in voicechannel.members:
  members_ids.append(x.id)
#

well put them in the list

maiden fable
#

u can also do member_ids = [x.id for x in vc.members]

full valley
#

true

#

ty

leaden cargo
#

Why is it not responding to message edits?

async def on_message_edit(before, after):
  await before.channel.send(f'{after.content}\n \n Editado por: {before.author}')```
sick talon
#

is it possible to set different cooldown for users with different roles ?

maiden fable
#

!d discord.ext.commands.dynamic_cooldown

unkempt canyonBOT
#

@discord.ext.commands.dynamic_cooldown(cooldown, type=BucketType.default)```
A decorator that adds a dynamic cooldown to a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")

This differs from [`cooldown()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.cooldown "discord.ext.commands.cooldown") in that it takes a function that accepts a single parameter of type [`discord.Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") and must return a [`Cooldown`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Cooldown "discord.ext.commands.Cooldown") or `None`. If `None` is returned then that cooldown is effectively bypassed.

A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").

If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") and the local error handler.

A command can only have a single cooldown.

New in version 2.0.
maiden fable
#

@sick talon

cloud dawn
#

Hunt could you get it to build?

maiden fable
cloud dawn
#

Yeah

maiden fable
#

Well I asked in the official IRC channel and found aqtinstall, a module to package Python QT apps 😄

#

!pypi aqtinstall

unkempt canyonBOT
cloud dawn
#

Ah yeah IRC are all the big brains

#

Slow response time though

#

But worth it as you can see

maiden fable
#

Well yea, but I got the reply almost instantly. Lucky me

cloud dawn
#

Impossible

maiden fable
#

It was in under 10 min

cloud dawn
maiden fable
#

Hahaha

#

damn it was released just yesterday 😄

cloud dawn
#

The pypi?

maiden fable
#

Yea

#

PySide6

cloud dawn
#

Nice

#

I always try to keep my modules up to date aswell as python

maiden fable
#

Same but sadly some modules like tensorflow don't support 3.10 so I have to use 3.9 with py -3.9 -m pip install tensorflow to install them ;-;

#

(I know its a total pain)

cloud dawn
#

I feel the struggle

#

I do it aswell

#

Have you seen the 3.11 TB logs?

sick talon
maiden fable
maiden fable
#

different cooldowns for different people

sick talon
#

oh wait

#

ok i didnt see the hyperlink in the title of the embed

maiden fable
#

Haha its fine

cloud dawn
#

It's almost fully blue in there lol

maiden fable
#

damn QTDesigner do be cute 😄

cloud dawn
#

2010 would like their design back

maiden fable
#

Really need to find dark mode tho

#

Still this is the only module with a GUI Designer out there

cloud dawn
#

C#

maiden fable
#

Python

leaden cargo
#

why is it not acepting the channels?

async def on_message_edit(before, after):
  channel1 = [":page_with_curl:・central"]
  if str({before.channel}) == channel1:
    channel = client.get_channel(918425787420508170)
    await channel.send(f"{after.content}\n \n Editado por: {before.author}")```
#

like its not responing rn

sick talon
# maiden fable sure, that is what dynamic cooldown does
@commands.command(name='cooldown')
if not user in high_cooldown_users:
  #cooldown set to 3000s
else:
  #no cooldown
async def cdown(self, ctx):
  await ctx.send("Executed")

i want to make something like this 😅 i am not able to do it

#

oh wait i have found a github gist on this same thing :D, btw thanks tho for letting me know about dynamic cooldown

raw latch
#

Is there any event like on_guild_join but for when the bot leaves a server(if it's kicked for example)?

raw latch
placid skiff
#

!d discord.on_guild_remove

unkempt canyonBOT
#

discord.on_guild_remove(guild)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild") is removed from the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").

This happens through, but not limited to, these circumstances...
raw latch
sick talon
#

how can i make a command disabled for a user for a specific user??
the command which i want to disable have cooldown, so if the user uses that disabled command then he would get the cooldown after the command gets enabled
how to fix this issue ?

slate swan
#

the bot doesn't stops sending the embeds

@bot.listen()
async def on_message(message):
    if message.channel.id !=872071584175779871:
      return
    with open('image_urls.txt', 'r') as f:
        lines = f.readlines()
        g = random.choice(lines)
        embed = discord.Embed(title='hm', description='hmm')
        embed.set_image(url=f'{g}')
        await message.channel.send(embed=embed)

how do I make it to send just 1 time?

river kindle
#

I'm creating a review command, only I can't load the user's image

code:

async def test (ctx, product, stars, *, message, member: discord.Member):
    embed = discord.Embed (
        title = f '** New review **',
        description = f '** Product: ** {product} \ n \ n ** Stars: ** {stars} \ n \ n ** 
         Description: ** {message}')
    embed.set_thumbnail (url = member.avatar_url)
    

    embed.set_footer (text = f "Server: {ctx.message.guild.name}")  
await ctx.send(embed=embed)```

   

The wrong part is embed.set_thumbnail (url = member.avatar_url) await for ctx.send (embed = embed) and the error is The command raised an exception: AttributeError: object 'NoneType' has no attribute 'avatar_url but I don't know how to fix
manic wing
boreal ravine
manic wing
verbal cairn
#
@bot.command(name='pf')
@commands.is_owner()
async def profile(ctx, username):
    async with bot.session.get(f"https://api.mojang.com/users/profiles/minecraft/{username}") as mc_ign:
        mc_info = await mc_ign.json()
    async with bot.session.get(f'https://api.hypixel.net/skyblock/profiles?key={API_KEY}&uuid={mc_info["id"]}') \
            as profile_req:
        profile_info = await profile_req.json()
        prof_string = f"**Name:** {mc_info['name']} - **UUID:** {mc_info['id']}\n---\n"
        for i in profile_info["profiles"]:
            prof_string += f"**Profile ID:** {i['profile_id']} - **Cute Name:** {i['cute_name']}\n"
        await ctx.send(prof_string)

can this be improved or nah

manic wing
#

everything can be improved

#

you can make that one line

verbal cairn
slate swan
#

i have a command that logs (f'{ctx.guild.id} {channel.id} {str(role.id)}\n') all in 1 text file, how can i search for a line that has ctx.guild.id and remove it?

#

without doing it manually, and without clearing the file

proven aurora
#

use append mode

slate swan
proven aurora
#

wait nvm

slate swan
#
890306563565305866 917289006335680592 917284127701598250
821722608767598663 864368495952396309 863016275613319209
``` this is whats currently in the text file
#

i need to make a function that searches for the guild id (being the first statement) and remove it

upbeat otter
#

then iterate through the generated list

sullen shoal
upbeat otter
#
with open("file.txt") as f:
  content = f.read()
lst = content.split(" ") #generates a list
'''Now iterate through the list to check if the guild id exists and pop it and write the remaining content back to the file'''```
sullen shoal
#

otherwise, you may use splitlines and split function

slate swan
#

one moment

sullen shoal
#

!e print(list(map(lambda x: x.split(" "), "hi hi hi\nhi hi hi".splitlines())))

unkempt canyonBOT
#

@sullen shoal :white_check_mark: Your eval job has completed with return code 0.

[['hi', 'hi', 'hi'], ['hi', 'hi', 'hi']]
upbeat otter
#

.....

slate swan
#
        file = open("verification/info.txt" , 'r')
        for line in file:
            if str(ctx.guild.id) in line:
                embed = discord.Embed(title=f'Verification Configuration', description=f'Verification is already configurated for this server, would you like to reset it? `Y/N`', color=clr)
                await ctx.send(embed=embed)

                msg = await bot.wait_for('message', check=check, timeout = 30)
                if msg.content == 'Y':

                    with open('verification/info.txt','a') as file:
                        file.write(f'{ctx.guild.id} {channel.id} {str(role.id)}\n')
                    embed = discord.Embed(title=f'Verification Configuration', description=f'You have successfully setup a verification system', color=clr)
                    await ctx.send(embed=embed)
                    return

                if msg.content == 'N':
                    return``` this is what i have currently. under the `if msg.content == 'Y':` statement, its adding a new line based on their response. whilst adding the new line to 'replace the old verification configuration', i want it to delete the original line where `ctx.guild.id` is located
#

does that make sense or

upbeat otter
sullen shoal
#

ik im kinda lazy to indent it

upbeat otter
#

why to imagine when its not necessary @maiden fable

maiden fable
#

idk I keep imagining things for some reason

sullen shoal
#

tbh i wasnt expecting it to work without fixing some EOF errors

upbeat otter
slate swan
upbeat otter
dapper garnet
#

@eager sorrel
i'm sorry for the ping but i wanted to tell you that the new banner looks sick!

sullen shoal
#

nice ping my guy

upbeat otter
#

lol

sullen shoal
#

and the most right channel for this kind of thing

upbeat otter
eager sorrel
dapper garnet
eager sorrel
#

pretty sure I helped make that banner, though it's been a few years now

unkempt canyonBOT
limber cosmos
#

I have a message ID in a string. How can I get the channel of the message if I only have the ID?

eager sorrel
simple gulch
#

I have a discord bot that has been working great with no problems for a couple months but today it says 'latin-1' codec can't encode character '\u1edd' in position 3667: ordinal not in range(256) Any ideas

upbeat otter
eager sorrel
#

I don't mind. you're all right.

upbeat otter
full lily
#

SMALL LETTER O WITH HORN AND GRAVE

#

Something somewhere in your code doesn't support that character

shadow wraith
slate swan
#

Lemon was here thats cool lol

rare saddle
#

The message is not sent after specifying the category, why?

upbeat otter
rare saddle
slate swan
upbeat otter
maiden fable
#

one gives local time other gives UTC time

slate swan
#

Yes

rare saddle
maiden fable
#

utc time

slate swan
maiden fable
#

!d datetime.datetime

unkempt canyonBOT
#

class datetime.datetime(year, month, day, hour=0, minute=0, second=0, microsecond=0, tzinfo=None, *, fold=0)```
The *year*, *month* and *day* arguments are required. *tzinfo* may be `None`, or an instance of a [`tzinfo`](https://docs.python.org/3/library/datetime.html#datetime.tzinfo "datetime.tzinfo") subclass. The remaining arguments must be integers in the following ranges...
maiden fable
#

U can see all the methods here

rare saddle
#

How to make a display error due to Missing Access?

slate swan
#

A instance of the error

upbeat otter
maiden fable
slate swan
maiden fable
#

!d discord.HTTPException

unkempt canyonBOT
#

exception discord.HTTPException(response, message)```
Exception that’s raised when an HTTP request operation fails.
maiden fable
#

there is nothing like missing perms lol

#

istg errors are documented weirdly

#

!d discord.ext.commands.MissingPermissions

unkempt canyonBOT
#

exception discord.ext.commands.MissingPermissions(missing_permissions, *args)```
Exception raised when the command invoker lacks permissions to run a command.

This inherits from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
maiden fable
#

There

upbeat otter
#

H

maiden fable
#

mhm

manic wing
maiden fable
#

Haha

manic wing
#

defo posted 'great bot tysm'

maiden fable
#

Well it was a bug where I was able to review my own bot but was not able to delete it

#

¯_(ツ)_/¯

manic wing
#

what would you do if someone made a script to one star it

slate swan
#

Find himđŸš¶

manic wing
maiden fable
#

Sure

manic wing
#

the only hard part would be making it in c++

maiden fable
#

đŸ€·â€â™‚ïž

slate swan
#

How is it possible to register an event wrongđŸš¶

manic wing
#

my c++ skills are ... in progress

upbeat otter
#

Me having no clue about the conversation

maiden fable
#

U can also scrape the website and get banned

maiden fable
#

¯_(ツ)_/¯

slate swan
unkempt canyonBOT
maiden fable
lament mesa
slate swan
#

đŸš¶

slate swan
shadow wraith
slate swan
#

Im not talking about a typo but just the event not being registered properly

maiden fable
#

Lmao

shadow wraith
#

and uses message instead

lament mesa
#

I use _ smh

slate swan
maiden fable
#

Me who uses the alpha part of my token 😐

slate swan
maiden fable
#

since its gonna error with numerical part

slate swan
#

I just use everything with their namejam_cavedude

shadow wraith
#

say "simple" if you use client to define your commands.Bot() and say "fast" if you use bot to define your commands.Bot()

#

fast

maiden fable
#

I should really start getting serious about my life my coding

shadow wraith
manic wing
#

i call bot no

slate swan
#

If seen people do:

msg = commands.Bot()

@msg.event
async def on_ready():
....
```đŸš¶
maiden fable
slate swan
#

Im just a normal person and i type botđŸš¶

shadow wraith
maiden fable
maiden fable
shadow wraith
#

same for me

upbeat otter
shadow wraith
#

i implemeneted a report member system in 3 lines of code

slate swan
#

I use bot since it looks cleaner and understandable đŸš¶

maiden fable
shadow wraith
#

freaking bot.get_channel understandable now for me dude

maiden fable
#

LMAO

slate swan
fringe harness
#

can someone help me with my bot

shadow wraith
# slate swan Whats hard about it?

idgaf about it before but i tried implementing a system because i thought so but forgor then i realized bot.get_channel exists from nowhere then i used it

maiden fable
#

I hate it when Flake8 screams at me just cz bot.get_channel() can also return a DMChannel and it doesn't have a guild attr, even after casting the type to Guild Channel ;-;

shadow wraith
maiden fable
manic wing
#

I present a masterpiece ```py
import discord as notdiscord
from discord import *

no = notdiscord.Ext.Commands.bot(command_prefix=typing.Union[0], intents=notdiscord.intents.none)

no.start if false is False```

#

that took longer than it should of

upbeat otter
manic wing
maiden fable
fringe harness
#

So I am trying to create a bot that is a calculator but has much more advanced functions rather than + or -, more like sin, cos, etc.

shadow wraith
maiden fable
#

cz I am noob

fringe harness
#

i wrote some basic script for a basic calc

slate swan
#

@shadow wraith dont tell me you await get_channel đŸš¶

maiden fable
#

!d math

unkempt canyonBOT
#

This module provides access to the mathematical functions defined by the C standard.

These functions cannot be used with complex numbers; use the functions of the same name from the cmath module if you require support for complex numbers. The distinction between functions which support complex numbers and those which don’t is made since most users do not want to learn quite as much mathematics as required to understand complex numbers. Receiving an exception instead of a complex result allows earlier detection of the unexpected complex number used as a parameter, so that the programmer can determine how and why it was generated in the first place.

maiden fable
#

u can use this, ig

shadow wraith
fringe harness
#

would sympy be good tho

maiden fable
#

!d cmath or this

unkempt canyonBOT
#

This module provides access to mathematical functions for complex numbers. The functions in this module accept integers, floating-point numbers or complex numbers as arguments. They will also accept any Python object that has either a __complex__() or a __float__() method: these methods are used to convert the object to a complex or floating-point number, respectively, and the function is then applied to the result of the conversion.

slate swan
maiden fable
fringe harness
#

ytea

#

yea

maiden fable
#

O

#

Me who doesn't know anything about bot making: Idk đŸ˜¶

shadow wraith
fringe harness
#

wait how do u do the code thing

#

in discord

shadow wraith
#

i mean, i define my channel i want to get as a variable

fringe harness
#

so its not normal text

slate swan
maiden fable
shadow wraith
upbeat otter
#

Me who uses try and exceptions for get_channel

slate swan
shadow wraith
#

wait a second, my brain can't understand why tf you used your own function inside of defining what the function is meant to do

maiden fable
maiden fable
shadow wraith
fringe harness
upbeat otter
shadow wraith
#

what a complicated chad

fringe harness
#

im not here to be toxic

maiden fable
fringe harness
#

but I wrote some basic script

shadow wraith
upbeat otter
maiden fable
#

I want my console to be full of errors just cz someone forgot to give my bot Read Message History perms

shadow wraith
#

you are going to explode my brain, since my brain is a bomb which is defusable

shadow wraith
#

the channel doesn't exist nvm

maiden fable
#

LMAO

slate swan
#

No pep8

try:
    await ctx.send("")
except:
    pass
```đŸš¶
upbeat otter
shadow wraith
#

to be honest i can do this

maiden fable
upbeat otter
shadow wraith
maiden fable
#

just like me

shadow wraith
fringe harness
#

how do u do the think in discord where it makes ur code look like not and not plain text

shadow wraith
#

it simplifies error handling for stupid coders like me

upbeat otter
maiden fable
slate swan
slate swan
upbeat otter
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

fringe harness
#

alr

upbeat otter
#

Backticks

fringe harness
#

thanks

shadow wraith
slate swan
shadow wraith
#

h

upbeat otter
fringe harness
#

does anyone here know the lib discord-components?

shadow wraith
#

people who make seperate cogs only to add cleaner categorization is a chad

maiden fable
fringe harness
#

do u know if it works on mac

fringe harness
#

cause it works on my pc just fine

upbeat otter
shadow wraith
fringe harness
#

but not on my mac

shadow wraith
#

read github

fringe harness
maiden fable
fringe harness
#

github doesmt jave info

maiden fable
#

and make discord verify the bot 😄

shadow wraith
#

thank me later

slate swan
shadow wraith
#

and this is funny discord bots

#

it's just crapped discord bot events which nobody should use at all

maiden fable
slate swan
#

why bother sending it ?

shadow wraith
maiden fable
#

I am out bye

shadow wraith
#

ok no seriously read the channel topic

#

it didn't say ppl only came here for discord bot issues

#

it was for discussions (never said it had to be unfunny) and questions

#

we discussing about crap bot evetns

slate swan
maiden fable
#

aw

shadow wraith
maiden fable
#

wait which insult

shadow wraith
#

i said "you only came here for discord bot issues"

maiden fable
#

o

shadow wraith
#

and changed it to "ppl"

#

your capping if you use among_us for defining commands.Bot()

maiden fable
shadow wraith
maiden fable
#

Uhhh I was trolled by some peeps in the dpy server, so uhhh we don't talk about it

shadow wraith
#

it, is a word, what are your opinions on it- ok ill stop trolling unless its related to discord bots

maiden fable
#

Better

#

istg discord got a really slow service

shadow wraith
#

which discord

maiden fable
#

been like 21 days but no response

shadow wraith
#

the python module or the

maiden fable
#

Bot Verification LMAO

shadow wraith
#

wait you actually got your bot through verification?

#

zamn 😍

maiden fable
#

no

#

I didn't

#

It's being reviewed

shadow wraith
#

ik you didn't but you meet the reqs to

maiden fable
#

its been sent for verification since 3 weeks

upbeat otter
shadow wraith
#

imo there's something slower than that called starting your bot with over 194 billion lines of code

maiden fable
shadow wraith
upbeat otter
#

Smh

maiden fable
upbeat otter
maiden fable
#

I know my sense of humor sucks

shadow wraith
upbeat otter
slate swan
#

I'm not even worried anymore about my raspberry exploding

maiden fable
shadow wraith
#

I'm even worried about my bot's cpu reaching 62% (the limit is 65% since i use a discord bot host) becuase i git cloned discord.py

slate swan
#

I'm still not worried

maiden fable
#

The bot would be blocked as soon as I ran a small eval

slate swan
#

all my bots are private

maiden fable
#

cz my bot's allocated RAM was only 500 MB

upbeat otter
maiden fable
slate swan
slate swan
#

it would use the half of it...

#

tho I don't know what kind of brutal b that bot was

devout iris
#

how can i ping message author?
as f string

maiden fable
#

Memory leak somewhere idk

#

message.author.mention @devout iris

fringe harness
#

does someone mind helping me with discord-components

devout iris
slate swan
#

neither for an f string

slate swan
maiden fable
#

@shadow wraith

devout iris
maiden fable
#

tho its 150 now since it joined a new server

shadow wraith
slate swan
maiden fable
#

not epikhost but okay

shadow wraith
devout iris
#

ah

maiden fable
#

ik

#

literally every host uses that

shadow wraith
peak loom
#

So I get this error

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: KeyError: 201
172.18.0.1 - - [10/Dec/2021 

I need to know how to fix it, it only occurs when I run !w leaderboard and this it shows, and it keeps the leaderboard from working...

shadow wraith
#

code? (idk how to help though)

peak loom
devout iris
peak loom
#

😂

slate swan
devout iris
#

indents are ok?

peak loom
# shadow wraith code? (idk how to help though)
@bot.command(aliases = ["lb"])
async def leaderboard(ctx,x = 1):
    users = await get_bank_data()
    leader_board = {}
    total = []
    for user in users:
        name = int(user)
        total_amount = users[user]["wallet"] + users[user]["bank"]
        leader_board[total_amount]
        total.append(total_amount)

    total = sorted(total,reverse=True)    

    em = discord.Embed(title = f"Top {x} Richest People" , description = "This is decided on the basis of raw money in the bank and wallet",color = discord.Color.blue)
    index = 1
    for amt in total:
        id_ = leader_board[amt]
        member = bot.get_user(id_)
        name = member.name
        em.add_field(name = f"{index}. {name}" , value = f"{amt}",  inline = False)
        if index == x:
            break
        else:
            index += 1

    await ctx.send(embed = em)
slate swan
devout iris
peak loom
#

Ping me when you help

slate swan
slate swan
#

If you want it in the first if you are correct

devout iris
#

yeah then it's correct i guess

devout iris
slate swan
#

YES

#

Or elseyert

shadow wraith
devout iris
#

wait i'll say all extentions for colorful codes

slate swan
#

we love u

slate swan
shadow wraith
slate swan
#

people like you make programming a better place

shadow wraith
#

i have the worst programming standards 🚎

slate swan
#

cried

shadow wraith
#

exclude comments, what else is wrong

slate swan
shadow wraith
#

yea im pretty stupid ngl

slate swan
#

Efficiency pithink

devout iris
#
Extentions For Colorful codes

1-) Indents-Rainbow
2-)Bracket Pair Colorizer

shadow wraith
#

zamn, thanks for making my bot's report system 2 line of code

devout iris
#

i found x2

devout iris
#

normally i'm using a few more

shadow wraith
devout iris
devout iris
slate swan
slate swan
edgy lion
#
    @commands.Cog.listener()
    async def on_guild_role_create(self, role):
        async with aiohttp.ClientSession() as session:
            async with self.db.execute(
                    f"SELECT webhook, guild_id from 'logging' where guild_id = {role.guild.id}",
            ) as cursor:
                config = await cursor.fetchone()

            if config is not None:
                webhook = Webhook.from_url(config[0], adapter=AsyncWebhookAdapter(session))
                if role.guild.id == int(config[1]):
                    guild = self.bot.get_guild(int(config[1]))
                    embed = discord.Embed(
                            description="A role was created",
                            color=discord.Color.dark_theme()
                    )
                    embed.add_field(name='Name', value=role.name, inline=False)
                    embed.add_field(name="Type", value="User", inline=False)

                    embed.add_field(name="ID", value=f'Role = {role.id}\n'
                                                     f'Perpetrator = ? IDK', inline=False)
                    embed.timestamp = datetime.datetime.utcnow()
                    embed.set_footer(text=f'{self.bot.user}', icon_url=self.bot.user.avatar_url)
                    await webhook.send(embed=embed)
                    break``` does anyone know how i can get the role creator?
shadow wraith
#

my realization is better than my skill imo

slate swan
shadow wraith
slate swan
shadow wraith
#

you can do many discord bot things with await

slate swan
#

Not only bot thingsđŸ•Žïž

devout iris
#
@bot.command()
@commands.has_permissions(ban_members = True)
async def ban(ctx, member : discord.Member = None , *, reason = None ):
  if member is None or member == ctx.author:
    await ctx.send("Geçerli Bir Kullanıcı Girilmedi... İßlem İptal Edildi!", delete_after = 6)
    if reason == None:
      dmmsj = f"{ctx.guild.name} Sunucusundan Banlandın Geçmiß olsun\n\n Sebep = {reason}"
      await ctx.ban()
      await ctx.member.send(dmmsj)
      await ctx.channel.send(f"{member} Baßarılı Bir ƞekilde Banlandı")
  else:
      await ctx.channel.send(f"Eğer Bu Hata Mesajını Alıyorsan LĂŒtfen @devout iris ile iletißime geç")
@ban.error
async def ban_error(ctx, error):
  if isinstance(error,MissingPermissions):
    await ctx.send(f"Bu İƟlemi Yapmak İçin Yeterli Yetkiye Sahip Değilsin {ctx.author.mention}!")

i really need help for this code

#

it's not banning (always else is working

shadow wraith
slate swan
shadow wraith
#

actually seriously no

broken dirge
slate swan
edgy lion
#
    @commands.Cog.listener()
    async def on_guild_role_create(self, role):
        async with aiohttp.ClientSession() as session:
            async with self.db.execute(
                    f"SELECT webhook, guild_id from 'logging' where guild_id = {role.guild.id}",
            ) as cursor:
                config = await cursor.fetchone()

            if config is not None:
                webhook = Webhook.from_url(config[0], adapter=AsyncWebhookAdapter(session))
                if role.guild.id == int(config[1]):
                    guild = self.bot.get_guild(int(config[1]))
                    embed = discord.Embed(
                            description="A role was created",
                            color=discord.Color.dark_theme()
                    )
                    embed.add_field(name='Name', value=role.name, inline=False)
                    embed.add_field(name="Type", value="User", inline=False)

                    embed.add_field(name="ID", value=f'Role = {role.id}\n'
                                                     f'Perpetrator = ? IDK', inline=False)
                    embed.timestamp = datetime.datetime.utcnow()
                    embed.set_footer(text=f'{self.bot.user}', icon_url=self.bot.user.avatar_url)
                    await webhook.send(embed=embed)
                    break``` does anyone know how i can get the role creator?
shadow wraith
#

madlad for having the dedication to code logs

#

when you can check audit logs

#

i moved back to my deffiency and got this madlad code whilst using copilot for no reason

shadow wraith
#

now i realized

#

how to make my report system more complicated

#

what other args can you specify in bot.get_channel

#

!d discord.ext.commands.Bot.get_channel

slate swan
devout iris
#

now this is banning but only sends if's message

#
@bot.command()
@commands.has_permissions(ban_members = True)
async def ban(ctx, member : discord.Member = None , *, reason = None ):
  if member is None or member == ctx.author:
    await ctx.send("Geçerli Bir Kullanıcı Girilmedi... İßlem İptal Edildi!", delete_after = 6)
  elif reason == None:
    dmmsj = f"{ctx.guild.name} Sunucusundan Banlandın Geçmiß olsun\n\n Sebep = {reason}"
    await member.ban()
    await ctx.member.send(dmmsj)
    await ctx.send(f"{member} Baßarılı Bir ƞekilde Banlandı")
  else:
      await ctx.channel.send(f"Eğer Bu Hata Mesajını Alıyorsan LĂŒtfen @devout iris ile iletißime geç")
@ban.error
async def ban_error(ctx, error):
  if isinstance(error,MissingPermissions):
    await ctx.send(f"Bu İƟlemi Yapmak İçin Yeterli Yetkiye Sahip Değilsin {ctx.author.mention}!")
shadow wraith
#

i was thinking maybe it was reason: None

devout iris
#

should i remove reason = None ?

slate swan
#

And if something is given it will probably give a error or do nothing as its expecting reason to be None

slate swan
shadow wraith
devout iris
#

ahh

slate swan
shadow wraith
#

wait i think the error your trying to achieve is if the arguments don't exist

#

but your doing a seperate error msg for each missing argument

devout iris
#
@bot.command()
@commands.has_permissions(ban_members = True)
async def ban(ctx, member : discord.Member = None,*, reason = None):
  if member is None or member == ctx.author:
    await ctx.send("Geçerli Bir Kullanıcı Girilmedi... İßlem İptal Edildi!", delete_after = 6)
  elif reason == None:
    dmmsj = f"{ctx.guild.name} Sunucusundan Banlandın Geçmiß olsun\n\n Sebep = {reason}"
    await ctx.member.send(dmmsj)
    await member.ban()
    await ctx.send(f"{member} Baßarılı Bir ƞekilde Banlandı")
  else:
      await ctx.channel.send(f"Eğer Bu Hata Mesajını Alıyorsan LĂŒtfen @devout iris ile iletißime geç")
@ban.error
async def ban_error(ctx, error):
  if isinstance(error, commands.MissingPermissions):
    await ctx.send(f"Bu İƟlemi Yapmak İçin Yeterli Yetkiye Sahip Değilsin {ctx.author.mention}!")

shadow wraith
#

you fixed it, but what are you trying to fix, are you checking if the member or reason is not there?

#

if so, use the error handler to do that

#

i dont support giving people copypastable code but the errors with commands. are MissingRequiredArgument but if they are optional tell me

devout iris
#

if i use ban command, bot is banning member but no sends any message when banned

#

i'll try new code a sec

#

everything still same btw

slate swan
#

@devout iris heres my ban error handler

 ​@​banhammer​.​error 
 ​async​ ​def​ ​example_error1​(​ctx​,​error​: ​commands​.​CommandError​): 
 ​    ​if​ ​isinstance​(​error​, ​commands​.​MissingPermissions​): 
 ​        ​embed7​ ​=​ ​disnake​.​Embed​(​title​=​"Error!!!"​, 
 ​        ​description​=​f"​{​ctx​.​author​.​mention​}​You do not have permissions to ban members."​, 
 ​        ​color​=​0xe74c3c​, 
 ​        ​timestamp​=​datetime​.​datetime​.​utcnow​())  
 ​        ​await​ ​ctx​.​send​(​embed​=​embed7​,​ephemeral​=​True​)
#

Straight from gityert

slate swan
#

So typehint it

#

As shown above

devout iris
#

anything else

slate swan
#

And you should to

#

Since it thinks error is a nonetype

devout iris
#

may be but what should i do for reason idk

slate swan
#

error​: ​commands​.​CommandError​
​    ​

slate swan
slate swan
devout iris
#

ah right

#

wait there is error

slate swan
#

Show?

devout iris
#

i can't show cus if i use it in params, others commands are not workiiing

slate swan
#

Read the error

devout iris
#

i should reboot

#

a sec

slate swan
#

Thats weird

pliant gulch
devout iris
#

3.8.8

slate swan
#

3.10 is kinda buggy with type hints

devout iris
#

...

slate swan
#

Use 3.9.9

devout iris
#

but... will you lost all modules?

slate swan
lament mesa
#

You can create a requirements.txt and reinstall it

slate swan
#

I dont think so

pliant gulch
#

Not sure how upgrading to python 3.9 would fix

cinder breach
#

^

pliant gulch
#

The typehint stuff should work past 3.5

devout iris
cinder breach
#

yep

devout iris
#

idk how can i make this

slate swan
lament mesa
#

Not sure, can't remember the exact command. You could Google it up though.

devout iris
lament mesa
#

Nope

#

If you have a requirements.txt file you don't have to do that.

devout iris
#

i didn't create this... is this creating auto?

slate swan
#

Is this how I change a channels permission for a specific role?

member_role = ctx.channel.overwrites_for(918955830810923049)
member_role.send_messages = False
lost wolf
#
 SolverProblemError

  Because no versions of discord match >1.7.3,<2.0.0
   and discord (1.7.3) depends on discord.py (>=1.7.3), discord (>=1.7.3,<2.0.0) requires discord.py (>=1.7.3).
  Because discord.py (1.7.3) depends on aiohttp (>=3.6.0,<3.8.0)
   and no versions of discord.py match >1.7.3, discord.py (>=1.7.3) requires aiohttp (>=3.6.0,<3.8.0).
  Thus, discord (>=1.7.3,<2.0.0) requires aiohttp (>=3.6.0,<3.8.0).
  So, because repl-python3-incomparablecraftytoolbox depends on both aiohttp (^3.8.1) and discord (^1.7.3), version solving failed.

  at /opt/virtualenvs/python3/lib/python3.8/site-packages/poetry/puzzle/solver.py:241 in _solve
      237│             packages = result.packages
      238│         except OverrideNeeded as e:
      239│             return self.solve_in_compatibility_mode(e.overrides, use_latest=use_latest)
      240│         except SolveFailure as e:
    → 241│             raise SolverProblemError(e)
      242│ 
      243│         results = dict(
      244│             depth_first_search(
      245│                 PackageNode(self._package, packages), aggregate_package_nodes
#

?

slate swan
#

How can I stop the bot.run process

#

Without closing the program

final iron
lost wolf
#

i could use visual studio code if i need to?

#

@final iron

final iron
#

Yeah use vsc

lost wolf
#

ok

#

do i just have to do pip install bs4?

#

@final iron

slate swan
#

How to get username and id of bot that is running

lost wolf
#

it should be a module

#

im new to vs code

#

@slate swan

final iron
split cosmos
#

And addet to path

lost wolf
split cosmos
#

Type into the console
python --version

lost wolf
final iron
#

You need the actual python software

split cosmos
# lost wolf

that is the python extension for visual studio code

lost wolf
lost wolf
young flower
#

Code

@bot.command()
async def sus(ctx, message):
    a = random.randint(1, 3)
    if not message.content == ".sus":
        return
    if message.content == ".sus":
        message.delete()
    print(a)
    if a == 1:
        await ctx.send("https://tenor.com/view/suspicious-suspicious-person-dangerous-gif-13070288")
    elif a == 2:
        await ctx.send("""
    :red_square::red_square::red_square:
:white_large_square::white_large_square::red_square::red_square:
:red_square::red_square::red_square::red_square:
:red_square:      :red_square:
""")
    elif a == 3:
        await ctx.send("https://tenor.com/view/amogus-gif-21498845")
    elif(a != 1,2,3):
        print("somehow you broke this, now fix it")

Error

RuntimeWarning: coroutine 'Message.delete' was never awaited
young flower
#

bruh

split cosmos
young flower
#

i don't know how to await Message.delete

final iron
young flower
#

that's the main problem

lost wolf
split cosmos
#

sudo apt install python3

slate swan
young flower
young flower
split cosmos
#

and to get pip:
sudo apt install python3-pip

young flower
#

it's the same as telling a sad person to not be sad

#

i have no idea how

#

that's why i ask

final iron
# young flower how

You should really learn async/python before learning dpy. It's not a beginner project

slate swan
slate swan
#

You’ve awaited other commands

#

So await this one

young flower
final iron
young flower
#

it's old code that i don't understand bc i made it months ago

slate swan
#

The tb even says it the coro 'coro' was never awaited

slate swan
young flower
slate swan
#

Your not gonna learn if you don’t understand

young flower
#

thanks for helping

slate swan
lost wolf
slate swan
#

We don’t sit around all day on the python discord server

final iron
slate swan
#

We have lifes too

lost wolf
slate swan
slate swan
lost wolf
slate swan
#

I dontđŸ•Žïž

slate swan
slate swan
lost wolf
#

no

slate swan
#

Nvm, these are personal questions

#

I think I’m breaking some sort of rule

#

Idk what but it’s probably something

lost wolf
slate swan
#

You cant download vsc on a chromebook

manic wing
#

!ot

unkempt canyonBOT
slate swan
lost wolf
slate swan
#

😭

slate swan
slate swan
#

I assume it’s very slow

#

Prob

lost wolf
slate swan
#

As it’s a virtual machine on an allready shitty laptop

manic wing
#

go off-topic channel.

final iron
lost wolf
slate swan
#

Since where trying to help him

slate swan
manic wing
final iron
#

@lost wolf then use the link I gave you

slate swan
slate swan
#

So who cares

ebon island
#

How do I handle something like a 503 HTTP Exception with regards to something like sending a message to a channel? Discord itself handles retrying to send the message but my script doesn't know the message has been send and instead gets an exception because the Async task was never retrieved. How do I work around this? I'd like to wrap some logic around the message sending method in my code to always handle that sort of failure. Any ideas?

slate swan
final iron
manic wing
slate swan
#

Idk what Linux version they are using

lost wolf
slate swan
#

It could be a matter of bad software

ebon island
#

Does that work for something like async await ctx.send?

final iron
ebon island
#

say try: send except discord.HTTPException: do something