#discord-bots

1 messages · Page 772 of 1

sacred sigil
#

OH YH

maiden fable
#

Which language do u speak?

summer halo
slate swan
#

man
Check if the voice client if none using conditionals

maiden fable
#

I mean, yea... There's numerous ways

maiden fable
# summer halo Turkish

Oops, sorry I don't know Turkish was worth a try tho

Mind DMing me your question in Turkish or something?

maiden fable
#

I got a friend who can speak Turkish

#

Way better than gTranslate

slate swan
#

Pogg

#

Turkish people are amazing 3HC_Peace

maiden fable
#

Actually he's from Pak but unrelated

#

Wait what? @unkempt canyon got a stroke

#

!d disnake.Client works tho

unkempt canyonBOT
#

class disnake.Client(*, asyncio_debug=False, loop=None, **options)```
Represents a client connection that connects to Discord. This class is used to interact with the Discord WebSocket and API.

A number of options can be passed to the [`Client`](https://docs.disnake.dev/en/latest/api.html#disnake.Client "disnake.Client").
maiden fable
#

Weird 🤷‍♂️

modern fiber
#

how do I fix my copy paste, it only works if I copy smth in pycharm not ouside of it

#

???

summer halo
maiden fable
#

Not a discord bot issue lol

quaint epoch
#

where would i find all the events in disnake? like async def on_ready() and async def on_message, like those?

maiden fable
slate swan
#

Capital e
Welp

maiden fable
unkempt canyonBOT
#

disnake.on_ready()```
Called when the client is done preparing the data received from Discord. Usually after login is successful and the [`Client.guilds`](https://docs.disnake.dev/en/latest/api.html#disnake.Client.guilds "disnake.Client.guilds") and co. are filled up.

Warning

This function is not guaranteed to be the first event called. Likewise, this function is **not** guaranteed to only be called once. This library implements reconnection logic and thus will end up calling this event whenever a RESUME request fails.
maiden fable
#

Just click on the event reference section on the left

slate swan
#

Welp

limpid thicket
#

Is there sub commands for slash commands in Nextcord?

modern fiber
#

I got this error?
" raise CommandInvokeError(exc) from exc
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Member' object has no attribute 'avatar_url'"

limpid thicket
#

If so, could someone link me to it, I can't find it.

summer halo
maiden fable
maiden fable
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

summer halo
maiden fable
#

So with what do u need help in it?

summer halo
maiden fable
#

Ah, so you want to see if anyone doesn't input anything random?

rough acorn
#

Hey..!!

maiden fable
#

Wait, why do u even have another arg? @summer halo

You are using buttons for calculator anyways

maiden fable
rocky trench
#

anyone here experienced with database postgresql?

maiden fable
quaint epoch
#

!d disnake.TextChannel.delete_messages

unkempt canyonBOT
#

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

Deletes a list of messages. This is similar to [`Message.delete()`](https://docs.disnake.dev/en/latest/api.html#disnake.Message.delete "disnake.Message.delete") except it bulk deletes multiple messages.

As a special case, if the number of messages is 0, then nothing is done. If the number of messages is 1 then single message delete is done. If it’s more than two, then bulk delete is used.

You cannot bulk delete more than 100 messages or messages that are older than 14 days old.

You must have the [`manage_messages`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.manage_messages "disnake.Permissions.manage_messages") permission to use this.
rocky trench
cloud dawn
#

I got summoned 19080000ms latency.

rocky trench
#

could u help me for some time in dms? Its 1 small problem

cloud dawn
#

You are already getting helped.

rocky trench
#

yh but he doesnt really understand me

cloud dawn
rocky trench
cloud dawn
#

You should just use INSERT INTO then count all the warnings using SQL

rocky trench
#

I got a system to count the amount of warns, but how do I make it insert in the right place (next to the pinged members id)

cloud dawn
#
SELECT count(*) FROM warning WHERE user_id = 897789854472106004
rocky trench
#

whats count?

potent spear
#

count all rows

cloud dawn
rocky trench
livid cosmos
#

dm gel kanka

rocky trench
#

that doesnt fix the overwrites or does it?

cloud dawn
rocky trench
#
@bot.command()
async def warn(ctx, member: discord.Member = None, reason= None):
    try:
        await db.execute('''INSERT INTO warnings (member) VALUES ($1)''',member.id)
    except:
        pass
    await db.execute(
    '''UPDATE warnings set reasons= $1 WHERE member = $2''',reason+',', member.id)
    await db.execute('''UPDATE warnings SET warns = warns + 1 WHERE member = $1''', member.id)```
#

the 7th line updates warn count

#

But I want a list of reasons

cloud dawn
potent spear
#

you can just get the amount of matches with a specific WHERE clause, which does this for you

#

you don't have to "manually" do this

rocky trench
#

ok

potent spear
#

so, as mentioned in the other guild
have a table with warnings
this has a userID guildID and reason

potent spear
#

very true

maiden fable
#

I said the same thing but yea you are correct

slate swan
maiden fable
#

Facts

slate swan
#

Lol

modern fiber
#

Worked just fine until I added new whois command

#

..

maiden fable
#

Lol

modern fiber
maiden fable
#

The file is corrupted

modern fiber
maiden fable
#

0 Bytes

slate swan
maiden fable
maiden fable
modern fiber
#

.....

maiden fable
#

Bruh

modern fiber
#

Here

maiden fable
#

It's a corrupted image

#

Okay

#

U have two join events?

modern fiber
#

wait where

maiden fable
#

I'm asking...

modern fiber
#

I don't-

maiden fable
#

Weird then...

modern fiber
#

This is the new command I added

maiden fable
#

No

#

Search the file for member_join

modern fiber
#

Just one appears,

#

and thats the one from the welcome event.

#

help?

maiden fable
#

Hmm weird... Try restarting the bot

desert ice
#

how do i send a message like this

modern fiber
slate swan
modern fiber
slate swan
#

Weird , but it exists

maiden fable
maiden fable
unkempt canyonBOT
#
I'm sorry Dave, I'm afraid I can't do that.

No documentation found for the requested symbol.

maiden fable
#

Bruh

#

!d discord.Embed.colour

unkempt canyonBOT
#

The colour code of the embed. Aliased to color as well. This can be set during initialisation.

maiden fable
#

Same thing

slate swan
modern fiber
maiden fable
#

Ah okay

modern fiber
#

but didn't terminate

#

so what I do now?

maiden fable
#

Hmm

#

Open Task Manager

#

Ctrl Shift Esc iirc

modern fiber
#

next?

#

iirc?

maiden fable
#

Then search for Python

slate swan
#

reset your token and it gets killed already

maiden fable
modern fiber
#

not a problem lol ill do it

pine verge
#

is there a way to open a commandline when i start the bot, and everything i type gets sent to the channel by the bot ?

maiden fable
slate swan
#

And resetting the token would just kill the bot

maiden fable
unkempt canyonBOT
#

coroutine asyncio.create_subprocess_shell(cmd, stdin=None, stdout=None, stderr=None, limit=None, **kwds)```
Run the *cmd* shell command.

The *limit* argument sets the buffer limit for [`StreamReader`](https://docs.python.org/3/library/asyncio-stream.html#asyncio.StreamReader "asyncio.StreamReader") wrappers for `Process.stdout` and `Process.stderr` (if [`subprocess.PIPE`](https://docs.python.org/3/library/subprocess.html#subprocess.PIPE "subprocess.PIPE") is passed to *stdout* and *stderr* arguments).

Return a [`Process`](https://docs.python.org/3/library/asyncio-subprocess.html#asyncio.asyncio.subprocess.Process "asyncio.asyncio.subprocess.Process") instance.

See the documentation of [`loop.subprocess_shell()`](https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.subprocess_shell "asyncio.loop.subprocess_shell") for other parameters.

Important

It is the application’s responsibility to ensure that all whitespace and special characters are quoted appropriately to avoid [shell injection](https://en.wikipedia.org/wiki/Shell_injection#Shell_injection) vulnerabilities. The [`shlex.quote()`](https://docs.python.org/3/library/shlex.html#shlex.quote "shlex.quote") function can be used to properly escape whitespace and special shell characters in strings that are going to be used to construct shell commands.
maiden fable
slate swan
#

under a command/method

pine verge
maiden fable
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**.
maiden fable
#

!d discord.Client.get_channel

unkempt canyonBOT
pine verge
#

the problem is i have to use an await

#

i mean how do i trigger the send inside a command or an event

#

knowing it has to be a while loop accepting input

maiden fable
#

await bot.get_channel(...).send(...)

pine verge
#

how do i connect them

maiden fable
#

DON'T allow users to execute shell commands

pine verge
#

ah man it doesnt have to be a shell

slate swan
#

that just screams bad

maiden fable
#

Then???

maiden fable
slate swan
maiden fable
slate swan
#

lol

pine verge
#
while True:
  message = input("enter your message")

i want to send this message in the channel

slate swan
#

no

maiden fable
#

input 😐

pine verge
maiden fable
#

Bro, what u even doing

slate swan
#

input isnt async and tht goes to YOUR terminal

maiden fable
#

!d discord.ext.commands.Bot.wait_for

unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
slate swan
pine verge
#

i am just using discord as a medium

fresh orchid
#
{"695229647021015240": {"messages": 17465}, "6183414919322706506": {"messages": 201}

I have a json file like this and now I want to get the messages amount of all users
So just print out every message amount but idk how to do it

anyone knows how to do it?

maiden fable
slate swan
maiden fable
slate swan
#

lol

pine verge
#

i mean do you guys have an answer ?

fresh orchid
#

ok thx

maiden fable
maiden fable
pine verge
maiden fable
#

@slate swan can help u better at this point

slate swan
maiden fable
slate swan
maiden fable
#

¯_(ツ)_/¯

slate swan
#

ok so who needs help?

maiden fable
#

@pine verge

slate swan
#

knownymous what do you need help with?

slate swan
pine verge
#

open a separate window to allow a user to enter input and send it to a certain channel after starting the bot

slate swan
slate swan
pine verge
#

i just started reading the docs today, not familiar with discordpy yet

slate swan
#

it just makes the bot wait for an event which you can use "message"

#

Okimii providing free help?

#

yup

slate swan
pine verge
slate swan
#

their it is

#

just use a check for a specific msg

slate swan
pine verge
slate swan
pine verge
#

it will just be in the scripts runtime memory

maiden fable
#

Okay time for me to half die

slate swan
#

this is not hacker school

#

this is a discord api wrapper

#

dont make me explain whats an api cuz i can😉

slate swan
slate swan
fresh orchid
slate swan
maiden fable
slate swan
maiden fable
#

I'm in the state of being half dead rn

slate swan
fresh orchid
#

I can give code if needed

slate swan
fresh orchid
#

I just want to print every single message "amount" of the members

slate swan
#

just index the json data

#

!e

a = [1, 2]
print(a[1])
unkempt canyonBOT
#

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

2
slate swan
# slate swan Would definitely be bette than maine , sure
@bot.command()
async def giveaway(ctx):
    j = input("giveaway reward/title:\n")
    u = input("whats the hosts name:\n")
    r = input("any more info like contacting info:\n")
    h = input("how much seconds for the giveaway to end(options:0s 1m 5m 30m 1h 24h ):\n")
    if h == "1m":
        await asyncio.sleep(60)
        print("1 m delay has been set")
    elif h == "5m":
        await asyncio.sleep(300)
        print("5m delay has been set")
    elif h == "30m":
        await asyncio.sleep(1800)
        print("30m delay has been set")
    elif h == "1h":
        await asyncio.sleep(3600)
        print("1h delay has been set")
    elif h == "24h":
        await asyncio.sleep(86400)
        print("24h delay has been set")
    else:
        print("0s delay has been set")

    embed = disnake.Embed(title=f"🎉{j}🎉",
                          description=f"the winner is:{random.choice(ctx.guild.members).mention}\nhosted by {u}\n {r}",
                          colour=0x3498db)
    g = await bot.get_channel(905616933905387531).send(embed=embed)
    print(f"{j} giveaway has been made")

you sure?

maiden fable
#

My first bot code:
client = discord.Client()
@client.event
async def on_message(message):
if message.content == "Spam":
while True:
await ctx.send("Spammy Spammy Spam")
client.run("||Never gonna give you up-||")

slate swan
#

my commands now

@command(
    aliases=[
        "kickhammer",
        "userkick",
        "memberkick",
        "banmember",
        "banuser"
        ]
        )
async def kick(
    self,
    ctx: Context,
    member: Member,
    *,
    reason: str = "No Reason Provided"
    ) -> Optional[Message]:
    if ctx.author.id == member.id:
        return await ctx.send(
            f"{ctx.author.mention} you cannot ban yourself"
            )
    await ctx.send(
        f"Would you like to kick {member.mention}",
        view=KickConfirmation(
            ctx.author,
            member,
            reason
            )
            )
    ```
😩
maiden fable
slate swan
maiden fable
#

¯_(ツ)_/¯

slate swan
#

my commands now are seggsy😩

slate swan
slate swan
#

i did

slate swan
#

and im getting hated for following the max line limit😔

#

its 72 ok😔

#

you don't need to change lines for the kwargs until they exceed a limit

delicate moat
slate swan
#

see im getting hated for following the line limit rule😔

#

I won't blame you , it looks fancy first

#

But it's bad afterall

slate swan
#

it has to be done tho

#

it has to be done to follow pep8 sad😔

maiden fable
slate swan
#

I use ```bash
$python -m black .

maiden fable
slate swan
#

My initial code is always ugly

#

i need to follow pep8 guys it hurts and my code looks weird but it has to be done😔

#

Don't tell me this is how you did the "1000 lines" bot

slate swan
#

some people count lines lol

#

ew i dont

#

guys

#

i need opinions

#
@sleep_and_retry
@limits(
    calls=900,
    period=900
    )
def get_tweet(
    self,
    id: int
    ) -> str:
    """
    Gets a tweet by ID.
    Parameters
    ----------
    id: :class: `int`
    """
    if not isinstance(id, int):
        raise Exception(f"id must be an int, not a {type(id).__name__}")
    try:
        resp = requests.get(
            f"https://api.twitter.com/2/tweets?ids={id}",
            headers=self.header
            )
        data = json.loads(resp.text)
        return data
    except Exception as errorcode:
        raise errorcode

what do you think about this?

#

Hmmmmmmmmm

slate swan
maiden fable
slate swan
#

lol

slate swan
slate swan
maiden fable
slate swan
maiden fable
#

||Don't write discord bots||
||Use IDLE||

slate swan
pliant gulch
#

What do you guys think about ```py
@GatewayClient.on(rin.Event.MESSAGE_CREATE, ...)
async def callback(...) -> None: ...

VS

@rin.Event.MESSAGE_CREATE(...)
async def callback(...) -> None: ...

maiden fable
#

First one

maiden fable
#

Ofc

pliant gulch
#

any reason

slate swan
#

first looks seggsy

maiden fable
slate swan
#

yeah

#

first makes more sense

pliant gulch
maiden fable
#

BTW in the first deco, what does ... signify? We can specify multiple events or smth?

pliant gulch
#

E.g rin.Event.MESSAGE_CREATE.wait(...) would return a type of Message

maiden fable
#

Ah

maiden fable
#

Still... first one is better ngl

pliant gulch
#

Eg check=lambda *_: True

maiden fable
#

Damn

slate swan
#

mhmmm

maiden fable
#

You gonna spoil developers istg

slate swan
#

fr

pliant gulch
maiden fable
#

Korta, why

pliant gulch
#

Because I have a CacheableMeta class in my wrapper, E.g rin.User.cache works

#

So that means I don't need to append listener data to self.dispatch.listeners

slate swan
#

why not make another one🧠

untold token
#

I mean GatewayClient is unnecessary , if second does it alreadt

pliant gulch
#

Instead I can append listener data to rin.Event.READY.listeners

maiden fable
#

Okay, I'm seriously half dead rn so I don't understand shit rn. Imma instead just head out cya

pliant gulch
#

👁️ 👁️

slate swan
maiden fable
pliant gulch
#

Why would I implement a redis cache into the wrapper

slate swan
#

i should use redis

pliant gulch
#

That should be up to the user to decide

untold token
#

or maybe not but if you have inbuilt support for redis cache, that would be cool

pliant gulch
#

It's easy enough to extend my cache

untold token
#

Ah nice

hearty sierra
#
    asyncio_ensure_future = asyncio.async      # Python < 3.5
                                    ^
SyntaxError: invalid syntax```
hearty sierra
#

ok

#

heres the code: ```py
import asyncio
import http

Replace with BaseEventLoop.create_task when dropping Python < 3.4.2.

try: # pragma: no cover
asyncio_ensure_future = asyncio.ensure_future # Python ≥ 3.5
except AttributeError: # pragma: no cover
asyncio_ensure_future = asyncio.async # Python < 3.5

try: # pragma: no cover
# Python ≥ 3.5
SWITCHING_PROTOCOLS = http.HTTPStatus.SWITCHING_PROTOCOLS
OK = http.HTTPStatus.OK
BAD_REQUEST = http.HTTPStatus.BAD_REQUEST
UNAUTHORIZED = http.HTTPStatus.UNAUTHORIZED
FORBIDDEN = http.HTTPStatus.FORBIDDEN
INTERNAL_SERVER_ERROR = http.HTTPStatus.INTERNAL_SERVER_ERROR
SERVICE_UNAVAILABLE = http.HTTPStatus.SERVICE_UNAVAILABLE
except AttributeError: # pragma: no cover
# Python < 3.5
class SWITCHING_PROTOCOLS:
value = 101
phrase = "Switching Protocols"

class OK:
    value = 200
    phrase = "OK"

class BAD_REQUEST:
    value = 400
    phrase = "Bad Request"

class UNAUTHORIZED:
    value = 401
    phrase = "Unauthorized"

class FORBIDDEN:
    value = 403
    phrase = "Forbidden"

class INTERNAL_SERVER_ERROR:
    value = 500
    phrase = "Internal Server Error"

class SERVICE_UNAVAILABLE:
    value = 503
    phrase = "Service Unavailable"
#

or mine?

slate swan
#

this really isnt related to this channel

hearty sierra
#

sorry

#

im trying to make a discord bot but im getting this error

final iron
#

!pypi disnake

unkempt canyonBOT
hearty sierra
#

thank you

storm steppe
#

hey how do i get all the data that comes after the command like if i do /test asdasgf it would say asdasgf

storm steppe
#

i tried b = ctx.message.content then b.split("/code ") but did not work

keen talon
#

U don't use .split like that

storm steppe
#

b = code.split("/login ")

final iron
keen talon
#

What is your prefix

storm steppe
#

/

storm steppe
keen talon
#

!d str.split

unkempt canyonBOT
#

str.split(sep=None, maxsplit=- 1)```
Return a list of the words in the string, using *sep* as the delimiter string. If *maxsplit* is given, at most *maxsplit* splits are done (thus, the list will have at most `maxsplit+1` elements). If *maxsplit* is not specified or `-1`, then there is no limit on the number of splits (all possible splits are made).

If *sep* is given, consecutive delimiters are not grouped together and are deemed to delimit empty strings (for example, `'1,,2'.split(',')` returns `['1', '', '2']`). The *sep* argument may consist of multiple characters (for example, `'1<>2<>3'.split('<>')` returns `['1', '2', '3']`). Splitting an empty string with a specified separator returns `['']`.

For example:
final iron
#

!e

list_ = ["a", "b"]
print(list_[1])
unkempt canyonBOT
#

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

b
storm steppe
final iron
keen talon
storm steppe
#

!e


b = ['', '02b480dfec114c30bfaaac1f89fca503'] 
print(b[2])
s```
unkempt canyonBOT
#

@storm steppe :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 2, in <module>
003 | IndexError: list index out of range
final iron
#

Remember, the index always starts at 0 not 1

storm steppe
#

oh yeah

#

IT WORKED

final iron
keen talon
#

Great

keen talon
velvet tinsel
keen talon
#

This chat uses too much pika pithink pithink

velvet tinsel
slate swan
keen talon
velvet tinsel
#

LONG TIME NO SEE

final iron
#

So I currently have a command that sends a menu and when it is used deletes the message. It's working but I don't like how the code looks. Is there anyway I can shorten the code?

slate swan
#

Heroku errors:

2022-01-23T20:15:18.559130+00:00 heroku[worker.1]: Starting process with command `python bot.py`
2022-01-23T20:15:20.322723+00:00 heroku[worker.1]: Stopping all processes with SIGTERM
2022-01-23T20:15:19.266847+00:00 heroku[worker.1]: State changed from starting to up
2022-01-23T20:15:19.352944+00:00 heroku[worker.1]: Idling
2022-01-23T20:15:20.575307+00:00 heroku[worker.1]: Process exited with status 0
2022-01-23T20:15:19.412294+00:00 heroku[worker.1]: State changed from up to down
2022-01-23T20:15:19.466582+00:00 heroku[worker.1]: Idling because quota is exhausted

What kind of mistake?

native wedge
#

how do i make databases with python?

final iron
tough mirage
#

hello ```py
from discord.ext import commands, tasks
from discord import Member
from discord.ext.commands import Bot, has_guild_permissions, is_owner
import random
import asyncio
from keep_alive import keep_alive
import requests as rq

class Moderation(commands.Cog):
def init(self, client):
self.client = client

   @commands.command()
    async def gban(ctx, user: discord.User):
    for guild in bot.guilds:
        await guild.ban(user)

def setup(client):
client.add_cog(Moderation(client))``` im getting error TabError: inconsistent use of tabs and spaces in indentation but im pretty sure its all correct.

slim ibex
#

uh yeah

#

your command there

#
@commands.comman()
async def gban(ctx, user):
  ...
slate swan
#

You have exceeded the free Heroku usage per month :)

#

Wait until next month to be able to launch your bot again, and expect the same to happen again.

#

Take a look at the Heroku section and why not to use it.

tough mirage
#
class Moderation(commands.Cog):
    def __init__(self, client):
       self.client = client

    @commands.command()
    async def gban(self, ctx, user: discord.User):
      for guild in bot.guilds:
        await guild.ban(user)
        
def setup(client):
    client.add_cog(Moderation(client))```

error code:

```Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 606, in _load_from_module_spec
    spec.loader.exec_module(lib)
  File "<frozen importlib._bootstrap_external>", line 879, in exec_module
  File "<frozen importlib._bootstrap_external>", line 1017, in get_code
  File "<frozen importlib._bootstrap_external>", line 947, in source_to_code
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\Administrator\Desktop\Bots\iRP bot\cogs\Moderation.py", line 13
    @commands.command()
TabError: inconsistent use of tabs and spaces in indentation

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

Traceback (most recent call last):
  File "C:\Users\Administrator\Desktop\Bots\iRP bot\main.py", line 37, in <module>
    client.load_extension(f'cogs.{filename[:-3]}')
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 678, in load_extension
    self._load_from_module_spec(spec, name)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 609, in _load_from_module_spec
    raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.Moderation' raised an error: TabError: inconsistent use of tabs and spaces in indentation (Moderation.py, line 13)```
slate swan
#

Error says all.

#

You're sometimes using tabs for indentation and sometimes you use spaces.

#

Only use spaces or tabs. Not sometimes one sometimes the other one.

keen talon
#

You shouldn't ask us everything 🙂

tough mirage
#
import discord
from discord.ext import commands, tasks
from discord import Member
from discord.ext.commands import Bot, has_guild_permissions, is_owner
import random
import asyncio
from keep_alive import keep_alive
import requests as rq
intents = discord.Intents().all()

class Moderation(commands.Cog):
    def __init__(self, client):
        self.client = client

    @commands.command()
    async def gban(self, ctx, user: discord.User):
        for guild in self.guilds:
            await guild.ban(user)
        
def setup(client):
    client.add_cog(Moderation(client))```

Error: 
```Ignoring exception in command gban:
Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\Administrator\Desktop\Bots\iRP bot\cogs\Moderation.py", line 17, in gban
    for guild in self.guilds:
AttributeError: 'Moderation' object has no attribute 'guilds'

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

Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\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: AttributeError: 'Moderation' object has no attribute 'guilds'```
final iron
#

Don't you mean

#

!d discord.ext.commands.Bot.guilds

unkempt canyonBOT
final iron
#

Is there a more elegant way to get user input than wait_for?

dry kelp
#

i tried making a banner command.. and the banner won't display as gif.. does anyone know why?

final iron
#

Also, where should my classes be in my code since I'm going to have a ton of them because of menus and buttons

#

Should they all be at the top?

echo rover
#

You hate to see it

manic wing
#

🤦

echo rover
#

It's just that it took 2 minutes to respond for some reason

#

and then it's an error

manic wing
#

just subclass ctx so it automatically sends embeds as an embed

final iron
#

Subclassing is hard

#

I really need to learn oop

echo rover
#

More as a challenge than to actually do something

#

Everyone talking about it as the ultimate super hard language but idk

#

I don't really think that's the case

final iron
#

Subclassing is oop right

manic wing
#

well everything is an object

echo rover
#

I have a feeling this is far from pythonic

manic wing
#

x = 0 is oop

#

0 is an instance of int

echo rover
#

pure OOP is cringe

#

OOP combined with functional is the best imo

manic wing
echo rover
#

If you force everything into an object it's gonna overcomplicate stuff

manic wing
#

also use disnake

echo rover
#

why not nextcord?

#

and is it as easy to migrate?

manic wing
#

ill help you automate your help command if you use disnake 😋

manic wing
manic wing
echo rover
manic wing
#

better docs, maintainers, code standard, etc

echo rover
manic wing
#

course

echo rover
#

and the mods of their discord are inept asf

#

someone joined just to be racist and say something about "___s burning" and they spend 5 minutes arguing over warn or ban instead of doing shit

#

and they have some shitty paste tool and banned codeblocks because they don't color correctly on mobile

#

ill def switch to disnake

manic wing
#

most people in this channel use disnake

#

its not ran by children like nextcord and pycord

slate swan
#

hey. ihave this event but it gives this error ```python
channel = self.client.get_channel(int(config['supportcha']))
await channel2.set_permissions(member, connect = True)
await channel2.set_permissions(guild.default_role, connect = False, view_channel = False)
await member.move_to(channel2)

Traceback (most recent call last):
File "D:\coding_things\pythonV2\lib\site-packages\nextcord\client.py", line 415, in _run_event
await coro(*args, **kwargs)
File "C:\Users\Δημήτρης Κολιόπουλος\Desktop\moma\events\support.py", line 58, in on_voice_state_update
await member.move_to(channel2)
File "D:\coding_things\pythonV2\lib\site-packages\nextcord\member.py", line 859, in move_to
await self.edit(voice_channel=channel, reason=reason)
File "D:\coding_things\pythonV2\lib\site-packages\nextcord\member.py", line 803, in edit
data = await http.edit_member(guild_id, self.id, reason=reason, **payload)
File "D:\coding_things\pythonV2\lib\site-packages\nextcord\http.py", line 337, in request
raise HTTPException(response, data)
nextcord.errors.HTTPException: 400 Bad Request (error code: 10003): Unknown Channel

potent spear
velvet tinsel
cloud dawn
velvet tinsel
slim ibex
echo rover
slate swan
finite grotto
cloud dawn
#

No idea since pycord changed a lot of internals.

#

Best is to just replace all pycord with disnake and then run it.

finite grotto
mighty dust
#

how do i remove a user from vc?

potent spear
finite grotto
#

Also why is disnake better than pycord? (Besides "not being maintained by children)

potent spear
#

if you pass None, it'll kick them

slate swan
cloud dawn
mighty dust
#

!p move_to()

unkempt canyonBOT
#
Bad argument

Converting to "int" failed for parameter "pep_number".

cloud dawn
unkempt canyonBOT
#
Command Help

!pep <pep_number>
Can also use: get_pep, p

Fetches information about a PEP and sends it to the channel.

mighty dust
#

wait what

cloud dawn
unkempt canyonBOT
#

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

Moves a member to a new voice channel (they must be connected first).

You must have the [`move_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.move_members "discord.Permissions.move_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").

Changed in version 1.1: Can now pass `None` to kick a member from voice.
cloud dawn
#

eyy :3

mighty dust
#

thanks

#

how do i remove someone by their ID from a vc?

cloud dawn
#

You get the member first

mighty dust
#

how do i do that

#

sorry im new to discord bot coding

cloud dawn
#

ah

#

!d discord.Guild.get_member

unkempt canyonBOT
mighty dust
#

so member = get_member( user_id ) ?

#

okiii

cloud dawn
#

No, read the embed.

mighty dust
#

oh shit yeah

cloud dawn
#

get_member is a method of guild

mighty dust
#

ok

cloud dawn
#

We don't help with that here due to violation of YouTube's Terms of Service.

inner nimbus
#

Ok

potent spear
#

you're probably looking for yt_dl

cloud dawn
potent spear
#

I guess it's a music bot, that's all I read

cloud dawn
#

So?

mighty dust
#

panda

#

once i get the member

#

do i do this?

#
await discord.Member.move_to(member)
cloud dawn
mighty dust
#

this is so confusing lmao

cloud dawn
#
member = guild.get_member(1289128)
await member.move_to(None)
mighty dust
#

wait but didnt the embed say discord.Guild stuff

cloud dawn
#

That is because that's the location of the method yeah

boreal ravine
mighty dust
#

ohhh

#

you guys are legends

cloud dawn
#

Then define that as member and then await member.move_to(None)
so this is actually discord.Member.move_to

mighty dust
#

oh

#

i get it now

velvet tinsel
#

evening panda

cloud dawn
#

👋

slate swan
#

Lol ummm, I'm making a discord bot and I'd love for you to tell me something that a discord bot may help you with in your usual discord experience weather as a normal member of a discord server, a moderator or even a server owner. I'll make sure to add every interesting feature that you might recommend lol

#

ok

#

so what commands do u have

slim ibex
#

that does not require a dashboard

final iron
slate swan
#

Looking for something unique that a normal bot does not have

slate swan
slate swan
slim ibex
#

but bad practices

final iron
slate swan
cloud dawn
slim ibex
final iron
slim ibex
slate swan
final iron
#

Right not the discord bot space is not the best

slim ibex
#

^

slate swan
slim ibex
#

i do

cloud dawn
slim ibex
#

i have a sqlite db, but gonna change to postgres

final iron
#

So many unused imports

slim ibex
#

hoplt shit

#

i was about to say why aiosqlite is there

#

as i didnt see it in the code

slate swan
cloud dawn
final iron
cloud dawn
#

water gaze always so serious

final iron
slate swan
slim ibex
slate swan
#

Wtf is platform used for @final iron

final iron
cloud dawn
#

!d platform

unkempt canyonBOT
#

Source code: Lib/platform.py

Note

Specific platforms listed alphabetically, with Linux included in the Unix section.

final iron
#

It's @slate swan's code

cloud dawn
#

Ah it returns info about the current machine.

final iron
#

Copied it in to pycharm for readability

#

Why not just use psutil

cloud dawn
#

!pypi psutil

unkempt canyonBOT
#

Cross-platform lib for process and system monitoring in Python.

slate swan
#

Imagine using C++: 🤡

cloud dawn
#

Meh platform is build-in

slim ibex
#

c#

final iron
#

Actually might be a usecase for platform

#

They were checking their python version

slate swan
#

What is platform used for lol I'm kinda new

final iron
slate swan
#

Definitely understood...

final iron
#

From my understanding it gets information about the system

#

Not sure though. What was shown above was not my code

slate swan
#

That's pretty useless ngl

final iron
#

Meh

cloud dawn
#

Useless for you

final iron
#

It can get some interesting information

slate swan
#

Log4J is op in all types of situations, I love Log4J (Java)

slim ibex
#

but has security issues as shown by the incident

final iron
#

"some" issues

slim ibex
#

that

final iron
#

Very grand understatement

slate swan
slim ibex
slate swan
#

Imagine you're playing Minecraft and just a random Rickroll shows up

cloud dawn
final iron
#

Just don't play a shit game

#

¯_(ツ)_/¯

slim ibex
slate swan
#

Yea ik someone had to type some shit in chat idk

slim ibex
#

bro destroyed everyones childhood in 1 sentence

slate swan
#

Yep

#

I had mc since I was 3 lol

placid escarp
#

can i somehow get all users names "name" and send all of them with their id's

unkempt canyonBOT
final iron
unkempt canyonBOT
placid escarp
#

tags

#

not ids

slate swan
slim ibex
#

you should see hikari

placid escarp
slim ibex
#

and pincer

slate swan
cloud dawn
placid escarp
#

just get to the point

slate swan
#

I love coding in brainfuck, not that I'm good at it, just because it makes me look superior

placid escarp
#

[+++++-----+]

slate swan
slate swan
#

i see

cloud dawn
cloud dawn
#

*3

placid escarp
slate swan
#

import choice one and second from random import choice

#

+++++ +++[- >++++ ++++< ]>+++ ++++. <++++ +[->+ ++++< ]>+++ ++.<+ ++[->
+++<] >++++ ++.<+ +++++ +++[- >---- ----- <]>-- -.<++ +++++ ++[-> +++++
++++< ]>+.< +++[- >---< ]>--- -.+++ +++.+ +++++ +++.< +++++ ++++[ ->---
----- -<]>- --.<+ +++++ ++[-> +++++ +++<] >++++ +++++ +++++ .+..< +++[-

---< ]>--- -.<

placid escarp
cloud dawn
slate swan
slate swan
#

@placid escarp

#

nope

#

Then who is gae

cloud dawn
#

Guy's please keep it appropriate.

slate swan
#

i just add this nick cuz i like this nick name

slim ibex
#

gert back on topic

slate swan
#

Why you got the LGBT color

placid escarp
slate swan
#

Ok get back to discord bots

slate swan
slim ibex
#

ctx

placid escarp
cloud dawn
potent spear
slate swan
final iron
placid escarp
#

whew

cloud dawn
potent spear
#

surely not, since a bot can only see from guilds he's in

potent spear
#

he can use get_user, ok, but that won't get him the name unless he knows the ID

placid escarp
placid escarp
#

i dont need id

#

i need tag

slate swan
#

Damn

#

Use api idk

slate swan
potent spear
slim ibex
#

!d discord.abc.User.mention

unkempt canyonBOT
slim ibex
#

idk?

slate swan
#

Yea but how does that help

#

can sameone give link for cat aip

slim ibex
#

that why i said idk

slate swan
#

@slim ibex test purpose

#

i mean cat aip

#

You can't analyze the contents of a ping to get a tag since damn

potent spear
#

you can convert a mention into a member / user object tho

slate swan
#

Lemme try

#

@slate swan

#

That should help

potent spear
slate swan
#

Yea

potent spear
#

a user mention is just <@!id>

slate swan
#

ok

#

@slate swan you're a bit too young to start coding...

slim ibex
slate swan
#

im almost 16 years old

placid escarp
#

are yall really using d.py? Like it is dead

slate swan
slim ibex
#

i use nextcord

slate swan
final iron
cloud dawn
slate swan
#

Ok sorry

final iron
cloud dawn
placid escarp
#

i mean i started at 10

#

it is fine

slim ibex
#

i started at 5

#

scratch programming

placid escarp
#

oh yeah i had it in school when i was 7 lol

final iron
# placid escarp april..

Still about 2 months until april. It takes less than 5 minutes to transition to a well made fork

placid escarp
#

but scratch is not really coding

slim ibex
#

ehh

slate swan
#

im runing my bot to test if he dosent get any erros when i added cat command

#

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

slate swan
#
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "bot.py", line 317, in kot
    cat = json_data['message']
KeyError: 'message'

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

Traceback (most recent call last):
  File "/home/container/.local/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/home/container/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/home/container/.local/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: KeyError: 'message'
storm steppe
#

how do i tell my bot to send a message then wait for someone to respond then take that data and respond again

placid escarp
storm steppe
#

thanks

placid escarp
slim ibex
#

!d discord.Client.wait_for

unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
final iron
unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
slim ibex
#

!d discord.ext.commands.Bot.wait_for

unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
slate swan
slim ibex
#

there is an issue with the key of message value

slate swan
#

nah

final iron
slate swan
#

i can give a code

#
async def kot(ctx):
   r = requests.get("https://aws.random.cat/meow")
   json_data = r.json()
   cat = json_data['message'] 
   embed=discord.Embed(color=0xff0000)
   embed.add_field(name ="1.", value="kotek", inline=False)
   embed.set_image(url=cat)
   await ctx.reply(embed=embed)``` my cat command
final iron
#

print json_data

#

Also don't use requests. Its blocking

#

Use aiohttp

slate swan
#

and this is my dog command that works normaly without errors @bot.command() async def pies(ctx): r = requests.get("https://dog.ceo/api/breeds/image/random") json_data = r.json() dog = json_data['message'] embed=discord.Embed(color=0xff0000) embed.add_field(name ="1.", value="piesek", inline=False) embed.set_image(url=dog) await ctx.reply(embed=embed)

final iron
#

There is no message key in the json data

#

It returns {'file': 'https://purr.objects-us-east-1.dream.io/i/20170219_154626.jpg'}

final iron
#

They're not going to return the exact same thing

storm steppe
#

!e

unkempt canyonBOT
#
Command Help

!eval [code]
Can also use: e

*Run Python code and get the results.

This command supports multiple lines of code, including code wrapped inside a formatted code block. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.

We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!*

slate swan
#

#bot-commands

slate swan
slate swan
#

ugh my hosting what i using for hosting my bot

#

i cant save what i add to the flie cuz

#

the hosting have error 503

#

i mean has

#

yes i can save file

#
        boosting = []
        for guild in member.mutual_guilds:
            getmember = guild.get_member(member.id)
            if getmember.premium_since:
                boosting.append(guild.id)

        if boosting == []:
            return```im trying to depict which guild in this array was boosted first
when i print `boosting` this is the output
`[821722608767598663, 930914924262207519]`
how can i put the guilds/member objects themselves in a `list` instead of the `guild id`, then `sort()` the list with a `key` that returns the `premium_since`
#

ugh

cloud dawn
final iron
storm steppe
#

any ideas

Traceback (most recent call last):
  File "C:\Users\hoosi\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "c:\Users\hoosi\Desktop\ArrowBots\Archer\main.py", line 195, in hbnc
    reqSetHomebaseName = requestText(session.post(links.profileRequest.format(account_id, "SetHomebaseName"), headers=homebaseHeaders, json={"homebaseName": hbname}))
  File "C:\Users\hoosi\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 578, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "C:\Users\hoosi\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 516, in request
    prep = self.prepare_request(req)
  File "C:\Users\hoosi\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 449, in prepare_request
    p.prepare(
  File "C:\Users\hoosi\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\models.py", line 317, in prepare
    self.prepare_body(data, files, json)
  File "C:\Users\hoosi\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\models.py", line 467, in prepare_body
    body = complexjson.dumps(json)
  File "C:\Users\hoosi\AppData\Local\Programs\Python\Python39\lib\json\__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "C:\Users\hoosi\AppData\Local\Programs\Python\Python39\lib\json\encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "C:\Users\hoosi\AppData\Local\Programs\Python\Python39\lib\json\encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "C:\Users\hoosi\AppData\Local\Programs\Python\Python39\lib\json\encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type Message is not JSON serializable

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

Traceback (most recent call last):
  File "C:\Users\hoosi\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 903, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\hoosi\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 859, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\hoosi\AppData\Local\Programs\Python\Python39\lib\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: Object of type Message is not JSON serializable```
cloud dawn
#

put [] in it

pliant gulch
#

Or something along those lines

wide marlin
#

Hey guys! I'm using d.py and it seems as though TextChannel.purge() is blocking on some chats. I'm trying to delete all messages that match a check from a chat. I'm not sure if it just takes way too long or not, has anyone experienced the same/have any fixes?

cloud dawn
slate swan
wide marlin
storm steppe
#
        await ctx.message.delete()
        code = ctx.message.content
        b = code.split("/hbnc ")
        reqToken = requestText(session.post(links.getToken, headers={"Authorization": "basic discord token", "Content-Type": "application/x-www-form-urlencoded"}, data={"grant_type": "authorization_code", "token_type": "eg1", "code": b[1]}))
        access_token, account_id, displayName = reqToken["access_token"], reqToken["account_id"], reqToken["displayName"]
        await ctx.send('Please Respond with what you want the homebase name to be')
        check = lambda m: m.author == ctx.author
        try: 
            hbname = await client.wait_for('message', check=check, timeout=30)
        except asyncio.TimeoutError:
            await ctx.send('Homebase Name Change cancelled, timed out.')
            pass
        homebaseHeaders = {"Authorization": f"bearer {b[1]}", "Content-Type": "application/json"}
        reqGetHomebaseName = requestText(session.post(links.profileRequest.format(account_id, "QueryProfile"), headers=homebaseHeaders, data="{}"))
        reqSetHomebaseName = requestText(session.post(links.profileRequest.format(account_id, "SetHomebaseName"), headers=homebaseHeaders, json={"homebaseName": hbname}))
        oldHomebaseName, newHomebaseName = [reqGetHomebaseName['profileChanges'][0]['profile']['stats']['attributes']['homebase_name'], reqSetHomebaseName['profileChanges'][0]['profile']['stats']['attributes']['homebase_name']]
        embed=discord.Embed(title="Succsess!", color=discord.Color.green())
        embed.add_field(name="__{oldHomebaseName}__ :arrow: {newHomebaseName}", value="Homebase name changed to {newHomebaseName}!", inline=True)
        embed.set_footer(text="Homebase Name Change | /hbnc")
        await ctx.send(embed=embed)

im getting error TypeError: Object of type Message is not JSON serializable

storm steppe
#

wdym

pliant gulch
#

You leaked your APIs token

cloud dawn
#

You leaked your token

storm steppe
#

crap

slate swan
#

😘

storm steppe
#

il reset its only in my own sercer

wide marlin
#

You're passing a Message object into... somewhere... where it's trying to be written into JSON.

#

Wherever that is if you can find it, just do Message.content.

slate swan
#
async def cat(ctx):
   async with aiohttp.ClientSession() as session:
      request = await session.get('https://some-random-api.ml/img/cat')
      dogjson = await request.json()
      request2 = await session.get('https://some-random-api.ml/facts/cat')
      factjson = await request2.json()``` bot dosent sent imagine of cat and facts
wide marlin
#

I can't find it for the life of me

cloud dawn
#
  reqSetHomebaseName = requestText(session.post(links.profileRequest.format(account_id, "SetHomebaseName"), headers=homebaseHeaders, json={"homebaseName": hbname}))
storm steppe
alpine gale
#

im new to coding and i keep getting this error, while everytime i run it i get ''pycharm crashed unexpectedly'' but it never closes, i have no clue whats going on lmao

alpine gale
cloud dawn
alpine gale
#

oh

cloud dawn
#

Besides they are more experienced than us regarding that topic.

pliant gulch
pliant gulch
# slim ibex indeed pog

Yes, what is your opinion on which is better? @GatewayClient.on(rin.Events.READY) or @rin.Events.READY()

#

I'm writing some manuals for the wrapper soon so I wanted to know which to prioritise

slim ibex
#

gatewayclient.on

#

sounds more badass

pliant gulch
#

Well that's the class itself, actual impl would be @client.on(...)

slim ibex
#

ah ok

#

so

#

when will this wrapper be able to be used

pliant gulch
#

I've been to lazy to add actual models

#

I've been doing the skeleton for the wrapper this whole time

slim ibex
#

lol

rocky trench
storm steppe
#
oldHomebaseName, newHomebaseName = [reqGetHomebaseName['profileChanges'][0]['profile']['stats']['attributes']['homebase_name'], reqSetHomebaseName['profileChanges'][0]['profile']['stats']['attributes']['homebase_name']]

KeyError: 'profileChanges'

rocky trench
#

No await ctx.send()

#

Await ctx.send(thevariableuwantittosend)

slate swan
rocky trench
#

If I'm right

slate swan
#

ok

slate swan
#
    bot.run("mytoken ") 
    ^
SyntaxError: invalid syntax```
final iron
lost vine
#

Hi, I'm trying to use Mangadex API and I got this error. Help me please

slate swan
final iron
slate swan
slate swan
final iron
lost vine
lost vine
slate swan
slate swan
final iron
lost vine
#

But they just told me to import

#

I don't even know what is that error

slate swan
#

whats mangadex

final iron
#

Whatever that is

slate swan
lost vine
slate swan
lost vine
slate swan
#

u think he'd be asking for help if he was the creator of the wrapper

#

cuz i just implemented rate limits in my wrapper lol

slate swan
hallow wolf
#

im trying to make a discord bot

lost vine
#

btw I need help, don't mind at the file directory lol

hallow wolf
#

it's my first time

lost vine
hallow wolf
# lost vine Then?

im making a ping pong command i understand a lil bit like if message.content.startswith('!ping') await message.channel.send('pong!')

hallow wolf
final iron
#

What

lost vine
hallow wolf
final iron
#

Check out this tutorial

lost vine
lost vine
lost vine
#

mb

hallow wolf
#

nvm

final iron
#

When you use the actual commands extension you define the prefix

lost vine
#

But like, when you use the startwith one

final iron
#

There is no reason to be making "commands" with message.content.startswith

final iron
slim ibex
#

LMAO

lost vine
final iron
#

What is auto respond

lost vine
#

Just like Mimu

lost vine
slate swan
lost vine
#

btw help please 😭

final iron
#

You replied to my message which said "There is no reason to be making "commands" with message.content.startswith"

#

Saying auto respond

final iron
#

Like what

#

Do you just reply to random messages?

slate swan
#

my guy came here to get some help about his random mangadex wrapper, u out here makin his life more miserable where_are_the_egirls_at

slim ibex
#

LMAO

lost vine
final iron
#

Doubt it

final iron
final iron
lost vine
lost vine
final iron
#

For questions and discussions relating to Discord bot development with discord.py and other relevant Python libraries.

lost vine
#

Other relevant

final iron
#

It's not a relevant library

slate swan
#

hurtful

final iron
#

Most people have probably never heard of it

lost vine
#

mehh k k

#

istg they will kick me to this place again when I ask

slate swan
final iron
warped nebula
#

Hi, I want to add a new feature to my Modmail bot.

  1. When the staff members do !close 10m the bot closes the ticket in 10 minutes. I got that already. But I want it to cancel the close when the user who opened the ticket message the Bot within the 10 minnutes.
  2. When the staff members do !close 10m the bot dms the user who opened the ticket:

Hello! This ticket is scheduled to close automatically in 10 minutes and will be marked as resolved. However, you can send another message to cancel this if you still need something. Otherwise, thank you for reaching out to us!

You are more than welcome to re-open another ticket if you feel like you have another query related to Unicorn.

We appreciate your continued support!

#

Please ping when answering. can you send me the new code if you have it thx.

unkempt canyonBOT
warped nebula
final iron
lost vine
warped nebula
#

k

lost vine
#

ideone can be nice

final iron
#

Why are people so opposed to reading

final iron
#

It gives you a pasting service with syntax highlighting right here

warped nebula
#

I pasted it. How do I download it?

lost vine
lost vine
final iron
#

Click on this and copy the link

warped nebula
warped nebula
lost vine
warped nebula
#

what that?

lost vine
warped nebula
#

i dumb

final iron
#

Sending everything really isnt useful

warped nebula
#

I just want to add the feature

#

I need the line text to insert

final iron
#

You're not going to get spoonfed code

warped nebula
#

I didn't mean code

final iron
#

What is line text

warped nebula
#

like what to put under what line

final iron
#

Thats called code...

warped nebula
#

o

final iron
#

!e

print("a")
unkempt canyonBOT
#

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

a
final iron
#

What I just wrote out is code

warped nebula
#

ok

final iron
#

I'm afraid spoon feeding isn't really what this server is about

#

If you need any help with thinking of how to add something or an error we can help

#

But most people aren't going to write up lines of code

warped nebula
#

ok, if u say so

honest vessel
cerulean quest
#

Hey, for my pthon discord bot, i want to make it send colored text. If i import a color module like colorama, and add it with the bots following messages, would it appear as colored?

#

Check if the bot works?

quaint scaffold
#

You are missing the buckettype I believe

#

And I don't think they are kwargs

slate swan
#

Do you have an on_message event?

slate swan
quaint scaffold
#

Ah

slate swan
#

Do you have one or not?cause it can block commands from working

#

If it was in a cog there would be no issue lol

#

Change the event decorator to .listen() and it would be fine

warped nebula
hallow wolf
#

help how to make an uhh bot command prefix

slate swan
#

!d discord.ext.commands.Bot takes a command_prefix kwarg

unkempt canyonBOT
#

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

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

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

even if they mean custom prefixes , the answer remains same.

#

with the way he worded it

dreamy sluice
#

I am getting this error when my bot tries to delete a message in a server

nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: Forbidden: 403 Forbidden (error code: 60003): Two factor is required for this operation
slate swan
#

i'd imagine he wants to make a prefix on server basis

hallow wolf
slate swan
#

you will be needing some database setup for that , and a function which returns the prefix for the command_prefix kwarg

slate swan
dreamy sluice
#

lemme ask the owner of the application to verify

dry kelp
#

how to edit the guild icon to None ?

cerulean quest
#

yo. im working on a discord bot, and rn the bot is being made to tell jokes. when a user says !joke i want the bot to say a joke. i have managed to make it say one joke, although i want it to say multiple with a single command, sort of like an RNG to get a joke, there will be 10 and i want a equal chance for each joke to run and make a joke run only once

#

anyone have any idea how i can manage to do this in my code?

slate swan
unkempt canyonBOT
#
await edit(*, reason=..., name=..., description=..., icon=..., banner=..., splash=..., discovery_splash=..., community=..., region=..., afk_channel=..., owner=..., ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the guild.

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

Changed in version 1.4: The rules\_channel and public\_updates\_channel keyword-only parameters were added.

Changed in version 2.0: The discovery\_splash and community keyword-only parameters were added.

Changed in version 2.0: The newly updated guild is returned.
slate swan
final iron
slate swan
#

cause it tends to edit a complete server

dry kelp
#

like

#

if the icon is none and after is being changed .. to set it to none

pallid galleon
#

python -u "/home/idontlikegames288/DIscord Project/discordbot.py"
/bin/sh: 1: python: not found

wot dis mean

#

new to this no bulli

slate swan
dry kelp
#

await after.edit(icon=None)

#

that's what i was using

#

but it's not working

pine crown
#

how to make slash commands

final iron
echo wasp
#

How would I make config commands to configure the welcome messages turn it off and other things per guild

cerulean quest
slate swan
#

you need to have 2.0

#

yes

#

discord.__version__

#
print(discord.__version__)
#

weird that it raised that error

#

did you use any other libraries like discord_components or something?

#
for i in client.commands:
    print(i)``` stops the bot's execution no error message
slate swan
slim ibex
#

Oh no not discord components

slate swan
#

remove it from your bot completely

slate swan
slate swan
slate swan
#

!d discord.ext.commands.Command

unkempt canyonBOT
#

class discord.ext.commands.Command(*args, **kwargs)```
A class that implements the protocol for a bot text command.

These are not created manually, instead they are created via the decorator or functional interface.
slate swan
unkempt canyonBOT
slate swan
#

does the bot send the message with the button?

slate swan
# slate swan now?

you may try restarting the bot once or twice , and dont print the Cmmand object , print its name..

slate swan
slate swan
#

not responding to the for loop

#

also not printing a dummy text I placed after the loop