#discord-bots

1 messages Β· Page 995 of 1

slate swan
#

decent

#

because it was fun and i needed some upgrades 🀣

boreal ravine
#

Stop.

olive osprey
#

decent

slate swan
#

ew wtf

#

I make just under a grand a month

supple thorn
olive osprey
#

bruh

slate swan
#

on average

supple thorn
slate swan
#

!rule 7

unkempt canyonBOT
#

7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.

maiden fable
#

@slate swan didn't u say smth about ot talks in #discord-bots channel before?

slate swan
#

lmao

#

setattr

#

u see yeah

slate swan
#

Ok discord bot mode

slate swan
#

the past is the past

olive osprey
#

πŸ’€

slate swan
#

ok back to discord bots

maiden fable
slate swan
#

hunter took my revenge πŸ‘

maiden fable
slate swan
#

jaguar type faster (5)

olive osprey
slate swan
olive osprey
#

jaguar type faster (7)

boreal ravine
#

stop

slate swan
#

3 wps

maiden fable
#

Dudes can everyone take this to an ot channel?

slate swan
#

Jaguar stop typing and run away from here

supple thorn
slate swan
#

sorry BOBBI

#

yes go there

#

all come

slate swan
slate swan
olive osprey
#

I'm wondering if its gonna be shorter then before

slate swan
strong vector
#

guys dont mind me this server is big as hell i just wanto see the intents

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.

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

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

from discord import Intents
from discord.ext import commands

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

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

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

flat solstice
#

I've tried to simplify it as much as possible, it's a complex bit of logic.
In short:
arrow_blue A guild may or may not have a afk_channel (a attr of before or after
arrow_blue if before has a afk_channel attr or if after has a afk_channel attr then I want to add a field to my embed
arrow_blue so long as the above returns true once: I check if the afk_channel attr of both before and after is not None
arrow_blue if the above returns true then I check if the attrs are not the same, then I have my end value
arrow_blue if the second step returns false then I check which of the conditions caused it to be false
arrow_blue then depending on which of the conditions was false it changes the output value slightly

You following to this point?
My next thing is that I want to run this logic 4 times for guild.afk_channel, guild.system_channel, guild.public_updates_channel and guild.rules_channel
My idea of how to do this is create a function for it, I'm just not sure at which point of the code I should call the function (the bottom section of my previous msg where the combinations I have thought of so far)
My current condition (the code version of steps 2 - 6 above) https://paste.pythondiscord.com/cemomojosi
My current check function layout https://paste.pythondiscord.com/buxidawisi

olive osprey
#

Yes.

strong vector
slate swan
strong vector
slate swan
#

send code and error

flat solstice
strong vector
#

i tought the problem in my code but...

@bot.command()
async def commandname(ctx, *, somevariable):
    #If you don't need a variable, then you only need (ctx)
    """Command description"""
    await ctx.send('Message')
strong vector
slate swan
strong vector
slate swan
boreal ravine
strong vector
slate swan
#

Trying to get my time in my bots status:

@tasks.loop(minutes=1) 
async def status_task():
    now = date.today()
    gmt_time_zone = pytz.timezone('Europe/London')
    now_gmt = now.astimezone(gmt_time_zone).strftime("%I:%M %p")
    await bot.change_presence(status=discord.Status.do_not_disturb, activity=discord.Activity(type=discord.ActivityType.watching, name=f"Time {now_gmt}"))```
Error:
```AttributeError: 'datetime.date' object has no attribute 'astimezone'```
gaunt ice
#

do u want it to update every second?

slate swan
#

minute

gaunt ice
#

that's kinda hard

#

the bot might get ratelimited

slate swan
#

wouldn’t it get ratelimited with every second?

gaunt ice
#

u can keep it to like 10 mins

gaunt ice
boreal ravine
slate swan
#

i’ve seen other people use every minute

gaunt ice
#

hm

gaunt ice
#

idk then

#

I prefer keeping it smth more than a min

slate swan
#

still get an attribute error

strong vector
#

is there an a way to msg arg with out making a cmd?

gaunt ice
#

wym

#

u mean respond to messages?

strong vector
#

what i mean split the msg to an args

?cmd arg1 arg2
#

with out making a new cmd cuz i want to use it in on_msg

gaunt ice
#

hm

olive osprey
#

parameters

gaunt ice
#

yes

strong vector
olive osprey
#
@bot.command()
async def test(ctx, arg1, arg2):
  await ctx.reply(f"{arg1} | {arg2}")
strong vector
gaunt ice
#

femboy

olive osprey
gaunt ice
#

I'm new to python

slate swan
#

thats a thing!?!??!

strong vector
slate swan
#

since when

gaunt ice
#

split function gives a dict?

slate swan
strong vector
gaunt ice
olive osprey
gaunt ice
strong vector
gaunt ice
#

I'm a beginner

slate swan
gaunt ice
#

doesn't mean i cant use dpy

slate swan
#

yeah wth

#

:( come to ot3

#

is it bad to query a database whenever a reaction is added?

olive osprey
#

!d discord.Message.reply @slate swan i think you can also remove that it mentions you somehow

unkempt canyonBOT
#

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

A shortcut method to [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") to reply to the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message").

New in version 1.6.

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

too*

strong vector
gaunt ice
#

welp

slate swan
#

cap

strong vector
slate swan
gaunt ice
#

everyone can use the dpy

#

regardless ur a beginner or a professional

strong vector
#

good hearing that by python server himself

final iron
#

When they said that the bot wil get banned they were either referring to someone using replit or doing something that was spamming the api.

sacred oyster
#

Error syntax line 31 at ")"

gaunt ice
final iron
slate swan
slate swan
gaunt ice
slate swan
#

learn python πŸ™

strong vector
#

i am going to look at the discord libery to find a way to split msg args

final iron
gaunt ice
#

IPS too

slate swan
gaunt ice
#

lol

strong vector
gaunt ice
#

the "keep_alive"

slate swan
strong vector
#

what if the cmd like (a, *, b)

slate swan
#

it will split it into a list of args

strong vector
slate swan
#

.e

#

1e

#

!e

unkempt canyonBOT
#
Missing required argument

code

#
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!*

strong vector
#

okay okay

#

no need for explain i know

#

i know how to use it

slate swan
#

!eval print("hello")

unkempt canyonBOT
#

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

hello
slate swan
#

good boi

strong vector
#

!e

string = "arg1 arg2"
print(string.split(" "))
unkempt canyonBOT
#

@strong vector :white_check_mark: Your eval job has completed with return code 0.

['arg1', 'arg2']
strong vector
slate swan
#

Yo

#

!e ```py
command = "?cmd arg1 arg2 still arg2"
split = command.split(" ")
finished = " ".join(split[:1])
print(finished)

unkempt canyonBOT
#

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

?cmd
slate swan
#

i was thinking

#

!e print("buggin is cute")

unkempt canyonBOT
#

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

buggin is cute
slate swan
#

tysm

slate swan
#

Ash do u have a discord bot

#

#bot-commands @slate swan

slate swan
#

which is now broken

#

H why?

#

lol

slate swan
# slate swan H why?

since I used json files as a db 2 years back, then tried shifting it to a database, lost interest, now it remains

#

I have created a bot but no hosting :(

slate swan
slate swan
#

or use unlimited hosting repl.it method pika_laugh

#

So what u do now ? In python

slate swan
#

i have like 15 🀣

slate swan
#

llol

slate swan
strong vector
slate swan
#

!e ```py
command = "?cmd arg1 arg2 still arg2"
split = command.split(" ")
finished = " ".join(split[2:])
print(finished)

unkempt canyonBOT
#

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

arg2 still arg2
slate swan
#

there we go

#

Whole sorce code

#

I've not worked on a bot for a good two months

#

thats why i'm gathering a development team for a big upcoming bot

#

discord bots are boring now

#

yh a little

#

Ye

#

unless you make something original

#

since there's a couple thousand bots for the same purpose

#

I like ando dev

slate swan
#

!e ```py
command = "?cmd arg1 arg2 still arg2"
split = command.split(" ")
finished = [split[1], split[2]].append(" ".join(split[2:]))
print(finished)

unkempt canyonBOT
#

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

None
slate swan
#

wait

#

ashley and femboy

slate swan
#

would u be interested in a server or a channel for discord? we could make that 🀣

#

yt channel or a dc srv

#

cba rlly to make a bot rn

#

unless its original

#

im really only in the bot game atm

slate swan
#

i c

slate swan
slate swan
#

wdym bro

#

wdym where

slate swan
#

bet

slate swan
#

Hi

#

hgi sparky

slate swan
slate swan
slate swan
#

tiktok

#

smh

#

man said smh

#

im out, nor do I have time since my exams are nearing

#

i jus realised i got exams too u kno

#

i needa revise

#

fr fr

#

how tf you making 1k a month at exam age

slate swan
#

Not hard

#

i used to make more from minecraft servers 🀣

#

ive made 20 this month πŸ’€

slate swan
slate swan
slate swan
slate swan
#

Hi

slate swan
#

Ye

frozen patio
#

Hi

slate swan
#

jonathan55

frozen patio
#

Yes?

slate swan
#

nothing

frozen patio
#

Ok

slate swan
#

u need help?

frozen patio
#

No I am looking for people to help

slate swan
#

kinda dead chat ngl

frozen patio
#

It’s Saturday what do you expect

slate swan
#

bro im so bored

#

idfk what to do

#

saturday, noones in school, they have time to code

rare saddle
#

How can I prevent the bot from deleting messages older than two weeks?

slate swan
#

Lets create bot together in replit

slate swan
frozen patio
slate swan
#

im also not from pc

frozen patio
slate swan
#

jaguar is back

slate swan
#

I have schools on saturday :(

rare saddle
# slate swan wdym?

Many popular bots cannot delete messages that were sent more than 2 weeks ago

slate swan
#

oh no.

frozen patio
slate swan
slate swan
slate swan
slate swan
slate swan
gaunt ice
#

hm

slate swan
frozen patio
#

I got an order from my server last night, so proud of my work.

slate swan
#

Ye me too

slate swan
slate swan
slate swan
#

cold

slate swan
flat solstice
slate swan
#

How?

frozen patio
slate swan
#

How much

#

And whats the order

rare saddle
frozen patio
slate swan
gaunt ice
#

i got caught inhaling cup noodles πŸ’€

frozen patio
#

LMAO

slate swan
gaunt ice
#

i kept the water to boil

slate swan
rare saddle
frozen patio
slate swan
gaunt ice
slate swan
gaunt ice
#

stop.

slate swan
#

I suggest learning python first

frozen patio
#

Yep

gaunt ice
#

get some help.

slate swan
# rare saddle ?

The popular bots probably have special things forbeing popular

slate swan
gaunt ice
#

wha do u wan

slate swan
#

Im also new idk

boreal ravine
rare saddle
slate swan
#

!d discord.ext.commands.Bot.command

unkempt canyonBOT
#

@command(*args, **kwargs)```
A shortcut decorator that invokes [`command()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.command "discord.ext.commands.command") and adds it to the internal command list via [`add_command()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin.add_command "discord.ext.commands.GroupMixin.add_command").
slate swan
#

uh why

slate swan
slate swan
slate swan
#

Motivation

rare saddle
slate swan
#

learn python then come back 😻

boreal ravine
#

Stop shitposting

slate swan
#

recruit bobbi for moderator rn

#

anyways, im gonna steal sparky's command idea

#

...

rare saddle
rare saddle
gaunt ice
#

i got ponged

slate swan
slate swan
slate swan
#

yeah lemme be his private tutor

#

uh

gaunt ice
#

ashley stop. she a big pro in python

slate swan
#

Lol

slate swan
slate swan
gaunt ice
#

u

slate swan
#

no u

#

xenoren ❀️ ashley

#

Python rider of begginer stage

gaunt ice
#

me who doesn't know how to use for function

slate swan
#

for function tf?

slate swan
slate swan
#

i feel sick

gaunt ice
slate swan
gaunt ice
#

ik it's for loops

#

but ye

slate swan
slate swan
#

!e ```py
list = ['1', '2', '3']
for item in list:
print(item)

unkempt canyonBOT
#

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

001 | 1
002 | 2
003 | 3
slate swan
#

Rich guy

#

i dont regret it

#

$200 on mobile game is worth

#

No

delicate hornet
#

how do i use / commands?

slate swan
#

L

#

Lol

#

oh wait it has to be a list

supple thorn
#

L

slate swan
#

!e bot.reply("hi")

unkempt canyonBOT
#

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

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | NameError: name 'bot' is not defined
slate swan
#

o

slate swan
unkempt canyonBOT
#

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

['1', '2', '3']
slate swan
#

Who want these

#

nvm, im high

#

!e print(''' HI
hey
hi''')

unkempt canyonBOT
#

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

001 |  HI
002 | hey
003 | hi
supple thorn
#

!e ```py
print(*item for item in ['1', '2', '3'])

unkempt canyonBOT
#

@supple thorn :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     print(*item for item in ['1', '2', '3'])
003 |           ^^^^^
004 | SyntaxError: iterable unpacking cannot be used in comprehension
slate swan
#

ty

#

L

supple thorn
#

Sadge

strong vector
#

huh i have not idea what i am doing


async def function(TheSplit="('cmd', 'arg1', '*', 'arg2')"):
    #split (cmd, arg1, *, arg2)
    split = list(args)[:]
    print(split)
    cmd = args[0]
    del split[0]
    print(split)
    return (cmd,arg1,arg2)
slate swan
#

lmao πŸ’€

#

!e
for x in range(11):
print(x*"Yo")

unkempt canyonBOT
#

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

001 | 
002 | Yo
003 | YoYo
004 | YoYoYo
005 | YoYoYoYo
006 | YoYoYoYoYo
007 | YoYoYoYoYoYo
008 | YoYoYoYoYoYoYo
009 | YoYoYoYoYoYoYoYo
010 | YoYoYoYoYoYoYoYoYo
011 | YoYoYoYoYoYoYoYoYoYo
slate swan
#

I deleted those msg se everyone can see this

unkempt canyonBOT
#

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

001 |   File "<string>", line 1
002 |     for x in range(500)
003 |                        ^
004 | SyntaxError: expected ':'
slate swan
#

Lmao

boreal ravine
#

This is the last time I'm warning you guys stop going offtopic, offtopic channels exist for a reason

slate swan
#

ok sorry

slate swan
#

!e
for x in range(50):
print(x*"yo")

unkempt canyonBOT
#

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

001 | 
002 | yo
003 | yoyo
004 | yoyoyo
005 | yoyoyoyo
006 | yoyoyoyoyo
007 | yoyoyoyoyoyo
008 | yoyoyoyoyoyoyo
009 | yoyoyoyoyoyoyoyo
010 | yoyoyoyoyoyoyoyoyo
011 | yoyoyoyoyoyoyoyoyoyo
... (truncated - too many lines)

Full output: https://paste.pythondiscord.com/ikeqegapij.txt?noredirect

slate swan
#

ty

#

!ot ?

unkempt canyonBOT
slate swan
#

..

strong vector
slate swan
#

Jaguar is not typing

slate swan
strong vector
slate swan
#

No

#

Brain = None

strong vector
strong vector
slate swan
#

kxsdakxs#

#

Abuse

strong vector
slate swan
#

lol

flat solstice
# boreal ravine maybe you can show the code you have right now and i could help with where you s...

My current condition https://paste.pythondiscord.com/cemomojosi
My current check function layout https://paste.pythondiscord.com/buxidawisi
I was thinking of calling it within embed.field.value but then realized that I don't want the field added unless either before.afk_channel or after.afk_channel exist
and I'm not sure if I should be creating the embed within the function or just returning the value of the func to embed.field.value

slate swan
#

!e ```py
content = "?cmd arg1 arg2 and still arg2"

split = content.split(" ")
arg2 = " ".join(split[2:])
print(split[:2] + arg2)

#

L

unkempt canyonBOT
#

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

arg2 and still arg2
slate swan
#

there we go

#

No

#

Im here

#

!e ```py
content = "?cmd arg1 arg2 and still arg2"

split = content.split(" ")
arg2 = " ".join(split[2:])
print(split[:2] + [arg2])

unkempt canyonBOT
#

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

001 | Traceback (most recent call last):
002 |   File "<string>", line 5, in <module>
003 | TypeError: can only concatenate list (not "str") to list
slate swan
#

bruh

#

!e ```py
content = "?cmd arg1 arg2 and still arg2"

split = content.split(" ")
arg2 = " ".join(split[2:])
print(split[:2] + [arg2])

unkempt canyonBOT
#

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

['?cmd', 'arg1', 'arg2 and still arg2']
slate swan
#

@strong vector there we go

strong vector
#

is that clean?

TheSplit,TheSplit,TheSplit = TheSplit.replace("("),TheSplit.replace(")"),TheSplit.split(",")
slate swan
#

what πŸ’€

strong vector
slate swan
#

no

#

tell me what your trying to do again

#

ash please dont

strong vector
#

Thx someone understand my telent

strong vector
boreal ravine
slate swan
slate swan
slate swan
olive osprey
slate swan
#

brian wants to do it this way 😭

#

how to fix

slate swan
#

he is a bit special

olive osprey
little viper
#
Traceback (most recent call last):
  File "C:\Users\mp420\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 352, in _run_event    
    await coro(*args, **kwargs)
  File "C:\Users\mp420\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 793, in on_connect       
    await self.register_commands()
  File "C:\Users\mp420\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 338, in register_commands
    to_update = update_guild_commands[guild_id]
KeyError: '951383974817697793'``` how do i fix?
flat solstice
strong vector
#

cuz i will use it in on_msg not in bot.cmd you will know when i finsih doing my bot

#

ye

olive osprey
#

what

#

lmao

strong vector
#

i don't wnat to use if

slate swan
#

on_message blocks all commands and he doesnt know about the command listen thing

olive osprey
#

bruh

little viper
# slate swan send code
        async for guild in self.fetch_guilds(limit=None):
            update_guild_commands[guild.id] = []
        for command in [
            cmd
            for cmd in self.pending_application_commands
            if cmd.guild_ids is not None
        ]:
            as_dict = command.to_dict()
            for guild_id in command.guild_ids:
                to_update = update_guild_commands[guild_id]
                update_guild_commands[guild_id] = to_update + [as_dict]

        for guild_id, guild_data in update_guild_commands.items():
            try:
                commands = await self.http.bulk_upsert_guild_commands(
                    self.user.id, guild_id, update_guild_commands[guild_id]
                )```
strong vector
#

cuz make the code ugly and hard to read

slate swan
slate swan
#

Traceback (most recent call last): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3312.0_x64__qbz5n2kfra8p0\lib\asyncio\proactor_events.py", line 116, in __del__ self.close() File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3312.0_x64__qbz5n2kfra8p0\lib\asyncio\proactor_events.py", line 108, in close self._loop.call_soon(self._call_connection_lost, None) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3312.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 751, in call_soon self._check_closed() File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3312.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 515, in _check_closed raise RuntimeError('Event loop is closed') RuntimeError: Event loop is closed

strong vector
#

oof i want to explain what i want to do

slate swan
#

what RuntimeError: Event loop is closed means

#

ok

#

wait

unkempt canyonBOT
#

Hey @slate swan!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

little viper
little viper
slate swan
#

Yo back

little viper
#

someone help me pls

slate swan
#

Why is my anti virus going off

#

idk

#

LMAO

#

so like

#

I should make cogs ??

slate swan
strong vector
#

@slate swan @slate swan
what i am try to do is make fuc split args.
something work like a fuc
i want to args like a fuc will do and return dict with name of the args and values of the args but what if an arg takes *args

strong vector
#

function

slate swan
#

Bru function

#

wait

#

alaias = "fuc"

bleak karma
#
                      async with ctx.typing():
                        await asyncio.sleep(1)
                        await ctx.send("Please type a message")
                        msg = await self.bot.wait_for('message', check=check, timeout=300)
                        async with ctx.typing():
                          await asyncio.sleep(1)
                          await ctx.send(f"You typed {msg.content}")

how do i make the bot do the typing thing after it detects the message bc it does the typing thing even though i haven't sent a message

slate swan
#

I uninstalled nextcord because my code didn't need it, but now it says ImportError: cannot import name 'commands' from 'discord.ext' (unknown location)

#

code :

import discord from discord.ext import commands

#

Bruh

#

pip show discord.py

#

discord.py 1.7.3

#

`
C:\Users\ydzja\Desktop\Bot_Discord\Dox Defender>python main.py
C:\Users\ydzja\Desktop\Bot_Discord\Dox Defender\main.py:6: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
Traceback (most recent call last):
File "C:\Users\ydzja\Desktop\Bot_Discord\Dox Defender\main.py", line 12, in <module>
from discord.ext import commands
ImportError: cannot import name 'commands' from 'discord.ext' (unknown location)

C:\Users\ydzja\Desktop\Bot_Discord\Dox Defender>
`

#

`
C:\Users\ydzja\Desktop\Bot_Discord\Dox Defender>python main.py
C:\Users\ydzja\Desktop\Bot_Discord\Dox Defender\main.py:6: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
Traceback (most recent call last):
File "C:\Users\ydzja\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\http.py", line 300, in static_login
data = await self.request(Route('GET', '/users/@me'))
File "C:\Users\ydzja\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\http.py", line 254, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized

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

Traceback (most recent call last):
File "C:\Users\ydzja\Desktop\Bot_Discord\Dox Defender\main.py", line 234, in <module>
bot.run(TOKEN)
File "C:\Users\ydzja\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 723, in run
return future.result()
File "C:\Users\ydzja\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 702, in runner
await self.start(*args, **kwargs)
File "C:\Users\ydzja\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 665, in start
await self.login(*args, bot=bot)
File "C:\Users\ydzja\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 511, in login
await self.http.static_login(token.strip(), bot=bot)
File "C:\Users\ydzja\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\http.py", line 304, in static_login
raise LoginFailure('Improper token has been passed.') from exc
discord.errors.LoginFailure: Improper token has been passed.
Exception ignored in: <function _ProactorBasePipeTransport.del at 0x0000023C71B44940>
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3312.0_x64__qbz5n2kfra8p0\lib\asyncio\proactor_events.py", line 116, in del
self.close()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3312.0_x64__qbz5n2kfra8p0\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3312.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 751, in call_soon
self._check_closed()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3312.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 515, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
`

#

o my

#

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

little viper
#
Traceback (most recent call last):
  File "C:\Users\mp420\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 352, in _run_event    
    await coro(*args, **kwargs)
  File "C:\Users\mp420\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 793, in on_connect       
    await self.register_commands()
  File "C:\Users\mp420\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 338, in register_commands
    to_update = update_guild_commands[guild_id]
KeyError: '799296335663595530'``` how do i fix this someone please help me
slate swan
little viper
#

the key is my guild id, i checked it out multiple times. is there something else wrong there? there must be but idk what it is:(

slate swan
little viper
#
        async for guild in self.fetch_guilds(limit=None):
            update_guild_commands[guild.id] = []
        for command in [
            cmd
            for cmd in self.pending_application_commands
            if cmd.guild_ids is not None
        ]:
            as_dict = command.to_dict()
            for guild_id in command.guild_ids:
                to_update = update_guild_commands[guild_id]
                update_guild_commands[guild_id] = to_update + [as_dict]

        for guild_id, guild_data in update_guild_commands.items():
            try:
                commands = await self.http.bulk_upsert_guild_commands(
                    self.user.id, guild_id, update_guild_commands[guild_id]
                )```
strong vector
#

here async def text(ctx, arg ,*, args='test'):
how it works?:

msg = '?cmd arg1 args still args'
text(msg)
"""
text : retrun (['?cmd','arg1','args still args'], {'cmd':'?cmd','arg1','args':'args still args'})
#

my wifi just turn red for some reson

#

that why i took a long time to reply

little viper
#

alright

strong vector
slate swan
#

print(text?

#

yes it worked

strong vector
slate swan
#

!d text whats text i wonder?

unkempt canyonBOT
#
slate swan
#

huh?

#

idk

#

pandas.text

strong vector
#
@bot.command(help='random text font')
async def text(ctx, arg ,*, args='test'):

text is a cmd

little viper
#

where is it

strong vector
#

I WANT TO SPLIT the msg you told me to make discord.py explain

modern fiber
#

Hey guys, how can I make a command like /post category message.
For example /post looking-for-scripter I need a scripter, and then it sends that message in the certain channel

#

Any documentation or sources?

strong vector
#

when you send a msg the bot split and chack if the msg start with perfix if it is he split the msg to arg i explain that in the explain

gaunt ice
#

u get the channel

#

id

#

and send the arg

modern fiber
#

How so?

#

Mind showing me?

gaunt ice
#

are u using slash cmds?

modern fiber
#

Not really, I would love to.

gaunt ice
#

phew

modern fiber
#

They kinda complicated af.

gaunt ice
#

don't now

gaunt ice
strong vector
#

okay let me explain why i don't use cmd

#

plus i split the msg content not the obj

#

i don't think you understood me

#

i want to use mutple perfix

pliant gulch
#

Discord.py does indeed split the "message" into arguments, they then read the function signature along with it's annotations to know how to convert the argument

strong vector
#

that what i want to do i want to split the msg to func args

#

in the libery self

#

or... discord split

pliant gulch
gaunt ice
pliant gulch
#

What do you mean

strong vector
pliant gulch
#

They need the content to know what to pass to the command's callback

pliant gulch
strong vector
slate swan
little viper
#

can i pay someone to fix this error?

pliant gulch
#

It would raise an error

#

Unnecessary parsing or not, it doesn't matter

#

You need to check the content at the very least

#

This is the very CORE of the commands extension

strong vector
unkempt canyonBOT
#

discord/ext/commands/core.py lines 780 to 781

if view.eof and self.require_var_positional:
    raise MissingRequiredArgument(param)```
pliant gulch
#

You were explaining a case where the user didn't provide any arguments right?

maiden fable
#

Kayya, is u Yerl?

strong vector
slate swan
#

Hey! I have a command where people can basically report something like typos or errors to the staff of the bot, were getting the id of the user and if we want to dm with their id in a command it doesnt work, but on my alt it does work! Can someone tell me why?

maiden fable
#

Aaaaaaa didn't recognize u

pliant gulch
#

Ok, didn't read any of what they are trying to do, but I was responding to your statement saying discord.py doesn't split message into arguments

strong vector
pliant gulch
#

The arguments are made by the StringView class, which is then CONVERTED by utilising inspect.signature

maiden fable
#

@slate swan where your anime pfp is?

pliant gulch
#

The arguments are made by the StringView class, but are to be considered "raw"

slate swan
#

Error:

File "C:\Users\ydzja\Desktop\Bot_Discord\Dox Defender\main.py", line 29, in get_prefix return prefixes[str(message.guild.id)] KeyError: '843234962135187456'

Code:

`def get_prefix(client, message):

with open("prefixes.json", "r") as f:
    prefixes = json.load(f)

return prefixes[str(message.guild.id)]

bot = commands.Bot(command_prefix = get_prefix)`

pliant gulch
#

The actual conversion is done by using inspect.signature, but hence the name "conversion" it doesn't determine the arguments, just does casting

maiden fable
pliant gulch
#

Without the StringView class you wouldn't have tokens to even convert, therefor discord.py does split to get the arguments

slate swan
#

so much var

pliant gulch
#

Can you rephrase your question?

slate swan
#

white

pliant gulch
#

I couldn't understand it

slate swan
pliant gulch
#

Yea we seem to be talking about two different things here

slate swan
#

im not good in list compre :<

slate swan
#

How could i get the description of the selected option in a dropdown menu, self.values[0] gets the label but what gets the desc

slate swan
slate swan
slate swan
slate swan
#

sixtyy four bits

#

thirty two bits

maiden fable
#

This isn't the correct channel to count bits

slate swan
maiden fable
#

Hm?

slate swan
#

agreed

slate swan
#

10 years experience in python

maiden fable
#

What request

slate swan
#

yes 20

maiden fable
slate swan
maiden fable
#

I started in 2020 August or smth idk

slate swan
#

same

#

😢

#

I started like late 2016 πŸ’€

slate swan
maiden fable
#

Eh, I started in lockdown which was in like July or smth

slate swan
#

i also started in 2020 but didnt focus a lot

slate swan
maiden fable
#

Was bored, me and my friend were like: Let's learn some coding. He gave up and I didn't

slate swan
#

😭

#

I’ve moved onto other languages

paper sluice
slate swan
maiden fable
#

I forgot how to navigate the dpy docs rip

maiden fable
#

!d discord.ui.Button

unkempt canyonBOT
#

class discord.ui.Button(*, style=<ButtonStyle.secondary: 2>, label=None, disabled=False, custom_id=None, url=None, emoji=None, row=None)```
Represents a UI button.

New in version 2.0.
slate swan
maiden fable
#

thanks

cold sonnet
#

this channel is more and more off topic everyday

maiden fable
paper sluice
#

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

maiden fable
#

lmao

cold sonnet
#

Ashley said ot 125 times in this server

paper sluice
slate swan
#

i said "ot" 31 times

#

!rule 7

unkempt canyonBOT
#

7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.

slate swan
#

o god 😭

cold sonnet
#

.topic

lament depotBOT
#
**What commands/features are you proud of making?**

Suggest more topics here!

slate swan
cold sonnet
#

mm

#

memes

slate swan
#

im very proud cuz i didnt completed it

tired hinge
#

how do i get the list of guilds the bot is in?

slate swan
unkempt canyonBOT
tired hinge
#

ty

slate swan
#

returns a list of Guild objects

maiden fable
#

!d discord.Guild

unkempt canyonBOT
#

class discord.Guild```
Represents a Discord guild.

This is referred to as a β€œserver” in the official Discord UI.

x == y Checks if two guilds are equal.

x != y Checks if two guilds are not equal.

hash(x) Returns the guild’s hash.

str(x) Returns the guild’s name.
paper sluice
#

server

slate swan
#

then why discord use guild instead of server

slate swan
stuck oyster
#

How can I make the bot stop a command if the channel wasn't created by the bot or something like that

stuck oyster
slate swan
#

use a return statement

cold sonnet
slate swan
#
if not channel_created_by_bot:
     return
print("uwu")```
#

this wont print uwu if conditional is run

#

no

stuck oyster
maiden fable
#

@slate swan did some asking, for now there is no way to get the SelectOption object

cold sonnet
#

!d discord.ui.Select.options

unkempt canyonBOT
cold sonnet
paper sluice
#

<@&831776746206265384>

maiden fable
#

Uh

cold sonnet
#

oof...

slate swan
#

shit i missed that !!!!!!!!

torpid zinc
#

scums

maiden fable
# cold sonnet ?

Yea just found out he can use a loop with that but too much work πŸ˜”

blissful lagoon
#

!ban 899284537312419851 troll

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied ban to @torpid zinc permanently.

slate swan
#

uh

tall dust
#

good evening dpy

paper sluice
#

ge

slate swan
#

good evening

maiden fable
#

Evening hsp

cold sonnet
#

good daytime for y'all

stuck oyster
#
  if not ctx.channel == client.user:
     return```
Will this work?
slate swan
#

no

#

ask ash how to get

quiet jacinth
#

anyone know what is the problem

cold sonnet
#

why are you comparing a channel to a user

stuck oyster
paper sluice
slate swan
quiet jacinth
stuck oyster
slate swan
paper sluice
cold sonnet
#

no way to check

stuck oyster
#

oh

torn sail
#

Does audit logs have it?

cold sonnet
#

it would be really hard to check audit logs and store everything

paper sluice
cold sonnet
#

everytime

slate swan
paper sluice
stuck oyster
#

Oh ok

slate swan
maiden fable
#

if ctx.author == client.user: return

stuck oyster
maiden fable
#

this will make it so that it won't respond if the message author is bot

quiet jacinth
maiden fable
paper sluice
#

rip

slate swan
stuck oyster
#
@client.command()
async def done(ctx):
  con = sqlite3.connect('main.db')
  cur = con.cursor()

  if ctx.author.id == 565327770083917835:
      for i in cur.fetchall():
        test = i[0]
        test += 1
        await ctx.channel.delete()```
I tried running the command but it did not work and there was no error
quiet jacinth
#

anyone have bot code which is used in tournament registration

slate swan
#

dont copy paste

#

very bad habit

quiet jacinth
#

oh

slate swan
#

hi okimii

slate swan
slate swan
paper sluice
cold sonnet
#

how

slate swan
#

return isnt in a function

cold sonnet
#

no except

slate swan
paper sluice
maiden fable
slate swan
#

bro

#

😭

stuck oyster
slate swan
#

mhm?

stuck oyster
#

what do you mean

slate swan
olive osprey
slate swan
olive osprey
#

Hello

scarlet rune
#

is the user id, channel id, guild id always different? do they ever interfere?

slate swan
#

no

#

theyre all different

scarlet rune
#

ah, okay

slate swan
scarlet rune
#

hmm aight, sounds nice.

slate swan
#

they never change but

slate swan
#

the @everyone and @here have the same as the guild

#

how can i let my bot check if the user said stop?

olive osprey
#

@slate swan you know any cool APIs to use for some commands

scarlet rune
cold sonnet
slate swan
scarlet rune
#

just define it

#

if it's not a slash command

cold sonnet
#

so if !stop is a command and run, then stop

slate swan
scarlet rune
#

try mal-api for finding anime lol

slate swan
slate swan
scarlet rune
#

πŸ‘€

slate swan
#

😳

olive osprey
slate swan
unkempt canyonBOT
#

The message that triggered the command being executed.

Note

In the case of an interaction based context, this message is β€œsynthetic” and does not actually exist. Therefore, the ID on it is invalid similar to ephemeral messages.

scarlet rune
#

oh it's him, i didn't notice

slate swan
# unkempt canyon

returns a message which the message class has the content attr which returns a string

olive osprey
unkempt canyonBOT
slate swan
scarlet rune
slate swan
#

circle down bad for knowing so much about the api😳

scarlet rune
#

no, no, no, i'm leaving this chat, thanks for your help.

slate swan
#

😳

tacit horizon
#

can i use discord bot with threading

slate swan
#

for?

tacit horizon
#

for..

slate swan
#

for what lol

tacit horizon
#

send msg

slate swan
#

like daily?

tacit horizon
#

like in a sec

slate swan
#

you could use Tasks but you would probably get ratelimited

olive osprey
slate swan
#

and why seconds it seems very sus😳

#

for anime one can use kitsu api

slate swan
tacit horizon
#

nvm 😳

maiden fable
#

@slate swan DMs

slate swan
#

it works good

slate swan
slate swan
olive osprey
olive osprey
# slate swan i know you canπŸ’œ

Tbh, I probably can if I would focus on it, but I will probably get lost easily and make unecessary stuff or something, maybe in the future, who knows

tacit horizon
#

how i can reduce bot ping

paper sluice
#

buy a house next to a discord server

tacit horizon
#

where is discord server

olive osprey
#

lmao

tacit horizon
#

give me coordinates im going

slate swan
#

that's a nice tip tho.. to live in basement

olive osprey
# slate swan then keep trying!

Well, you know what, I don't have that much to do atm, just some debugging my bot & adding some stuff into another one, Ig then I will give it a shot

slate swan
#

i'll give a try :"/

tacit horizon
#

when i host bot in Heroku or ... gets like 15ms but in pc 300 ;-;

stuck oyster
slate swan
slate swan
slate swan
stuck oyster
olive osprey
#

idk what yall talking about but my bots ping is fine

olive osprey
slate swan
#

ive done many

#

ive done probably 5+

#

now im doing an api wrapper for the discord api😳

grim oar
#

Ok and

olive osprey
#

Sounds like a lot of work, how long you took as average for one API wrapper?

stuck oyster
slate swan
#

its nice

#

woahh now i'm jealous

slate swan
#

i get like 200 ping, and my friend gets 400

#

so dw about pc thing,

#

my ping is usually like 150 iirc

grim oar
#

Still bitchless

maiden fable
#

PC will, at most times, get a high ping since our hom wifi networks ain't designed for hosting

paper sluice
maiden fable
#

They are made for general use more

stuck oyster
olive osprey
maiden fable
slate swan
maiden fable
#

I know many people host bots on their PCs

stuck oyster
olive osprey
#

My internet is bad af

maiden fable
#

Well my 2.4G internet gives good ping but 5G gives a good speed

slate swan
#

i use my isps server as a hosting server

paper sluice
maiden fable
slate swan
slate swan
olive osprey
stuck oyster
paper sluice
grim oar
slate swan
#

theyre a whole mess

grim oar
#

Skill issues.

slate swan
#

how

#

they barely can impl endpoints

slate swan
grim oar
#

excuses

slate swan
#

How do I get the arguments of a command?

slate swan
#

nova, i'm looking forward if you make one twitter api :")

#

nice work okimii :>

paper sluice
slate swan
slate swan
grim oar
#

Twitter is a lost case, won't wrap

olive osprey
slate swan
#

my wrapper is old and garbage but better than novas for sure

slate swan
slate swan
slate swan
grim oar
#

Yeah, you b*tchhaven't followed back yet.

slate swan
slate swan
#

when you actually post good work on github

olive osprey
slate swan
#

loll

grim oar
#

My work is better than your entire life

slate swan
slate swan
#

Is there a way to get a command from its name?

grim oar
slate swan
slate swan
unkempt canyonBOT
#

get_command(name, /)```
Get a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") from the internal list of commands.

This could also be used as a way to get aliases.

The name could be fully qualified (e.g. `'foo bar'`) will get the subcommand `bar` of the group command `foo`. If a subcommand is not found then `None` is returned just as usual.

Changed in version 2.0: `name` parameter is now positional-only.
slate swan
#

youre like zeffo but zeffo is a cool guy

slate swan
#

alright

grim oar
olive osprey
slate swan
slate swan
olive osprey
slate swan
#

:"D

slate swan
olive osprey
#

Well, It most likely sounds easier then it is lol

slate swan
#

it is

grim oar
slate swan
#

How can I edit a message that was sent before the bot restarted ? Maybe some kind of get_message

message = bot.get_message(channel, 967456535284420718)
embed = ....
await message.edit(embed=embed)
slate swan
#

@olive osprey

olive osprey
#

@slate swan

slate swan
#

ho

#

@slate swan

acoustic parcel
#

is it possible to loop through all the members in a server? in the code that I wrote, it only loops through the bot, not the members in the server

  print(str(x.name))```
slate swan
#

@slate swan

olive osprey
unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.

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

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

from discord import Intents
from discord.ext import commands

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

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

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

grim oar
acoustic parcel
# slate swan !intents

oh so do I have to write ```from discord import Intents
from discord.ext import commands

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

slate swan
#

depending on the api it could be one of the 2

grim oar
#

Bor

#

http is a network protocol

slate swan
#

bro

#

do you know how to read

grim oar
#

Bor

slate swan
#

its read as
HTTPClient or RESTClient

#

IT DEPENDS ON THE API

grim oar
#

That makes no difference bozo, say http2 client, that will only make sense!!

slate swan
#

stop starting useless arguments nova

#

lets take it to dms if you want to argue with me more

grim oar
#

Ok

slate swan
sage otter
#

Man I love this channel so much.

slate swan
#

tyler

#

you have dissapeared 😳

sage otter
twin flower
#

I'm trying to make a command which you can pass multiple users to, but I'm getting error "TypeError: object of type 'Member' has no len()"

jaunty hamlet
#

Anyone know of any free hosting services that does not limit hours per month etc? (Hosting for code)

maiden fable
slate swan
#

i'm using py-cord

maiden fable
#

Ah then u gotta use fetch message

slate swan
grim oar
#

I wanna slap some users myself but yeah.

#

How is it supposed to work

#

It has to be a slash command?

#

Ok good luck

#

I have work

slate swan
#

you would need img manipulation and depending on your lib you add an argument

#

if you would like the users pfp then yes use pillow for img manipulation

maiden fable
#

breh anyways

#

!d discord.TextChannel.fetch_message

unkempt canyonBOT
#

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

Retrieves a single [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") from the destination.
grim oar
#

Don't do it in on_ready

maiden fable
#

use a task instead btw

#

set the count to 1

#

!d

unkempt canyonBOT
maiden fable
#

well pycord isn't there lol

grim oar
#

Just use dpy πŸ₯Ί

maiden fable
#

Bruh discord

slate swan
#

How could I get the arguments of a command

grim oar
#

is it a slash command?

slate swan
#

No

maiden fable
#

!d discord.ext.commands.Context.args

unkempt canyonBOT
obsidian ledge
#

is there a way to do if content == table:

slate swan
#

No I mean

#

Like the actual programmatic names on the command

maiden fable
#

uh

grim oar