#discord-bots

1 messages · Page 639 of 1

tawdry perch
#

I don't just remember the meaning of constructor in Finish

sullen shoal
#

constructor of every python class is object.__init__

#

!d object._init_

unkempt canyonBOT
#

object.__init__(self[, ...])```
Called after the instance has been created (by [`__new__()`](https://docs.python.org/3/reference/datamodel.html#object.__new__ "object.__new__")), but before it is returned to the caller. The arguments are those passed to the class constructor expression. If a base class has an [`__init__()`](https://docs.python.org/3/reference/datamodel.html#object.__init__ "object.__init__") method, the derived class’s [`__init__()`](https://docs.python.org/3/reference/datamodel.html#object.__init__ "object.__init__") method, if any, must explicitly call it to ensure proper initialization of the base class part of the instance; for example: `super().__init__([args...])`.

Because [`__new__()`](https://docs.python.org/3/reference/datamodel.html#object.__new__ "object.__new__") and [`__init__()`](https://docs.python.org/3/reference/datamodel.html#object.__init__ "object.__init__") work together in constructing objects ([`__new__()`](https://docs.python.org/3/reference/datamodel.html#object.__new__ "object.__new__") to create it, and [`__init__()`](https://docs.python.org/3/reference/datamodel.html#object.__init__ "object.__init__") to customize it), no non-`None` value may be returned by [`__init__()`](https://docs.python.org/3/reference/datamodel.html#object.__init__ "object.__init__"); doing so will cause a [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") to be raised at runtime.
tawdry perch
#

oh.

#

yh, this will be too hard

boreal ravine
#

I thought just kwargs lol

sullen shoal
#

yeah that will work too

#

because all the parameters of Embed are keyword only

#

!d discord.Embed

unkempt canyonBOT
#

class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.

len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.

bool(b) Returns whether the embed has any data set.

New in version 2.0.

Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").

For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
sullen shoal
#

yeah

tawdry perch
#

let me guess, this ain't correct.. ```py
import discord

class Factory(discord.Embed):
def init(self, *args, **kwargs):
super().init()
self.embed = Factory(*args, **kwargs)

async def mod_log(self, ctx, title, description, field, value):
    embed = self.embed(title=title, description=description, color=ctx.author.color)
    embed.add_field(name=field, value=value)
    return embed
sullen shoal
#

no

#

, a good OOP tutorial will explain it pretty easily and quick

#

the basics of OOP will take around an hour to learn if you pay attention

tawdry perch
#

I have no idea what am I even supposed to do for it to work so I will probably continue it later or just give it up and make embeds manually

sullen shoal
#

it could be a function too but it will not look that good tho

tawdry perch
#

I'll just look up online smth that might work

obtuse jewel
#

quick question

#

is there an on_mention event?

silk mauve
#

on member mention?

sullen shoal
vocal shoal
#

how to get guild description?

spring flax
unkempt canyonBOT
vocal shoal
#

thx

silk mauve
#

Guys, this is my error: discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'discord.utils' has no attribute 'get_role'

#

@bot.command()
async def snipe(ctx):
Serverbooster = discord.utils.get_role("874795834733117450")

#

What do I have to change now?

sullen shoal
#

utils is slow, use discord.Member.get_roles instead
discord.Member has to be an instance of the class

silk mauve
#

Alright

sullen shoal
#

oh

#

wait

#

!d discord.Member.roles

unkempt canyonBOT
#

property roles: List[Role]```
A [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that the member belongs to. Note that the first element of this list is always the default [‘@everyone](mailto:'%40everyone)’ role.

These roles are sorted by their position in the role hierarchy.
silk mauve
#

Serverbooster = discord.discord.Member.get_roles("874795834733117450")

sullen shoal
#

!d discord.Member.get_role

unkempt canyonBOT
#

get_role(role_id, /)```
Returns a role with the given ID from roles which the member has.

New in version 2.0.
slate swan
#

get from the guild

silk mauve
#

Like this?

#

One discord too much

sullen shoal
#

what do you want to do

silk mauve
#

I've a command.

slate swan
#

do you want to check if user has the role

silk mauve
#

Yeah

#

If he doesnt, a embed is gonna send

slate swan
#

use the decorator, @commands.has_role()

silk mauve
#

@bot.command()
async def snipe(ctx):
Serverbooster = discord.Member.get_role("874795834733117450")
if not ctx.author.has_role("Server Booster"):
embed = discord.Embed(title="Booster Command", description="Du hast ein Booster Vorteil Entdeckt!",
colour=discord.Colour.red())

slate swan
#

!code pls

silk mauve
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.

silk mauve
#
async def snipe(ctx):
    Serverbooster = discord.Member.get_role("874795834733117450")
    if not ctx.author.has_role("Server Booster"):
        embed = discord.Embed(title="Booster Command", description="Du hast ein Booster Vorteil Entdeckt!",
                              colour=discord.Colour.red())```
#

I alried tried has role

slate swan
#

its a decorator

silk mauve
#

But I dont know how to do it if someones doen't have the role, and the person uses a the command

slate swan
#

not an attribute

sullen shoal
#

!d discord.Member.premium_since check this as well maybe thats what you want

unkempt canyonBOT
#

An aware datetime object that specifies the date and time in UTC when the member used their “Nitro boost” on the guild, if available. This could be None.

silk mauve
#

yeah, and?

slate swan
#

I don't get why you use discord.Member as well, you need to use ctx.author

silk mauve
#

if not ctx.author.has_role("Server Booster"):

slate swan
#

member has no has_role attribute

silk mauve
#

Yeah

slate swan
#

you have to check if its in its roles

silk mauve
#

Got that error rn lol

slate swan
#

hello

silk mauve
silk mauve
slate swan
#

so i have dis work command


@bot.listen()
async def on_message(message):
    if message.content.startswith('!work'):
        channel = message.channel
        await channel.send('print hello world')

        player = message.author
        gg = random.randint(100, 150)

        def check(m):
            return m.content == "```py print('hello world')```" or '```print("hello world")```' or "print('hello world')" or 'print("hellow world")' and m.channel == channel

        msg = await bot.wait_for('message', check=check)
        c.execute(f"UPDATE data SET balance = balance+{gg} WHERE ID = {player.id}")
        conn.commit()
        await channel.send(f"You Worked Hard To Fix The Bug, You Got **{gg}:nexus:** as Salary")
        print(gg)

so I am trying to make a function such as work "list"

i currently have 3 works such as this types and want to make a command such as
!work {work_name}
and allow the users to take 1 work out of 3

#
role_ids = [r.id for r in ctx.author.roles]

if not ROLEID in role_ids:
  ...

wouldnt recommend this, so long, another way would be getting the role. u could use a decorator

silk mauve
#

wut

slate swan
#

@silk mauve

slate swan
slate swan
silk mauve
slate swan
#

soo i am trying to make a command such as

!work {work_name}
and i have 3 work names
naming
coder
gamer
artist

silk mauve
#

cool

slate swan
#

and if the person types
! work coder
than the user cannot use
work command of gamer or artist

#

can you pls help me to make this system

atomic wolf
#

Do you guys know the minimum amount of time between messages from a loop I can send at?

#

I'm trying to make a bot that sends a message every hour.\

velvet tinsel
#

Huh?

#

Asyncio.sleep

#

!d asyncio.sleep

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:
slate swan
#

no asyncio sleep, use tasks from discordpy

velvet tinsel
velvet tinsel
slate swan
#
@tasks.loop(hours=1)
async def myloop():
   # do stuff
velvet tinsel
#

Im bad at helping people

#

😭 I was called toxic

slate swan
#

it's the thought that matters

#

:CB_patcat:

#

bruh

sullen shoal
#

epic nitro fail

atomic wolf
#

makes sense

velvet tinsel
#

:sadge:

atomic wolf
#

I guess I wait the 5 minutes and see if it sends

velvet tinsel
#

I told people to Google it

#

I don’t know why they hate me for this

atomic wolf
#

async def myloop():

    response = "Hugu Wugu"

    await ctx.send(response)
    channel.send(response)```
slate swan
#

yeah, uh, don't do that.

atomic wolf
#

any prollums here?

slate swan
atomic wolf
#

on loops too eh?

velvet tinsel
#

What’s wrong with that

#

It’s the obvious answer 🤷‍♂️ unless you already searched it up or nothing happens

slate swan
#

rude, also anyone can guess googling may lead to answers

slate swan
velvet tinsel
#

I guess they don’t like googling

#

And plus they just come directly into discord

atomic wolf
#

instead of on the hour every hour? I suppose so.

#

kind of cheap of me.

slate swan
slate swan
dusky elk
#

how do people usually go about running webservers and sharing data with a discord bot? do they have it run on the same event loop or is it different processes?

#

communicating with a DB or something else

slate swan
#

you just have to implement it

dusky elk
#

ah gotcha

atomic wolf
#

I'm getting TypeError: myloop() missing 1 required positional argument: 'ctx'

#

async def myloop(ctx):

    response = "Hugu Wugu"

    await ctx.send(response)

myloop.start()```
#

is the ctx wrong?

slate swan
#

What are you tryng to do?

atomic wolf
#

send hugu wugu 5 times upon start up of bot?

maiden fable
slate swan
#

Make a function and create a task loop

atomic wolf
#

name ctx is not defined is what i'm getting now

#

for myloop.start(ctx)

#

yes, but ultimately I want it to send a message every hour 😐

maiden fable
#

But u need to use bot.get_channel to get the channel

#

where do u want to send the message

atomic wolf
#

general

maiden fable
#

The bot doesn't know what is general

#

You can do something like

@tasks.loop(...)
async def loop():
    await bot.wait_until_ready()
    channel = bot.get_channel(id)
    await channel.send(...)

loop.start()
#

Welp I just spoonfed ;-;

slate swan
#

it's base code

maiden fable
#

Stilllllll

atomic wolf
#

what's the import for that?

slate swan
#

no...

maiden fable
atomic wolf
#

module 'discord.ext.commands.bot' has no attribute 'get_channel'

spring flax
slate swan
#

import discord.ext.commands.bot

#

let's go

spring flax
#

not discord.ext.commands.bot

slate swan
#

we're doing the thing that even youtube tutorials can

sullen shoal
#

i dont think they even opened the link i sent

maiden fable
#

Lmao

#

!d discord.ext.tasks.Loop also exists BTW

unkempt canyonBOT
#

class discord.ext.tasks.Loop```
A background task helper that abstracts the loop and reconnection logic for you.

The main interface to create this is through [`loop()`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.loop "discord.ext.tasks.loop").
sullen shoal
#

oh yeah

tawdry perch
#

for embed this is incorrect, but what is correct one? ```py
icon_url=member.display_avatar.url

slate swan
#

member.avatar.url

tawdry perch
#

ah

hollow mortar
#

hey i have a problem in my code

#
with open('songs') as f:
    lines = f.read().splitlines()
print(lines)




for line in lines:
    count=+ 1
    results = YoutubeSearch(line, max_results=1).to_dict()
    if len(results) > 0:
        dictionary = results[0]
        songs_urls =(f"youtube.com{dictionary.get('url_suffix')}")
        with open('songs','w') as f:
            f.write((songs_urls) + '\n')
        
    else:
        print("No results found.")
f.close()```
#

this is my code when i try to write the songs_urls in a txt file it write the url but write it and then remove it and write new one and keep doing this

#

i want it to write one and then go to anther line and go to the for loop and write the other one

#

even when im using writelines same problem any idea how to fix it ?

cloud dawn
#

!blocking

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!

velvet tinsel
#

pandabweer

sweet chasm
#

how would you get mutual members in python (im making a modmail bot)? Ik you can do it in js but how would we do it in py

full lily
#

mutual members?

maiden fable
unkempt canyonBOT
#

property mutual_guilds: List[Guild]```
The guilds that the user shares with the client.

Note

This will only return mutual guilds within the client’s internal cache.

New in version 1.7.
sweet chasm
#

idk how to word stuff

unkempt canyonBOT
#

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

001 | a='a=%r;print(a%%a)';print(a%a)
002 | Traceback (most recent call last):
003 |   File "<string>", line 3, in <module>
004 |   File "<string>", line 1
005 |     print('exec("print('''Hello, World!''')")')
006 |                                        ^
007 | SyntaxError: unterminated triple-quoted string literal (detected at line 1)
maiden fable
#

#bot-commands exists

slate swan
#

Hi, I am trying to make an event to send a message in a channel that the bot has permission to send in on join. I have this so far but it does not work and no errors are produced.

    @commands.Cog.listener()
    async def on_server_join(self,ctx):
        for guild in self.bot.guilds:
            for channel in guild.text_channels:
                if channel.permissions_for(guild.me).say:
                    await ctx.message.channel.send('Hello! \n')
                    break
cloud dawn
velvet tinsel
#

Pandabweer

cloud dawn
velvet tinsel
#

Such a nice name

cloud dawn
#

Your's implies something nice as well😉

umbral dome
#

Can someone tell me how i can keep my discord bot up with a html?

sage otter
umbral dome
#

Idk

sage otter
umbral dome
#

my freind told me that with html the bot would keep being online

sage otter
#

But that’s not what really matters.

#

instead of ctx.message.channel.send() it’s just supposed to be channel.send()

slate swan
#

ah ok

cloud dawn
slate swan
#

oh lol

sage otter
#

on_guild_join() pl0x

cloud dawn
#

!d discord.on_guild_join

unkempt canyonBOT
#

discord.on_guild_join(guild)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild") is either created by the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") or when the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") joins a guild.

This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
slate swan
#

So something like this

    @commands.Cog.listener()
    async def on_guild_join(self,guild,ctx):
        for guild in self.bot.guilds:
            for channel in guild.text_channels:
                if channel.permissions_for(guild.me).say:
                    await channel.send('Hello! \n')
                    break
#

don't need ctx

cloud dawn
slate swan
#

wait what

#

It spams it?

sage otter
#

Well it does exactly what you want it to do.

cloud dawn
sage otter
#

Sends a message in every chat the bot has perms in

umbral dome
#

But is there some kind of method to keep a discord bot online so i dont have to pay for a vps or have mig pc open og day all night

slate swan
#

I definitely don't want that

#

I'm not trying to make a nuke bot lol

#

How do I make it so It only sends once?

cloud dawn
#

And i also recommend not copying code

slate swan
#

I used that yeah

sage otter
slate swan
sage otter
#

random.choice() on Guild.channels

#

And send it to that one

#

Or better yet

#

Use the system messages channel

cloud dawn
#
@commands.Cog.listener()
async def on_guild_join(self, guild: discord.Guild) -> discord.TextChannel.send:
    return await guild.system_channel.send('Hello!')
``` Don't think too difficult guys
slate swan
#

oh

#

It doesn't send a message for me, is that something to do with intents?

cloud dawn
#

Could you show it?

sage otter
#

the error as well pls

slate swan
#

There was no error but dw I fixed it. It was an indents problem

cloud dawn
#

So time for a beer?

slate swan
#

yes

cloud dawn
#

🍻

sage otter
slate swan
sage otter
#

you could of just annotated it to discord.Message but that’s ok 👌

velvet tinsel
#

Pandabweer

#

🍻

hollow mortar
umbral dome
#

😭

#

But is there no way to keep a bot online without vps

slate swan
#

You don't need to use vps

#

There is just regular bot hosting

upbeat otter
slate swan
#

Bot hosting is really really cheap and easy

umbral dome
#

but its not a bot i wanna make a profit of i just want to be able to close my pc so my house dont burn to hell

slate swan
#

It's not a discord bot?

upbeat otter
umbral dome
#

yea replit is not strong but when i close the web the bot closes too

upbeat otter
#

Closes it?

umbral dome
#

yea

upbeat otter
#

Weird

umbral dome
#

The bot shutdown when u close the web(replit)

upbeat otter
umbral dome
#

what is that?

upbeat otter
#

Constantly pinging your bot's web server every 5 mins for free

#

But you need to refresh your repl every 9 hours

umbral dome
#

ohhh

#

Okay

velvet tinsel
#

I thought you have to pay

slate swan
#

How is this invalid syntax?

    return await guild.system_channel.send(embed=em)
    ^
SyntaxError: invalid syntax
late wigeon
#

how do I catch a discord interactions timeout error?
interaction = await self.bot.wait_for("button_click", timeout=30)

velvet tinsel
#

I think you dont have to await it

outer violet
#

How do I make the commands have description when showing the help command?

velvet tinsel
#

idk how to use the bot

late wigeon
#

yeah I can't find any api for discord interactions

velvet tinsel
late wigeon
#

it makes it hard

velvet tinsel
velvet tinsel
slate swan
late wigeon
late wigeon
velvet tinsel
#

wont work I think

velvet tinsel
slate swan
# velvet tinsel show full code
    @commands.Cog.listener()
    async def on_guild_join(self, guild: discord.Guild) -> discord.abc.Messageable.send:
        em = discord.Embed(title = "Title", description = "Description",colour=0x3FE452)
        em.add_field(name="Name", value="Value"
        return guild.system_channel.send(embed=em)
opal skiff
#

i get this err or but my code still works nextcord.errors.InteractionResponded: This interaction has already been responded to before my code : py @nextcord.ui.button(label="testlabel",style=nextcord.ButtonStyle.grey) async def Field1(self,button : nextcord.ui.Button,interaction:nextcord.Interaction): while True: await interaction.response.send_message("Dein spielfeld XD",ephemeral=True)

late wigeon
outer violet
late wigeon
haughty quartz
#

i used this guide https://www.showwcase.com/show/11710/Host-a-Discord-Bot-online-247-for-FREE! to get my bot to run 24/7 but it wont show a website window on repl pls help ```py
import os
import discord
from discord.ext import commands, tasks
import re
from urllib.request import urlopen
from bs4 import BeautifulSoup
import requests
import random
from itertools import cycle

from flask import Flask
from threading import Thread

app = Flask('')

@app.route('/')
def main():
return "Your Bot Is Ready"

def run():
app.run(host="0.0.0.0", port=8000)

def keep_alive():
server = Thread(target=run)
server.start()

bot = commands.Bot(command_prefix="!")
bot.remove_command('help')
case_insensitive=True
status = cycle(['!help','!scs <product>'])

@bot.event
async def on_ready():
change_status.start()
#os.system("clear")
print("{0.user} is online".format(bot))

@tasks.loop(seconds=10)
async def change_status():
await bot.change_presence(activity=discord.Game(next(status)))

velvet tinsel
#

I tried doing that, nothing happened

haughty quartz
#

thanks :)

velvet tinsel
#

bruh it's javascript

haughty quartz
#

scroll down

#

its both js and py on that guide

velvet tinsel
#

oh wait there is a python section

slate swan
#

guys how do i add emoji reaction for the bots message

velvet tinsel
#

any errors?

slate swan
#

await msg.add_reaction?

haughty quartz
velvet tinsel
velvet tinsel
haughty quartz
#

i dont have that window

#

website not working

velvet tinsel
#

what window

haughty quartz
#

that white thing

velvet tinsel
#

it is showing?

haughty quartz
#

no

velvet tinsel
#

no?

haughty quartz
#

its not showing

velvet tinsel
#

It says "I'm alive"

haughty quartz
#

thats what it should look like

#

took that image from the guide

velvet tinsel
#

show me the link?

haughty quartz
#

i dont have it

velvet tinsel
#

what do you mean?

haughty quartz
#

this is what i get

velvet tinsel
#

when you create a flask repl, there should be a link...

haughty quartz
#

but it doesnt work

velvet tinsel
#

ok...

#

did you follow the uptimeRobot?

haughty quartz
#

i cant as i dont have a link

velvet tinsel
#

Ok

#

it may be outdated

haughty quartz
#

wdym

outer violet
haughty quartz
velvet tinsel
#

but this should be a #web-development question, as it does not apply to discord bots (fully)

haughty quartz
#

but i dont have a https link that i could put there

velvet tinsel
outer violet
haughty quartz
velvet tinsel
outer violet
haughty quartz
#

how?

velvet tinsel
# haughty quartz okay

I have no experience with Flask, but my Django projects work pretty well
we dont talk about the time where I spent hours trying to pip install django

outer violet
#

Then import it in the main file

velvet tinsel
haughty quartz
velvet tinsel
haughty quartz
#

okay

velvet tinsel
#

sorry

#

😦

haughty quartz
#

@velvet tinsel

velvet tinsel
#

errr

#

try without '.py'

haughty quartz
#

okay

velvet tinsel
#

I never really used replit

haughty quartz
#

with '' ?

#

or without

velvet tinsel
#

try ^

haughty quartz
#

okay

#

wont work

warm torrent
#

helllo i have a question

velvet tinsel
#

idk

#

from server ig

velvet tinsel
slim whale
#

i have that

warm torrent
#

i know it may sound dumb but how can I edit a channel ? idk if i must do channel.edit(blablabla) or another thing like await channel.edit. and can you tell me how to do the command becuse i doont understand the "reason" and where to put the channel's id or name to change it with a new name

slate swan
#

How can I check if a user joined in the last 24 hours or not?

valid niche
valid niche
#

!d discord.Member.joined_at

unkempt canyonBOT
#

An aware datetime object that specifies the date and time in UTC that the member joined the guild. If the member left and rejoined the guild, this will be the latest date. In certain cases, this can be None.

slate swan
valid niche
#

!d datetime.timedelta

unkempt canyonBOT
#

class datetime.timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)```
All arguments are optional and default to `0`. Arguments may be integers or floats, and may be positive or negative.

Only *days*, *seconds* and *microseconds* are stored internally. Arguments are converted to those units...
warm torrent
valid niche
#

keyword argument

warm torrent
valid niche
#

await channel.edit(name="hello world")

pliant gulch
unkempt canyonBOT
#

*args and **kwargs

These special parameters allow functions to take arbitrary amounts of positional and keyword arguments. The names args and kwargs are purely convention, and could be named any other valid variable name. The special functionality comes from the single and double asterisks (*). If both are used in a function signature, *args must appear before **kwargs.

Single asterisk
*args will ingest an arbitrary amount of positional arguments, and store it in a tuple. If there are parameters after *args in the parameter list with no default value, they will become required keyword arguments by default.

Double asterisk
**kwargs will ingest an arbitrary amount of keyword arguments, and store it in a dictionary. There can be no additional parameters after **kwargs in the parameter list.

Use cases
Decorators (see !tags decorators)
Inheritance (overriding methods)
Future proofing (in the case of the first two bullet points, if the parameters change, your code won't break)
Flexibility (writing functions that behave like dict() or print())

See !tags positional-keyword for information about positional and keyword arguments

dire folio
#

so i have this:

          try:
                role = 'Staff'
                await client.wait_for("message", check=lambda m: m.channel == ticket_channel and m.content == "!close", timeout=3600)

            except asyncio.TimeoutError:
                    await ticket_channel.delete()

            else:
                    await ticket_channel.delete()

and i want to check if the user who sent the msg has the role Staff how would i do that. lmk if i should post the whole code

slow fog
slate swan
#

How to make a add roles for user by using buttons?

dire folio
cedar stream
#

It’ s all in the docs

slate swan
#

where is the docs? send link please

dire folio
warm torrent
cedar stream
#

Read docs from library ur using

velvet tinsel
#

hi enslo

cedar stream
#

Hi

lapis socket
#
Ignoring exception in command collatz:
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 855, in invoke
    await self.prepare(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 789, in prepare
    await self._parse_arguments(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 697, in _parse_arguments
    transformed = await self.transform(ctx, param)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 542, in transform
    raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: num is a required argument that is missing.``` 
help i tried doing collatz conjecture on a discord bot and this is the error and i understand none of it
slate swan
#

I’m trying to make a bot command where if you ping bot it gives prefix

#

it says num is a required argument that is missing.

late wigeon
#

does anyone know how to use the check parameter with buttons
msg = await client.wait_for('message', check=check)

slate swan
late wigeon
#

interaction = await client.wait_for('button_click', check=check)

#

there

slate swan
#

you can make it check=lambda interaction: interaction.author == ctx.author, although it depends on what library you're using.

late wigeon
slate swan
#

😉

dire folio
#

so i have a category called tickets and i when i do the command $close in a channel, i want that channel to be deleted how would i do that?

manic wing
#

!d discord.TextChannel.delete

unkempt canyonBOT
#

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

Deletes the channel.

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

await ctx.channel.delete()

dire folio
#

how would i check if the channel is in a specific category?

slate swan
#

hi i have a bot that pulls posts from reddit by copying the link into discord and discord auto embeds it. the issue is sometimes the post is not a jpg or png and it doesnt properly embed so is there anyway to identify the link type before it sends?

manic wing
# dire folio yes

!d discord.TextChannel.category || you make a command called close, check if its in the category, and then do await ctx.channel.delete()

unkempt canyonBOT
#

property category: Optional[CategoryChannel]```
The category this channel belongs to.

If there is no category then this is `None`.
manic wing
#

sometimes it has the file ending in the link

slate swan
slate swan
manic wing
#

thats why im asking what the link looks like

slate swan
#

Hes searching for many links so i think he cant specify it

slate swan
manic wing
#

but not all links end with the file suffix

#

a link could just be an object

slate swan
#

ight but thats better then what i have

#

so thanks!

dire folio
dire folio
slate swan
slate swan
#

how can i invoke something in a command so i can have more room for arguments? like
async def globalnote(ctx, member : discord.Member, guild : discord.Guild, note):. it says that certain arguments are required but even if i provide them all it wouldnt work

#

does anyone know what i mean or shall i explain more

sick birch
slate swan
#

Ok so I made a suggest command and here is the main code:

@commands.command(name="Suggest", brief="*Send a suggestion to our suggestions channel to suggest things for bots, channels, events, etc.*")
async def suggest(self, ctx, suggestion):

    embed = discord.Embed(
        title = "Affinitys Advertising New Suggestion",
        description = f"*{suggestion}*",
        color = 0xFF8000,
        timestamp = ctx.message.created_at
    )```

there is more but this is the main 
When I use the command and I use multiple words spaced out it only sends the first word
not the entire sentence
sick birch
#

you would call it like if you were using keyword-arguments

#
def functionName(positionalArgument1, *, keywordArgument1, keywordArgument2, ...):
  # code here
slate swan
#

I dont understand why I would need to do that so manually

sick birch
#

That's just how the library is designed

slate swan
sick birch
#

No, this is how the docs tell you to do it as well

#

Alternative is to keep it like you have right now, and use quotes around multi-word arguments

slate swan
#

where do I put as the ```py

code here```

sick birch
#

such as

!commandName "multi word argument"
sick birch
slate swan
#

so like: ```py
@commands.command(name="Suggest", brief="Send a suggestion to our suggestions channel to suggest things for bots, channels, events, etc.")
def functionName(positionalArgument1, *, keywordArgument1, keywordArgument2, ...):
async def suggest(self, ctx, suggestion):

    embed = discord.Embed(
        title = "Affinitys Advertising New Suggestion",
        description = f"*{suggestion}*",
        color = 0xFF8000,
        timestamp = ctx.message.created_at
    )......```??
#

wait shit

sick birch
#

what i provided was only psuedocode, don't copy and paste it

#

i was only demostrating a concept

slate swan
#

I have to find someone else, this is helpful sorry

sick birch
#

?

slate swan
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

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

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

slate swan
#
@client.event
async def statuschange():
  await client.wait_until_ready()
  while True:
    await client.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name="a song", url="song"))

Why does this not work?

sick birch
#

most likely because statuschange is not a valid event name

final iron
slate swan
sick birch
#

well what errors do you get this time?

slate swan
sick birch
final iron
#

Everything except calling the command will be stored in suggestion

slate swan
#

is there somewhere in the dev portal that I have to enable?

sick birch
sick birch
#

prehaps you didn't mean to have the decorator?

slate swan
#

thank you so much, I will try it

sick birch
#

Also, what's calling the coro?

final iron
#

I also just have no idea what the * is called

valid niche
final iron
#

And if it even has a special name

sick birch
#

i think it actually does

#

can't think of it off the top of my head

sick birch
#

don't use a while True

valid niche
sick birch
#

also, the recommended way to have good status changing is using the tasks extension

#

Set a task for, say, 60 seconds and change it like that

valid niche
#

or just not use some weird status updater because they are often super annoying

sick birch
#

Common mistake i see people making is also setting the presence in on_ready, you shouldn't do that

slate swan
# sick birch can't think of it off the top of my head

I understand the fact that just telling them the answers isnt ok, but what I was asking wasnt spoon feeding. I was wondering how I can get this commmand to work and what I do to make it work and how it makes it work.

valid niche
sick birch
#

similar to channel edits haha

slate swan
#
Command raised an exception: AttributeError: 'NoneType' object has no attribute 'send'```
slate swan
#
  @commands.command(name="Suggest", brief="*Send a suggestion to our suggestions channel to suggest things for bots, channels, events, etc.*")
  async def suggest(self, ctx, *, suggestion):
  
      embed = discord.Embed(
          title = "Affinitys Advertising New Suggestion",
          description = f"*{suggestion}*",
          color = 0xFF8000,
          timestamp = ctx.message.created_at
      )
      embed.set_footer(text=f"Requested by {ctx.message.author} | ID-{ctx.message.author.id}" .format(ctx.message.author, ctx.message.author.id))

      channel = bot.get_channel(911686489782489177)#907446181624447066

      await channel.send(embed=embed)
      await ctx.send("*Suggestion sent to the servers bot suggestion channel.*")```
#

its the *

sick birch
#

Yep, that would consume all the arguments

valid niche
slate swan
sick birch
#

on_presence_update i think

valid niche
#

That’s a type

#

That’s not an event

sick birch
#

I think they want the event when bot detects a status update?

slate swan
valid niche
sick birch
valid niche
sick birch
#

If so, you shouldn't change presence in on_ready

#

^ that is the recommended way

slate swan
#

i have a command that adds notes to users as per guild, how can i use pages to limit it to 10 per page and add an argument for the page like ^notes <user> <page> to prevent bot lag using button reactions? the notes are stored in a txt file by the way

valid niche
final iron
slate swan
valid niche
#

If you add it to the bot constructor, it gets send with the identify payload to discord, which is the intended way

final iron
slate swan
#

how can i start this file ? the \f is annoying

final iron
slate swan
#

How can I do watching and add a link? @valid niche

#

I thought I could just add url=""

#

but doesn't seem so

slate swan
valid niche
unkempt canyonBOT
#

class discord.Activity(**kwargs)```
Represents an activity in Discord.

This could be an activity such as streaming, playing, listening or watching.

For memory optimisation purposes, some activities are offered in slimmed down versions:

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

• [`Streaming`](https://discordpy.readthedocs.io/en/master/api.html#discord.Streaming "discord.Streaming")
final iron
valid niche
#

!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.
slate swan
#

so I remade the suggestion channel, and I forgot to fix the id

final iron
#

Pick either f strings or .format

final iron
#

The code works but it doesn't make sense

slate swan
#

@valid niche

final iron
#

Using them at the same time is useless

slate swan
#

i have a command that adds notes to users as per guild, how can i use pages to limit it to 10 per page and add an argument for the page like ^notes <user> <page> to prevent bot lag using button reactions? the notes are stored in a txt file by the way

valid niche
slate swan
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.

outer violet
#

how would i make this send in dms instead of the channel?

import discord
from discord.ext import commands

from datetime import datetime

attributes = {
   'name': "help",
   'aliases': ["commands"],
   'cooldown': commands.Cooldown(1, 5, commands.BucketType.user)
}

# Unimportant part
class MyHelp(commands.HelpCommand):
    async def send_bot_help(self, mapping):
        channel = self.get_destination()
        embed = discord.Embed(
            title="Bobert Help!",
            description="Welcome to Bobert's official help menu! Bobert is the official utility and moderation bot for test server.\nFor more in depth help and info regarding the use of Bobert, you should contact @outer violet as this command only shows information about commands.\n\n***Use the reactions below to change pages***",
            color=0x2f3136,
            timestamp=datetime.utcnow()
        )
        await channel.send(embed=embed)


class YourCog(commands.Cog):
    def __init__(self, client):
       self.client = client
        
       # Focus here
       # Setting the cog for the help
       help_command = MyHelp(command_attrs=attributes)
       help_command.cog = self # Instance of YourCog class
       client.help_command = help_command


def setup(client):
    client.add_cog(YourCog(client))```
visual island
outer violet
#

ok

maiden fable
#

👀

slate swan
#

I added slash commands to my bot but the commands say "Interaction failed". my code is correct

#

it only happens to commands that dont have a ctx.send

maiden fable
#

Yea it's bound to happen

#

!d discord.InteractionResponse.defer

unkempt canyonBOT
#

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

Defers the interaction response.

This is typically used when the interaction is acknowledged and a secondary action will be done later.
slate swan
#

should I add some type of response? maybe it will fix it from saying the error

maiden fable
#

Use this

slate swan
maiden fable
#

await ctx.response.defer()

slate swan
#

what does it do exactly?

maiden fable
#

Do you know that some bots do the thinking reply?

maiden fable
#

That's what it does

slate swan
#

my bot is doing that, then responds with the Interaction Failed

#

So I can just add await ctx.response.defer() ?

#

AttributeError: 'SlashContext' object has no attribute 'response'

maiden fable
#

Huh?

#

Can I see some code?

#

Which library u using?

slate swan
#

discord-py-slash-command

#

3.0.1

maiden fable
#

Ah don't use that one

slate swan
#

Why?

maiden fable
#

Idk I never used it but people say that it's broken and doesn't work properly

slate swan
#

which is better?

maiden fable
#

!pypi disnake u can use this. It's a dpy fork with slash commands and buttons too

unkempt canyonBOT
slate swan
maiden fable
#

Sure

slate swan
#

how do I use slash commands with it?

maiden fable
#

You just need to change your imports to disnake

maiden fable
#

Like change import discord to import disnake and stuff

slate swan
#

only once though right?

maiden fable
#

Well you need to change every import

#

Since u r gonna change libraries

slate swan
#

else how am I gonna import datetime, os etc

maiden fable
#

Ah u will be able to do those like u r doing those rn

slate swan
#

so i only change the import discord?

maiden fable
#

Yea

slate swan
#

so I completly remove my import discord?

maiden fable
#

And also imports like from discord.ext import commands to from disnake.ext import commands

slate swan
#

from discord.ext import commands

#

to?

maiden fable
#

from disnake.ext

slate swan
#

how do I use slash commands

#

and also will em = discord.Embed turn into disnake.Embed

maiden fable
#

There are examples (:

maiden fable
#

But if u r using VSCode, just search discord and right click and then select change all occurrences

slate swan
#

can u send an example

maiden fable
#

?

slate swan
#

of the slash commands

slate swan
#

which

maiden fable
#

Those are different types of slash command

slate swan
#

I just need regular ones

maiden fable
#

One is with autocomplete, other with options

slate swan
#

difference?

maiden fable
#

Kk lemme share

slate swan
#

basically all I do is change the .command to client.slash_command()

maiden fable
slate swan
#

?

#

does disnake not have voice_client ?

#

@maiden fable

maiden fable
#

You mean VoiceClient?

slate swan
#

discord voice client

maiden fable
#

Ah

#

It has that, why

slate swan
#

AttributeError: 'ApplicationCommandInteraction' object has no attribute 'voice_client'

maiden fable
#

Ah

#

Show code

slate swan
#

well it's only happening for my commands that are in cog

maiden fable
#

Okay... Can I see code

#

Seems like it's a slash command or something

slate swan
#

!code

#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

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

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

sick birch
# slate swan what does it do exactly?

If you still need to know, it basically tells Discord's servers, "Hey, I received the interaction, I'm not gonna do anything just yet, but just know that I got your request"

#

I.e a fake response

#

It comes in handy when you want to do the *_original_message functions

slate swan
#

can you help me with something

sick birch
#

To the best of my ability, I'd be glad to 😄

slate swan
#

can we go to dms

sick birch
#

Sorry but I don't do dm help

slate swan
#

oh

sick birch
#

You can ask here and I'll help, others will be able to chime is as well

slate swan
#

Command raised an exception: AttributeError: 'NoneType' object has no attribute 'channel'

#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

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

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

sick birch
#

The guild ID is probably incorrect, though I'd need to see your code to properly diagnose the issue

#

Ohh, that happens when the author isn't in a voice channel

slate swan
#

the bot does return "You're not in a voice channel"

sick birch
#

It does both at the same time?

slate swan
#

wait no

sick birch
#

Makes sense, it doesn't care if you're in a voice channel or not when it tries to find the channel

#

You should add an else after the first if, and move the voice_channel variable into it

slate swan
#

it only does "You're not in a voice channel!" when I try running the command without being in a voice channel

#

and it says "Successfully joined the voice channel!" When I am in a voice channel

#

does not do them both at the same time

#

how do I make it so the error does not occur in the Console

slate swan
#

it does everything correctly

#

Im asking how I can make it so the error Command raised an exception: AttributeError: 'NoneType' object has no attribute 'channel'
does not happen in the Console

sick birch
#

Can you post the full traceback? Maybe it's happening somewhere else

#

So its only where i thought it was

slate swan
#

So?

sick birch
#

When exactly does the error happen again?

slate swan
#

when I do /join but am not in a voice channel

visual island
#

return await ctx.send("You're not in a voice channel!")

slate swan
#

this command is inside of a cog btw

slate swan
visual island
slate swan
#

ok let me try that

#

should I add return to await ctx.send("Successfully joined the voice channel! ✅")

#

aswell?

visual island
#

it's the end of the code so no need

slate swan
#

oh alright.

#

thanks, it worked! happy

visual island
#

yes

#

but I wont help you here

#

!ytdl

unkempt canyonBOT
#

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

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

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

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

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

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
slate swan
#
@bot.command(aliases=['latency', 'ping', 'ram', 'cpu', 'hostinfo'])
async def state(ctx):
#hidden important stuff
    if CPU_usage < 50:
        cpuu = "![CPU](https://cdn.discordapp.com/emojis/911735199073722408.webp?size=128 "CPU")"
    elif 50 < CPU_usage < 75:
        cpuu = "![CPU](https://cdn.discordapp.com/emojis/911745867634081812.webp?size=128 "CPU")"
    elif 75 < CPU_usage:
        cpuu = "![CPU](https://cdn.discordapp.com/emojis/911785584119402518.webp?size=128 "CPU")"

    if RAM_usage < 50:
        ramu = "![RAM](https://cdn.discordapp.com/emojis/911735199577034782.webp?size=128 "RAM")"
    elif 50 < RAM_usage < 75:
        ramu = "![RAM](https://cdn.discordapp.com/emojis/911760707291328523.webp?size=128 "RAM")"
    elif 75 < RAM_usage:
        ramu = "![RAM](https://cdn.discordapp.com/emojis/911781348270804993.webp?size=128 "RAM")"

    if ping < 75:
        ms = "![ping](https://cdn.discordapp.com/emojis/911735199073718313.webp?size=128 "ping")"
    elif 75 < ping < 180:
        ms = "![ping](https://cdn.discordapp.com/emojis/911773743465005106.webp?size=128 "ping")"
    elif 180 < ping:
        ms = "![ping](https://cdn.discordapp.com/emojis/911781362695020575.webp?size=128 "ping")"

    embed = discord.Embed(title = 'Status', description = f'{cpuu} {CPU_usage}%\n{ramu} {RAM_usage}%\n{ms} {ping}ms', color = 0x2f3136)
    embed.set_author(name=f'{bot.user.name}#{bot.user.discriminator}', icon_url=bot.user.display_avatar)
    await ctx.send(embed=embed)```
error:`discord.ext.commands.errors.CommandInvokeError: Command raised an exception: UnboundLocalError: local variable 'ramu' referenced before assignment`. ive defined ram_usage, ping, and cpu_usage as the proper objects (refuse to show due to larps and skids). i dont know why the command fails, could someone help?
#

the command works sometimes, then sometimes it doesnt

#

i think its an error with the values ive provided in the intervals

#

    if RAM_usage < 50:
        ramu = ":RAM:"
    elif 50 < RAM_usage < 75:
        ramu = ":RAM:"
    elif 75 < RAM_usage:
        ramu = ":RAM:"``` any of these conditions is not fulfilled
#

it's happens when your ram is accurately 75

slate swan
#

elif 50 < ram_usage < 75 or ram_usage = 75?

#

ram_usage <= 75

#

i see, thanks

cobalt jacinth
#

should i be worried about my bots future since discord.py is abandoned ? any advice ?

sullen shoal
#

use forks

#

like disnake

cobalt jacinth
#

i just need to import one of the fork instead of discord.py ? or needs to change the syntex as well

sullen shoal
#

idk about others, but if you use disnake, you just gotta replace discord. to disnake.

#

i heard pycord changed the path of Bot subclass, so you might have a hard time with that one

cobalt jacinth
#

okay..my bot has about 4k lines and i was worried about discord.py

sullen shoal
#

forks are pretty good, shouldn't be something to be worried about

#

if you want something entirely new with new syntax, you could try hikari

cobalt jacinth
#

so disnake you recommand ?

sullen shoal
#

yes

digital sonnet
#

Can I connect a website to other websites and then put a command my bot?

sullen shoal
#

they also have a version, where you dont even have to change your code

cobalt jacinth
#

i want to spend least time on changing code i have

sullen shoal
digital sonnet
maiden fable
sullen shoal
#

however its not recommended to do that

sullen shoal
digital sonnet
#

Ok

pliant gulch
slate swan
cobalt jacinth
#

great..my browser history had started filling up with js guides😅

sullen shoal
#

disnake[shim]

pliant gulch
#

Ah

#

I remember seeing disnake in their FAQ that you should uninstall discord.py

#

Was wondering the reason for that

sullen shoal
#

maybe they were talking about that one

#

if you use that version, you dont have to replace anything in your code

#

but idk if its updated that often

pliant gulch
#

Still wouldn't explain why you would need to uninstall discord.py to use disnake

sullen shoal
#

you dont need to uninstall it if you use the normal branch

pliant gulch
#

So are you saying that if you use a different branch you need to uninstall discord.py?

sullen shoal
pliant gulch
#

????

#

🤔

sullen shoal
#

the shim branch will replace the original discord.py files, its better to delete it

pliant gulch
sullen shoal
#

it can :/

pliant gulch
#

In python you have you packages folder, and those are separated

cobalt jacinth
#
class one(commands.Cog):
   """Cog description"""

    @commands.command()
    async def earth(self, ctx):
        """Command description"""
        await ctx.send("Pong!")
class two(commands.Cog):
   """Cog description"""
    @commands.command()
    async def mars(self, ctx):
        """Command description"""
        await ctx.send("Pong!")

bot = commands.Bot(command_prefix="!")
bot.add_cog(one())
bot.add_cog(two())
bot.run('token')
pliant gulch
#

I'm unsure how the disnake library would override those files in a different folder...

cobalt jacinth
#

is this the correct format for cogs

sullen shoal
#

there are extensions for disnake

spring flax
brave flint
#

umm how to make this work

sullen shoal
#

if you pip installl them

brave flint
#

i want make like if ?help show main help embeds cuz i have another classes of cmd

pliant gulch
#

Unless I'm looking at the wrong repo

sullen shoal
#

they move it to the original ext folder of the library

cobalt jacinth
pliant gulch
spring flax
sullen shoal
sullen shoal
pliant gulch
#

Give me a second

cobalt jacinth
spring flax
sullen shoal
#

one sec i have to check if its available or not

pliant gulch
#

Isn't that how you install optional stuff on pip??

cobalt jacinth
pliant gulch
#

And I just went off of what you sent

cobalt jacinth
pliant gulch
#

I cannot install from a repo branch as one literally doesn't exist..

brave flint
#

maybe its work

pliant gulch
brave flint
pliant gulch
#

So how would installing from the repo url do what I want

keen quartz
#

hi

sullen shoal
#

idk if it still exists or not, its been a while i chcked

pliant gulch
#

I don't get what you mean

pliant gulch
brave flint
sullen shoal
pliant gulch
#

And did your discord.py exts folder get overwritten

sullen shoal
#

theres no otherway it could work

#

it must be overriden

spring flax
pliant gulch
cobalt jacinth
#

i thought it should be easy to make catergory for my help commands

sullen shoal
pliant gulch
# pliant gulch And why is that

These are two separate packages, one is a fork of the other so the fork has literally all the methods and classes of the other one. You don't need to overwrite the old package in order to use the new one, because the fork literally has all the implementations

brave flint
pliant gulch
#

Lmao... I even mentioned early python packages get their own folders so that makes no sense either way

sullen shoal
pliant gulch
spring flax
sullen shoal
#

if you install it, you dont have to replace discord to disnake, instead the entire package is named discord so no need to change imports

pliant gulch
#

Lol???

sullen shoal
#

and how would you use both of them ?

slate swan
#

How can I use slash commands for a client.group using disnake?

pliant gulch
sullen shoal
pliant gulch
#

I'm not saying it doesn't allow you to use disnake without changing imports, but what I'm saying is that it DOESN'T CHANGE DISCORD.PY FILES

#

!e ```py
import sys; sys.modules["math"] = import("random")

unkempt canyonBOT
#

@pliant gulch :warning: Your eval job has completed with return code 0.

[No output]
sullen shoal
#

you gotta keep one

#

unless there are some weird workarounds im unknown of

cobalt jacinth
brave flint
cobalt jacinth
sullen shoal
spring flax
cobalt jacinth
slate swan
#

How can I use slash commands for a client.group using disnake?

brave flint
sullen shoal
spring flax
#

i think

slate swan
#

yes

upbeat otter
pliant gulch
spring flax
cobalt jacinth
#

ok i dont need cogs...i will make my own help command😂 ..thanks for guiding me to the right path

sullen shoal
#

also what is original

pliant gulch
spring flax
#

wrong ping sorry

pliant gulch
#

And yes obv you have to do that if you want to use them both, cause obv from what you said the shim ext overwrites the import...

#

If you are that lazy to not want to change imports then I'm sure that wouldn't be a big deal to use both

sullen shoal
#

but isn't the original also named discord

#

or original is some special prefix or smth

pliant gulch
#

🤔

slate swan
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

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

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

sullen shoal
#

in your file or some other files in the package folder

slate swan
slate swan
slate swan
#

the backticks

upbeat otter
slate swan
#

Just .bm it and why mobile has it and so does desktop

graceful mulch
#

whats eval

sullen shoal
#

evaluate

upbeat otter
pliant gulch
slate swan
#

Must be a simple block*

graceful mulch
#

ok

sullen shoal
graceful mulch
#

but how you all manage to keep track like so many messages per second

slate swan
#

If its a complicated code block use

exec(a)
upbeat otter
pliant gulch
graceful mulch
pliant gulch
#

I don't really care about that, I just don't see the reason why discord.py needs to be uninstalled when using disnake

#

I don't even know why it says that in the FAQ either

slate swan
upbeat otter
slate swan
graceful mulch
#

Hello I dont know Why isn't it working
py await client.change_presence( activity=discord.Activity( type=discord.ActivityType.watching, name= str(len(client.guilds))+ sum(1 for g in client.guilds for _ in g.channels), ) )

slate swan
#

Wait nvm

upbeat otter
slate swan
sullen shoal
upbeat otter
pliant gulch
graceful mulch
#

cany ou give example

upbeat otter
sullen shoal
pliant gulch
#

It will say somewhere to uninstall discord.py before installing

upbeat otter
# graceful mulch ??
commands.Bot(command_prefix=prefixes, intents=discord.Intents.all(), help_command=None, activity=discord.Activity(type=discord.ActivityType.listening, name=".help"))
#

like this ^

upbeat otter
maiden fable
#

O

#

Ok so I wanna know something

graceful mulch
#

and client is coming undefined

maiden fable
#

What's the meaning of

class Btn(discord.ui.Button["Btn"]):
    pass
upbeat otter
graceful mulch
upbeat otter
graceful mulch
#

which is undefined

maiden fable
unkempt canyonBOT
#

property guilds: List[discord.guild.Guild]```
The guilds that the connected client is a member of.
upbeat otter
graceful mulch
upbeat otter
graceful mulch
# upbeat otter code
client = commands.Bot(
    command_prefix= (get_prefix),activity=discord.Activity(type=discord.ActivityType.listening, name=str(len(client.guilds)))
maiden fable
#

Eevee do you know

upbeat otter
maiden fable
#

U need to do

client = commands.Bot(...) 
client.activity=... 

In a separate line

graceful mulch
#

e.listening, name=str(len(client.guilds))))
NameError: name 'client' is not defined

upbeat otter
#

what do I know...

maiden fable
#

didn't I just tell u the answer

upbeat otter
graceful mulch
maiden fable
maiden fable
#

@graceful mulch dude I just told u the answer

upbeat otter
#

^

maiden fable
#

Imagine ignoring 😐

#

Welp, time to KMS ;-;

maiden fable
upbeat otter
#

@maiden fable closing Curly Bracket when?

maiden fable
maiden fable
pliant gulch
#

Although I don't get the use for it in with commands.Bot

#
import typing


T = typing.TypeVar("T")


class A(typing.Generic[T]):
    values: typing.List[T] = []

    def set(self, *value: T) -> None:
        self.values.extend(value)

    def get(self) -> typing.List[T]:
        return self.values


a = A[int]()
a.set(1, 2, 3, 4, 5)
#

quick lil example

shadow wraith
#

looks like javascript

#

you can def see why

graceful mulch
vale wing
#

Wtf generics in python 9839megaflushed

#

Didn't even know they exist here

chilly current
#

uhmm hello?

vocal plover
maiden fable
#

Eevee be flexing nitro

vocal plover
maiden fable
#

Wait discord broke. Before it showed that the lemon emoji was from a private server yert

#

Breh I hate it when that happens. Discord Beta lemon_sweat

boreal ravine
#

😨

maiden fable
#

O

boreal ravine
#

😨

maiden fable
#

?

spring flax
#

this code:
py embed = disnake.Embed(description=f"{member.mention} {str(member)}") embed.set_thumbnail(url=member.avatar.url) embed.set_footer(text=f"{member.id} | {embed.timestamp}") await channel.send(embed=embed)
Gives

maiden fable
#

Mhm

spring flax
#

can i make the space less? i.e make the thumbnail smaller

maiden fable
#

Sure, but for that u will need to do some hackery

#

There's a size param

#

I think that should work

#

See

#

When editing the size, the image will resize. That should work

slate swan
#

From 16 to 4096, only powers of 2 are valid

maiden fable
#

Idts, it's 100 rn and it resized

slate swan
#

The returned size can be changed by appending a querystring of ?size=desired_size to the URL. Image size can be any power of two between 16 and 4096.

maiden fable
#

Weird, then how does 100 work 🤨

slate swan
#

It doesn't resize to 100x100

maiden fable
#

O

livid crane
#

Is it possible to change a guild's system channel through code?

maiden fable
#

No

livid crane
#

Huh.. ok. Thanks. But, how do some bots do it? Give you an option as to where you want to send member join / leave notifications?

sullen shoal
#

does the bot notify

unkempt canyonBOT
#

discord.on_member_join(member)``````py

discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") leaves or joins a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").

This requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
sullen shoal
#

or discord?

livid crane
#

I thought about that, but not in the way I should have to see that's the answer. Thank you

pliant gulch
sullen shoal
# pliant gulch “But don't forget to remove discord.py”

oh yeah, didn't notice, its not needed but disnake can do everything discord.py 2.0 can so it doesn't really matter but you could keep both of them if you want, maybe they included that because while modifying their code they might forget to replace some imports and complain something aint working and shit so yeah

spring flax
#

@maiden fable also in the image i sent why does embed.empty come in footer?

maiden fable
spring flax
#

oh the timestamp

#

whoops

maiden fable
#

And the default value is Embed.Empty

spring flax
#

i should have just done message.created_at

maiden fable
#

Lol

graceful mulch
#

Bye

spring flax
#

if i have a list of role ID's what's the best way to check if a member has any one of these roles? role_array_list = ["something", "something", "something","something", "something", "something"]

sullen shoal
#

iterate through it and use in keyword

#

you use any

maiden fable
sullen shoal
#

!d any

unkempt canyonBOT
#
any

any(iterable)```
Return `True` if any element of the *iterable* is true. If the iterable is empty, return `False`. Equivalent to:

```py
def any(iterable):
    for element in iterable:
        if element:
            return True
    return False
maiden fable
#

!d any

unkempt canyonBOT
#
any

any(iterable)```
Return `True` if any element of the *iterable* is true. If the iterable is empty, return `False`. Equivalent to:

```py
def any(iterable):
    for element in iterable:
        if element:
            return True
    return False
maiden fable
#

;-; Why

sullen shoal
#

lol

#

use generator expression with it

#

!e

print(any(i for i in (0,1,0)))```
unkempt canyonBOT
#

@sullen shoal :white_check_mark: Your eval job has completed with return code 0.

True
spring flax
slate swan
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

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

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

maiden fable
#

I would love to add that but I won't be surprised if the people in disnake server term this thing as "useless" 🤷‍♂️

pliant gulch
maiden fable
sullen shoal
#

yeah ik i realised it later

spring flax
#

ah

#

thank you andy

pliant gulch
#

👍

slate swan
#

Anyone here familiar with disnake?

spring flax
#

you want slash commands for command groups?

boreal ravine
spring flax
maiden fable
#

Walrus operator

spring flax
#

what's that never heard of it

pliant gulch