#discord-bots

1 messages · Page 1007 of 1

slate swan
#

Nope

#

In 2.0 it works

livid elk
#

something like that

slate swan
#

No

paper sluice
#

u need to git clone it

slate swan
#

It's a development version, so not on PyPI

livid elk
#

oh

#

but it worked on local machine

#

is it the rapptz repo

slate swan
#

Yes

paper sluice
#

python -m pip install git+https://github.com/rapptz/discord.py

livid elk
#

oh i remeber that command

#

now i remember

#

thanks it works

slate swan
#

hi

feral lichen
#

i recc bot-hosting.net i use it and its really cheap but since urs seems more complicated idk just logging into ptreodactyl is odd at first and imports but i'd say its good

#

took some time, currently working on an anti nuke rn which is easier than expected

supple thorn
#

Damn i wanted to see it's source code

slate swan
#
        msg = await self.bot.get_partial_messageable(channel).fetch_message(id)
        dsd = [users.id for reaction in msg.reactions if reaction.emoji == '\U0001f389' async for users in reaction.users() if option == 1 for i in await msg.guild.invites() if i.inviter == users and i.uses < number]
#

AttributeError: 'NoneType' object has no attribute 'invites'

#

why this is None

#

😑

#

Do you or someone else use it in DMs? In that case msg.guild would be None. If not we need more context

potent spear
#

correct intents are also important

potent spear
#

most important note: you should get the message, probably no reason to fetch it

placid skiff
potent spear
#

also, I see you like list comprehension, but readability is also important

placid skiff
#

but until we know what is channel and id we could not know why

slate swan
#

this works fine ... for reaction in msg.reactions

#

Read the error

#

yes

#

yes

placid skiff
slate swan
#

It would be 'NoneType' object has no attribute 'guild' if message is None

slate swan
slate swan
#

It's just error reading

slate swan
slate swan
#

<class 'disnake.message.Message'>
<Message id=968800945142104114 channel=<Object id=966647744196382750> type=<MessageType.default: 0> author=<User id=931480587829653555 name='Sluppy' discriminator='6431' bot=True> flags=<MessageFlags value=0>>

#

LOL

#

Enable the guilds intent

PS: There we have another confirmation msg.guild is None and not msg.

slate swan
#

Which ones have you enabled?

#

And when you create the bot variable?

slate swan
# slate swan And when you create the `bot` variable?
class Sluppy(commands.Bot):
    def __init__(self):
        super().__init__(command_prefix=prefix, intents=intents)

    def setup(self):
        self.add_view(RowButtons(bot))

    def run(self):
        super().run(token=tokens)
        self.setup()
bot =  Sluppy()
paper sluice
#

are prefix and intets global vars?

paper sluice
slate swan
#

..

paper sluice
#

ya whats the prob, im late

paper sluice
#

what did u run?

slate swan
#

msg = await self.bot.get_partial_messageable(channel).fetch_message(id)

#

this return that

#

hi?

feral lichen
slate swan
feral lichen
#

or distake.intents.all()

slate swan
#

No it doesn't matter

feral lichen
#

no just enables everything

slate swan
slate swan
#

Just make sure you enable all privileged intents in the developer portal

slate swan
#

Which you might not have access to once your bot gets verified

#

So I would recommend to only enable the ones you really need and not all just because someone said so

#

let me check again

#

in dev portal

vale wing
slate swan
vale wing
#

If I build a server I will host it there

feral lichen
#

ight

vale wing
#

Cause cloud hosting doesn't exist for russians now

slate swan
#

imagine hosting bot in a usb

vale wing
#

😩

slate swan
#

and connect it to mobile charger

feral lichen
#

oh, i didnt know you were russian, and cloud hosting for russians aint good'

vale wing
slate swan
#

lol

potent spear
slate swan
vale wing
feral lichen
#

im guessing for the ukraine shit

vale wing
#

Not our business this is discord bots

feral lichen
#

ah

feral lichen
potent spear
#

isn't that obvious?

slate swan
feral lichen
#

either that or my brain is the guy in my pfp

slate swan
potent spear
#

war ~ companies don't want to support "the wrong side" ...

feral lichen
#

i asked and he said not our business just discord bots lmfao

#

but idk then

slate swan
#

i want a pfp for my bot

supple thorn
slate swan
supple thorn
tired hinge
#

if i was to create a @tasks.loop which repeated a method every hour,
will the loop reset if my bot goes down? if yes, can i prevent it from doing so?

slate swan
#

anyone pls help me

potent spear
supple thorn
livid elk
#

somebody explain to me COGS

tidal hawk
#

I'd say these are just different files where you can store different commands

#

You can also change the code inside there and reload the file - update the bot without restarting it

#

Awesome for categorizing

jade tartan
#
    file=discord.File('rickerd.png', filename = "rickerd.png")
    e.set_image(url= "Desktop/discord server bot/rickerd.png")
    await ctx.send(file=file, embed=e)```
Is that the right way to have the bot send an embed image?
livid elk
jade tartan
#

how is it done?

tidal hawk
#

First of all the file location in your pc ain't url

livid elk
#

ye

#

url is WEB

jade tartan
#

well the image is in my desktop folder

tidal hawk
#

embed.set_image(file=discord.File(path))

jade tartan
#

embed.set_image(file=discord.File(Desktop/discord server bot/rickerd.png))

tidal hawk
#

""

#

It must be a string and I think you have to specify the disk aswell

jade tartan
#

embed.set_image(file=discord.File("C:\Desktop/discord server bot/rickerd.png"))

tidal hawk
#

yeah try it

jade tartan
#

doesnt work

slate swan
#

That's not how it works

tidal hawk
#

Error?

slate swan
#

!local-file

unkempt canyonBOT
#

Thanks to discord.py, sending local files as embed images is simple. You have to create an instance of discord.File class:

# When you know the file exact path, you can pass it.
file = discord.File("/this/is/path/to/my/file.png", filename="file.png")

# When you have the file-like object, then you can pass this instead path.
with open("/this/is/path/to/my/file.png", "rb") as f:
    file = discord.File(f)

When using the file-like object, you have to open it in rb mode. Also, in this case, passing filename to it is not necessary.
Please note that filename can't contain underscores. This is a Discord limitation.

discord.Embed instances have a set_image method which can be used to set an attachment as an image:

embed = discord.Embed()
# Set other fields
embed.set_image(url="attachment://file.png")  # Filename here must be exactly same as attachment filename.

After this, you can send an embed with an attachment to Discord:

await channel.send(file=file, embed=embed)

This example uses discord.TextChannel for sending, but any instance of discord.abc.Messageable can be used for sending.

slate swan
#

You can see an example here on how adding local images to an embed work ^

tidal hawk
#

Oh sorry, It works in disnake XD

jade tartan
#

am using py not disnake @tidal hawk

#

its different

tidal hawk
#

Yeah I figured it after you said it doesn't work

slate swan
unkempt canyonBOT
#

disnake/embeds.py lines 449 to 455

if file:
    if url:
        raise TypeError("Cannot use both a url and a file at the same time")
    if file.filename is None:
        raise TypeError("File doesn't have a filename")
    self._image = {"url": f"attachment://{file.filename}"}
    self._files.append(file)```
jade tartan
#
Traceback (most recent call last):
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "c:\Users\thoma\OneDrive\Desktop\discord server bot\verification.py", line 82, in verify5
    file = discord.File("discord server bot/line.png", filename="line.png")
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\file.py", line 73, in __init__        
    self.fp = open(fp, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: 'discord server bot/line.png'

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

Traceback (most recent call last):
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: FileNotFoundError: [Errno 2] No such file or directory: 'discord server bot/line.png'```
#

Do i have to specify the disc?

#

@slate swan

tidal hawk
#

If the image directory isn't in the same folder where ur bot is, then I'd also specify the disk

slate swan
#

I would overall not use spaces for development folder names

jade tartan
#

file = discord.File("file:///C:\Users\thoma\Desktop\discord server bot/line.png", filename="line.png") well it is directed to a folder when my bot is located

slate swan
#

C:Desktop is for sure wrong

#

That's not Windows's structure if you have it on your Desktop

#

C:\Users\<Username>\Desktop is the path when using the file explorer

#

And if you run the bot script in the discord server bot folder, then you can just use line.png as file.

potent spear
#

~relative paths

slate swan
#

Also note that using spaces in file and folder names is horrible in development

drifting arrow
#

spaces are fun

potent spear
tidal hawk
#

What does the x mean behind the sentence?

potent spear
#

it's a kiss

drifting arrow
#

in other words, disregard it

tidal hawk
#

but what's double xx?

drifting arrow
#

disregard it.

potent spear
tidal hawk
#

What's xoxo

drifting arrow
#

Disregard it. You dont know this stranger. dont accept kisses from them.

#

How do we know you havent been kissing other people?!

potent spear
#

does that matter?

drifting arrow
#

For me it does

tidal hawk
#

Let's seE wHat My BoT sAys

potent spear
#

there's some jealousy involved I see

jade tartan
#
    file = discord.File("file:///C:\Users\thoma\Desktop\discordserverbot/line.png", filename="line.png")
                                                                                  ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 10-11: truncated \UXXXXXXXX escape```
drifting arrow
potent spear
jade tartan
#

(__file__) whats this for?

#

the file directory

drifting arrow
potent spear
potent spear
drifting arrow
#

lol

jade tartan
#

linefile_path = Path(file:///C:\Users\thoma\Desktop\discord_server_bot/line.png).parent / 'line.png')

potent spear
#

never wrote that

boreal ravine
potent spear
jade tartan
#
async def verify5(ctx):
    channel = client.get_channel(967788019526561822)
    file = discord.File("file:///C:\Users\thoma\Desktop\discord_server_bot/line.png", filename="line.png")
    linefile_path = Path(__file__).parent / 'line.png'
    embed = discord.Embed()
    embed.set_image(url="attachment://line.png")
    await channel.send(file=file, embed=embed)```
potent spear
#
file = discord.File(linefile_path, filename="line.png")```
#

then you're done

#

obv define it UNDER the linefile_path

jade tartan
#
Traceback (most recent call last):
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "c:\Users\thoma\OneDrive\Desktop\discord server bot\verification.py", line 82, in verify5
    file = discord.Filefile = discord.File(linefile_path, filename="line.png")
UnboundLocalError: local variable 'linefile_path' referenced before assignment

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

Traceback (most recent call last):
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: UnboundLocalError: local variable 'linefile_path' referenced before assignment```
potent spear
#

maybe start reading what I type?

tidal hawk
#

x

jade tartan
#

i know what you mean there

boreal ravine
clever field
#

how to get values ​​from a string separated by a space ?

class con:
    async def console(self):
        ask = input(">")
        if ask == "exit":
            exit()
        elif ask == "ban HERE_ID":
            result = subprocess.run('ls')
        else:
            print("я нихуя не нашел")
potent spear
tidal hawk
#

x

clever field
boreal ravine
#

@tidal hawk you ok?

tidal hawk
#

xo

jade tartan
#

y

boreal ravine
#

no reason

potent spear
#

asking for input in console is blocking... unless you're working with some CLI which is independent of your main bot

clever field
potent spear
flint isle
#

I did more console art cause I was bored and I love the turnout

slate swan
potent spear
flint isle
potent spear
#

I wouldn't do that

flint isle
#

If anyone has any tips on how to make the parts scroll across like of terminal id love thay.

potent spear
flint isle
flint isle
buoyant zodiac
flint isle
supple thorn
#

My brain immediately thought of James Powell

flint isle
#

Lmao

supple thorn
#

Thought "He's a furry?"

#

I immediately looked into your github

flint isle
#

Lmao

supple thorn
#

I was thinking "There is no fucking way this is James Powell" while github was loading

#

Lmfao

flint isle
supple thorn
buoyant zodiac
supple thorn
flint isle
flint isle
supple thorn
#

This?

flint isle
supple thorn
slate swan
supple thorn
slate swan
#

heypithink

supple thorn
slate swan
#

its a capybara😡

supple thorn
#

😔

slate swan
#

hes drippy ok

supple thorn
#

It looks funny

slate swan
supple thorn
slate swan
supple thorn
slate swan
#

😳

supple thorn
#

I wonder where

slate swan
#

everywhere

supple thorn
#

Slimy capybara

slate swan
#

!d discord.Guild.emojis ?

unkempt canyonBOT
supple thorn
#

!d discord.Guild.emojis

unkempt canyonBOT
slate swan
#

slow

supple thorn
#

God fuck your speed

flint isle
#

Ty

slate swan
#

im a fast capybara

supple thorn
#

I was replying to david

slate swan
#

ok

flint isle
#

Wait what command do I put that courratine in to get an output

supple thorn
#

I stopped cause he deleted it 😠

supple thorn
slate swan
slate swan
#

Back

slate swan
#

I'm having error

spring flax
#

why are you trying to one line the dsd? Just making it complicated for yourself.

buoyant zodiac
#

bro could u help me please... when i get out of school i'll send u mine

livid hinge
#

is it possible to remove someone's ability to ping anyone? 😄

flint isle
#

The emojis

(<Emoji id=802746458088013864 name='furheart' animated=True managed=False>, <Emoji id=802746559912869918 name='petme' animated=True managed=False>, <Emoji id=802746690993913856 name='scream' animated=True managed=False>)

Code

await msg.add_reaction('<furheart:802746458088013864>')
paper sluice
livid hinge
novel apexBOT
#

This is not a Modmail thread.

potent spear
#

have you tried it?

cold sonnet
#

not dpy server is it

potent spear
#

yup, I was confused for half a sec

flint isle
potent spear
#

please, for the love of god, add an
else in your error handler
also, use elif

quaint epoch
#

how come when i tried this py @commands.command() async def ticket(self, ctx, reason): ... @ticket.on_error async def tick_error(self, ctx, error): await ctx.send(f'An error occurred while opening a ticket - `{error}`') raises an error that says command objects have no on_error attribute? im using the latest disnake version

cold sonnet
#

it's just error

#

not on_error

quaint epoch
livid hinge
#

they are doing some post where theres like 200 zero-width-space chars, which seems to stop the mention from showing up in their message

quaint epoch
#

!d disnake.ext.commands.Command.error

unkempt canyonBOT
#

@error```
A decorator that registers a coroutine as a local error handler.

A local error handler is an [`on_command_error()`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.disnake.ext.commands.on_command_error "disnake.disnake.ext.commands.on_command_error") event limited to
a single command. However, the [`on_command_error()`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.disnake.ext.commands.on_command_error "disnake.disnake.ext.commands.on_command_error") is still
invoked afterwards as the catch-all.
quaint epoch
#

nice

potent spear
#

can't understand you

cold sonnet
#

he asks how

quaint epoch
#

!elif

livid hinge
#

someone in a server i help with

quaint epoch
#

!d elif

unkempt canyonBOT
#

8.1. The if statement

The if statement is used for conditional execution:


if_stmt ::=  "if" assignment_expression ":" suite
             ("elif" assignment_expression ":" suite)*
             ["else" ":" suite]
``` It selects exactly one of the suites by evaluating the expressions one by one until one is found to be true (see section [Boolean operations](https://docs.python.org/3/reference/expressions.html#booleans) for the definition of true and false); then that suite is executed (and no other part of the [`if`](https://docs.python.org/3/reference/compound_stmts.html#if) statement is executed or evaluated). If all expressions are false, the suite of the [`else`](https://docs.python.org/3/reference/compound_stmts.html#else) clause, if present, is executed.
boreal ravine
#

i see

cold sonnet
#

but natixe does it work

#

not if you give x a letter or word

#

or if it's missing

#

add

else:
    raise error 
```at the end of your error handlers
#

cuz they'll just eat up errors like this

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.

potent spear
#

^^

boreal ravine
#

Wrong token

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.

cold sonnet
#

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

potent spear
#

great copy paste

cold sonnet
#

thanks

boreal ravine
#

there should be a command that converts a txt file into a pastebin link

potent spear
#

that would be too spammy

#

people should do the effort themselves

#

Althought, there's an existing bot which has this feature

boreal ravine
livid hinge
#

!charinfo |​|

unkempt canyonBOT
potent spear
boreal ravine
#

Wrong token

potent spear
#

error says it all

cold sonnet
#

improper token has been passed

livid hinge
#

one more question, how does "syncing commands" work? if I run a bot that uses the same token as a different bot, but it has no commands , and I've got sync_commands=True, will this cause all of the original commands to disappear? I'm kind of thinking yes because it listed them all as "commands to delete" when I pass sync_commands_debug=True

cold sonnet
#

same token?

#

there's no such thing as bots with the same token

#

or do you mean running two scripts for the same bot?

supple thorn
maiden fable
flint isle
#

How can I hard code a guild and channel into ctx send so I can have a startup notifier

tired hinge
#

how can i send a message in a channel every hour?

#

tasks.loop or smth like that?

maiden fable
#

mhm

flint isle
maiden fable
#

@flint isle I would be happy to help you but wanted to say something

#

Please always try to understand what is happening in a piece of code and then write it

#

Anyways

#

!d discord.Client.get_guild

unkempt canyonBOT
#

get_guild(id, /)```
Returns a guild with the given ID.

Changed in version 2.0: `id` parameter is now positional-only.
maiden fable
#

!d discord.TextChannel.send

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

Sends a message to the destination with the content given.

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

Yeah I try to understand it so I can use it in different cases

flint isle
maiden fable
#

u get the guild and then get_channel?

#

Or just client.get_channel idk

flint isle
#

Would I use bot.get_guild ? Since I don't use client in mine

regal pulsar
zenith mural
placid skiff
regal pulsar
livid hinge
regal pulsar
#

channel = that

maiden fable
maiden fable
#

!d discord.Guild.get_channel

unkempt canyonBOT
#

get_channel(channel_id, /)```
Returns a channel with the given ID.

Note

This does *not* search for threads...
regal pulsar
#

oh

tired hinge
#

how can i fetch a channel from a guild

regal pulsar
tired hinge
regal pulsar
#

lmao

flint isle
placid skiff
regal pulsar
#

send is a coroutine

flint isle
# regal pulsar what
    print('Waiting For Commands')
    ready = ' true'
    bot.get_guild(798726719573065749)
    bot.get_channel(798726720181633047)
    await send('Bot Online!')
tired hinge
livid hinge
#

bot.get_channel might work too

livid hinge
flint isle
regal pulsar
#

depends on what you want to do

tired hinge
regal pulsar
#

you could just add the channel as an argument

livid hinge
regal pulsar
tired hinge
tired hinge
#

so to use guild.get_channel, how do i get guild in the first place

livid hinge
flint isle
#

Ok I added channel = before the chann get and the channel. Before the send and it worked

regal pulsar
#

do you want it to start sending messages with a command

#

or when it joins a guild

unkempt jewel
#

it is not about code but my code didnt have error, but when i type command it wont reply me

regal pulsar
#

or what

tired hinge
#

like as soon as the bot starts, i'd like to start the tasks.loop

tired hinge
#

and start sending a msg in a channel per hour

quaint epoch
tired hinge
#

is there a method to get guild with id?

regal pulsar
livid hinge
quaint epoch
#

or in a __init__ method in a cog

regal pulsar
#

use on_ready

unkempt jewel
#
import discord
import random
import os

from discord.ext import commands

PREFIX = (".")

client = commands.Bot(command_prefix = PREFIX, description = "HaD")

@client.event
async def on_ready():

    activity = discord.Game(name = "ur mom", type = 3)
    await client.change_presence(status = discord.Status.idle, activity = activity)

    print("HaD is ready")

@client.command()
async def ping(ctx):

    await ctx.send(f"! {round(client.latency * 1000)}ms !")



answers = [
    'Đéo.',
    'Chắc thế',
    'Hổng có bít, hổng có nhớ nữa...',
    'Bố dí buồi thèm vào',
    '=))) Có',
    'Không e',
    'Địt mẹ cuộc đời',
    'Tao không trả lời đấy mày làm gì tao?',
    'aww, ksao đâu cố gắng lên ^^',
    'Kimi no pantsu... Nani iru?',
    'Không nói :00',
    'Trông k hay lắm nhỉ',
    'that su thi tao chi muon chet...',
    'Hên xui',
    'cc',
    'cút',
    'iu thé uwu',
    'qua ghe gom',
    'ge vay sao?',
    'uk r s',
    'Hu ce?',
    'Hu át?',
    'Chịu :v',
    'tao đang dỗi r, cút',
    'abc',
    'electrify my heart, ohh'
]

@client.command(aliases = ['8ball'])
async def _8ball(ctx, *, question):

    await ctx.send(f'question: {question}\nanswer: {random.choice(answers)}')


client.run('')

regal pulsar
#

ive never used tasks.loop

#

gimme a sec

unkempt jewel
regal pulsar
#

lol

quaint epoch
unkempt jewel
regal pulsar
#

oh

#

im blind 💀

#

wait

slate swan
#

Yo

unkempt jewel
#

this is log

slate swan
#

👋

unkempt jewel
#

no error

regal pulsar
#

oh i know why

unkempt jewel
#

why-y

slate swan
livid hinge
#

also check the output for a message like "command x not found"

regal pulsar
#

you started your presence in on_ready

quaint epoch
# regal pulsar how come

i tried to do a bunch of api calls once in on_ready, (try to send every single user the bot could see "hello!"), pretty bad mistake, got a bunch of 429s and ratelimits

tired hinge
#

what's the command to get a guild with its id-

unkempt jewel
slate swan
#

"Emotional support"

regal pulsar
#

dont

quaint epoch
tired hinge
regal pulsar
#

that stops your bot from doing anything else

unkempt jewel
regal pulsar
#

use this

quaint epoch
livid hinge
unkempt jewel
slate swan
#

Yo whats going on?

quaint epoch
regal pulsar
quaint epoch
#

a single presence update never hurt anyone

slate swan
#

What(????

regal pulsar
#

activity=disnake.Activity(type=disnake.ActivityType.watching, name="something")

unkempt jewel
regal pulsar
#

add this in commands.Bot

quaint epoch
regal pulsar
#

and get rid of the activity thing in on_ready

regal pulsar
unkempt jewel
#

ok wait

slate swan
#

Hi?

regal pulsar
unkempt jewel
#

disnake is not defined

regal pulsar
#

lmao

regal pulsar
tired hinge
#

do guild & channel ids have to be strings or ints?

slate swan
regal pulsar
tired hinge
#

alr

slate swan
#

Ye

#

all ids are to be integers in all the methods

#

"Very cool " u don't even need ac

regal pulsar
#

lmao

unkempt jewel
slate swan
unkempt jewel
#

and it have no error

slate swan
#

Ur cpu will work as an air conditioner

regal pulsar
slate swan
#

If u use disnake

regal pulsar
#

wait

slate swan
placid skiff
regal pulsar
#

oh no wonder

#

lmfao

maiden fable
unkempt jewel
#

helwp

maiden fable
#

@unkempt jewel did u import disnake

unkempt jewel
slate swan
#

Nice

maiden fable
regal pulsar
unkempt jewel
#
import discord
import random
import os

from discord.ext import commands

PREFIX = (".")

client = commands.Bot(command_prefix = PREFIX, description = "HaD", activity=discord.Activity(type=discord.ActivityType.watching, name="ur mom"))

@client.event
async def on_ready():

    print("HaD is ready")



@client.command()
async def ping(ctx):

    await ctx.send(f"! {round(client.latency * 1000)}ms !")



answers = [
    'Đéo.',
    'Chắc thế',
    'Hổng có bít, hổng có nhớ nữa...',
    'Bố dí buồi thèm vào',
    '=))) Có',
    'Không e',
    'Địt mẹ cuộc đời',
    'Tao không trả lời đấy mày làm gì tao?',
    'aww, ksao đâu cố gắng lên ^^',
    'Kimi no pantsu... Nani iru?',
    'Không nói :00',
    'Trông k hay lắm nhỉ',
    'that su thi tao chi muon chet...',
    'Hên xui',
    'cc',
    'cút',
    'iu thé uwu',
    'qua ghe gom',
    'ge vay sao?',
    'uk r s',
    'Hu ce?',
    'Hu át?',
    'Chịu :v',
    'tao đang dỗi r, cút',
    'abc',
    'electrify my heart, ohh'
]

@client.command(aliases = ['8ball'])
async def _8ball(ctx, *, question):

    await ctx.send(f'question: {question}\nanswer: {random.choice(answers)}')


client.run('')
slate swan
unkempt jewel
flint isle
#
import discord
from discord.ext import commands

def setup(bot):
    bot.add_cog(developerfeatures(bot))
class developerfeatures(commands.Cog):
    """Useful Features for Bot Development."""

    def __init__(self, bot: commands.Bot):
        self.bot = bot
        print('loading chat_room_managment cog')


@commands.command(name='gemoji')
async def gemoji(self, ctx):
	await ctx.send(ctx.guild.emojis)
	print (ctx.guild.emojis)

thats my cog and the command wont run or be recognized

unkempt jewel
#

can u write the on_message for me

regal pulsar
#

no i mean

#

you dont need it

#

its just that it tends to lead to errors

#

or the bot not responding

slate swan
#

gemoji

unkempt jewel
#

my brains is shutting down

regal pulsar
#
import discord
import random
import os

from discord.ext import commands

PREFIX = "."

bot = commands.Bot(
    command_prefix=PREFIX, description="HaD", activity=discord.Activity(type=discord.ActivityType.watching, name="something")
)


@bot.event
async def on_ready():
    print("HaD is ready")


@bot.command()
async def ping(ctx: commands.Context):

    await ctx.send(f"! {round(bot.latency * 1000)}ms !")


answers = [
    "Đéo.",
    "Chắc thế",
    "Hổng có bít, hổng có nhớ nữa...",
    "Bố dí buồi thèm vào",
    "=))) Có",
    "Không e",
    "Địt mẹ cuộc đời",
    "Tao không trả lời đấy mày làm gì tao?",
    "aww, ksao đâu cố gắng lên ^^",
    "Kimi no pantsu... Nani iru?",
    "Không nói :00",
    "Trông k hay lắm nhỉ",
    "that su thi tao chi muon chet...",
    "Hên xui",
    "cc",
    "cút",
    "iu thé uwu",
    "qua ghe gom",
    "ge vay sao?",
    "uk r s",
    "Hu ce?",
    "Hu át?",
    "Chịu :v",
    "tao đang dỗi r, cút",
    "abc",
    "electrify my heart, ohh",
]


@bot.command(aliases=["8ball"])
async def _8ball(ctx: commands.Context, *, question: str):

    await ctx.send(f"question: {question}\nanswer: {random.choice(answers)}")


bot.run()

slate swan
#

Joy is not a cat

regal pulsar
#

the code ^

regal pulsar
slate swan
#

No!

regal pulsar
#

Yes!

placid skiff
#

Joy is a C++ code successfully compiled

regal pulsar
slate swan
#

Joy is fun!!

unkempt jewel
#

thanks

regal pulsar
#

lol

#

i saw that

#

someone ask for help im bored 😩

flint isle
unkempt jewel
regal pulsar
unkempt jewel
#

yes

regal pulsar
#

hmm

slate swan
regal pulsar
#

try the ping cmd @unkempt jewel

unkempt jewel
#

ping comands?

regal pulsar
#

.ping

regal pulsar
#

bot template moment

livid hinge
regal pulsar
slate swan
unkempt jewel
livid hinge
#

idk,need help coming up with my question

flint isle
#

how do i make optional int?

regal pulsar
slate swan
unkempt jewel
#

didt work Emotion

regal pulsar
#

what

quaint epoch
#

wrong reply

regal pulsar
quaint epoch
flint isle
#

thx

regal pulsar
#

does the bot have perms

#

to send msgs in that channel

regal pulsar
slate swan
regal pulsar
#

isnt it

unkempt jewel
#

my bot even has highest role

slate swan
#

just saw

visual island
#

@unkempt jewel What's your discord.py version? If it's 2.0.0a (the master branch) you need to enable message_content intent.

unkempt jewel
#

how to check the version huh

regal pulsar
#
@bot.command()
async def func(ctx: commands.Context, amt: int = None):
    if int is None:
        await ctx.channel.send("Nothing here")
    else:
        await ctx.channel.send(amt)
placid skiff
#

type pip freeze in your terminal

regal pulsar
regal pulsar
#

^

#

im using v1.7.3

slate swan
flint isle
regal pulsar
#

yikes

quaint epoch
#

bruv

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied mute to @unkempt jewel until <t:1651065216:f> (9 minutes and 59 seconds) (reason: newlines rule: sent 128 newlines in 10s).

regal pulsar
#

ah

livid hinge
quaint epoch
#

(pat pat)

regal pulsar
#

dm it to me @unkempt jewel

regal pulsar
#

how would that help

quaint epoch
#

oh you mean by the bot itself?

regal pulsar
#

or

slate swan
quaint epoch
regal pulsar
#

you could just run the default help command

#

unless the other instance has it disabled

#

it should send twice if its 2 instances

quaint epoch
livid hinge
#

like my own ping command ?

flint isle
#

yes

livid hinge
#

hm that could work

flint isle
#

how can i make the optional arg i had trouble trying to extract one from the msg

livid hinge
#

could make an not-visible channel to send it in i guess

livid hinge
regal pulsar
#
def func(arg1: int, arg2: int = None):
    pass
flint isle
#

what does pass do?

regal pulsar
#

nothing

velvet compass
#

!unmute 720991106048720916

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: pardoned infraction mute for @unkempt jewel.

regal pulsar
#

im just too lazy to put something inside

regal pulsar
velvet compass
#

Please use the pastebin for long files

#

Also, ytdl breaks ToS

regal pulsar
#

ytdl?

flint isle
#

youtube dl

regal pulsar
#

oh that

flint isle
#

lmao still have it cloned on my github from a while ago. its just sitting there dormant

livid hinge
#

it's possible to send the ping to the bot's DM?

maiden fable
regal pulsar
maiden fable
#

Well that's the only way 🤷‍♂️
Or u can always reset yr token

regal pulsar
#

theres another tho

#

just run the default help cmd

#

unless the other instance has it disabled

#

it should send it x amount of times

livid hinge
slate swan
#

so pretty useless

livid hinge
#
@my_bot.ipc.route()
async def get_member_count(data):
    guild = my_bot.get_guild(data.guild_id)  # get the guild object using parsed guild_id

    return guild.member_count  # return the member count to the client

if __name__ == "__main__":
    my_bot.ipc.start()  # start the IPC Server
    my_bot.run("TOKEN")```  looks nice
livid hinge
#

yes!

maiden fable
maiden fable
livid hinge
#

maybe for stats collection too

#

looks like it uses a small Quart server to do its thing

maiden fable
slate swan
livid hinge
#

maybe you don't need to manually manage the server

slate swan
#

Back

maiden fable
#

Well, I would have instead created a client side websocket and use another VPS to connect to the same and access data

amber bloom
#

Hello is there possible to block link from About me section in python with a bot?

maiden fable
#

Bots can't access About Mes

placid skiff
#

but force others to change their about me is extremely

#

take me for example, i have my website

#

why I should remove it to join your guild

amber bloom
#

but how to detect, witch function can i use for make this? why not, i'l listen all suggestion...

tired hinge
#

though, can you see a user's about me with the discord api?

#

!d discord.ext.commands.Bot.get_guild

unkempt canyonBOT
tired hinge
#

there you go

flint isle
#

thanks lol

paper sluice
#

gm

cloud dawn
#

👋

ashen perch
#

anyone know a good place for bot hosting?

cloud dawn
#

netcup

#

For eu

ashen perch
#

ye eu is what im looking for

#

is it expensive?

cloud dawn
#

5,55 for decent specs

ashen perch
#

not bad

cloud dawn
#
  • 1000mbps ⬆️ ⬇️
vocal plover
#

80TB traffic for that price is nice

cloud dawn
#

I don't see how you can reach 80tb/ month with a Discord bot lol

maiden fable
#

@ashen perch just get the free Oracle VPS if it's a hobby

cloud dawn
#

5,55 for pursueing a hobby is not much.

vocal plover
#

Of course this is a personal opinion so do your own research but I'd personally say you should avoid Oracle due to them being generally pretty far from ethical

maiden fable
vocal plover
maiden fable
#

Damn thanks for the link

ashen perch
#

thanks for all the suggestions

final iron
quaint epoch
#

=java bad

slate swan
#

Alright essentially im trying to make it so every 15 minutes, a channel is automatically purged py @tasks.loop(minutes=15.0) async def background_loop(): await client.wait_until_ready() while not client.is_closed: channel = client.get_channel(968618644236038235) await channel.purge(limit=1000) background_loop.start()
thats what i have but it doesn't work

#

no errors + doesn't purge the channel

cloud dawn
slate swan
#

ok

sullen pewter
#

How can I fix the attribute error

slate swan
cloud dawn
heady sluice
slate swan
cloud dawn
#

or in your case ctx.response.send_message i recommend naming it inter not ctx.

sullen pewter
#

ok

slate swan
slate swan
#

its just supposed to purge the channel every 15 mins

slate swan
#

lemme add one and see

heady sluice
#

but I don't see a problem unless there's actually a 1000 messages to delete

slate swan
#

one of my friends wanted it

#

so im making it

slate swan
# slate swan lemme add one and see

and you should really change

while not client.is_closed:
    ... #this creates a loop that will keep running until the bot is shut down

to

if not client.is_closed:
   ... #this checks if the bot is running without creating a loop
heady sluice
#

yeah right

slate swan
#
@tasks.loop(seconds=5.0)
async def background_loop():
    await client.wait_until_ready()
    if not client.is_closed:
        channel = client.get_channel(968618644236038235)
        await message.channel.send("test")
background_loop.start()  

client.run(token)

@client.event
async def on_ready():
    print('on')
#

nothing is sent on the on ready btw the print is tabbed in on the script

slate swan
#

oh sorry, i never knew

slate swan
#

ok it showed the on now

#

cool

#

i think its a problem with it finding the channel

#

is there any other way i could find it

slate swan
# slate swan is there any other way i could find it
channel = client.get_channel(id) or await client.fetch_channel(id)

this will check if the TextChannel object of that id isnt found in the cache (get_channel) it will make an API call to get that object instead

heady sluice
#

oooh why not 😦

slate swan
#
@client.event
async def on_ready():
    print('on')



@tasks.loop(seconds=1.0)
async def background_loop():
    await client.wait_until_ready()
    if not client.is_closed:
        channel = client.get_channel(968683899175698482) or await      client.fetch_channel(968683899175698482)
        await message.channel.send("test")
background_loop.start()  

client.run(token)``` i got this and it still doesn't send anything
#

it only exists in disnake and that too for user/member

heady sluice
#

it really doesn't

slate swan
#

!d disnake.Guild.getch_member

unkempt canyonBOT
#

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

Tries to get a member from the cache with the given ID. If fails, it fetches the member from the API and caches it.

If you want to make a bulk get-or-fetch call, use [`get_or_fetch_members()`](https://docs.disnake.dev/en/latest/api.html#disnake.Guild.get_or_fetch_members "disnake.Guild.get_or_fetch_members").
slate swan
#

oh ok

heady sluice
#

mmm

slate swan
potent spear
slate swan
vocal plover
cloud dawn
heady sluice
#

that doesn't seem closed

slate swan
#

that works

regal pulsar
slate swan
# heady sluice

im sorry if this sounds a lot but could you try find a way i could do it because its the last thing i need

#

i need it to detect the channel, purge it, wait 15 mins and repeat

#

its fine if you can't

heady sluice
#

print("something")
after await client.wait_until_ready() to see if the task started

heady sluice
slate swan
#

wasn't trying to challenge u

#

xd

#

could you put it in code

heady sluice
#
@tasks.loop(seconds=1.0)
async def background_loop():
    await client.wait_until_ready()
    print("something")
    if not client.is_closed:
        channel = client.get_channel(968683899175698482) or await client.fetch_channel(968683899175698482)
        await message.channel.send("test")
#

see if it prints

slate swan
#

it doesn't print

heady sluice
#

but commands work

slate swan
#

yeah they do

heady sluice
#

!d discord.Client.is_closed

unkempt canyonBOT
#

is_closed()```
[`bool`](https://docs.python.org/3/library/functions.html#bool "(in Python v3.10)"): Indicates if the websocket connection is closed.
slate swan
#

but they are in a different file if that changes anything

heady sluice
#

this is the main file right

slate swan
#

no

heady sluice
#

then why are you using client.event on_ready

potent spear
#

the if statement is redundant

slate swan
#

because i wanted to see if it would show anything

potent spear
#

but that's a note, not a fix

heady sluice
#

yes but don't matter right now

slate swan
#

i have removed it now though

heady sluice
#

so where is this

slate swan
#
import discord
import random
import asyncio
from discord.ext import commands, tasks

token = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx'
client = discord.Client()

@tasks.loop(seconds=1.0)
async def background_loop():
    await client.wait_until_ready()
    print("something")
    if not client.is_closed:
        channel = client.get_channel(968683899175698482) or await client.fetch_channel(968683899175698482)
        await message.channel.send("test")



client.run(token)
#

this is what i have right now its a separate script

heady sluice
#

so this is the main file

maiden fable
#

also, what formatting u using

slate swan
#

i closed the main ones

slate swan
maiden fable
#

it isn't the correct onr

potent spear
#

you should still start the task

slate swan
#

or does it?

heady sluice
#

it's got nothing to do with each other

slate swan
#

im confused now

cloud dawn
#

It is not connected to eachother

slate swan
#

yeah im dumb

cloud dawn
heady sluice
#

WAIT

#

wait has to be

slate swan
heady sluice
#

!d discord.ext.tasks.loop

unkempt canyonBOT
#

discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True)```
A decorator that schedules a task in the background for you with
optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
heady sluice
#

guess it's just a folder

slate swan
#

hi

potent spear
#

hi, Hau from vietnam

slate swan
#

oh

potent spear
#

as mentioned earlier...

heady sluice
#

get ignored

potent spear
#

It's clear, I'm out

slate swan
#

lmao

#

ok update: its now printing in the console but no messages are being sent in the server

heady sluice
#

remove the if statement

potent spear
heady sluice
#

god damnit sniper

slate swan
#

IT WORKS

#
import discord
import random
import asyncio
from discord.ext import commands, tasks

token = 'xxxxxxxxxxxxxxxxxxxxx'
client = discord.Client()

@tasks.loop(seconds=1.0)
async def background_loop():
    await client.wait_until_ready()
    print("something")
    channel = client.get_channel(968683899175698482) or await client.fetch_channel(968683899175698482)
    await channel.send("test")
background_loop.start()


client.run(token)``` that was the final code
#

it is the same as before

#

now if i just change the channel.send to purge it should work fine

slate swan
heady sluice
#

yes nuking achieved

slate swan
#

wait no the if statement isn't there

slate swan
steady flume
#

How fix that ? I put in shell dpy 2.0

heady sluice
#

repl

slate swan
slate swan
cloud dawn
#

Despite it being repl.it this code looks pretty good.

slate swan
#

ModuleNotFoundError: No module named 'discord.ui'

slate swan
heady sluice
steady flume
cloud dawn
#

!e print(bool(str))

unkempt canyonBOT
#

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

True
steady flume
#

I’d use pycharm ofc

potent spear
heady sluice
#

!e
if str.lower: print("Yes")

unkempt canyonBOT
#

@heady sluice :white_check_mark: Your eval job has completed with return code 0.

Yes
slate swan
heady sluice
#

EITO

cloud dawn
slate swan
heady sluice
#

I feel offended about what you said earlier and I'm starting not to believe in what you say

slate swan
heady sluice
#

install dpy 2.0

#

dpy > pycord

cloud dawn
#

py -m pip install git+https://github.com/Rapptz/discord.py

slate swan
#

LMAO same thing is happenong

cloud dawn
heady sluice
#

I don't understand panda

potent spear
#

eat some Bamboo, you will

heady sluice
#

is this the secret

cloud dawn
#

Yes

slate swan
#
# ban
@bot.command( pass_context = True )
@commands.has_permissions( administrator = True)

async def ban( ctx, member: discord.Member, *, reason = None ):
    emb = discord.Embed( title = 'Ban', colour = discord.Color.light_grey() )
    await ctx.channel.purge( limit = 1 )

    await member.ban( reason = reason )
    
    emb.set_author( name = member.name, icon_url = member.avatar_url )
    emb.add_field( name =f"Moderator:", value =f'Reason: {reason}'.format( member.mention ) )
    emb.set_footer( text = 'Was banned administrator {}'.format( ctx.author.name ), icon_url = ctx.author.avatar_url )

    await ctx.reply( embed = emb )

@ban.error
async def ban_error(ctx, error):
    emc = discord.Embed(title="Error", colour=discord.Color.red())
    if isinstance(error, commands.MissingPermissions):
        emc.add_field(name="Not enough permissions", value="make sure you have access to this command")

    await ctx.reply(embed=emc)

    if isinstance(error, commands.MissingRequiredArgument):
        emc.add_field(name="Check spelling", value="`K.`ban <@name>")

        await ctx.reply(embed=emc)```
#

why is it sending 2 messages?

#

help pls.

slate swan
frigid apex
#

how do i check if a role exists? i use cogs

# check if role exists in server
        if not discord.utils.get(self.guild.roles, name="mod"):
            # create role
            await self.guild.create_role(name="mod")
            print(">> Role created")
        else:
            print(">> Role exists")```

error:
```error
AttributeError: 'Moderation' object has no attribute 'guild'```
heady sluice
#

only the missingrequiredargument one

#

he didn't indent the first ctx.reply

vale wing
#

You kinda confused I think

vale wing
heady sluice
#

that's not the reason!

vale wing
#
emb = ...
if isinstance(error, Error1):
    emb.add_field(...)
elif isintance(error, Error2):
    emb.add_field(...)
else:
    raise error

await ctx.reply(embed=emb)```
pseudo portal
#

yooo sup! is there a way to do @bot.slash_command and a prefix command for same thing? think

frigid apex
#
@commands.Cog.listener()
    async def on_ready(self):
        print('>> Moderation Cog is ready')

        # MOD ROLE
        # mod_role = role['mod']  # get channel id from toml
        guild_id = connection['guild_id']
        # check if role exists in guild_id
        # guild = self.bot.get_guild(guild_id)
        if not discord.utils.get(self.ctx.guild.roles, name="mod"):
            # create role
            await self.ctx.guild.create_role(name="mod")
            print(">> Role created")
        else:
            print(">> Role exists")```

error: AttributeError: 'Moderation' object has no attribute 'ctx'
#

cogs

spring flax
slate swan
willow marsh
#

Hello, i was wondering why this won't work, if you have any answers please reply

paper sluice
#

u cant add str and int

pseudo portal
paper sluice
#

use fstrings

willow marsh
#
async def purge(ctx, arg:int):
  if arg == 0:
    staffchat = client.get_channel(967408894546673665)
    embed = discord.Embed(title="🗑 Purge Executed", description=ctx.author.mention + " has purged the entire " + ctx.channel.mention + " channel.",color=0x2ecc71, timestamp=datetime.utcnow())
    embed.set_footer(text="iTOW Protection Service")
    await ctx.channel.purge()
    await staffchat.send(embed=embed)
  else:
    staffchat = client.get_channel(967408894546673665)
    embed = discord.Embed(title="🗑 Purge Executed", description=ctx.author.mention + " has purged " + arg + "messages in " + ctx.channel.mention,color=0x2ecc71, timestamp=datetime.utcnow())
    embed.set_footer(text="iTOW Protection Service")
    await ctx.channel.purge(limit=arg)
    await staffchat.send(embed=embed)
paper sluice
#

!fstring

willow marsh
#

Why wont this work

unkempt canyonBOT
#
Did you mean ...

» sql-fstring
» f-strings

willow marsh
#

The problem here is on the "Else:"

paper sluice
pseudo portal
willow marsh
paper sluice
willow marsh
#

how can i take out the int and put it into text

paper sluice
unkempt canyonBOT
#

Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.

>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."

Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.

willow marsh
#

whats that 😂

paper sluice
#

read the embed :/

willow marsh
#

Ohh i got it

#

i was testing a bit around i had to do

slate swan
willow marsh
slate swan
slate swan
paper sluice
slate swan
#

typo

willow marsh
slate swan
#

def

pseudo portal
slate swan
#

bro

#

you typed def to define a function?

paper sluice
willow marsh
#

wdym?

paper sluice
#

use fstrings, u dont have to convert an int to str then

willow marsh
#

what can i do instead of that then

paper sluice
#

!e

print(f'hello {1}')
unkempt canyonBOT
#

@paper sluice :white_check_mark: Your eval job has completed with return code 0.

hello 1
slate swan
#

no need for it lol

#

read on top

slate swan
#

wrong keyword usage

#

bro

#

look what youre doing

willow marsh
paper sluice
slate swan
#

def is the keyword used to define functions

sick birch
#
def snipe_message_content[message.channel.id]```
slate swan
#

thanks robin for repeating what ive said and what the traceback saysyert

paper sluice
paper sluice
#

BRUH

sick birch
#

I doubt it's the same error after you fix it

paper sluice
#

did u even change anything?

sick birch
#

I'm saying it's impossible for you to get the same error after fixing it

#

Also use something else to delete key-value from a dict

#

Pretty sure del is used for other purposes

slate swan
#

i recommend you learn python and pythons keywords

paper sluice
#

del doesn't free up the memory right? it just removes the element then its gc'ed

slate swan
#

bro

#

Owo

heady sluice
#

no

sick birch
#

right, and?

sick birch
slate swan
#

learning python is a good step before doing discord bots👍

sick birch
#

But del doesn't immediate return that mem to you, not as far as I know

slate swan
sick birch
#

Python kind of abstracts memory management away from you so it's difficult to tell

slate swan
slate swan
#

And what is gc'ed btw?😭

paper sluice
#

garbage collected

sick birch
#

garbage collector'd

paper sluice
slate swan
#

💀oh I see

paper sluice
#

type hints?

sick birch
#

Given you typehint stuff properly on your end

sick birch
#

The models are types, e.g discord.Message

slate swan
#

like for interactions, nor oauth2 stuff

sick birch
#

Not for the API endpoints, no

slate swan
#

why it doesnt exist one

sick birch
#

Good question

#

Maybe it's just not as easy to make and export types in Python as it is in Typescript

slate swan
#

oh nvm i think i found one

sick birch
#

Use the right syntax

slate swan
#

learn python and its keywords

heady sluice
#

why not in python general

paper sluice
#

not gonna say that 💀

clever field
#
@commands.command(aliases=data_aliases['analogue']['tts'])
async def _TTS(self, ctx, *, text: str = None):
    global gTTS
    translator = Translator()
    speech = None
    x = translator.translate(text)
    channel = ctx.author.voice.channel
    vc = await channel.connect()
    if x.src == 'ru':
        speech = gTTS(text=text, lang='ru', lang_check=True, tld='ru').stream()
    elif x.src == 'en':
        speech = gTTS(text=text, lang='en', lang_check=True, tld='com.au').stream()
    else:
        speech = gTTS(text=text, lang='en', lang_check=True, tld='com.au').stream()
    vc.play(nextcord.FFmpegPCMAudio(speech.read(), pipe=True))

How to stream speech directly to ffmpegPCMAudio?

error:
Command raised an exception: AttributeError: 'generator' object has no attribute 'read'

slate swan
#

speech is a generator

slate swan
#

!e a

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 'a' is not defined
slate swan
#

see how it doesnt exist?

heady sluice
#

what's it supposed to be

slate swan
#

you define it?

heady sluice
#

open_account = something

slate swan
#

bro

slate swan
#

you can define something in many ways

heady sluice
#

yeah it's not exactly something

slate swan
#

well the erros says it the interaction has already been acknowledged

heady sluice
#

you dunno either do you

slate swan
#

?

echo wasp
#

tasks.loop not working properly code: on it's way

heady sluice
#

I'd like to see your code

#

like the command

#

yeah

#

and at which line the error occured

#

the full traceback always has the issue in your file

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.

heady sluice
#

hm, what lib is this

#

yeah I get that

echo wasp
#
@tasks.loop(minutes=5)
    async def vc(self, member: discord.member):
        guild = self.client.get_guild(804864016584977438)
        hannel = self.client.get_channel(967194769731402862)
        annel = self.client.get_channel(967196545644967535)
        channel = self.client.get_channel(9668477673380556900)
        bot_user = len(list(filter(lambda x: x.bot, guild.members)))
        user = len(list(filter(lambda x: not x.bot, guild.members)))
        await channel.edit(name=f"{len(guild.members)} Total Members")
        await hannel.edit(name=f"{user} Humans")
        await annel.edit(name=f"{bot_user} bots")```
heady sluice
#

you don't pass arguments to a task

echo wasp
heady sluice
#

then you just gotta get the member

#

you don't even use it

#

and it's discord.Member, not discord.member

echo wasp
#

@heady sluice ^^^

heady sluice
#

guild's NoneType

echo wasp
#

i removed it

heady sluice
#

get didn't get the guild from the cache

heady sluice
heady sluice
echo wasp
heady sluice
#

not guild

echo wasp
heady sluice
#

that's good

echo wasp
#

how do make it work then on ready goes after it loads the co

heady sluice
#

now, add
await bot.wait_until_ready()
at the start of the task

#

mm @slate swan Idk what lib you're using or how slash commands work there, I can't help you

echo wasp
heady sluice
#

and it doesn't work?

echo wasp
heady sluice
#

oh nice

echo wasp
#

help please

slate swan
heady sluice
#

no

echo wasp
#

that was for me

heady sluice
echo wasp
heady sluice
#

library

cloud dawn
#

!pypi

unkempt canyonBOT
#
Missing required argument

package

heady sluice
#

a python module

heady sluice
cloud dawn
#

!pypi aiohttp