#discord-bots

1 messages Β· Page 671 of 1

slate swan
#

Youll have to convert the emoji to a str right?

stark lintel
#

OHHHHHHH

#

I KNOW WHAT IS CAUSING THE ERROR

sage otter
#

honestly idk. If they are default emojis I just pass it in as is. "☝️"

slate swan
#

How do I do it then?

slate swan
#

I mostly do it like that

#

you can't copy emojis in like that

#

they are default discord emojis

sage otter
#

Copy them off the internet

stark lintel
#

I GOT A NEW ERROR! thats a success in my book, but now i need help with this new one lol

sage otter
#

Send

stark lintel
#

@sage otter if it says channel has no attribute 'send' as the error, what should i do to this piece of code to fix it

slate swan
#

Why dont you just send the msg with the channel of the context that was invoked?

pliant gulch
slate swan
#

\πŸ™‚

stark lintel
manic wing
#

andy

slate swan
manic wing
#

do you know how to subclass on_message in subclassed discord.ext.commands.Bot with it acting as a listener and commands still work?

slate swan
#
from disnake.ext import commands
from disnake.ext.commands.bot import Bot

class On_ready(commands.Cog):
    @commands.Bot.event()
    async def on_ready(self):
        print("hi")

def setup(bot: Bot) -> None:
    bot.add_cog(On_ready(bot))

wont work, any1 help?

tough mirage
#

why doesnt this work

    @tasks.loop(seconds=75)
    async def live_status():
        pcount = pc()
        Dis = self.client.get_guild(876471014043815966) #Int

        activity = discord.Activity(type=discord.ActivityType.watching, name=f'🐌 {pcount}')
        await self.client.change_presence(activity=activity)
        await asyncio.sleep(15)

        activity = discord.Activity(type=discord.ActivityType.watching, name=f'πŸ‘₯ {Dis.member_count}')
        await self.client.change_presence(activity=activity)
        await asyncio.sleep(15)

        activity = discord.Activity(type=discord.ActivityType.watching, name=f'NOT lowkey#0669')
        await self.client.change_presence(activity=activity)
        await asyncio.sleep(15)

        activity = discord.Activity(type=discord.ActivityType.watching, name=f'City of lights')
        await self.client.change_presence(activity=activity)
        await asyncio.sleep(15)

        activity = discord.Activity(type=discord.ActivityType.watching, name=f'DISCORD INVITE')
        await self.client.change_presence(activity=activity)
        await asyncio.sleep(15)
manic wing
manic wing
#

!d discord.ext.commands.Bot

unkempt canyonBOT
#

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

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

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

its this, and you dont just import it, you need to pass it through bot.load_extension(...)

slate swan
#

bruh facepalm

slate swan
stark lintel
#

@slate swan see this is what i want it to do, and it successfully gets the announcement command, but it wont send because its not getting the channel correctly

slate swan
slate swan
slate swan
manic wing
slate swan
#

I was looking at the class name

manic wing
#

!d discord.ext.commands.bot.Bot

unkempt canyonBOT
#

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

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

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

wtf lol

quick gust
pliant gulch
manic wing
slate swan
#

I'm not using the fork made by rapptz

slate swan
#

there is nothing wrong with the imports at all, it's the event listener im having issues with, and there is no @commands.Bot.listener in disnake

pliant gulch
#

So you would end up doing stuff, but then also having a regular on_message?

manic wing
pliant gulch
#

If you just want commands to work you can just add await self.process_commands(message)

#

To the on_message

#

No need for calling the superclasses on_message

slate swan
#

Wait nvm

slate swan
#

I need glasses

pliant gulch
normal ginkgo
stark lintel
#

okimii, i decided to switch to what you said, which is just use the context of the channel to send, but now, when i try to mention the role, it wont let me. this is the error i get

sage otter
#

Type hint

#

So whatever role you pass can convert

stark lintel
#

how?

sage otter
#

role: discord.Role

stark lintel
#

oh, ok, thanks

slate swan
#

what's the thing for doing an event on a members ban?

#

is it on_member_ban

sage otter
#

Precisely.

stark lintel
#

now what @sage otter 🀣 sorry for bothering you so much btw

sage otter
#

How are you using the command

stark lintel
#

here, ill get a screenshot

#

here it is

sage otter
#

Remove role

stark lintel
#

ok

#

IT WORKED

#

THANK YOU SO MUCH

#

oh man that is sweet, thanks a ton

#

@sage otter one more question, its not super important, but the thing you told me to do with the role where i set it role: discord.Role... can i do something similar with the channel, like idk channel : discord.Channel or something like that?

sage otter
#

Yes

stark lintel
#

how would i do it

sage otter
#

well in your case

#

discord.TextChannel

stark lintel
#

ok, let me go try that... ill brb

#

IT WORKED @sage otter I CANNOT THANK YOU ENOUGH

#

thanks so much for helping me this morning

sage otter
#

πŸ‘Œ

slate swan
#

How do I fix this?

            member_role = ctx.guild.get_role(916843979411185674)

            await ctx.channel.set_permissions(member_role, send_messages=False)

Command raised an exception: InvalidArgument: target parameter must be either Member or Role

sage otter
#

print member_role

#

If it’s None then you need intents.

slate swan
#

yeah it came back as none

#

I have this for intents tho?

import discord
from discord.ext import commands
from discord import Intents


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

bot = commands.Bot(command_prefix=".", intents=intents)
sage otter
#

You sure you got the right role ID?

#

And is that role actually in that guild

stark lintel
#

I got another question if you are willing to try right now

#

how would i make the role argument optional @sage otter

sage otter
#

Default it

stark lintel
#

how lol

sage otter
#

role = None

#

And do some logic stuff.

stark lintel
#

ok, ill try that, thanks

lost vine
#

Hey, how can I solve this?
File "main.py", line 19
await ctx.send(f'Banned {member.mention}')
^
IndentationError: unindent does not match any outer indentation level

sullen shoal
#

uh

#

!indent

unkempt canyonBOT
#

Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

normal ginkgo
stark lintel
#

@sage otter like this?

lost vine
#

How to solve this problem? I typed this and it showed errors:

stark lintel
#

@lost vine do you know how, in this code, id set role to default or role = None?

lost vine
stark lintel
#

how would i do this?

slate swan
#

when you call the command you add the role obj

stark lintel
#

how would i type it so it doesn't trigger a SyntaxError

lost vine
lost vine
slate swan
lost vine
#

Ohh

stark lintel
#

idk for sure though

slate swan
stark lintel
#

so okimii, how would i set it so that sometimes i can set a role to ping, but i dont have to?

slate swan
#

idk why both of you are getting syntax errors when its correct

lost vine
#

Lol

#

I don't really know

sage otter
#

Oh yeah Okimii. Professional helper.

slate swan
stark lintel
slate swan
lost vine
slate swan
#

really stupid i think you ment

sage otter
#

Omg don’t tell me you're using IDLE

stark lintel
#

LMAO

sage otter
#

I might actually lose it if you are.

stark lintel
#

I AM

#

I LIKE IT

lost vine
#

I'm using replit

slate swan
slate swan
#

wait no

stark lintel
#

keep in mind though, im trying to keep it so that it says its discord.Role

slate swan
#

what is that

#

role: discord.Role=None

#

thats how it should look

stark lintel
#

now what...

slate swan
#

says it in the error lol

#

just add the positional arg on front and make all of them kwargs after

stark lintel
#

i know, but i still want to keep it there when im typing the actual command. Is that possible?

slate swan
#

what is the if > < >= <= sign for "under ---" i forgot

sage otter
#

Are you asking what they are for?

slate swan
#

kinda basic its like math lol

lost vine
#

Like I even used command prompt to run the program and this error is still there

slate swan
# slate swan wdym?

im asking like which one is it for "under (number)" for if statements because i forgot

sage otter
#

Oh

stark lintel
sage otter
#

<

lost vine
sage otter
#

Less than operator.

slate swan
#

it should be 4

lost vine
#

Ohhh lemme try

#

Thank you so much

slate swan
stark lintel
#

how thoughh

verbal cairn
#

anyone know how to create a paginator with reactions and not buttons

stark lintel
#

oh wait

#

i firgeured it out

slate swan
#

not sure if this will even work but
else: is having an error

    if bot.latency * 1000 < 300:
      embed = discord.Embed(color=discord.Colour.green())
    embed.add_field(name=":WS: Web Socket", value=f"```py\n{round(bot.latency * 1000)} ms```")
    embed.set_thumbnail(url="https://cdn.discordapp.com/emojis/899908402766032897.gif?size=40")
    await ctx.send(embed=embed)
    else:
    embed = discord.Embed(color=discord.Colour.red())
    embed.add_field(name=":WS: Web Socket", value=f"```py\n{round(bot.latency * 1000)} ms```")
    embed.set_thumbnail(url="https://cdn.discordapp.com/emojis/899908402766032897.gif?size=40")
    await ctx.send(embed=embed)```
stark lintel
slate swan
lost vine
#

@slate swan Thank you so much I can now fix my error. Take a cookie JPcookie as a gift even when it isn't real lol

tawdry perch
slate swan
lost vine
normal ginkgo
slate swan
tawdry perch
#

Why did you pong me..

slate swan
#

my 3 best buddies

tawdry perch
#

...

novel bolt
#

hey can we get attachments url from slash commands?

tough lance
#

Have you indented the else statement?

slate swan
slate swan
# tough lance Have you indented the else statement?
@bot.command(name="ping")
async def pingme(ctx):
    # ws ping
    if bot.latency * 1000 < 300:
      embed = discord.Embed(color=discord.Colour.green())
    embed.add_field(name="![WS](https://cdn.discordapp.com/emojis/919155302287421470.webp?size=128 "WS") Web Socket", value=f"```py\n{round(bot.latency * 1000)} ms```")
    embed.set_thumbnail(url="https://cdn.discordapp.com/emojis/899908402766032897.gif?size=40")
    await ctx.send(embed=embed)
    else:
    embed = discord.Embed(color=discord.Colour.red())
    embed.add_field(name="![WS](https://cdn.discordapp.com/emojis/919155302287421470.webp?size=128 "WS") Web Socket", value=f"```py\n{round(bot.latency * 1000)} ms```")
    embed.set_thumbnail(url="https://cdn.discordapp.com/emojis/899908402766032897.gif?size=40")
    await ctx.send(embed=embed)
tawdry perch
#

!paste can you paste your code here so I can view the indent properly @slate swan

unkempt canyonBOT
#

Pasting large amounts of code

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

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

slate swan
#

you need an indent after else:

#

and your if has to be connected with the else

#
Command raised an exception: TypeError: Subscripted generics cannot be used with class and instance checks```
#

!resources before dpy

unkempt canyonBOT
#
Resources

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

slate swan
#

Here is the command: ```py
@commands.command(
name="SetRange",
brief="Choose a lucky number between a range of values."
)
@commands.has_permissions()
async def set_range(self, ctx, *, range):
if range.startswith("random"):
return await self.set_number(
ctx.message,
ctx.channel.id,
range
)

minimum, maximum = [int(float(value)) for value in range.split("-")]

await self.set_number(
  ctx.message, 
  ctx.channel.id, 
  [minimum, maximum],
  range=True
)

await resources.default.embed(
  msg=ctx.message,
  title=f"**The range has been set to {minimum}-{maximum}**"
)```
slate swan
#

now

slate swan
#

try naming your variable something else than range

#

lmao ihacu

slate swan
#

because it's a keyword

slate swan
#

which line?

#

in your function's parameters

#

this dude looks like he's tryna get spoon fed

#

and where you use it

#

ahh so in this part:

#
  async def set_range(self, ctx, *, range):
    if range.startswith("random"):```
slate swan
tawdry perch
#

The help embed is becoming a bit too large, I have ~borrowed yeeted a paginator from someones repo that I have used to embeds but how can I paginate a help embed? Current help command ```py
class MyNewHelp(commands.MinimalHelpCommand):
"""Bots help command class"""
async def send_pages(self):

    destination = self.get_destination()
    for page in self.paginator.pages:
        emby = disnake.Embed(description=page)
        await destination.send(embed=emby)
slate swan
#

everything between if and else has to be on the same indent, one level above the if

slate swan
slate swan
tawdry perch
#

hm?

slate swan
#

like PaginatorHelpCommand or smth, I don't know the name

slate swan
#

there aswell

tawdry perch
#

Where should I look it up?

hushed surge
#

dn

slate swan
# slate swan im confused, what am i supposed to change because the lines are already togther
if bot.latency * 1000 < 300:
    embed = discord.Embed(color=discord.Colour.green())
    embed.add_field(name=":WS: Web Socket", value=f"```py\n{round(bot.latency * 1000)} ms```")
    embed.set_thumbnail(url="https://cdn.discordapp.com/emojis/899908402766032897.gif?size=40")
    await ctx.send(embed=embed)
else:
    embed = discord.Embed(color=discord.Colour.red())
    embed.add_field(name=":WS: Web Socket", value=f"```py\n{round(bot.latency * 1000)} ms```")
    embed.set_thumbnail(url="https://cdn.discordapp.com/emojis/899908402766032897.gif?size=40")```
slate swan
#

like this

#

oh why doesn't this work

slate swan
slate swan
slate swan
#

you want it to be a variable

#

but variable names can't be keyword names

#

k let me see

tawdry perch
slate swan
#

Imma search after it

tawdry perch
#

I saw that used in @unkempt canyon, and thx if you mind to search it up πŸ˜„

slate swan
#

the minimalhelpcommand does have a paginator attribute

nimble bobcat
#

hi

slate swan
nimble bobcat
slate swan
#

and what's the issue?

nimble bobcat
#

how to convert this

slate swan
#

so it will send the embed whatever happens

#

it's my bad

nimble bobcat
#

im bad english sorry for my warnings

slate swan
#

is disnake very different from dpy?

slate swan
tawdry perch
#

not really

#

it's very close, it's a fork of dpy

slate swan
#

oh god I found a really complex github repo

#

oh wow

#

and he isn't even subclassing the help command

tawdry perch
#

how should I start creating a pagination for help command

slate swan
#

I'm gonna cry

nimble bobcat
# nimble bobcat

I'm new to datetime so I don't know how to convert it to the format I want

tawdry perch
slate swan
#

my help command still isn't subclassed

tawdry perch
#

oh

slate swan
#

and I can tell you the worst part

tawdry perch
#

Do I want to hear it πŸ‘€

slate swan
#

I'm storing my commands' data in a .txt file

tawdry perch
#

oh god

slate swan
#

I'm grabbing every command's name and description in a text file

tawdry perch
#

I'm outt

slate swan
#

and the required permission too

#

but I have a reload cogs system and the help command only updates when the whole bot restarts thinkmon

#

that's where you see, that sometimes, I can't think straight

tawdry perch
#

oof

#

uh how can I implement the pagination for the MinimalHelpCommand?

slate swan
#

Β―_(ツ)_/Β―

tawdry perch
#

oh..

sage otter
#

Consider looking at this gist

tawdry perch
#

it seems really nice

tawdry perch
slate swan
#

only if you help us helping you (:

sinful pasture
#

*Infinite Dad Jokes, ACTIVATE

BOT
Yessiree
I fear for the calendar, its days are numbered.
I fear for the calendar, its days are numbered.
I fear for the calendar, its days are numbered.
I fear for the calendar, its days are numbered.*

@client.event
async def on_message(message):
  if message.content.startswith('Infinite Dad Jokes, ACTIVATE'):
    await message.channel.send('Yessiree')
  if message.author ==client.user:
      await message.channel.send(dadjoke.joke)
      time.sleep(10)

So basically it's supposed to send out a random dad joke from dadjokes library every 10 seconds, based on responding to it's own messages. But it sends the same dad joke over and over again

sinful pasture
tawdry perch
unkempt canyonBOT
#

Why do we need asynchronous programming?
Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you do not use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming.

What is asynchronous programming?
An asynchronous program utilises the async and await keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. Any code within an async context manager or function marked with the await keyword indicates to Python, that whilst this operation is being completed, it can do something else. For example:

import discord

# Bunch of bot code

async def ping(ctx):
    await ctx.send("Pong!")

What does the term "blocking" mean?
A blocking operation is wherever you do something without awaiting it. This tells Python that this step must be completed before it can do anything else. Common examples of blocking operations, as simple as they may seem, include: outputting text, adding two numbers and appending an item onto a list. Most common Python libraries have an asynchronous version available to use in asynchronous contexts.

async libraries
The standard async library - asyncio
Asynchronous web requests - aiohttp
Talking to PostgreSQL asynchronously - asyncpg
MongoDB interactions asynchronously - motor
Check out this list for even more!

#

Concurrency in Python

Python provides the ability to run multiple tasks and coroutines simultaneously with the use of the asyncio library, which is included in the Python standard library.

This works by running these coroutines in an event loop, where the context of the running coroutine switches periodically to allow all other coroutines to run, thus giving the appearance of running at the same time. This is different to using threads or processes in that all code runs in the main process and thread, although it is possible to run coroutines in other threads.

To call an async function we can either await it, or run it in an event loop which we get from asyncio.

To create a coroutine that can be used with asyncio we need to define a function using the async keyword:

async def main():
    await something_awaitable()

Which means we can call await something_awaitable() directly from within the function. If this were a non-async function, it would raise the exception SyntaxError: 'await' outside async function

To run the top level async function from outside the event loop we need to use asyncio.run(), like this:

import asyncio

async def main():
    await something_awaitable()

asyncio.run(main())

Note that in the asyncio.run(), where we appear to be calling main(), this does not execute the code in main. Rather, it creates and returns a new coroutine object (i.e main() is not main()) which is then handled and run by the event loop via asyncio.run().

To learn more about asyncio and its use, see the asyncio documentation.

sinful pasture
#

fukc

#

I gotta work with async

unkempt canyonBOT
#

coroutine asyncio.sleep(delay, result=None)```
Block for *delay* seconds.

If *result* is provided, it is returned to the caller when the coroutine completes.

`sleep()` always suspends the current task, allowing other tasks to run.

Setting the delay to 0 provides an optimized path to allow other tasks to run. This can be used by long-running functions to avoid blocking the event loop for the full duration of the function call.

Deprecated since version 3.8, removed in version 3.10: The `loop` parameter. This function has been implicitly getting the current running loop since 3.7. See [What’s New in 3.10’s Removed section](https://docs.python.org/3/whatsnew/3.10.html#whatsnew310-removed) for more information.

Example of coroutine displaying the current date every second for 5 seconds:
sinful pasture
#

ima die while working with that, I can do it, but I will die

sinful pasture
#

oof that hurts

#

alr then

#

Ty

cloud dawn
sinful pasture
#

I don't understand how asyncio sleep fixes the bot sending the same joke

cloud dawn
cloud dawn
sinful pasture
#

ah, so it effectively refreshes it, causing it to send a different joke?

#

smort

royal jasper
#

how can i send a dm to specific user using id?

cloud dawn
cloud dawn
sinful pasture
#

it's from the dadjokes library

cloud dawn
unkempt canyonBOT
royal jasper
cloud dawn
#

!d discord.ext.commands.Bot.fetch_user I recommend this as a backup.

unkempt canyonBOT
#

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

Retrieves a [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") based on their ID. You do not have to share any guilds with the user to get this information, however many operations do require that you do.

Note

This method is an API call. If you have [`discord.Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") and member cache enabled, consider [`get_user()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.get_user "discord.ext.commands.Bot.get_user") instead.
cloud dawn
#

Cache system is kinda flawed.

cloud dawn
slate swan
#

How can I make the bot send a png picture that's in a specific path?

cloud dawn
#

./subfolder/file.png

slate swan
#

but what is the function/method called to upload a file image as a message?

cloud dawn
#

!d discord.abc.Messageable.send

unkempt canyonBOT
#

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

Sends a message to the destination with the content given.

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

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
slate swan
#

something like discord.File("")

cloud dawn
slate swan
unkempt canyonBOT
#

class discord.File(fp, filename=None, *, spoiler=False)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for sending file objects.

Note

File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")s.
slate swan
#

yup

#

spoiler kwarg looks handy

slate swan
cloud dawn
slate swan
#

hehehehaw

#

search disnake docs lol

slate swan
#

Yes.

#

idk chief

cloud dawn
#

!d disnake.abc.Messageable.send

unkempt canyonBOT
#

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

Sends a message to the destination with the content given.

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

To upload a single file, the `file` parameter should be used with a single [`File`](https://docs.disnake.dev/en/latest/api.html#disnake.File "disnake.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`File`](https://docs.disnake.dev/en/latest/api.html#disnake.File "disnake.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://docs.disnake.dev/en/latest/api.html#disnake.Embed "disnake.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Embed`](https://docs.disnake.dev/en/latest/api.html#disnake.Embed "disnake.Embed") objects. **Specifying both parameters will lead to an exception**.
#

class disnake.File(fp, filename=None, *, spoiler=False, description=None)```
A parameter object used for [`abc.Messageable.send()`](https://docs.disnake.dev/en/latest/api.html#disnake.abc.Messageable.send "disnake.abc.Messageable.send") for sending file objects.

Note

File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://docs.disnake.dev/en/latest/api.html#disnake.abc.Messageable.send "disnake.abc.Messageable.send")s.
slate swan
#

but this has a description too

slate swan
#

it's actually better in a way

cloud dawn
#

disnake IS better lol

slate swan
#

but idk where that description is shown

slate swan
cloud dawn
#

Not much info on it in the docs

slate swan
#

mhmmm

#

weird

cloud dawn
#

!d disnake.File.description

unkempt canyonBOT
slate swan
#

Argument of type "str" cannot be assigned to parameter "file" of type "File" in function "send_message"
"str" is incompatible with "File"

slate swan
#

The file’s description.

#
        for file_name in os.listdir("exts\\utils\\imagine_img"):
            await inter.response.send_message(file=f"exts\\utils\\imagine_img\\{file_name}")
slate swan
#

you can't do that

slate swan
slate swan
#

file takes an actual File object

#

isnt it file = disnake.File("")

cloud dawn
#

Yeah that's what we've been trying to say hehe

#

!d disnake.File

unkempt canyonBOT
#

class disnake.File(fp, filename=None, *, spoiler=False, description=None)```
A parameter object used for [`abc.Messageable.send()`](https://docs.disnake.dev/en/latest/api.html#disnake.abc.Messageable.send "disnake.abc.Messageable.send") for sending file objects.

Note

File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://docs.disnake.dev/en/latest/api.html#disnake.abc.Messageable.send "disnake.abc.Messageable.send")s.
cloud dawn
#

fp == file path

slate swan
#

ahh I see now

#

lmfao

#

wrong answer

cloud dawn
slate swan
#

kinda lazy lol

cloud dawn
slate swan
upbeat belfry
#

Sorry question, how do you color text in discord to make it look like code?

slate swan
cloud dawn
unkempt canyonBOT
#

Here's how to format Python code on Discord:

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

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

#
Out of the question.

No documentation found for the requested symbol.

upbeat belfry
#

Thankies

sinful pasture
#

I don't think I used asyncio.sleep properly

cloud dawn
#

I mean tbf we don't see anything you are doing lol

sinful pasture
#

ye

slate swan
slate swan
#

max 10 of what?

quick gust
#

images?

cloud dawn
#

Images aka files

slate swan
#

there is only one image..

cloud dawn
quick gust
#

maybe size then?

maiden fable
#

Yea

slate swan
#

oh so it cant be over what size?

cloud dawn
#

Anything over 8mb is a nono

slate swan
#

alright, ty

quick gust
#

8mb as panda said ^^

cloud dawn
#

tbf 8mb image is almost 8k lol

slate swan
#

google_crawler.crawl(keyword=keyword, max_num=1, max_size=), do I set 8 or 0.8?

cloud dawn
#

Module?

slate swan
#
class Imagine(commands.Cog):
    @commands.slash_command(description="Returning a image with related to the keyword that has been provided")
    async def imagine(self, inter: AppCmdInter, keyword: str):
        google_crawler = GoogleImageCrawler(storage={"root_dir": "C:\\Users\\truth\\Skrivbordet\\bot\\exts\\utils\\imagine_img"})
        google_crawler.crawl(keyword=keyword, max_num=1, max_size=8)

        for name in os.listdir("exts\\utils\\imagine_img"):
            print(name)
            file = disnake.File(f"exts\\utils\\imagine_img\\{name}")

            await inter.response.send_message(file=file)

def setup(bot: Bot) -> None:
    bot.add_cog(Imagine(bot))
cloud dawn
quick gust
#

Not sure, set it to 8 if it takes the size in MBs?

sinful pasture
#

OK then, is there a way to have a bot rerun itself?

slate swan
#

lemme try

cloud dawn
#

Most likely it will take KB

slate swan
#

return max(sz1) <= max(sz2) and min(sz1) <= min(sz2)
TypeError: 'int' object is not iterable

quick gust
#

yeah, no idea though I've never used google crawler

cloud dawn
# slate swan ```py class Imagine(commands.Cog): @commands.slash_command(description="Retu...
class Imagine(commands.Cog):
    @commands.slash_command(description="Returning a image with related to the keyword that has been provided")
    async def imagine(self, inter: AppCmdInter, keyword: str):
        google_crawler = GoogleImageCrawler(storage={"root_dir": "C:\\Users\\truth\\Skrivbordet\\bot\\exts\\utils\\imagine_img"})
        google_crawler.crawl(keyword=keyword, max_num=1, max_size=8)

        await inter.response.send_message(files=[disnake.File(f"exts\\utils\\imagine_img\\{x}") for x in os.listdir("exts\\utils\\imagine_img")])

def setup(bot: Bot) -> None:
    bot.add_cog(Imagine(bot))
slate swan
#

max_size don't take a int apparently

cloud dawn
slate swan
cloud dawn
sinful pasture
#

I feel dumb, can't even understand what the error is lol pithink

slate swan
cloud dawn
#

!pypi icrawler

unkempt canyonBOT
quick gust
cloud dawn
#

This docs is like solve x in nothing or decrypt the answer lol

slate swan
#

Oh shit i got it working

upbeat otter
slate swan
#

so cute

upbeat otter
cloud dawn
#

When it works but you don't know why it works rooMonkaS

slate swan
upbeat otter
#

same to you

slate swan
#

though the issue here is

#

if the user searches for porn, a porn image will pop up.

#

lol

cloud dawn
#

So now every channel officially has to be a NSFW channel.

upbeat otter
#

my bad

manic wing
#

!d discord.TextChannel.nsfw

unkempt canyonBOT
#

If the channel is marked as β€œnot safe for work”.

Note

To check if the channel or the guild of that channel are marked as NSFW, consider is_nsfw() instead.

cloud dawn
#

!d discord.ext.commands.is_nsfw

unkempt canyonBOT
#

@discord.ext.commands.is_nsfw()```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that checks if the channel is a NSFW channel.

This check raises a special exception, [`NSFWChannelRequired`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NSFWChannelRequired "discord.ext.commands.NSFWChannelRequired") that is derived from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").

Changed in version 1.1: Raise [`NSFWChannelRequired`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NSFWChannelRequired "discord.ext.commands.NSFWChannelRequired") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure"). DM channels will also now pass this check.
cloud dawn
#

Wouldn't work anyways

unkempt canyonBOT
#

You are not allowed to use that command here. Please use the #bot-commands channel instead.

slate swan
#

Im thinking of downloading a file with every possible nsfw word, and use that to see if the keyword the user enters is not there

manic wing
slate swan
#

if userinput in thelistofnsfwwors:

cloud dawn
#

Yeah but ALL the words is basically impossible like a swear filter it just isn't 100%

#

The Snowgiving 2021 server has 4400 server boosts lol

quick gust
#

I opened vsc after 12 days KekwSob

slate swan
#

Anyone know client.guilds.cache.size in python form from js

#

!d number of cached guilds

unkempt canyonBOT
#

Number Protocol

manic wing
#

did the same for me

quick gust
manic wing
#

i didnt lol

#

just ignore it

whole sparrow
#

will aiosqlite stop database locking in adiscord bot?

stiff nexus
#
      with open("file", "w") as f:
        json.dump(....,f ,indent=4 )
```now how to delete that (the things u dumped in that file)?
normal ginkgo
magic ore
#

You can select the spaces and change it manually; tabs and spaces show up differently (spaces show up as dots) a

#

Or change all indentation to either spaces or tabs (ctrl + shift + p then search for the command)

quick gust
honest vessel
#

ExtensionFailed: Extension raised an error: AttributeError: 'Group' object has no attribute 'cooldown' cooldown not working for group-commands?

#

or should i use @commands.cooldown() ?

#
@dejay.cooldown(1)```
dosnt work
#

or should it be dejay.commands.cooldown()?

devout iris
#

How can i make custom help command?!?!?

quick gust
devout iris
#

Ah sorry loll

broken plinth
#

hello

#

anybody here?

#

I have an issue with my bot code

#

damn

upbeat otter
magic ore
peak loom
#

Don't know if this is count's as a discord bot but I'm trying to make a FB chat bot and it won't work.

#

Nvm f it.,

upbeat otter
# quick gust what?

As far as I remember, i retyped the whole file Use orettier code formatter

#

Prettier*

velvet tinsel
#

There’s a beautiful errors module, looking to install that

#

I saw it on Reddit

upbeat otter
velvet tinsel
#

Awww

manic wing
#

not enough detail

upbeat otter
velvet tinsel
manic wing
#

look at the pins, they all long as fuck

velvet tinsel
#

hold my juice

upbeat otter
velvet tinsel
#

I’m about to type a 500 word essay about posting a question and hopefully the mods will like me

slate swan
upbeat otter
#

@velvet tinsel

velvet tinsel
#

Damn

upbeat otter
#

Imagine reading this

velvet tinsel
#

Reading what

upbeat otter
#

Guide to ask questions

velvet tinsel
#

Imagine

manic wing
#

@pliant gulch

#

how do you subclass after_invoke lol

visual island
#

subclass?

slate swan
#

When someone mentions the bot it should send the prefix, but when someone mentions the bot with text it shouldnt say the prefix how would i stop this from happening

manic wing
visual island
#

do you mean override?

slate swan
#

this is what happens

#

it will send the command and like it has been mentioned

manic wing
slate swan
#

would i do if msg.content == "<@id>"?

manic wing
#

yes

slate swan
manic wing
slate swan
#

very colorful lol

slate swan
# manic wing yes

how would i make it so that if it has extra content like eg a command, it wouldnt work

#

eg. @bot help

manic wing
slate swan
manic wing
#

because if they add more shit it wont be equal

visual island
# manic wing same shit different terminology

just do

bot = commands.Bot(...)

def my_after_invoke(self, coro):
    # do stuff
    bot.after_invoke(coro)

bot.after_invoke = my_after_invoke
``` or
```py
class Bot(commands.Bot):
    def after_invoke(self, coro):
        # do stuff 
        super().after_invoke(coro)
``` this?
manic wing
visual island
#

any error?

manic wing
#

you cant override after_invoke like that

#

you just cant, no errors

#

its fine

pliant gulch
#

after_invoke only simply, sets the after_invoke method of the bot

manic wing
#

its okay i just looked at the source code and realised it can take coro arg

slate swan
#

how to download libopus DLLs?

#

or how to know whether an audio file is opus encoded

tawdry perch
#

What is difference when using command.Cog and commands.Bot

manic wing
#

what

tawdry perch
#

Uh.. for cogs you always use commands.Cog, right?

manic wing
#

yeah

slate swan
tawdry perch
#

But now I got it

rapid pebble
#

is there a way to get a Member object from their id?

sick birch
rapid pebble
#

thx

verbal cairn
#
datetime.fromtimestamp(int(spec_list[counter][2])).strftime('%d/%m/%Y')
#

is this the correct way to format unix time to a day month year

#

spec_list[counter][2] is a string for a unix time stamp

sick birch
#

Yes

verbal cairn
#

it doesnt work

#
Ignoring exception in slash command 'ahhistory':
Traceback (most recent call last):
  File "C:\Users\Vader\PycharmProjects\pythonProject1\venv\lib\site-packages\disnake\ext\commands\slash_core.py", line 569, in invoke
    await self(inter, **kwargs)
  File "C:\Users\Vader\PycharmProjects\pythonProject1\venv\lib\site-packages\disnake\ext\commands\base_core.py", line 187, in __call__
    return await self.callback(self.cog, interaction, *args, **kwargs)
  File "C:\Users\Vader\PycharmProjects\pythonProject1\taskscog.py", line 224, in ah_history
    f"{datetime.fromtimestamp(int(spec_list[counter][2])).strftime('%d/%m/%Y')}",
OSError: [Errno 22] Invalid argument
sick birch
#

Most likely the timestamp is incorrect

pine sluice
#

how do you make a bot that stores user information in a json file

Ex. @pine sluice have 5 coins, how can I code it so that it can find how much coins I have by accessing the json file and displaying it using a command?

verbal cairn
#

no the timestamp is just a unix number

sick birch
sick birch
pine sluice
verbal cairn
sick birch
#

A proper database

sick birch
verbal cairn
#

1589095799115

sick birch
#

Yeah that's not right

#

That maps to 6/11/52326, 5:45:15 AM

verbal cairn
#

what should it be

sick birch
#

It's only 2021, not 52326 haha

#

It's in ms most likely

verbal cairn
#

oh

sick birch
#

Divide by 1000 and int() it

#

If you divide it by 1000, you get 5/10/2020, 1:29:59 AM

#

You can test UNIX timestamps here on discord for example

verbal cairn
#

(int(1589095799115) / 1000) ?

sick birch
#

<t:1589095799:F>

sick birch
slate swan
sick birch
#

Yes about 50,000 years in the future

sick birch
slate swan
#

;-; rn its only <t:1639260727>

slate swan
sick birch
slate swan
#

^^^

#

<t:2021:year>

#

the timestamp has to be a unix timestamp

sick birch
#

No it's gotta be a UNIX timestamp

slate swan
#

how?

#

also the format is not like that

sick birch
#

seconds since Jan 1, 1970 I think

#

<t:1639260896:R>

slate swan
#

<t:20000000000000000>

#

;-;

#

<t:20000>

#

the past

#

bruh

#

how can I take the time that's right now

sick birch
#

Count

slate swan
#

lol

#

or use a bot πŸ‘

sick birch
#

<t:1638915341:R> for example

#

It also updates live

slate swan
#

<t:1639260930>

verbal cairn
#

wtf

#

it did month day year

sick birch
#

Yeah...

slate swan
#

ye that's correct?

verbal cairn
#

no my code

sick birch
#

That's how you do it

slate swan
#

<t:1639261017:F>

verbal cairn
#

but im us bruh

#

sigh

sick birch
#

that's how it's done in the US too

slate swan
#

us does month day year

sick birch
#

yeah

verbal cairn
#

strftime('%d/%m/%Y') = month day year yep

slate swan
#

others do in a ascending order: day month year

#

yes

#

Europe does Year-month-day

sick birch
verbal cairn
#

my code

#

is doing month day year with that

slate swan
sick birch
#

odd

slate swan
#

i thought eu does ascending lol

sick birch
#

oh wait %d is month

slate swan
#

guess i was wrong

sick birch
slate swan
#

it's 2021-12-11 for me 🀷

#

and I live in northern europe

#

idk ig

#

all ik is formats are different in other parts of the world lol

verbal cairn
#

%d 08 Day of the month as a zero-padded decimal number.

#

okok i got it

#

ty

placid meadow
#

whats the problem?

slate swan
#

So I have a command and I check if the argument provided is falling under the NSFW content (i have made a list of string myself), and if it does I don't wanna send a message but a response to the slash command that it's nsfw content, do u understand what I mean? Like, when u use slash commands I've seen other bots respond in a way but not through a normal message.

pine sluice
#

How do you DM everyone with a bot?

#

and also how do you DM everyone that is online with a bot?

slate swan
pine sluice
#

Ik you can prob do it using a for loop but idk what to do after that

sick birch
#

Don't think we can help you with that as that's breaking the TOS most likely

#

mass DM

manic wing
#

fuck it ill help

sick birch
#

I wouldn't

sick birch
manic wing
# pine sluice and also how do you DM everyone that is online with a bot?

!d discord.Guild.members || py for member in guild.members: #where guild is an instance of `discord.Guild` -> can be gotten by `ctx.guild` or `bot.get_guild(guild_id)` if str(member.status) == "online": #checks if they are online with `discord.Member.status` await member.send("Hello") #await discord.abc.Messageable.send -> same as doing `await ctx.send` seeing as they inherit from `discord.abc.Messageable

unkempt canyonBOT
#

property members: List[discord.member.Member]```
A list of members that belong to this guild.
manic wing
#

!d discord.Member.status

unkempt canyonBOT
#

property status: discord.enums.Status```
The member’s overall status. If the value is unknown, then it will be a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") instead.
manic wing
#

!d discord.abc.Messageable

unkempt canyonBOT
#

class discord.abc.Messageable```
An ABC that details the common operations on a model that can send messages.

The following implement this ABC...
unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

manic wing
#

@pine sluice all these are links to the docs where you can read more about what I have done here

manic wing
#
  • if he does this on servers his bot will just get kicked
slate swan
#

It may be used for ToS breaking purposes as we don't know what he's really doing with it. This falls under the rule that was provided:

Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

placid meadow
#

can anybody help me?

slate swan
placid meadow
#

so i'm trying to connect to the db but it says connect is undefined , how to define it?

manic wing
#

to connect to your db

#

sqlite3?

placid meadow
#

sqlite3

jade tartan
#

Hey I got a question when a member agrees to rules on a specific channel how do I make the bot say. (member.mention) role has been added message?

manic wing
#

from sqlite3 import connect

manic wing
magic ore
#

shouldn't use the sqlite3 library in a bot (it's blocking)
use an async wrapper around it such as asqlite

unkempt canyonBOT
placid meadow
jade tartan
placid meadow
#

tho i have a table name blacklisted userids

manic wing
jade tartan
placid meadow
#

i don't understand

slate swan
#

Not a python thing afaik

#

More dpy

#

But is related to classes

#

am I dumb or am I dumb

#
embed = Embed(color=#20d4b7)
#

πŸ•΄οΈ

#

makes a comment, how tf am I supposed to add color to my embed

#

ah so the 0x acts like #?

#

Get the hex color and add 0x to it

#
disnake.errors.InteractionTimedOut: Interaction took more than 3 seconds to be responded to. Please defer it using "interaction.response.defer" on the start of your command. Later you may send a response by editing the deferred message using "interaction.edit_original_message"
Note: This might also be caused by a misconfiguration in the components make sure you do not respond twice in case this is a component.
#
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: InteractionTimedOut: Interaction took more than 3 seconds to be responded to. Please defer it using "interaction.response.defer" on the start of your command. Later you may send a response by editing the deferred message using "interaction.edit_original_message"
Note: This might also be caused by a misconfiguration in the components make sure you do not respond twice in case this is a component.
#

bruh why did I get these errors? does it take that long to create a embed lmao

manic wing
#

if you ever want to add the same color to everything just subclass ctx.send or edit discord.Embed source code

#

be an alpha

slate swan
#
    @commands.slash_command(description="Returning a image related to the keyword that has been provided")
    async def imagine(self, inter: AppCmdInter, keyword: str):
        google_crawler = GoogleImageCrawler(storage={"root_dir": "C:\\Users\\OneDrive - Thorengruppen\\Skrivbordet\\bot\\exts\\utils\\imagine_img"})
        filters = dict(size='medium')
        google_crawler.crawl(keyword=keyword, max_num=1, filters=filters)

        embed = Embed(color=0x20d4b7)
        file_name = ""
        for name in os.listdir("exts\\utils\\imagine_img"):
            file_name += name
            file = disnake.File(f"exts\\utils\\imagine_img\\{name}")
            embed.set_image(file=file)

        if keyword not in NSFW:
                await inter.response.send_message(embed=embed)
                os.remove(f"exts\\utils\\imagine_img\\{file_name}")
        else:
            if inter.channel.is_nsfw():
                await inter.response.send_message(embed=embed)
                os.remove(f"exts\\utils\\imagine_img\\{file_name}")
            else:
                await inter.response.send_message("NSFW is not allowed in this channel!", ephemeral=True)
#

this is the code

placid meadow
#

how to define?

patent bluff
placid meadow
patent bluff
#

What

manic wing
#

by not copy and pasting 😎

placid meadow
#

right.

manic wing
#

right.

#

im not wrong.

placid meadow
#

nope you're not

#

alright just for you i'll actually start from scratch

manic wing
#

ty - you've literally got 4 undefined variables

patent bluff
#

i only see 2

manic wing
patent bluff
#

member is defined

patent bluff
manic wing
#

shit

#

im tired allow me

slate swan
#

I fixed it though

slate swan
slate swan
slate swan
slate swan
#

I obv did

from disnake.embeds import Embed

cosmicloldog

slate swan
#
        embed = Embed(color=0x20d4b7)
        file_name = ""
        for name in os.listdir("exts\\utils\\imagine_img"):
            file_name += name
            file = disnake.File(f"exts\\utils\\imagine_img\\{name}")
            embed.set_image(file=file)
            file.close()
#

got no error at all, but it sends a empty embed

#

and the file path is correct since I tried this without the embed, and it sends the image

rotund creek
#

Whats disnake?

slate swan
slate swan
rotund creek
#

Oh

#

I still use dpy

slate swan
rotund creek
#

Nah i gave up with discord api

#

Im into web dev now

#

Hit me up if your bot needs a website

slate swan
rotund creek
#

Oh ok :)

#

I forgot I need to make my bot a website

placid meadow
manic wing
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

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

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

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

from discord import Intents
from discord.ext import commands

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

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

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

placid meadow
#

What am i missing?

manic wing
#

how are we supposed to know lool

placid meadow
manic wing
#

i smell lack of basic python knowledge

#

learn python

placid meadow
#

literally show me how to learn , all these video are just showing how to make a bot , i want some help on that, even if i copy pasted most of it i modified that thing for over 8 hours straight

slate swan
#

you indent is wrong

#

also why do you have a blacklist function in a check

manic wing
manic wing
slate swan
#

lmao

lost wolf
#

why is it so hard to make a uptime command in py

manic wing
lost wolf
#

it is

manic wing
#

its extremely easy

lost wolf
#

f"{bot.uptime}" isnt a thing is it?

slate swan
#

no

manic wing
#

you just do bot.launch_time = datetime.datetime.utcnow() and then ```py
@commands.command()
async def uptime(self, ctx:Context):
delta_uptime = datetime.utcnow() - self.bot.launch_time
hours, remainder = divmod(int(delta_uptime.total_seconds()), 3600)
minutes, seconds = divmod(remainder, 60)
days, hours = divmod(hours, 24)

    return await thebed(ctx, '', f"I've been Up since **{days}** Days, **{hours}** Hours, **{minutes}** Minutes, and **{seconds}** Seconds!")
#

ignore indents fuck discord

slate swan
#

ay thats thw same way i did it

lost wolf
patent bluff
slate swan
lost wolf
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Bot' object has no attribute 'launch_time'

flat flower
#

can someone help me alter my modmail commands so it only allows 1 channel to be opened per person

unkempt canyonBOT
#

Hey @flat flower!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

β€’ If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

β€’ If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

flat flower
patent bluff
slate swan
#

Good morning, I am gonna sit in this chat and absorb knowledge

patent bluff
#

ok

potent spear
flat flower
#

What could be a fix?

#

without needing a db

potent spear
slate swan
#

πŸ•΄οΈ

flat flower
#

I will

#

but for now how can I fix this

potent spear
#

best way: add every member to the db that uses the modmail: have a column with a "isAlreadyBusy" boolean thingy in it
if that's true, you can just skip that member
else, create a new modmail

flat flower
#

is it possible without a db

potent spear
#

yes, but that's a bad way
that would be a json as config file, and if your bot would be used in multiple servers it could possibly corrupt your json, you don't want that

flat flower
#

I will switch it over

#

for now I just need a json file

potent spear
#

don't

#

do it good first try

flat flower
#

ok

#

can I use firebase?

potent spear
#

you don't want to do it bad and then rewrite, if you do it good on the first try, you won't have to spend extra time
since if it goes wrong, you'll curse at yourself

#

no, use an async wrapper of a db

flat flower
#

ok

#

can you help me set that up

potent spear
#

will your bot be used in multiple guilds?

flat flower
#

It will be used in multiple guilds

#

for now its still being developed

potent spear
#

asynpg will be the db for you then

#

*asyncpg

#

that's an async wrapper of the postgres db

flat flower
#

Ok

#

Can you help me set it up

potent spear
#

you'll need to learn basic sql after setting up the db ofc

#

for setting up a db, I'd suggest you to go to the discord py server, that question gets asked daily there

#

have a step-by-step guide of how you want things to go, you don't want to set up a db and be like "what's next?"

flat flower
#

ok

#

thank you

potent spear
#

gl!

slate swan
#

How can I make my footer in a embed a link?

#

How to create on_reaction_add multiple times so that there were no errors?

slate swan
slate swan
slate swan
slate swan
slate swan
slate swan
slate swan
slate swan
#
embed.set_footer(text="Redirect to Wikipedia")
#

this is what I've got, I want the "redirect to wikipedia" to be a link

#

I tried doing [thingy](link) but that didnt work

#

Ah

#

Idk if footers can do that

#

Hi, what to put in argument allowed_mentions so the bot cannot ping everyone?

slate swan
#

Same with titles

slate swan
slate swan
#

i cant seem to find yellow

#

and when i put yellow is also said no such color

#

Yellow isnt a color

#

Just use a color hex

#

yesterday when i did that i got told to make an entire db for a color hex

slate swan
# slate swan yesterday when i did that i got told to make an entire db **for a color hex**
default = 0
teal = 0x1abc9c 
dark_teal = 0x11806a
green = 0x2ecc71 
dark_green = 0x1f8b4c
blue = 0x3498db 
dark_blue = 0x206694 
purple = 0x9b59b6 
dark_purple = 0x71368a 
magenta = 0xe91e63
dark_magenta = 0xad1457
gold = 0xf1c40f 
dark_gold = 0xc27c0e 
orange = 0xe67e22 
dark_orange = 0xa84300 
red = 0xe74c3c
dark_red = 0x992d22 
lighter_grey = 0x95a5a6 
dark_grey = 0x607d8b 
light_grey = 0x979c9f
#

You can .bm if you want

#

Pretty handy

slate swan
slate swan
#

#FFFF00

slate swan
#

Is a bright yellow

#

is light_yellow a thing

#

No

#

Its red grey blurple green

#

C:\Users\ADMIN\PycharmProjects\Fluxo\main.py:21: SyntaxWarning: 'str' object is not callable; perhaps you missed a comma?
embed = discord.Embed(color='0xEFFF00'())

#

pls spoon feed me on this part

#

No need for ()

#

.red() contains the red hex

#

Its how that works

#

File "C:\Users\ADMIN\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\ADMIN\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\ADMIN\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Expected discord.Colour, int, or Embed.Empty but received str instead.

silent lark
#

hey I just created a script that is working in my console that will print out what I want, how would I go about putting this into discord. It only needs to print something out every maybe 5 minutes or so

slate swan
slate swan
#

0x0 is a type of integer

silent lark
slate swan
#

anyone know a 6 digit hex to 8 digit hex converter?

#

faa61a i need to this be 8

slate swan
slate swan
#

end

#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'FAA61A00' is not defined

#

oh wait

#

its going to be 6 because you forgot to add 0x

#

should be 0xFAA61A

#

Ah

slate swan
#

Whys my slash command instantly saying it failed? There is no error and I havent changed something great in my code only changed a variable

Even if that was the error, This Interaction Failed wouldnt instantly show up but after a few seconds

#

But it instantly shows up

#

I also restarted the code and also my discord

#

Weird I added just a random message being sent at the beginning and now it works!?!?!?

#

But I dont want that second message

#

Ok now I removed it and it doesnt work again

#

I dont understand...?

#

have you tried doing the command with a user by any chance?

#

What do you mean

#

whats the command for?

#

To start a battle

#

Takes no arguments

#

Only /battle

#

ah i see

#

It worked before

#

Until I changed a variable which is only for display purposes

#

hm

#

what is this var?

#

It calculates how many gold or xp you get

#

Before Ive set both to 0

#

Now its...

#

xp_gain = enemy.hp / enemy.damage

#

gold_gain = enemy.damage * random.randint(2,5)

#

And as you see in the first Image Ive sent it totally works fine

gaunt wedge
#

how do i set category of a command or add a special attribute?

bot.command() # how specify category

i tried using category kwarg

stark lintel
#

how do i make a slash command?

#

in my discord bot

#

this is a very basic "test", but it doesn't do anything

#

as usual, idk what im doing wrong

#

@slate swan how make slash command work lemon_angrysad

#

when you put @client.command(), in parenthesis you can put description='...'

#

ill show an example

#

@slate swan

#

brief is like a shortened version of your full description. description is what shows up when you run !help <command>. For this example, just let the ! be your command prefix

#

yeah

#

if you want them to have a description

#

lmao, idk to be honest

#

its up to you i guess

#

NP

final iron
#

Keep the description brief

stark lintel
#

@final iron can you try to help me with my issue

#

idk how experienced you are

#

how get this to work lemon_angrysad

final iron
#

I have only worked with dpy so I wont be able to help

stark lintel
#

oops, wrong thing

astral cobalt
#
@client.command()
async def get_meme(ctx):
    print("In here")
    memes_submissions = await reddit.subreddit('memes')
    #memes_submissions = await memes_submissions.hot()
    post_to_pick = random.randint(1, 10)

    submission = next(x for x in memes_submissions if not x.stickied)
    print(submission.url)
    await ctx.send(submission.url)``` Anyone know why this isnt working? Its running but wont return anything when I run !get_meme
stark lintel
#

do you already have a command called coinflip? this error could occur if you have multiple of the same name

gaunt wedge
#

how do i add a special attribute on bot.command()?

stark lintel
#

you should try that, and tell me if it gives you the same error

#

do you have multiple async def coinflip() commands?

#

to be honest, im not sure what exactly is causing that error

gaunt wedge
#

dont make multiple commands with the same name

#

yeah

#

also, how do i add a special attribute to a command in bot.command()

astral cobalt
#

I should be using asyncpraw for a discord bot that gets reddit posts correct?

boreal ravine
boreal ravine
magic ore
boreal ravine
stark lintel
#

so basically...

#

im trying to make a slash command, and its not necessarily triggering any errors, more or less its just flat out not working

boreal ravine
#

what lib are you using

stark lintel
#

here, ill send a screenshot of the libs that go with the slash commands...give me one sec

astral cobalt
#

@boreal ravine could you take a look at this and see if you can see anything wrong with it? ```py
reddit = asyncpraw.Reddit(
user_agent="Hello There)",
client_id="CLIENT_ID",
client_secret="CLIENT_SECRET",
username="USERNAME",
password="PASSWORD",
)

@client.command()
async def get_meme(ctx):
print("In here")
memes_submissions = await reddit.subreddit('memes')
#memes_submissions = await memes_submissions.hot()
post_to_pick = random.randint(1, 10)
for i in range(0, post_to_pick):
submission = next(x for x in memes_submissions if not x.stickied)
print(submission.url)
await ctx.send(submission.url)```

stark lintel
#

@boreal ravine

boreal ravine
#

show me the slash commans

stark lintel
#

this is the only one ive attempted so far

boreal ravine
boreal ravine
stark lintel
#

no, how would i set those

astral cobalt
#

@boreal ravine None, it just wont return a reddit post back to discord. Doesent throw any errors

boreal ravine
stark lintel
#

ok, im there

stark lintel
#

now where

boreal ravine
boreal ravine
gaunt wedge
#

!d discord.ext.commands.Command

unkempt canyonBOT
#

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

These are not created manually, instead they are created via the decorator or functional interface.
stark lintel
#

is it the thing that says bot permissions? @boreal ravine

stark lintel
#

ok, let me do that...

#

should i set the thing to administrator?

boreal ravine
#

no

boreal ravine
#

enable it the same place you enabled the bot scope for your bot

stark lintel
#

OHHHHHHH

#

can i send a screenshot and you tell me what to put a check on?

astral cobalt
#

@boreal ravine It just returns "memes"

stark lintel
#

@boreal ravine the slash command still isn't showing up

boreal ravine
stark lintel
astral cobalt
#

Memes submission: memes

boreal ravine
#

I mean the scopes

#

scopes

boreal ravine
stark lintel
astral cobalt
#

ss? substring?

stark lintel
#

screenshot

boreal ravine
astral cobalt
#

Oh

stark lintel
#

applications.builds.read

#

correct>

boreal ravine
stark lintel
#

applications.commands?

boreal ravine
#

then re-invite your bot with those scopes