#discord-bots

1 messages · Page 921 of 1

rose birch
#

hey guys, quick question. I have a function

@bot.command()
async def foo(ctx, arg):
  print(arg)

if I run !foo without any args, how to ctx.send(msg) on error?

left crater
#

no shit

cloud dawn
rose birch
jade meadow
#

theres nothing in console either

supple thorn
jade meadow
#

i removed the client.run(TOKEN) and the client.run(GUILD) and it's outputting the message in the console, but the bot's still not working

cloud dawn
unkempt canyonBOT
#

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

The default command error handler provided by the bot.

By default this prints to [`sys.stderr`](https://docs.python.org/3/library/sys.html#sys.stderr "(in Python v3.10)") however it could be overridden to have a different implementation.

This only fires if you do not specify any listeners for command error.
jade meadow
#

how do i make it send a message in the discord channel once it has connected

cloud dawn
placid skiff
#

not totally relevant to discord.py but a good package for mongoDB?

cloud dawn
#

!d discord.ext.commands.Bot.wait_until_ready ^^

unkempt canyonBOT
#

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

Waits until the client’s internal cache is all ready.

Warning

Calling this inside [`setup_hook()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.setup_hook "discord.ext.commands.Bot.setup_hook") can lead to a deadlock.
honest shoal
#

how can I get/fetch in a cog?

cloud dawn
cloud dawn
unkempt canyonBOT
#

get_cog(name, /)```
Gets the cog instance requested.

If the cog is not found, `None` is returned instead.

Changed in version 2.0: `name` parameter is now positional-only.
placid skiff
honest shoal
slate swan
cloud dawn
cloud dawn
#

!d discord.ext.commands.Bot.fetch_channel

unkempt canyonBOT
#

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

Retrieves a [`abc.GuildChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.GuildChannel "discord.abc.GuildChannel"), [`abc.PrivateChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.PrivateChannel "discord.abc.PrivateChannel"), or [`Thread`](https://discordpy.readthedocs.io/en/master/api.html#discord.Thread "discord.Thread") with the specified ID.

Note

This method is an API call. For general usage, consider [`get_channel()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.get_channel "discord.ext.commands.Bot.get_channel") instead.

New in version 1.2.

Changed in version 2.0: `channel_id` parameter is now positional-only.
honest shoal
#

not working in a cog

cloud dawn
# honest shoal

it's self.bot inside a cog. You also need to make it a method to access self.

#

You can make it like this but i don't recommend it.

honest shoal
#

then what should I consider using

cloud dawn
honest shoal
#

no

cloud dawn
# honest shoal

!e ```py
class Test:
def init(self, name: str) -> None:
self.name = name

@property
def g_name(self) -> str:
    return self.name

t = Test("dave")
print(t.g_name)

unkempt canyonBOT
#

@cloud dawn :white_check_mark: Your eval job has completed with return code 0.

dave
static beacon
honest shoal
static beacon
#

ok

#

is it in a command

honest shoal
#

no

cloud dawn
# static beacon ok

We can access name inside the method because we pass "self" but you are doing it outside of a scope.

static beacon
#

because you can use ctx.guild.get_role

wheat prawn
# honest shoal

bot (commands.Bot) or client (discord.Client) has no fucn, named get_role. You get the role from the guild. So basically its guild.get_role().

Watch your indentation. its wrong

static beacon
cloud dawn
static beacon
cloud dawn
static beacon
# honest shoal

but why? you can just use this in a command where ctx is available and use ctx.guild.get_role..

honest shoal
static beacon
honest shoal
cloud dawn
static beacon
wheat prawn
static beacon
slate swan
wheat prawn
cloud dawn
cloud dawn
wheat prawn
honest shoal
slate swan
cloud dawn
wheat prawn
cloud dawn
#

But you can't have async inside an init anyways without some hacky tricks.

honest shoal
wheat prawn
cloud dawn
honest shoal
slate swan
#

self=.......

honest shoal
#

nevermind

slate swan
# honest shoal yea...
class Roles(Cog):
       def __init__(self, bot):
               self.bot = bot
      def return_roles(self) -> dict:
               yellow = self.bot.get_role(id)
               blue = ....
               red = ........
               return {
"yellow": yellow,
"blue": blue
........
}
```you could do this
#

oh wait nvm, dont

spring flax
#

for subclassing bot when making overriding the Context (making custom context),

class MyBot(commands.Bot):
    async def get_context(self, message, *, cls=class_name):
        return await super().get_context(message, cls=cls)
        

bot = MyBot(command_prefix='prefix')

Now I can use my bot variable like how I do without subclassing bot right?
Like ```py
@bot.command()
async def e(ctx):
pass

or ```py
@bot.event
async def on_message(message)
honest shoal
cloud dawn
honest shoal
#

🗿

cloud dawn
#

Which is a class not a method.

slate swan
honest shoal
#

ohh

slate swan
#

so that you dont have to do self.bot.get.... again and again

cloud dawn
slate swan
#

yeah make a getch

spring flax
#

that example was for a main bot.py file by the way ^

cloud dawn
# slate swan yeah make a getch
from discord import Role
from discord.ext.commands import Context

async def getch_role(self, ctx: Context, role_id: int) -> Role:
    return ctx.guild.get_role(role_id) or await ctx.guild.fetch_role(role_id)
cloud dawn
# spring flax yeah example, and how does the use of cogs come here?

Well since you already subclassed it i like to include that inside the main folder since it is a pretty big task.
The use of cogs here is to separate the events and commands from the base of the bot. This is so it is easier for other people
and later on yourself to find code.

#

!source

unkempt canyonBOT
spring flax
#

no but that was an example to show how i would use bot

boreal ravine
#
    @ui.button(label="Cancel", style=ButtonStyle.red)
    async def confirm(self, button: ui.Button, interaction: Interaction):
        await interaction.response.edit_message(content="Cancelled.")
``` do I need to defer here?
cloud dawn
spring flax
#

without defer they have 3 seconds to respond

boreal ravine
#

thanks

cloud dawn
placid skiff
#

then nvm xD

cloud dawn
spring flax
#

when I subclass context i lose all the defaultsend methods and stuff right?

cloud dawn
boreal ravine
#

you are merely making a copy of the class

boreal ravine
#

do you guys prefer Ticketbot or TicketBot?

cinder horizon
#

is there smtn like

if messages.embeds:
  if messages.embeds.author == Slash_.mahn#0444:
  await message.delete()
```?
slate swan
slate swan
#

.embeds in the Message class returns a list

cinder horizon
cinder horizon
slate swan
#

!d discord.Message.embeds

unkempt canyonBOT
boreal ravine
#

yes

spring flax
#

okay thank you

slate swan
#

yeah but you should make content a needed argument and its Any

cloud dawn
#

!d typing.Any

unkempt canyonBOT
#

typing.Any```
Special type indicating an unconstrained type.

• Every type is compatible with [`Any`](https://docs.python.org/3/library/typing.html#typing.Any "typing.Any").

• [`Any`](https://docs.python.org/3/library/typing.html#typing.Any "typing.Any") is compatible with every type.
slate swan
#

iirc you cant send an empty message so set a valid value or make it required

boreal ravine
slate swan
shut axle
#

oh

#

I got it

spring flax
#

when subclassing context do I use

class MyContext(commands.Context):
    @property
    def something(self):
        return soemthing
slate swan
shut axle
#

: @slate swan

slate swan
spring flax
slate swan
spring flax
next heath
#

Sup im having trouble to find how im getting a ban Reson can someone help me Im using on_member_ban event

slate swan
#

whats the problem exactly

wheat prawn
next heath
#

Oh ok

wheat prawn
#
@commands.Cog.listener()
async def on_member_ban(self, guild, user):
    async for entry in guild.audit_logs(action=discord.AuditLogAction.ban,):
        if entry.target.id == user.id:
            reason = entry.reason if entry.reason else "No reason provided"
            break
next heath
#

Oh tnx

spring flax
#

if you want a command that shows the ban reason for a member rather just put the ban reason in a database

#

or are you doing a logging type of thing

#

is Context usually subclassed in the main bot file?

next heath
#

Im just making logging in a channel

cloud dawn
#

But if it get's too big you can make a separate file. Usually people subclass the ctx for small things.

spring flax
#

then i need to import in the cog files or is there any other way?

spring flax
cloud dawn
unkempt canyonBOT
#

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

Returns the invocation context from the message.

This is a more low-level counter-part for [`process_commands()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.process_commands "discord.ext.commands.Bot.process_commands") to allow users more fine grained control over the processing.

The returned context is not guaranteed to be a valid invocation context, [`Context.valid`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context.valid "discord.ext.commands.Context.valid") must be checked to make sure it is. If the context is not valid then it is not a valid candidate to be invoked under [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").
cloud dawn
#

This gets called on each command so you can just use ctx without import

forest perch
#

!d discord.Message.edit

unkempt canyonBOT
#

await edit(content=..., embed=..., embeds=..., attachments=..., suppress=..., delete_after=None, allowed_mentions=..., view=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the message.

The content must be able to be transformed into a string via `str(content)`.

Changed in version 1.3: The `suppress` keyword-only parameter was added.

Changed in version 2.0: Edits are no longer in-place, the newly edited message is returned instead.

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

nevermind

#

this is correct right?```py
class MyContext(commands.Context):
async def neutral_embed(self, message, **kwargs):
return await ctx.send(embed=disnake.Embed(description=message, colour=disnake.Color.blurple(), **kwargs))

boreal ravine
#

it's self.send and yes

spring flax
#

oh yeah

#

is this correct?

class Bot(commands.Bot):
    def __init__(self):
        super().__init__(
            command_prefix=commands.when_mentioned_or('='),
            intents=Intents.all(),
            case_insensitive=True,
            owner_ids=[751814647346102303],
            help_command=None,
            test_guilds=[897292885056176240], 
            sync_permissions=True, 
            activity=disnake.Activity(type=disnake.ActivityType.playing, name="DM To Contact Staff")
        )
        
    
    async def get_context(self, message, *, cls=CustomContext):
        return await super().get_context(message, cls=cls)

    self.db = bot.loop.run_until_complete(aiosqlite.connect("discord_bot_db.db"))
    self.launch_time = datetime.datetime.utcnow()
    self.last_result = None
cloud dawn
#

Is this for slash commands?

spring flax
#

It has prefix commands and interaction commands like buttons, select menus and application commands (context menus)

spring flax
#

What's that mean?

boreal ravine
#

looks good to me

#

wait no

#

how is bot defined?

spring flax
#

Oh it isn't

#

i need to replace bot with self

#

okay updated, I forgot about that

#

also, what happens exactly when you run the code of your nickname? @boreal ravine

#

how does it print elipsis

boreal ravine
#

but in a one liner

spring flax
boreal ravine
#

uh you'd still need to do self.bot.dbin cogs

spring flax
#

is it self.bot.db or bot.self.db?

boreal ravine
#

self.bot.db

spring flax
#

oh i meant in a main file

boreal ravine
#

then bot.db

spring flax
#

oh cool so i don't have to change anything

boreal ravine
#

yes

shut axle
#

I did it normally up in the top.

cloud dawn
#

!pypi aiofiles

unkempt canyonBOT
boreal ravine
shut axle
#

@boreal ravine I write the code only at Github!

#

how should I download it>

cloud dawn
#

Only at github?

shut axle
#

Yep

#

Not deploy it from other platform///

inner epoch
#

Hey guys I had thise code which was running flawlessly and suddenly its showing this error

disnake.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

P.S. I tried it bfr one hour and it worked I tried it now and didnt change a word and it stopped

gaunt ice
#

what command

#

show code

shut axle
#

@cloud dawn what do I got to do?

inner epoch
#

It was working bfr one hour or so and it suddenly stopped

gaunt ice
#

the bot needs higher permission tlo give the role to that user

cloud dawn
craggy cloak
#

What is this error lol?

Ignoring exception in on_command_completion
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.8/site-packages/discord/client.py", line 351, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 941, in on_command_completion
    await channel.send(embed=ce)
  File "/home/container/.local/lib/python3.8/site-packages/discord/abc.py", line 1422, in send
    data = await state.http.send_message(
  File "/home/container/.local/lib/python3.8/site-packages/discord/http.py", line 329, in request
    raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access

inner epoch
quaint epoch
#

just read the error properly, you're missing perms

craggy cloak
quaint epoch
#

give it admin

craggy cloak
#

ok thx :)

gaunt ice
#

u dont have perms to do that

#

but the bot can

#

there are 3 things the bot needs to add role

craggy cloak
#

The bot has now owner perms but still can't send the message?

gaunt ice
#

the author needs perms to change role, the bot needs high role

boreal ravine
vale wing
vale wing
slate swan
#
@bot.command()
async def пред(ctx, member: discord.Member = None, *, reason = None):
    print(45)
    if ctx.author.bot:
        return
    
   
    cursor.execute("""CREATE TABLE IF NOT EXISTS warning(guild BIGINT, userid BIGINT, warn INT, count INT, reasons VARCHAR);""")
    base.commit()
    print(1)

    if member is None:
        await ctx.send("Выберите участника")
        
        if reason is None:
           cursor.execute('INSERT INTO warning(guild, userid, warn, count, reasons) VALUES(%s, %s, %s, %s, %s)', (ctx.guild.id,ctx.author.id,1,1,'Отсутствует'))
           base.commit()
           print(2222)
           cursor.execute('UPDATE warning SET warn = warn + 1 WHERE userid = %s AND guild = %s', (member.id, ctx.guild.id))
           base.commit()
           await ctx.send(f"**{member}** Выдал предупреждение {ctx.author.name} , причина ``Отсутствует``.")
        else:
           cursor.execute('INSERT INTO warning(guild, userid, warn, count, reasons) VALUES(%s, %s, %s, %s, %s)', (ctx.guild.id,ctx.author.id,1,1,reason))
           base.commit() 
           cursor.execute('UPDATE warning SET warn = warn + 1 WHERE userid = %s AND guild = %s', (member.id, ctx.guild.id))
           base.commit()
           await ctx.send(f"**{member}** Выдал предупреждение {ctx.author.name} , причина {reason}.")     

Nothing output except 45 and 1, why?

dense swallow
#

so like what should I do...

inner epoch
inner epoch
slate swan
#

Hey Guys. I was wondering what is a good VPS for my discord bot, I live in the USA

shut axle
#

add it?

shut axle
lapis lintel
#

Best vps for hosting discord bots?

tidal hawk
shut axle
# shut axle

how do I write it in the requirements? @boreal ravine

lapis lintel
tidal hawk
slate swan
slate swan
tidal hawk
#

The 10$ one

slate swan
forest perch
#

!d discord.ext.commands.Context.send

quaint epoch
forest perch
#

sorry

slate swan
#
@bot.command()
async def пред(ctx, member: discord.Member = None, *, reason = None):
    print(45)
    if ctx.author.bot:
        return
    
   
    cursor.execute("""CREATE TABLE IF NOT EXISTS warning(guild BIGINT, userid BIGINT, warn INT, count INT, reasons VARCHAR);""")
    base.commit()
    print(1)

    if member is None:
        await ctx.send("Выберите участника")
        
        if reason is None:
           cursor.execute('INSERT INTO warning(guild, userid, warn, count, reasons) VALUES(%s, %s, %s, %s, %s)', (ctx.guild.id,ctx.author.id,1,1,'Отсутствует'))
           base.commit()
           print(2222)
           cursor.execute('UPDATE warning SET warn = warn + 1 WHERE userid = %s AND guild = %s', (member.id, ctx.guild.id))
           base.commit()
           await ctx.send(f"**{member}** Выдал предупреждение {ctx.author.name} , причина ``Отсутствует``.")
        else:
           cursor.execute('INSERT INTO warning(guild, userid, warn, count, reasons) VALUES(%s, %s, %s, %s, %s)', (ctx.guild.id,ctx.author.id,1,1,reason))
           base.commit() 
           cursor.execute('UPDATE warning SET warn = warn + 1 WHERE userid = %s AND guild = %s', (member.id, ctx.guild.id))
           base.commit()
           await ctx.send(f"**{member}** Выдал предупреждение {ctx.author.name} , причина {reason}.")      

Nothing output except 45 and 1, why?

tidal hawk
#

what's ctx.author.bot?

slate swan
#

?

tidal hawk
#

below print(45)

slate swan
#

Does not respond to bots

tidal hawk
#

You don't need it, it's recommended in on_message listeners

olive talon
#

hi all

tidal hawk
cold sonnet
scarlet hull
#

Will it work?

desert badger
#
Traceback (most recent call last):
  File "C:\Users\Niclas\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\player.py", line 118, in __del__
    self.cleanup()
  File "C:\Users\Niclas\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\player.py", line 241, in cleanup
    self._kill_process()
  File "C:\Users\Niclas\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\player.py", line 193, in _kill_process
    proc = self._process
AttributeError: 'FFmpegPCMAudio' object has no attribute '_process'``` what do i do
spring flax
cold sonnet
scarlet hull
tidal hawk
scarlet hull
cold sonnet
#

ctx.author.bot.user don't even exist

spring flax
#

!d disnake.Guild.member_count

unkempt canyonBOT
#

property member_count```
Returns the true member count regardless of it being loaded fully or not.

Warning

Due to a Discord limitation, in order for this attribute to remain up-to-date and accurate, it requires [`Intents.members`](https://docs.disnake.dev/en/latest/api.html#disnake.Intents.members "disnake.Intents.members") to be specified.
tidal hawk
spring flax
#

@scarlet hull ^

tidal hawk
#

ctx.author.client.user

cold sonnet
tidal hawk
#

asdjasd

desert badger
scarlet hull
cold sonnet
#

then we will decide if it breaks ToS or not

desert badger
# cold sonnet perhaps show your code
@client.command(name='play', help='This command plays music')
async def play(ctx):
    global queue

    if not ctx.message.author.voice:
        await ctx.send("You are not connected to a voice channel")
        return
    
    else:
        channel = ctx.message.author.voice.channel

    try: await channel.connect()
    except: pass

    server = ctx.message.guild
    voice_channel = server.voice_client
    
    try:
        async with ctx.typing():
            player = await YTDLSource.from_url(queue[0], loop=client.loop)
            voice_channel.play(player, after=lambda e: print('Player error: %s' % e) if e else None)
            
            if loop:
                queue.append(queue[0])

            del(queue[0])
            
        await ctx.send('**Now playing:** {}'.format(player.title))

    except:
        await ctx.send('Nothing in your queue! Use `?queue` to add a song!')
cold sonnet
#

it does

tidal hawk
desert badger
cold sonnet
#

break ToS

scarlet hull
desert badger
#

why

cold sonnet
#

!ytdl

unkempt canyonBOT
#

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
desert badger
#

ah ok

#

time to delete it lol i thought its legit

#

sorry discord <3

cold sonnet
scarlet hull
desert badger
cold sonnet
#

preferably not

cold sonnet
desert badger
cold sonnet
#

it's () not {}

scarlet hull
#

Bruh

desert badger
#

or basically just

#

await ctx.send(ctx.guild.members)

cold sonnet
#

it's gonna look weird tho

desert badger
#

any other ways to make music bots without breaking tos ?

scarlet hull
#

uhhh that didn't work I've tried this for long time ago

desert badger
cold sonnet
desert badger
#

what about spotify ? is that allowed ? lol

winged bone
#

Probably not

cold sonnet
#

idk

#

probably not indeed

winged bone
#

I'd Use copyright free music

desert badger
#

i was boutta say

cold sonnet
#

but how do you check that in a bot

desert badger
#

i basically just want my bot to chill 24/7 in vc and loop lofi music lol

cold sonnet
#

non-copyright is ok

desert badger
#

i could technically download mp3 files that are not copyrighted ig

cold sonnet
#

yes

#

but it'd make sense if you had to download it manually and then use it

#

so you don't fuck youtube 24/7 with downloads

#

I don't know

tidal hawk
cold sonnet
desert badger
#

voice_channel.play() what do i do in here if i want to play mp3 files

tidal hawk
#

!d discord.abc.User

unkempt canyonBOT
#

class discord.abc.User```
An ABC that details the common operations on a Discord user.

The following implement this ABC:

• [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User")

• [`ClientUser`](https://discordpy.readthedocs.io/en/master/api.html#discord.ClientUser "discord.ClientUser")

• [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member")...
cold sonnet
#

!d discord.Member.bot

unkempt canyonBOT
#

property bot```
Equivalent to [`User.bot`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.bot "discord.User.bot")
slate swan
#
@bot.command()
async def пред(ctx, member: discord.Member = None, *, reason = None):
    print(45)
    if ctx.author.bot.user:
        return
    
   
    cursor.execute("""CREATE TABLE IF NOT EXISTS warning(guild BIGINT, userid BIGINT, warn INT, count INT, reasons VARCHAR);""")
    base.commit()
    print(1)

    if member is None:
        await ctx.send("Выберите участника")
        
        if reason is None:
           cursor.execute('INSERT INTO warning(guild, userid, warn, count, reasons) VALUES(%s, %s, %s, %s, %s)', (ctx.guild.id,ctx.author.id,1,1,'Отсутствует'))
           base.commit()
           print(2222)
           cursor.execute('UPDATE warning SET warn = warn + 1 WHERE userid = %s AND guild = %s', (member.id, ctx.guild.id))
           base.commit()
           await ctx.send(f"**{member}** Выдал предупреждение {ctx.author.name} , причина ``Отсутствует``.")
        else:
           cursor.execute('INSERT INTO warning(guild, userid, warn, count, reasons) VALUES(%s, %s, %s, %s, %s)', (ctx.guild.id,ctx.author.id,1,1,reason))
           base.commit() 
           cursor.execute('UPDATE warning SET warn = warn + 1 WHERE userid = %s AND guild = %s', (member.id, ctx.guild.id))
           base.commit()
           await ctx.send(f"**{member}** Выдал предупреждение {ctx.author.name} , причина {reason}.")       

Nothing output except 45 and 1, why?

slate swan
#

help me

desert badger
#

seems legit

cold sonnet
#

don't even know what that is

cold sonnet
#

!d discord.User.bot

unkempt canyonBOT
cold sonnet
#

returns a boolean

#

does not exist

tidal hawk
slate swan
#

🤔

cold sonnet
tidal hawk
#

I think he used a command where he mentioned a Member

cold sonnet
#

me dumb

slate swan
cold sonnet
#

well, is member and reason None?

slate swan
neat pagoda
#

Ayo, does anyone know a lot about coding discord economy bots?

cold sonnet
slate swan
#

?

tidal hawk
#

How did you use that command? .пред(@slate swan, reason)?

slate swan
#

.пред @tidal hawk or .пред @tidal hawk reason

tidal hawk
#

Unindent if reason is None

cold sonnet
#

the if statement is only true if member is none

tidal hawk
#

Currently it only runs if you do not mention a user

cold sonnet
#

try just
.pred

#

with russian letters which I don't have

slate swan
#

._.

cold sonnet
#

without the ping

tidal hawk
#

You got it @slate swan?

slate swan
#

Not really

tidal hawk
#
@bot.command()
async def пред(ctx, member: discord.Member = None, *, reason = None):
    print(45)
    cursor.execute("""CREATE TABLE IF NOT EXISTS warning(guild BIGINT, userid BIGINT, warn INT, count INT, reasons VARCHAR);""")
    base.commit()
    print(1)

    if member is None:
        await ctx.send("Выберите участника")
        return
        
    if reason is None:
       cursor.execute('INSERT INTO warning(guild, userid, warn, count, reasons) VALUES(%s, %s, %s, %s, %s)', (ctx.guild.id,ctx.author.id,1,1,'Отсутствует'))
       base.commit()
       print(2222)
       cursor.execute('UPDATE warning SET warn = warn + 1 WHERE userid = %s AND guild = %s', (member.id, ctx.guild.id))
       base.commit()
       await ctx.send(f"**{member}** Выдал предупреждение {ctx.author.name} , причина ``Отсутствует``.")
    else:
       cursor.execute('INSERT INTO warning(guild, userid, warn, count, reasons) VALUES(%s, %s, %s, %s, %s)', (ctx.guild.id,ctx.author.id,1,1,reason))
       base.commit() 
       cursor.execute('UPDATE warning SET warn = warn + 1 WHERE userid = %s AND guild = %s', (member.id, ctx.guild.id))
       base.commit()
        await ctx.send(f"**{member}** Выдал предупреждение {ctx.author.name} , причина {reason}.")
slate swan
#

:(

neat pagoda
cold sonnet
#

youtube tutorial guy with horrible youtube tutorials

neat pagoda
#

lol

neat pagoda
#

I mean someone that can help me

cold sonnet
#

probably return await ctx.send in the first if statement

#

or dunno

slate swan
neat pagoda
#

like

boreal ravine
cold sonnet
neat pagoda
#

DOes anyone know a lot about coding economy bots, and could help me

tidal hawk
#

Don't forget the return !! @slate swan

tidal hawk
cold sonnet
#

almost everyone here can make an economy bot, but is used to helping those who know what they've got a problem with

neat pagoda
tidal hawk
#

And just do not store balance items etc in json

neat pagoda
#

I'm gonna be going to College in a few years lik the founder, and won't have a lot of time

cold sonnet
neat pagoda
#

Can anyone help us with the codings?

cold sonnet
#

we ain't writing a bot

#

like that

tidal hawk
#

Hahaha

cold sonnet
#

jk

neat pagoda
#

lol

velvet compass
#

!rule 9

unkempt canyonBOT
#

9. Do not offer or ask for paid work of any kind.

tidal hawk
#

bruh

winged bone
neat pagoda
#

very

velvet compass
cold sonnet
#

sorry

neat pagoda
#

but I'm a bit iffy on economy bots

slate swan
#

hi guys

cold sonnet
#

is every mod stalking like that? pithink

tidal hawk
#

xD

winged bone
#

but you know how to create a bot?

neat pagoda
wanton cipher
#

imagine stalking o.o

tidal hawk
#

Commited Discord mods

boreal ravine
cold sonnet
#

nerdy

velvet compass
slate swan
#

im trying to make a join message that looks similar to this. I'm very new to python and im excited to learn!

#

client = discord.Client()

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

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

    if message.content.startswith('$hello'):
        await message.channel.send('Hello! This is my only cmnd at the moment lol')

client.run('token')```
#

this is my code so far. I heard smth abt "member intents" but i do not know how to use those

desert badger
#

disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: source must be an AudioSource not str what do i do

slate swan
#

source must be an AudioSource not str

desert badger
#

ye but

#

how do i fix that it is an AudioSource

slate swan
#

no clue

desert badger
#
                musicdir = os.listdir("./music_downloads")
                for file in musicdir:
                    voice_channel.play(file)
```e
#

in here lol

slate swan
#

yeah but i dont know how to use on_member_join

tidal hawk
#

@client.event
async def on_member_join(member):
    your_channel = client.get_channel(id)
    embed = discord.Embed(title=f"{member.name} joined {member}", description="blabla")
    await your_channel.send(embed=embed)

neat pagoda
#

you wanna download something and play it?

gaunt ice
#

u wanna play all the music in that folder?

#

@desert badger

neat pagoda
#

or yeah what ^ said

cold sonnet
gaunt ice
#

ey hows ur chess bot going

desert badger
gaunt ice
cold sonnet
neat pagoda
#

ok

desert badger
#

ok

velvet compass
neat pagoda
#

try this

cold sonnet
#

you got two arms too?

neat pagoda
#

got it from stack overflow but

from time import sleep
from pathlib import Path  # for directory listing
import pygame

DIRECTORY = Path('./path/to/your/directory')
mixer.init()

for fp in DIRECTORY.glob('*.mp3'):
    # add each file to the queue
    mixer.music.load(str(fp))
    mixer.music.play()

    # now wait until the song is over
    while mixer.music.get_busy():
        sleep(1)  # wait 1 second
manic wing
#

this isn’t about discord bots…

neat pagoda
#

I'm too lazy to code this, I can, but i don't want to

gaunt ice
#

pathlib module

gaunt ice
desert badger
oak warren
#

!ytdl is a thing

desert badger
#

is that message meant to me lol

manic wing
gaunt ice
neat pagoda
desert badger
neat pagoda
gaunt ice
oak warren
gaunt ice
#

like foxy said

desert badger
gaunt ice
neat pagoda
#

yw

oak warren
#

Have you ever seen it

#

The command

neat pagoda
#

if it doesn't work, I'll code it

cold sonnet
neat pagoda
#

are you on mac linux or windows

gaunt ice
oak warren
#

Go to #bot-commands and do !ytdl

cold sonnet
#

chess.com

oak warren
#

We don’t help with music stuff here

#

Because source unknown

gaunt ice
#

lichess.com

cold sonnet
#

no

gaunt ice
#

ok

neat pagoda
#

I've had experience with files @desert badger

#

like autodeleting exe files

cold sonnet
#

you can move those pieces anywhere on the map

gaunt ice
desert badger
gaunt ice
cold sonnet
#

no

gaunt ice
#

hm

neat pagoda
#

if windows, prolly yes

desert badger
#

windows

desert badger
#

@neat pagoda disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: source must be an AudioSource not WindowsPath

formal basin
formal basin
wicked jungle
formal basin
#

Oh

wicked jungle
#

So like

gaunt ice
#

title="",description=""

wicked jungle
#

Yeah that Ty lol

gaunt ice
#

lol

wicked jungle
#

Was on phije

#

Phone

gaunt ice
#

hmhm

flat flower
#

I don’t think you need a tile and a description

gaunt ice
#

me too lol

flat flower
#

That’s only for name and value

gaunt ice
#

idk why that error pops up

wicked jungle
static beacon
flat flower
#

Let me look at how he set it up

static beacon
#

i can use only title. thats weird

formal basin
wicked jungle
#

That’s weird

#

Show code

gaunt ice
#

it was updated

flat flower
#

I am confused

gaunt ice
#

the description isnt required anymore

wicked jungle
#

Oh that’s cool

flat flower
#

The description should not be a problem, is it a indent error?

formal basin
static beacon
#

just spent 5 hours trying to fix a website error just to realize its in the css lemon_angrysad

gaunt ice
#

lmfao

gaunt ice
manic wing
wicked jungle
#

It looks good to me try resetting your repl

flat flower
#

OH, you have some lines that MUST be indented in order for it to run properly

flat flower
#

Let me circle it

gaunt ice
#

yes. its the repls problem

wicked jungle
#

Yeah unless I’m blind they look indented

gaunt ice
#

dont use replit for hosting d bots

#

as they use shared ips

flat flower
#

Never mind I’m an idiot lol

wicked jungle
#

@formal basin refresh your screen if that doesn’t work delete the module files and reninstall

flat flower
#

I think you can use netifly to host it for free. Or, I always rely on AWS.

wicked jungle
#

Aws??? Lol for discord bots

flat flower
#

It works

static beacon
wicked jungle
#

That’s like a pain to set up tho

#

I use uptime

flat flower
#

It’s a pain in the ass to set up, but once you set it up it is easy to change. You have to do it a certain way for it not to be annoying.

slate swan
#

Where can I host my bot for free 💀

flat flower
#

Look up how to do that

slate swan
static beacon
wicked jungle
static beacon
flat flower
#

Don’t use repl!!

static beacon
#

its pretty good

flat flower
#

It’s nothing but a messed up pain in the ass

#

Sorry if you like it

wicked jungle
#

Nah it’s good

slate swan
#

Honestly I don't like repl at all 💀

left crater
#

its not

flat flower
#

Thank you lol

static beacon
wicked jungle
#

I think it is

slate swan
static beacon
gaunt ice
#

use vsc and heroku

static beacon
#

we need to curb stomp replit

flat flower
gaunt ice
#

replit is for boomers

static beacon
flat flower
slate swan
#

Lol

slate swan
flat flower
wicked jungle
#

I don’t host it locally to much security issues

#

Not worth the risk

flat flower
static beacon
# slate swan Why

it gets rate limited, it sucks, its laggy, it crashes all the time, resources are limited, just use your pc, turns off every 8 seconds.

gaunt ice
# slate swan Why

it uses shared ips meaning if someone hosting a bot that gets rate limited ur bot will get ratelimited too

static beacon
wicked jungle
#

Yeah but still

slate swan
#

Nd yeah it was unable few times

static beacon
gaunt ice
flat flower
#

If you ever need help, google has everything 😂

static beacon
#

its so much easier to just host on ur pc

slate swan
flat flower
gaunt ice
gaunt ice
#

yes and ur pc

static beacon
#

notepad and your cp

#

PC***********

slate swan
#

Can my pc be able to host it?

static beacon
#

all you need

slate swan
#

24 hrs

static beacon
slate swan
#

How

static beacon
static beacon
# slate swan How

you run. it work on your computer. it stay on as long as host stay on.

slate swan
#

🙄 aint my laptop will fall sick , my poor laptop

gaunt ice
#

use vps

slate swan
formal basin
#

Nothing is working

gaunt ice
#

or link

formal basin
static beacon
#

not here edo

formal basin
formal basin
vale wing
#

!pypi aiohttp

unkempt canyonBOT
gaunt ice
static beacon
gaunt ice
#

he has keep_alive lol

static beacon
vale wing
#

Replit hosting

static beacon
#

if theres underscores, its probably from a tutorial

vale wing
#

No offense but that's cringe

gaunt ice
#

so cringe

#

yoooo

static beacon
#

i just use replit for the web development and then use cloudflare for everything else bc replit nameservers suck

gaunt ice
#

true

static beacon
#

like it isnt bad

#

because theres not many downsides

vale wing
#

Idk I have vsc for everything besides android dev

static beacon
#

except you cant edit the 404 page

gaunt ice
#

hmh

static beacon
#

well you can, but its rlly finnicky

#

then ill have to remake the whole site in node

#

it seems to work for https://mechabot.tk/

gaunt ice
#

is that urs?

static beacon
#

well not mine, i help with web development

#

but yeah i guess

formal basin
#

Anyone know what is wrong with the code

gaunt ice
#

hmhm

static beacon
#

were changing the color palette currently

gaunt ice
static beacon
#

honestly just looking for criticism if you're open

vale wing
#

Print the response code

#

90% you will have 401

static beacon
#

@formal basin click this

#

it formats the file for you

#

perhaps it could help

formal basin
#

It does nothing

static beacon
#

it resets replits formatter

#

so it wont give shitty errors like that

#

and also catch them better

formal basin
#

That’s a txt file

static beacon
#

?

formal basin
#

The image

tawdry perch
#

were from disnake.ext import menus those menus deleted from disnake?

boreal ravine
#

thats an extension, you gotta install it

tawdry perch
#

extension?

boreal ravine
#

yes

tawdry perch
#

how do I install it?

boreal ravine
#

it was for d.py, not sure if disnake has a monkey-patched version

#

!pypi disnake-ext-menus

unkempt canyonBOT
boreal ravine
#

download that :)

tawdry perch
#

thx!

static beacon
#

that looks 50% like a fork

boreal ravine
#

obviously

vale wing
#

That looks like a weird 10th party lib but that's only my opinion so don't pay attention 😅

tawdry perch
#

one more question, where could I install jishaku?

slate swan
#

!pypi jishaku

unkempt canyonBOT
tawdry perch
#

thx, I messed up all my pip packages smh

slate swan
desert badger
#
Traceback (most recent call last):
  File "C:\Users\Niclas\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\ext\commands\core.py", line 169, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\Niclas\Desktop\Other\Python\NcZ Discord Bots\NcZ\main.py", line 495, in play
    vc.play(source)
  File "C:\Users\Niclas\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\voice_client.py", line 605, in play
    raise ClientException("Already playing audio.")
disnake.errors.ClientException: Already playing audio.

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

Traceback (most recent call last):
  File "C:\Users\Niclas\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\ext\commands\bot_base.py", line 570, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\Niclas\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\ext\commands\core.py", line 920, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\Niclas\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\ext\commands\core.py", line 178, in wrapped
    raise CommandInvokeError(exc) from exc
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: ClientException: Already playing audio.``` how do i fix this error
#

just an asyncio.sleep(1) before the play thing ?

manic wing
#

what are you playing? o.O

desert badger
#

some copyright free mp3 file i downloaded

desert badger
glossy hill
#

hello. What have I missed in 3 days?

south jetty
#
Command raised an exception: NameError: name 'MyView' is not defined```
south jetty
placid skiff
#

Someone has an example of d.py working with motor? a github repo would be fine

south jetty
slate swan
#

!pip motor ic

unkempt canyonBOT
placid skiff
#

yeah i need some examples because motor uses a different loop when is declared and from the latest version you can't give a loop when you declare the database

tidal hawk
tidal hawk
#

Did you create a class inside a class?

#

move it outside

slate swan
#

imagine a class inside a class pffttt

placid skiff
#

today i tried to make it work, essentially i had to declare the database inside an async function and then call it with asyncio
in my bot i will not initialize the database using the bot loop, i want to create an utils folder where to put my essentials query, so i'm trying to find how others used it

south jetty
tidal hawk
#

Create the class outside the current class

slate swan
#

try self.MyView or move the class outside the cog

tidal hawk
#

please move it outside xD

slate swan
#

idk if you can have that

placid skiff
tidal hawk
#

HM

slate swan
#

!e


class FirstClass:
       def  __init__(self): pass
       class SecondClass: pass
c = FirstClass()
print(c)```
unkempt canyonBOT
#

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

<__main__.FirstClass object at 0x7f1824f555a0>
south jetty
placid skiff
#

btw is not suggested to create class inside class i think, we are not in Java D_D

cursive needle
#

I have a little knowledge of basic python. where can i learn on how to make discord bots because the freecodecamp video on YouTube is outdated as the code doesn't work anymore

tidal hawk
south jetty
slate swan
cursive needle
tidal hawk
#

Bro I really recommend you to learn classes first, it doesn't take long and ur life would be much easier

slate swan
tidal hawk
#

Exactly

night knoll
desert badger
#
    async with ctx.typing():
        song_list = []
        for f in os.listdir("./music_downloads"):
            song_list.append(f)
            chosen_song = random.choice(song_list)
            pass
        while True:
            song_name = chosen_song.replace(".mp3", "")
            em = disnake.Embed(
                color = disnake.Color.purple()
            )
            if chosen_song.startswith("uppbeat"):
                _song_name = song_name.replace("uppbeat", "")
                em.description = f"**Now playing: {_song_name}**"
                em.set_footer(text = "Downloaded from Uppbeat")
                pass
            source = disnake.FFmpegPCMAudio(f"./music_downloads/{chosen_song}")
            vc = ctx.guild.voice_client
            await asyncio.sleep(3)
            vc.play(source)
            await musicchannel.send(embed = em)
``` can anyone help me fixing this code? i keep on getting that `Command raised an exception: ClientException: Already playing audio.` error
night knoll
#

what should i type

tidal hawk
#

Bro you still here xD

slate swan
#

nice

placid skiff
# slate swan oh cool, nothing was understood by me

i had to do something like this:

async def insert():
  client = motor.motor_asyncio.AsyncIOMotorClient("localhost", 27017)
  #other stuff

asyncio.run(insert())

because this

client = motor.motor_asyncio.AsyncIOMotorClient("localhost", 27017)
async def insert():
  #other stuff

asyncio.run(insert())

Threw insert() already in a loop error

tidal hawk
night knoll
#

i dont know

tidal hawk
cursive needle
night knoll
#

i tried taking a bot from github and it asked me for this

slate swan
tidal hawk
#

uwu song

slate swan
#

ignore the typos

cold sonnet
#

and the uwu

placid skiff
#

oh maybe i find something on github, hoping that will not be the stereotype of disocrd bot developer declaring client = discord.ext.commands.Bot()

tidal hawk
#

@cold sonnet

cold sonnet
#

no

tidal hawk
#

Your bio worked!

cold sonnet
#

kingbio

placid skiff
#

||fuck|| this ||shit|| i'm out

tidal hawk
#

Mod is coming for you

#

xD

placid skiff
#

I feel them breathing on my poo-poo

maiden fable
#

😔

tidal hawk
#

Everybody do be with creative names and bios

slate swan
#

you guys are so funny ||oof||

cold sonnet
#

I called sink something while kiddin and a mod came and got me good

tidal hawk
#

Hahahah

#

You're on their watchlist now

cold sonnet
#

never

maiden fable
#

Everyone's humor here is on another level so I will just go back to optimizing my game

cold sonnet
#

mods love me and me Iove mods

tidal hawk
#

You're their kitten?

cold sonnet
#

yes

slate swan
placid skiff
#

WHAT I'M SEEING
I can't rely on people who wrote like that 😩

maiden fable
maiden fable
cold sonnet
tidal hawk
#

||Imagine if bot's cant read this||

placid skiff
placid skiff
cold sonnet
#

it's mine

#

for loops for noobs

#

right, hunter?

maiden fable
placid skiff
#

please no i can feel the pain without even openin' it

tidal hawk
#

That's hot

maiden fable
#

Nothing can beat this

#

LMAO

placid skiff
#

..................

boreal ravine
cold sonnet
#

that's my coder

south jetty
# tidal hawk Send multiple images
class Ticket_Bot(commands.Cog):

    def  __init__(self, client):
        self.client = client

    class MyView(View):
        def __init__(self, client):
            super().__init__(timeout=None)```
Or could you explain how its a class in a class or if theres a doc on it or smth
slate swan
maiden fable
cold sonnet
#

is it slow though

maiden fable
#

BTW are for loops faster than using slicing?

tidal hawk
placid skiff
maiden fable
#

Hmm okay

spring flax
#

Whats the #type ignore mean? I see that a lot

maiden fable
placid skiff
unkempt canyonBOT
#

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

maiden fable
#

I think I will just go away from here

boreal ravine
#

@slate swan stop ghost pinging people

slate swan
maiden fable
maiden fable
#

Eh, if u talking bout my message reply, I did saw the ping so it doesn't count as a ghost ping

south jetty
slate swan
#

😔 sad to see people try to act oversmart every time

maiden fable
#

Lmaoo

#

😔 I wanna comment so badly on the msg but I will just go away

tidal hawk
placid skiff
#

so to make a stupid example, to store some sort of Q:A i can do something like this:

Guild_Collection:
  id_of_the_guild{}
  some other stupid stuff{}
  Question{
    one_stupid_question{}
    another_stupid_question{}
  } 
  answer{
    stupid_answer_for_first_question{}
    another_stupid_asnwer{}
  }

Right?

maiden fable
#

uhhhhh

#

what am I looking at?

placid skiff
#

in python dict will be something like this:

my_guild = {"id": 1, "question": {"question_1": 1, "question_2": 2}, "answer": {"answer_1": 1, "answer_2": 2}}
maiden fable
#

Okay?

placid skiff
#

and so goes on, essentially can i store with mongo a dict which has a dict inside? lol

placid skiff
#

well find my asnwer and is NO of course hahahaha

#

mh my mind isn't trained to work with json using mongo is the baddest idea i've ever had

tidal hawk
#

my_guild = { "1": {"question_1": "answer_1", "question_2": "answer_2"}}

placid skiff
#

Will not work found this on stackoverflow

tidal hawk
#

Why?

boreal ravine
#

I saw you deleting the message Bruhmoment

placid skiff
south jetty
placid skiff
#

there is an async package for postgresql?

tidal hawk
tidal hawk
boreal ravine
unkempt canyonBOT
tardy plume
#

what do i need to make my bot allow to write to my github repository file?

south jetty
# tidal hawk channel1 = interaction.guild.get_channel(879783539258847354)

oh, this is another command

    @commands.command()
    @commands.has_role("Middleman")
    async def delete(self, ctx):
        if ctx.channel.category.name!="Closed Tickets":
            return await ctx.send("You can't use this command here!")
            
        embed = discord.Embed(description="Deleting ticket in 5 seconds...", color=0xb92222)
        await ctx.send(embed=embed)
        await asyncio.sleep(5)
        await ctx.channel.delete()
        
        channel1 = client.get_channel(879783539258847354)
        embed1 = discord.Embed(
            title = f"{ctx.author.name}#{ctx.author.discriminator}",
            description = f"**Logged Info:**\n Ticket: {ctx.channel.name}\n Action: Deleted",
            color = 0xb92222
            )
            
        await channel1.send(embed=embed1)```
slim ibex
boreal ravine
slim ibex
#

what is that supposed to mean🗿

quaint epoch
#

would bot.wait_for('message') return a message obj?

slate swan
#

yes

quaint epoch
slate swan
south jetty
tidal hawk
#

Good job

quaint epoch
#

If i have two instances of channel sus will inst1 == inst2 return True?

tidal hawk
#

two instances of the same channel?

quaint epoch
#

yes

tidal hawk
quaint epoch
#

run a check in on_message

#

im pretty sure logs are listed in discord tos

static beacon
#

check message.content through words and send a message and delete it. its pretty easy with an on_message event

quaint epoch
#

something like they have to be encrypted and deleted after 30 days

#

so no

static beacon
quaint epoch
static beacon
#

logging bots lemon_scared

#

np

slate swan
slate swan
#

what worked

quaint epoch
slate swan
#

!e

class A():
    ...
a = A()
b = A()
print(a == b, a is b)
unkempt canyonBOT
#

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

False False
slate swan
quaint epoch
static beacon
#

no bitches?

#

im sorry it reminded me of that

quaint epoch
slate swan
#

bro its basic python lmfao

quaint epoch
#

btw how you check who created a channel?

static beacon
static beacon
velvet tinsel
slate swan
# static beacon
print((password_generator:=lambda num:f"Your new password is:\n{''.join(__import__('random').sample('1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$%^&*()_-+=|>.<,/?', num))}")(2)) 

what ive done

slate swan
#

yes it is

slate swan
slate swan
rose birch
#

hey folks, I'm wondering what's a better way to send messages. output is very, very slow so I'm thinking I'm being rate limited

# my current one
lines = ['Hello..', ....]
for line in lines:
  await ctx.send(line)
marble rampart
#

you can use embed

#

or you can use webhook to send a lot of msgs without rate limit (i think)

honest shoal
#

can I obtain chat history of my bot and a user?

rose birch
marble rampart
#

ho nvm

marble rampart
#
@client.command() / @bot.command()
async def history(ctx):
    messages = await ctx.channel.history(limit=YourLimit).flatten() # you can change the messages var to the dm channel and it will work
    for message in messages: # Get only the messages and not any extra information
        print(message.content)
#

@honest shoal do you need any more help?

marble rampart
#

so?

honest shoal
#

I was asking about dms

marble rampart
#

i know

honest shoal
#

bot and a user

marble rampart
#

look at the comment

#

# you can change the messages var to the dm channel and it will work

honest shoal
#

do I need to create a dm

marble rampart
#

i think so

#

wait a sec

#

how do you want to fetch the user ? (with id ?)

honest shoal
#

yes

quaint epoch
#

I've had to redeploy my app 3 times, because i typed @commands.commands instead of commands, used a tuple instead of a list, and i did message.contentlower() instead of .lower()

marble rampart
#

so change messages var to await bot.fetch_user(id)

#

something like this

#

ho wait not ctx

honest shoal
#

bot

marble rampart
#

yes

honest shoal
#

I know how to fetch a user, but what will be defined as a channel there? or just the fetched var of user

cold sonnet
#

!d discord.User check here

unkempt canyonBOT
#

class discord.User```
Represents a Discord user.

x == y Checks if two users are equal.

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

hash(x) Return the user’s hash.

str(x) Returns the user’s name with discriminator.
marble rampart
#

i found it out

cold sonnet
#

!d discord.User.dm_channel

unkempt canyonBOT
#

property dm_channel```
Returns the channel associated with this user if it exists.

If this returns `None`, you can create a DM channel by calling the [`create_dm()`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.create_dm "discord.User.create_dm") coroutine function.
marble rampart
#

look:

honest shoal
slate swan
marble rampart
#
@client.command() / @bot.command()
async def history(ctx):
    messages = await bot.fetch_user(id).dm_channel.history() 
    for message in messages: # Get only the messages and not any extra information
        print(message.content)
cold sonnet
#

just user.dm_channel which is similar to a TextChannel, so you can use the history method of it

#

yeah

slate swan
#

you know whats better

marble rampart
#

?

slate swan
#

discords tos

#

💀

#

terms of service

marble rampart
#

dame

#

u saw none

marble rampart
slate swan
#

i saw everything 🗿

cold sonnet
#

😋 ToS delicious

slate swan
#

yes

honest shoal
#

oh

marble rampart
#

c ya

cold sonnet
#

about me haha

slate swan
#

those buttons😭

cold sonnet
#

what

marble rampart
#

bro lets talk

cold sonnet
#

the language?

slate swan
marble rampart
#

xD

slate swan
cold sonnet
#

I find them cul

slate swan
#

what are thoseeeee💀

marble rampart
#

tf is this

slate swan
marble rampart
#

whare you get this from

cold sonnet
#

they come with the theme

slate swan
cold sonnet
#

stop

marble rampart
#

lmfao

cold sonnet
#

cyberbully

slate swan
#

im sorry its just the theme looks so 2000😭

marble rampart
#

shame on you

#

u cyberbully

slate swan
cold sonnet
marble rampart
#

wat

slate swan
marble rampart
#

what have i done?

cold sonnet
#

selfbots

marble rampart
slate swan
marble rampart
#

no i didnt

cold sonnet
#

oh nice

slate swan
marble rampart
#

ok

#

ima need to get some milk

cold sonnet
#

me neither

#

I saw plenty of ToS breakers here

slate swan
cold sonnet
#

including myself

marble rampart
#

🥛🥛🥛🥛🥛

slate swan
cold sonnet
#

bro

slate swan
marble rampart
#

be a shame

cold sonnet
#

what did he say

#

be ashamed

honest shoal
#

@marble rampart thanks, and is it possible getting the messages only of user not the bot?

marble rampart
#

but it sound more cool

cold sonnet
#

but it sounds more cool

marble rampart
cold sonnet
#

uh

marble rampart
#

can you n o t

honest shoal
#

this is my code rn py user = await _bot.fetch_user(727526184161902614) async for message in user.dm_channel.history(limit=3): await _ctx.send(message.content)

marble rampart
#

ok when sec

cold sonnet
#

now wait

marble rampart
#

il check something

cold sonnet
#

!d discord.TextChannel

unkempt canyonBOT
#

class discord.TextChannel```
Represents a Discord guild text channel.

x == y Checks if two channels are equal.

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

hash(x) Returns the channel’s hash.

str(x) Returns the channel’s name.
honest shoal
#

🗿

marble rampart
#

discord.DMChannel.history() returns a list of messages class right ?

honest shoal
#

lemme check

cold sonnet
#

I'm so done

#

what's the syntax for an async iterator method

#

in the bot

#

!d discord.abc.Messageable.history

unkempt canyonBOT
#

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

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

Examples

Usage...
marble rampart
#

if it is so you can use author.user and get a lot of info about the user/bot that sent the message

cold sonnet
#

just got it

marble rampart
#

then you check if its a bot or not

cold sonnet
#

so just author.bot?

#

!d discord.User.bot

unkempt canyonBOT
marble rampart
#

yes it will return False or True

#

python is typing

cold sonnet
#

indeed

cold sonnet
#

basically you have a list of messages from history

#

which you use in the for loop

#

async for message in channel.history():

#

then you check if message.author.bot

#

which will either be True or False

marble rampart
#

thats right