#discord-bots

1 messages · Page 782 of 1

sonic flax
#
import discord
import requests
import json
from discord.ext import commands


prefix = "#"
bot = commands.Bot(command_prefix = prefix)
client = commands.Bot(command_prefix = 'prefix')
bot.remove_command('help')
latency = (client.latency)

TOKEN = ('*')
hpkey = ("*")
key = ("*")

@bot.event
async def on_ready():
    print('The bot has been turned on')
    await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="Dewier > You"))

@bot.command(pass_context = True)
async def alts(ctx, username):
    altApi = requests.get(f"http://api.antisniper.net/altfinder?key={key}&name={username}")
    hpApi = requests.get(f"https://api.hypixel.net/player?key={hpkey}&name={username}")

    altjson = altApi.json()
    hpjson = hpApi.json()

    if hpjson['player'] is None:
        embed = discord.Embed(title=".", description=(f"Player does not exist!"), color=(0xF85252))
        ctx.send(embed=embed)
    else:
        for alt in altjson['results']:
            embed = discord.Embed(title = ".", description = (f"(alt{'ign'})"), color = (0xF85252))
            ctx.send(embed = embed)

bot.run("TOKEN")```
#

i get Traceback (most recent call last):
File "main.py", line 38, in <module>
bot.run("TOKEN")
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 723, in run
return future.result()
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 702, in runner
await self.start(args, **kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 665, in start
await self.login(args, bot=bot)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 511, in login
await self.http.static_login(token.strip(), bot=bot)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 304, in static_login
raise LoginFailure('Improper token has been passed.') from exc
discord.errors.LoginFailure: Improper token has been passed.

maiden fable
#

the token is wrong...

slate swan
#

so someone can help me to make the check command for a premium user with a db

#

And why in the world does it have 2 bot instances

maiden fable
#

Sure

sonic flax
maiden fable
#

Bruh

sonic flax
shadow wraith
#

bruh how is "TOKEN" a token

maiden fable
#

Then u can fix the error for yourself

shadow wraith
#

2 bot instances? 💀 why is everything messed up

sonic flax
#

how would i fix it

hearty sierra
#

ive only transferred the script, it worked perfectly fine on my pc (with the same python version) plz help :(

slate swan
#

The database saves the user with this format

maiden fable
#

code @hearty sierra

maiden fable
slate swan
#

yea

shadow wraith
#

i know this may be off-topic but i got a cool custom cursor chrome extension

slate swan
#

I want to add some premium commands

#

But idk how can i check if a user is premium

maiden fable
#

!d discord.ext.commands.check

unkempt canyonBOT
#

@discord.ext.commands.check(predicate)```
A decorator that adds a check to the [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") or its subclasses. These checks could be accessed via [`Command.checks`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command.checks "discord.ext.commands.Command.checks").

These checks should be predicates that take in a single parameter taking a [`Context`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context"). If the check returns a `False`-like value then during invocation a [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure") exception is raised and sent to the [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") event.

If an exception should be thrown in the predicate then it should be a subclass of [`CommandError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError"). Any exception not subclassed from it will be propagated while those subclassed will be sent to [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error").
shadow wraith
maiden fable
#

Imagine fake nitro

shadow wraith
#

Imagine fake robux 😭

velvet tinsel
#

nice

slate swan
#

I mean the user has access to this command and the others don't

maiden fable
slate swan
unkempt canyonBOT
#

Hey @hearty sierra!

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

maiden fable
#

It returns either True or False. If it returns True, then the user can use it, else no

shadow wraith
maiden fable
#

!d discord.ext.commands.Cog.cog_check is also there

unkempt canyonBOT
#

cog_check(ctx)```
A special method that registers as a [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") for every command and subcommand in this cog.

This function **can** be a coroutine and must take a sole parameter, `ctx`, to represent the [`Context`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context").
shadow wraith
#

and then @commands.check(acheck) i think

maiden fable
#

Yea

shadow wraith
#

or commands.Cog.cog_check for if u i na cog

sonic flax
slate swan
#

all the answers are in the channel

maiden fable
#

I just told u the way

proven ore
#

!d discord.Embed.fields

unkempt canyonBOT
#

property fields: List[_EmbedFieldProxy]```
Returns a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of `EmbedProxy` denoting the field contents.

See [`add_field()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.add_field "discord.Embed.add_field") for possible values you can access.

If the attribute has no value then [`Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty") is returned.
proven ore
#

which field exatly

grand shell
#
selectMenu = Select(custom_id=servID, min_values=len(tagsToAdd), max_values=len(tagsToAdd), placeholder=f"you must select {5 - len(ogTags)} more tags")
            for tag in tagsToAdd:
                selectMenu.add_option(label=tag, value=tag)
            selectMenu.callback = self.submit_tags
            view.add_item(selectMenu)
            embed = discord.Embed (title = "Select the Five Tags That Describe Your Ad The Best!",colour=embedColor)
            print(view.children[0].callback)
            await interaction.response.edit_message(embed=embed, view=view)

hey guys, i have this code which works perfectly except the callback on the selectmenu just doesnt work. it prints out the correct method here but when I try it, discord says "interaction has failed". does anyone know what might be causing it?

proud rain
#

Someone who know how to do so only one id can use a command?

shadow wraith
proud rain
#

yes, but how

#

what is the code for that, cant i search it up?

shadow wraith
#

if ur new to python

proud rain
#

i made it in a year now, but other stuff in python im new to

shadow wraith
#

anyways bad timing but i gtg 😭 cya later, just make a function which does return ctx.author == id

#

!d discord.ext.commands.check

unkempt canyonBOT
#

@discord.ext.commands.check(predicate)```
A decorator that adds a check to the [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") or its subclasses. These checks could be accessed via [`Command.checks`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command.checks "discord.ext.commands.Command.checks").

These checks should be predicates that take in a single parameter taking a [`Context`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context"). If the check returns a `False`-like value then during invocation a [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure") exception is raised and sent to the [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") event.

If an exception should be thrown in the predicate then it should be a subclass of [`CommandError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError"). Any exception not subclassed from it will be propagated while those subclassed will be sent to [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error").
proud rain
#

thanks bro

tacit horizon
#

how to get message.content for dm

slate swan
#

elaborate

tacit horizon
#

like if i dm the bot, how to get that message

slate swan
tacit horizon
#

is there anything like async def on_DM(message):

slate swan
#

just check the type of the channel

#

!d discord.ChannelType.private

unkempt canyonBOT
tacit horizon
#

oh

#

works nice

honest vessel
#

u check if it is prem

#

n keep check - if not remove n kick?

#

i dunno

#

i know u try bust fake supporters, whoo boost n swap

#

keep checking em?

#

each promo goes db, check db

tacit horizon
#

;-;

honest vessel
#

independed from cancle

slate swan
#

who are you talking to

honest vessel
#

@slate swandarth wader ur father

slate swan
#

and what are you talking about 😭

honest vessel
#

who else

slate swan
honest vessel
#

hans solo

slate swan
#

it cant be😰

honest vessel
#

when was u born

#

yesterday?

slate swan
honest vessel
#

cannot be cause thats booked

#

whole day

marsh kestrel
#

python good for coding discord bots?

honest vessel
#

3 days ago, fuck u mature now then

slate swan
#

aka my bday was 3 days ago

slate swan
honest vessel
tacit horizon
#

omg this chat

slate swan
#

it is

vocal snow
honest vessel
#

its the worst community - u ask for help n they all try pull em self up for easy task

slate swan
vocal snow
#

heloo

marsh kestrel
# slate swan yes

okay thanks im trying to learn python and i wanna make a discord bot for fun as i wanna be a programmer as my career

honest vessel
#

its good communnity just ignore those with anime pfp

slate swan
#

you cant judge a community by personal experiences

slate swan
honest vessel
#

funny or correct? thats up to the judges aint it

slate swan
#

ignore andy then

honest vessel
#

anime andy -ignored amen

slate swan
marsh kestrel
#

why argue in this channel lmao..

honest vessel
#

how to babysit u?

marsh kestrel
#

okimii you seem nice :)

slate swan
honest vessel
keen talon
slate swan
#

thank you guyspithink

marsh kestrel
honest vessel
#

i dont have 4 acounts n

honest vessel
#

etc so prob not

slate swan
#

see people love me even if i have an anime pfppithink

marsh kestrel
#

pfps dont matter at all lmao

honest vessel
#

its ur alts 😄

slate swan
marsh kestrel
slate swan
#

didnt your mom said not to judge someone by appearance pithink

keen talon
slate swan
keen talon
slate swan
#

exactly its called manors pithink

sonic flax
#
import discord
import requests
import json
from discord.ext import commands


prefix = "#"
bot = commands.Bot(command_prefix = prefix)
client = commands.Bot(command_prefix = 'prefix')
bot.remove_command('help')
latency = (client.latency)

hpkey = ("*")
key = ("*")

(@bot.event
async def on_ready():
    print('The bot has been turned on')
    await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="Dewier"))

@bot.command(pass_context = True)
async def alts(ctx, username):
    altApi = requests.get(f"http://api.antisniper.net/altfinder?key={key}&name={username}")
    hpApi = requests.get(f"https://api.hypixel.net/player?key={hpkey}&name={username}")

    altjson = altApi.json()
    hpjson = hpApi.json()

    if hpjson['player'] is None:
        embed = discord.Embed(title=".", description=(f"Player does not exist!"), color=(0xF85252))
        await ctx.send(embed=embed)
    else:
        for alt in altjson['results']:
            embed = discord.Embed(title = ".", description = (f"(alt{'ign'})"), color = (0xF85252)))
            await ctx.send(embed = embed)

bot.run("*")```
I want my code to put all of the stuff into 1 message instead of making like 40 messages with each value, how would i do that
slate swan
#

use aiohttp

#

!pypi aiohttp

unkempt canyonBOT
slate swan
#

or httpx

unkempt canyonBOT
keen talon
slate swan
#

not that typo

#

!pypi httpx

unkempt canyonBOT
slate swan
#

^

#

is good aswell

#

and dont change presence on ready use the kwargs in the bot constructor

#

and remove the help command in the constructor and no need for the pass context kwarg since it will always be True

slate swan
#

delete one

#

and use the kwargs i said in

#

!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.
uncut zephyr
#

Hey Guys, how can I pin a message which was send inside my own function?

#

The error is

AttributeError: '_asyncio.Task' object has no attribute 'pin'

#

it works normal with "on_message"

#

Pls ping me if you have any idea or question. I cant figure this out :/

oblique cobalt
uncut zephyr
#

And I also changed it to

def test():
  (create a embed)
  x = client.loop.create_task(client.mchannel.send(embed=embedwinner))
  x.pin() #?
  here I want to pin this embed

But the "pin()" function only works with "await"

oblique cobalt
#

await it then ?

#

or loop.create_task that if u cant

uncut zephyr
#

I cant. Wait I try it and send you the code

uncut zephyr
final iron
oblique cobalt
#

what is problem ?

uncut zephyr
final iron
#

No

uncut zephyr
#

lol

final iron
#

!d discord.ext.tasks.loop

unkempt canyonBOT
#

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

Check out some examples

uncut zephyr
final iron
#

Scroll up

#

It shows some examples on how to create a task

dry kelp
#
        if whitelisted[str(ctx.guild.id)] is None:
            em = discord.Embed(title=":err: Whitelisted Error!", description=f"Nothing was found for this guild!", color=discord.Color.red())
            await ctx.reply(embed=embed, mention_author=False)
            return 
``` why is this not checking if the guild id data is none?
#
    @commands.command(aliases = ['wld'], hidden=True)
    @commands.has_permissions(administrator=True)
    @commands.bot_has_permissions(embed_links=True)
    async def whitelisted(self, ctx):

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

        if not str(ctx.guild.id) in whitelisted:
            em = discord.Embed(title=":err: Whitelisted Error!", description=f"Turn on the antinuke first!", color=discord.Color.red())
            await ctx.reply(embed=em, mention_author=False)
            return

        embed = discord.Embed(title=f":security: __TRUSTED MEMBERS__ :security:", description="", color=discord.Color.from_rgb(black1, black2, black3))

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

        if whitelisted[str(ctx.guild.id)] is None:
            em = discord.Embed(title=":err: Whitelisted Error!", description=f"Nothing was found for this guild!", color=discord.Color.red())
            await ctx.reply(embed=embed, mention_author=False)
            return 

        try:
            for u in whitelisted[str(ctx.guild.id)]:
                embed.description += f"<@{(u)}> - {u}\n"
            await ctx.reply(embed=embed, mention_author=False)
        except:
            em = discord.Embed(title=":err: Whitelisted Error!", description=f"Too many trusted members! Please remove some!", color=discord.Color.red())
            await ctx.reply(embed=embed, mention_author=False)
            return
uncut zephyr
final iron
uncut zephyr
#

okay

slate swan
#

I wanna make the Embed Color in Purple but its always grey I use the Hexadecimal color code color=0x965bbd that should be purple please lmk if you know how i can make it purple

slate swan
#

nvm

#

wait

dire folio
#

I would guess they want that colour

#

Like the hexadecimal one

slate swan
dire folio
#

Wait no

slate swan
#

okimii god here

#

doesnt matter if its color or colour

#

there aliases

proven ore
slate swan
#

and just use discordheximals pithink

#

Okimii if you may

#

!pypi discordheximals

unkempt canyonBOT
slate swan
proven ore
#

or u can use from_rgb()

slate swan
#

I was writing hexadecimals lmfao

dire folio
#

The colour worked for me

slate swan
#

there aliases doesnt matter

dire folio
#

I meant the colour on the embed

slate swan
#

hes probably not adding the kwarg in the constructor

#

or doing something wrong

slate swan
final iron
slate swan
#

use db not json and to have good file structure you must know dpy

velvet tinsel
slate swan
#

or more complicated

velvet tinsel
slate swan
#

which people with experience dont make commands in their bot file and they subclass Bot class

#

and what was that

slate swan
#

most people add commands in their bot file and then have catogories in cog files

#

which people with experience wont add any command inside the bot file so it will just be the bot subclass and you run the bot in another file

#

not really important but i cant help you with that

#

basic oop async programming thats all you need

#

correct

#

like i do

#

not quite

#

you just run the subclass since the class inherits everything from the parent class

#

no need

#

a subclass is a new class which inherites everything from the parent class

vocal snow
#

inti

unkempt canyonBOT
#

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

001 | Traceback (most recent call last):
002 |   File "<string>", line 9, in <module>
003 |   File "<string>", line 7, in __init__
004 | AttributeError: 'B' object has no attribute 'x'
vocal snow
#

💀

olive torrent
#

u never called the super.init

slate swan
#
from​ ​disnake​.​ext​ ​import​ ​commands 
 ​from​ ​disnake​.​ext​.​commands​ ​import​ ​Bot 
 ​from​ ​disnake​ ​import​ ( 
 ​    ​Embed​, 
 ​    ​Intents​, 
 ​    ​Game​, 
 ​    ​Status 
 ​    ) 
  
 ​import​ ​os 
 ​from​ ​datetime​ ​import​ ​datetime 
  
 ​class​ ​botname(​Bot​): 
 ​    ​def​ ​__init__​(​self​) ​->​ ​None​: 
 ​        ​super​().​__init__​( 
 ​            ​command_prefix​=​commands​.​when_mentioned_or​(​"ad!"​), 
 ​            ​intents​ ​=​ ​Intents​.​all​(), 
 ​            ​help_command​=​None​, 
 ​            ​case_insensitive​=​True​, 
 ​            ​status​=​Status​.​online​, 
 ​            ​activity​=​Game​(​f"!help"​) 
 ​        ) 
 ​             
 ​    ​def​ ​setup​(​self​) ​->​ ​None​: 
 ​        ​for​ ​filename​ ​in​ ​os​.​listdir​(​"./cogs"​): 
 ​            ​if​ ​filename​.​endswith​(​"py"​): 
 ​                ​self​.​load_extension​(​f"cogs.​{​filename​[:​-​3​]​}​"​) 
 ​             
 ​    ​def​ ​run​(​self​) ​->​ ​None​: 
 ​        ​self​.​setup​() 
 ​        ​super​().​run​(​os​.​environ​[​'DISCORD_BOT'​] 
 ​            , 
 ​            ​reconnect​=​True 
 ​            ) 
  
 ​    ​async​ ​def​ ​on_ready​(​self​) ​->​ ​None​: 
 ​        ​print​(​"bot  is online"​) 
  
 ​    ​async​ ​def​ ​on_command_error​( 
 ​        ​self​, 
 ​        ​ctx​, 
 ​        ​error 
 ​        ) ​->​ ​None​: 
 ​        ​embed​ ​=​ ​Embed​( 
 ​            ​title​=​"Command Error"​, 
 ​            ​description​=​f"{​error​}​"​, 
 ​            ​color​=​0x00FFFF​, 
 ​            ​timestamp​=​datetime​.​utcnow​() 
 ​            ) 
 ​        ​await​ ​ctx​.​send​(​embed​=​embed)
#

basic subclass

olive torrent
#

oh idk i just popped in just now

slate swan
#

not sure wdym

olive torrent
#

well it does inherit the methods, but init was overwrote when u declared init for the subclass

slate swan
#

ah you ment by the super lol

#

i thought of something else sorry

#

but yes you are correct

#

no no

tardy plume
#

how can i use my embed code from other file?

slate swan
#

cogs is a class which you subclass to make an ext for your bot

#

has a cog tab

velvet tinsel
slate swan
#

see the whole tutorial its good

slate swan
velvet tinsel
slate swan
slate swan
#

Is it possible to add two footer to a embed? And not only one?

sage otter
#

No

dire folio
#

you could do /n for a new line

vocal snow
#

\n

dire folio
#

^

next wing
#

can i have some help i'm trying to get my bot to send a invite to server but the issue is at link = a_channel.create_instant_invite(), a_channel seems to be a VoiceChannel but issue is doesnt seem like that function can be ran on channels for some reason. this is the full code ```py
@bot.command()
async def link(ctx, *, guild_name):
mm = bot.get_guild(db[guild_name])
guild_id = db[guild_name]
a_guild = bot.get_guild(guild_id)

 server = bot.get_guild(mm)


 print("test1")
 for a_channel in a_guild.channels:
    bot_me = a_guild.me 
    bot_permissions = a_channel.permissions_for(bot_me)
    if bot_permissions.create_instant_invite: 
        break 
 else:
    return
 
 print("test2")

 link = await ctx.channel.create_invite(destination=server,xkcd=True, max_age=0,max_uses=1)
 print("test3")
 link = a_channel.create_instant_invite()
 print("test4")


 await ctx.send(link)
final iron
#

I personally don't like how you're creating an invite to a random server

#

It's probably against discord developer privacy policy

next wing
next wing
final iron
#

You're creating an invite to a server your bot is in without the users knowledge

#

What happens if there's private information in the server?

#

Are your users aware that you are doing this?

next wing
final iron
next wing
final iron
#

What if a user is posting private information such as pictures of themselves, inappropriate pictures or where they live and you just pop in there

#

I dont see a real reason for being able to create an invite to a specified server

next wing
final iron
#

So why do you need to create invites then?

next wing
final iron
#

I still feel really uncomfortable

#

I'm just not going to help

next wing
#

also it wouldn't be in a server where those kinds of things are, and most not if all servers have some kind of role system and the once that dont well they simply dont need a bot

next wing
final iron
#

Respectfully, I dont really care

#

Bottom line is I'm not going to help

next wing
#

also if it would be in some inapropriate server i can simply make the bot leave the server

next wing
#

sad but oh well

next wing
quaint epoch
#

i have a spotify url, i know how to join a vc, but how do i play the spotify url song?

final iron
#

Probably against spotifys tos

quaint epoch
final iron
#

I would double check that

#

If it is, then its the same situation as music bots

velvet tinsel
#

uh oh

cloud dawn
cloud dawn
velvet tinsel
#

evening panda

cloud dawn
cloud dawn
velvet tinsel
cloud dawn
velvet tinsel
cloud dawn
#

So no beer today.

velvet tinsel
#

aww

cloud dawn
#

I did serve beer today.

#

Does that count xD

next wing
# cloud dawn

i mean i mentioned before that the admins and user are fully aware of it... so slightly confused

cloud dawn
velvet tinsel
#

step no.1: don't trust anybody

dire folio
#

Good start

velvet tinsel
dire folio
#

Going great

next wing
# cloud dawn We can't take your word for that unfortunately.

i mean i am the owner of each and single one of the servers, users are my friends and are aware, im in each of th servers anyways, and server that i do not own i have proof but i could also remove them from the db, which i was going to add feature so the admins/owner are able to remove there server from db so it can not be invited

#

i could show proof but let me guess simply do not care and will not help

cloud dawn
next wing
#

fair enough i suppose

cloud dawn
velvet tinsel
next wing
velvet tinsel
#

we can't take everybody's word, unfortunately.

next wing
final iron
#

How do we know you didn't just create that bot to fool us?

next wing
final iron
#

Yes.

next wing
final iron
#

...

velvet tinsel
#

🤦

next wing
#

why did i make bot to fool you... how could it fool you i mean

velvet tinsel
#

I'm gonna go sleep, goodnight chat

next wing
final iron
#

Look, with what's at stake you're going to need some pretty extensive proof

cedar stream
#

next wing
#

damn this got deep i just wanted to invite myself or my friends to server not having to send a invite myself every time lol

cloud dawn
final iron
cedar stream
next wing
cedar stream
#

Ohh, with selfbotting

velvet tinsel
#

final word to @next wing - we won't start a full scale criminal investigation into your evidence, just some is enough ^_^

next wing
final iron
cloud dawn
final iron
#

They're not self botting

cloud dawn
cedar stream
next wing
next wing
cedar stream
#

They are inviting themselves to server via bot?

next wing
#

i mean i dm the modmail but no response so jut waitin

cedar stream
cloud dawn
next wing
cloud dawn
final iron
velvet tinsel
#

it shouldn't be that hard, sending a link

cedar stream
velvet tinsel
#

easy

cloud dawn
velvet tinsel
next wing
velvet tinsel
#

can't you do a markdown, like server

next wing
velvet tinsel
cedar stream
#

Ohh, they wanna brute force an invite link even if the bot doesn’t have perms?

velvet tinsel
#

that would be illegal?

#

or

cedar stream
#

Idk what they are even trying to do

next wing
cedar stream
#

I’ m reading the thing from panda

final iron
cloud dawn
paper snow
#

I need help with the Hikari bot library. Without using an external framework (lightbulb, etc), how do I make a bot send a message in a channel?

slim ibex
#

i would read docs

next wing
# cloud dawn

but the admins would know, doesnt do it in secret, there will be a way so if wanted to it will allow so can not send inv to that server and the bot will have permission too

cloud dawn
next wing
velvet tinsel
#

they take quite a while but it shouldn't be that long

slim ibex
paper snow
#

done. still spinning my wheels...

velvet tinsel
paper snow
#

lmao

slim ibex
cedar stream
velvet tinsel
velvet tinsel
slim ibex
#

🗿

cedar stream
slim ibex
final iron
#

Step 3: Steal code from stack overflow

cloud dawn
velvet tinsel
slim ibex
velvet tinsel
#

step 5: google the error

cloud dawn
velvet tinsel
#

step 6: copy and paste code

#

step 7: wtf the folders in the module are broken

paper snow
slim ibex
#

“Collaborate”

final iron
cloud dawn
velvet tinsel
#

step 8: realize that the module is outdated and still uses print "hello world"

#

and raw_input()

#

step 9: cry

#

step 10: abandon project

cloud dawn
cedar stream
#

Step 21: go to second page of google

velvet tinsel
#

step 11: repeat step 1

slim ibex
#

step 12: re evaluate life choices

velvet tinsel
#

step 23: ask stack overflow

cloud dawn
velvet tinsel
#

step 24: -69 downvotes go brrr

final iron
#

Step what are we on: !ot

kindred epoch
paper snow
#

So I was looking in the wrong spot

#

I was looking in the Message class for a send method

#

Let's see what that does, thank you!

kindred epoch
cloud dawn
#

!pypi hikari

unkempt canyonBOT
paper snow
#

ye that's it

kindred epoch
#

yea ok its the same

paper snow
#

pip install hikari

kindred epoch
#

yea its the same, try what i told you, im guessing its almost the same as d.py

paper snow
#

I actually don't think the rest api mixes with the regular api

#

so I need to find the regular method to get a channel

cloud dawn
#

Does anyone have a pros/cons list with hikari vs discord.py?

paper snow
#

active/depreciated

#

all I need to hear

cloud dawn
paper snow
#

ehhh fair

cloud dawn
#

Disnake and Nextcord are doing goodish.

paper snow
#

I dired the event that I was listening for and found methods to get the channel the message was sent in

tacit token
#

Hello! I made a warn system, can this only work if you save warns in separate txt files from separate servers?

paper snow
#

Should be good from there along with the links Sasuke sent

paper snow
left crater
#

i have i few images located on my c drive that i would want to make the bot send at random but it is giving me error@bot.command(name="testing") async def test_ing(ctx): Img = image.get_List() rand_Img = random.randrange(len(Img)) await ctx.send(file=discord.File(Img[rand_Img])) def get_List(): return [r'C:\Users\nikit\Downloads\nft\images1.jpg', r'C:\Users\nikit\Downloads\nft\images2.jpg', r'C:\Users\nikit\Downloads\nft\images3.jpg', r'C:\Users\nikit\Downloads\nft\images4.jpg'] discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Command' object has no attribute 'get_List'

tacit token
slim ibex
cloud dawn
paper snow
#

I did not.

bold surge
#

use something like postgres or sqlite

cloud dawn
#

sqlite is a good option for people who make small bots.

slate swan
#

and their async bridges

tacit token
#

I've never used anything like this before, can you help me?

slate swan
#

youll need to learn sql first

slim ibex
#

^

tardy plume
#

how can i use my other bot codes from other file to my main.py?

slim ibex
#

Basic things like triggers and creating tables

#

and specific syntax for commands like UPDATE, INSERT INTO, etc

tacit token
#

use cogs

slate swan
#

or be smart and copy paste it

#

easy as that

tardy plume
#
#main.py

import tze

@tasks.loop(seconds=10)
async def tz(ctx):
	await tze.time(ctx)
#tze.py
async def time(ctx):
#

this is what i did

#

and i get error

slate swan
#

bruh

tacit token
#

😄

slate swan
#

cogs for other commands

#

and listeners

bold surge
#

^

tacit token
slim ibex
#

oo glowstik is here

bold surge
#

am i tho?

slim ibex
#

🗿

slate swan
#

only person i know is zyapguypithink

final iron
slate swan
final iron
#

Like a utils file

#

And others

slate swan
pliant gulch
#

Why wouldn't you just use imports at that point?

slate swan
#

idk what hes trying to even do lol

pliant gulch
#

Perhaps the teardown and setup hooks for Cogs would be helpful

#

but mostly in niche cases?

final iron
slate swan
#

! e

#

Umm

#

andys grammer is insane

tacit token
#

offtopic, but which program do you recommend? I currently use vsc for programming.

slate swan
#

!e

unkempt canyonBOT
#
Command Help

!eval [code]
Can also use: e

*Run Python code and get the results.

This command supports multiple lines of code, including code wrapped inside a formatted code block. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.

We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!*

slate swan
unkempt canyonBOT
#

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

use the bot commands channel
final iron
bold surge
slate swan
#

vsc if you have less ram

pliant gulch
slate swan
#

i use vsc cause pycharm doesnt support md files

final iron
#

Seriously?

slate swan
#

only the professional

tacit token
pliant gulch
bold surge
#

vsc eats up a lot of ram loll

pliant gulch
#

VSC can be pretty bloated

slate swan
bold surge
#

cuz its powered by electron which uses chromium

tacit token
final iron
tacit token
final iron
slate swan
tacit token
#

buy ram guys.

final iron
slate swan
final iron
#

Whens the last time you've tried?

tacit token
#

And what type of keyboard do you recommend?

final iron
#

May of been a recent update adding support

pliant gulch
slate swan
next wing
#

ive been arguing for 1h 20min now😂

slate swan
final iron
pliant gulch
#

VSC Is alright, but I by far depend on neovim

slate swan
#

i use an rk61 v1

slate swan
bold surge
#

some how tabnine uses up the most ram for me :I

tacit token
#

edge vs vsc

bold surge
#

why edge tho

tacit token
#

That's what I like, that's what I use, that's what I'm used to. I used opera/bravet/firefox, but it works.

#

brave*

bold surge
#

ah ¯_(ツ)_/¯

tacit token
#
  • a brave ate my ram
cloud dawn
#

31 tabs 1 gb ram.

slate swan
#

who uses opera

bold surge
cloud dawn
bold surge
#

oh damn

#

anyways uh have any of you worked with sqlite

pliant gulch
#

126mb with neovim

bold surge
#

cuz i have an error and it confooses me

pliant gulch
#

👁️ 👁️

cloud dawn
cloud dawn
cloud dawn
#

😂

pliant gulch
#

Are you talking about the same thing I'm talking about?

final iron
pliant gulch
#

Neovim is a CLI editor

cloud dawn
cloud dawn
final iron
#

I might do a fresh install of windows

#

I have so much bloat

cloud dawn
#

Notepad++ is 10mb ram, beat that.

bold surge
final iron
#

Discord is 34.4mb

pliant gulch
#

Notepad isn't really an IDE though, neovim is a fully fledged one

#

Plus I have many extensions installed and it's barely using 200mb

cloud dawn
final iron
cloud dawn
pliant gulch
#

There is a notepad++ port for linux iirc

#

Neovim isn't really close to notepad++ though

cloud dawn
chrome stratus
pliant gulch
#

Neovim

chrome stratus
#

Ok

bold surge
bold surge
cloud dawn
slate swan
#

panda is talking about the global setup function for cogs to register

cloud dawn
#

Yeah the code you provided is lacking one

bold surge
#

ahh yea... im just being stupid

slate swan
bold surge
#
def setup(client):
    client.add_cog(Aimod(client))

here ya go

slate swan
#

is it indented outside of the class?

pliant gulch
#

You should give more context, E.g show your client definition and preferably where db is set

cloud dawn
pliant gulch
#

Maybe you are deleting the attribute somewhere, who knows we can't really tell

#

More information is needed

cloud dawn
#

I also recommend to start the tasks inside the on_ready for cogs and destroy the tasks when cog is unloaded since task can start earlier than the bot has been fully loaded.

pliant gulch
#

There no need to do all that useless stuff

cloud dawn
pliant gulch
#

Yes, tasks are async

bold surge
#
intents = nextcord.Intents().all()
client = Bot(command_prefix=getprefix, intents=intents, case_insensitive=True)
client.remove_command("help")

async def initialize(): 
    await client.wait_until_ready()
    client.db = await aiosqlite.connect("main.db")

client.db init code ^

client.loop.create_task(initialize())
client.ipc.start()
client.run(TOKEN)
asyncio.run(client.db.close())

i also have this code to add the .db attr ^

(all of this is in the main.py)

cloud dawn
bold surge
pliant gulch
#

Tasks like the ones you showed START before the bot's cache is populated

#

Thus at runtime db has not been set yet

bold surge
#

ah

pliant gulch
#

I recommend just hooking onto commands.Bot.connect and setting up the connection there to your database

#

commands.Bot.start also works

bold surge
#

i can also just add an on_ready event in the cog and start the cog up there

pliant gulch
#

What

#

I don't recommend doing that

bold surge
#

:I

slate swan
#

Wanted to do a Server Count command so they could see in how many servers my bot is in but it says invalid syntax idk if i did something wrong

pliant gulch
#

You can't just do it inside of start or connect?

#

It isn't very hard, and it's a lot better than setting it inside of on_ready callback

bold surge
#

hmm... how would i do that though

cloud dawn
slate swan
cloud dawn
slate swan
#

ik that

pliant gulch
cloud dawn
#

When i make a connection to my DB i don't wait until ready just connect lol

slate swan
pliant gulch
#

It waits for the cache

slate swan
#

to be fully ready

cloud dawn
pliant gulch
#

It makes perfect sense

cloud dawn
#

Why does a database connection need to wait for the bot to be started fully?

slate swan
pliant gulch
#

I'm so confused, I'm not even saying to connect the database when the bot is fully ready

#

I'm responding to okimii

cloud dawn
slate swan
slate swan
cloud dawn
cloud dawn
pliant gulch
bold surge
#

!d

cloud dawn
#

It is specific though.

slate swan
bold surge
#

ayee they also got nc

cloud dawn
visual yarrow
#

@bold surge Test it out in #bot-commands

bold surge
#

i needed the command to check the docs tho... which was relevent to the topic

cloud dawn
#

I showed him my bad :3

bold surge
#

but oki

slate swan
pliant gulch
#

Discord won't allow you to set empty titles and descriptions, if you do not want them just omit them from the constructor

cloud dawn
unkempt canyonBOT
#

Hey @slate swan!

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

slate swan
visual yarrow
#

Sorry @cloud dawn, do you want the code that was deleted?

cloud dawn
#

Yeah retyping lol

visual yarrow
#

👍

#
@client.command()
async def servercount(ctx):
        embed = discord.Embed(title="** **", description=len(client.guilds))
        embed.set_footer(
            text=(
                "If you have any questions, suggestions or bug reports, "
                "please join our support Discord Server: ..."
                ),
            icon_url=f"{client.user.avatar_url}"
            )

        await ctx.send(embed=embed)
cloud dawn
#

Thanks LX :D

pliant gulch
#

Why does discord even render the invite in the first place when inside of a codeblock

cedar stream
cloud dawn
cedar stream
cloud dawn
pliant gulch
#

It doesn't, but they should as it would save a lot of compute-time instead of len(self.guilds)

cedar stream
cloud dawn
pliant gulch
#

Oh wait

#

Isn't len O(1) not O(n)???

#

I remember hearing about it from someone because I thought len was O(n)

cedar stream
pliant gulch
#
Lists:
                               Complexity
Operation     | Example      | Class         | Notes
--------------+--------------+---------------+-------------------------------
Index         | l[i]         | O(1)         |
Store         | l[i] = 0     | O(1)         |
Length        | len(l)       | O(1)         |
``` huh guess it is O(1)
cedar stream
cloud dawn
# cedar stream ?

Don't mind Andy he likes to ask questions here and then come up with the solution himself lol

#

Still ly andy

cedar stream
pliant gulch
#

This was a warranted question though ok

pliant gulch
#

Ah I see why it's O(1) now

#

It calls a dunder method __len__ instead of working like enumerate

cedar stream
cloud dawn
#

Aren't technically all dunder methods O(1)

cedar stream
#

Imma pretend like ik what O(1) is and say yes

left crater
#
async def randint_Game(ctx):                                           
    await ctx.send("Choose a number anywhere from 1-15")               
    random_Int = random.randint(0, 15)                                 
    global times_used                                                  
    def check(msg):                                                    
        return msg.author == ctx.author and msg.channel == ctx.channel 
    msg = await bot.wait_for("message", check=check)                   
    try:                                                               
        if int(msg.content.lower()) == random_Int:                     
            await ctx.send("Good Job!")                                
        else:                                                          
            await ctx.send(f"Wrong! It was {random_Int}")              
    except ValueError as valer:                                        
        await ctx.send(valer)
# I have also made a dictionary
def dict_():
    return {
        "one" : 1,
        "two" : 2,
        "three" : 3,
        "four" : 4,
        "five" : 5,
        "six" : 6,
        "seven" : 7,
        "eight" : 8,
        "nine" : 9,
        "ten" : 10,
        "eleven" : 11,
        "twelve" : 12,
        "thirteen" : 14,
        "fourteen" : 15 }
#how do i combine the two```
cedar stream
#

This guy just invented pep9

cloud dawn
pliant gulch
#

It would be O(n)

cedar stream
#

Whats O()

pliant gulch
#

Time complexity

cloud dawn
pliant gulch
#

Looking up rn

cedar stream
pliant gulch
#

Oh __next__ is O(1)

#

😔

cloud dawn
left crater
#

i am

#

but i also want to include one, two, three

cedar stream
left crater
#

i agree

cloud dawn
pliant gulch
#

That's O(1) don't even need to google

cloud dawn
#

__contains__?

pliant gulch
#

Not sure about that one

cloud dawn
#

Those were my 2

cloud dawn
left crater
#

can i make it accept "one", "two", "three" using a dictionary

slate swan
#

How do I make a bot

left crater
#

how

pliant gulch
cloud dawn
# left crater how

!e ```py
answer = "two"
correct = 2

l = {"one": 1, "two": 2}

if l.get(answer) == correct:
print("yes")

unkempt canyonBOT
#

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

yes
left crater
#

thanks

quaint epoch
#

so, i have a rickroll .mp3 file i got, i want to run a command that makes my bot join a vc and play the rickroll, i have the vc joining down but idk how to play the rickroll

worthy wadi
final iron
#

If you use replit you're still using discord.py. Replit is just an online text editor/ide

potent spear
#

discord.FFmpegPCMAudio("filename.mp3")
use this as audiosource in your voice_client.play(audiosource)

#

first of all, have you checked the docs? 😉

quaint epoch
potent spear
#

it's not, show me the link and I'll bow for you

#

well, they made a terrible mistake for putting that in there

#

what you actually should look for

#

the IF Statement is what fixes the problem

#

it's not an exact copy, I can't
you made a big variable naming mistake

#

no, the if statement checks IF the bot is the author of the message
=> it doesn't respond to itself

slate swan
#

why subclass Client

#

and not use the bot framework which is already a subclass of Client

#

!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.
final iron
#

Can somebody explain to me the advantages of subclassing your bot constructor file?

potent spear
#

I use it for db purposes

all my db methods and attributes are defined in the subclass of my bot

bot.db

bot.add_twitch_user(user_id)
bot._get_all_twitchusers()
bot.remove_twitch_user(user_id)

#

you see how this can work out?

#

it's to extend the functionality of my bot

final iron
#

Can't you do this without subclassing your bot class?

potent spear
#

you sure can, but that's like not really as clean

potent spear
#

also, adding a method AFTER creating an object of that class? idk about that 🤢

cloud dawn
#

You can add attributes but it's better to include them.

potent spear
#

I know add_command exists, but that's a different subject

pliant gulch
#

Provides an easier way to extend the class

slate swan
#

^

gentle badger
#

How to make a button after that Who presses the button It changes part of a message and writes the name of the person who clicked the button

slate swan
#

on interaction edit the msg with the author

feral ridge
#

Hey I have a flask server that receives webhooks, how can i send the webhooks data through a discord bot

gentle badger
#

That the button will be private only to a certain voice

slate swan
#

iirc

await interaction.response_edit_message(f"{interaction.author.mention} has pressed the button")
feral ridge
#

ik

#

thats why idk how to implement it

royal oar
#

Would anyone know how to hide a cog from a custom help command? I know how to hide a command with hidden=True im just wondering i could do it though. As I am trying to hide the autoresponses cog

potent spear
royal oar
#

Ok thank you

worthy wadi
#

can someone tell me if this is good at all

#

cause i suck at developing bots

#

lmao

slate swan
#

!d discord.CategoryChannel.channels

unkempt canyonBOT
#

property channels: List[GuildChannelType]```
Returns the channels that are under this category.

These are sorted by the official Discord UI, which places voice channels below the text channels.
slate swan
#

returns a list so just iterate through it

#

yw

#

issue by?

#

why are you making the channel a str?

#

channels have the .name attr

#

use the attr

#

wait

#

are you using client

#

or the Bot class

#

you wont lol

#

client has many outdated stuff compared to the bot class

#

the bot class has moderation cogs and way more stuff

#

i recommend you use the bot class before you subclass it

#

so you will learn its kwargs and attrs

#

can you show me everything

#

yes you can

#

doesnt create_thread take a snowflake

#
from discord.ext.commands import Bot
#

nvm youre using disnake

#

yw

#

nice but no need for the *args lol

#

no no

#

dont run the subclass in the same file and dont make an instance

#

just set all the stuff like the prefix and everything make a run method and make a main file and run the method their which runs the bot

pliant gulch
#

Why is it **args when It's keyword-arguments due to the double asterisk?

slate swan
#

that aswell

pliant gulch
#

Should be **kwargs to follow most used convention

#

args would be for *args

slate swan
#

which returns a tuple

#

welp if you want to learn basics dont subclass the Bot class and make an instance and make commands in the same file

#

you just inherit the run method of the bot class and make a method which you can run another function like a for loop which thats what i do

#

nononono

#

!src

unkempt canyonBOT
slate swan
#

check this bot

unkempt canyonBOT
#

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

Creates a thread in this text channel.

To create a public thread, you must have [`create_public_threads`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.create_public_threads "discord.Permissions.create_public_threads"). For a private thread, [`create_private_threads`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.create_private_threads "discord.Permissions.create_private_threads") is needed instead.

New in version 2.0.
tardy plume
#

how can i make everytime have new key and value in my dict my bot will add new embed field with the new key and value in my dict

slate swan
#

the message needs to be a discord.Message object, so just pass message variable in the create_thread for the message kwarg

final iron
#

!d discord.TextChannel.threads

unkempt canyonBOT
#

property threads: List[discord.threads.Thread]```
Returns all the threads that you can see.

New in version 2.0.
final iron
#

Uh

#

Not sure if you wanted that

#

Just took a blind guess

#

@slate swan It's not

#

!d discord.Thread

unkempt canyonBOT
#

class discord.Thread```
Represents a Discord thread.

x == y Checks if two threads are equal.

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

hash(x) Returns the thread’s hash.

str(x) Returns the thread’s name.

New in version 2.0.
final iron
#

There

#

You can check out all the attributes

#

No, you'll need a discord.Thread object

final iron
#

Check it before though

#

You are the type of person I like helping. You seem to actually know some python so I don't have to walk you through everything

blazing coral
#

how do i mention a role and it actually ping people

final iron
unkempt canyonBOT
final iron
blazing coral
#
async def contentupdate(ctx, mention: discord.Role.mention):
    embed = discord.Embed(
        title=' BlessGang ',
        description='Content update for Bless Gang check out the most recent upload. ',
        colour=discord.Colour.purple())

    embed.add_field(name=f" Most Recent stream !!!  :", value="   ", inline=True)
    embed.add_field(name=f"   :", value=f" {mention}   ", inline=True)
    await ctx.send(embed=embed)```
#

i cant get it to ping anyone

#

it keeps giving me this error

#
  File "C:\Users\ggmin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 697, in _parse_arguments
    transformed = await self.transform(ctx, param)
  File "C:\Users\ggmin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 552, in transform
    return await self.do_conversion(ctx, converter, argument, param)
  File "C:\Users\ggmin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 505, in do_conversion
    return await self._actual_conversion(ctx, converter, argument, param)
  File "C:\Users\ggmin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 476, in _actual_conversion
    raise BadArgument('Converting to "{}" failed for parameter "{}".'.format(name, param.name)) from exc
discord.ext.commands.errors.BadArgument: Converting to "property" failed for parameter "mention".```
final iron
#

No clue. Never worked with them

blazing coral
#

alright

slate swan
#

you type hint a obj

final iron
#

You would have mention: discord.Role and then you would mention it with mention.mention

blazing coral
#

ok

#

makes sense

final iron
#

But rename your variables

blazing coral
#

ok

slate swan
#

and you arent following pep8

final iron
slate swan
#

the closing ) shouldnt be in the same line as the color kwarg it should be in a new line

final iron
final iron
#

From what I heard, making a dashboard is pretty complicated

#

ipc?

slim ibex
#

just do in bot config ngl

#

as in config commands

#

mhmm

#

!pypi hikari

unkempt canyonBOT
final iron
#

Quick question

#

!d disnake.MessageInteraction.response

unkempt canyonBOT
final iron
#

This object has no intellisense or suggestions in my IDE

#

Is there a reason for that?

patent lark
#

its add_roles()

#

mhm.

#

i havent used threads in discord.py yet.

final iron
#

Are you looking for something specific?

pliant gulch
#

You won't be able to send messages in the thread

#

It's archived indefinitely, you might be able to unarchive but I haven't looked into it

maiden fable
final iron
#

Cool

#

I'm bored out of my tree

maiden fable
#

It's the method used by auto sharded bots and for making dashboard exchange data

final iron
#

Maybe its too late for this

shadow wraith
final iron
#

I'm just working on my wall paper command

#

I'm avoiding my custom help command

#

You need an id

true moon
#

how can i make cooldowns like if a user is donator his cooldown will be 5s if he is not then cooldown will be 10s

maiden fable
final iron
maiden fable
#

Haha

final iron
#

Are you in a class?

#

Then its self.Bot

#

Unless you defined Bot somewhere else

maiden fable
#

No, as long as they defined bot

#

Mind hovering over the red line?

#

It will tell the error

#

!d discord.Client.get_channel

unkempt canyonBOT
maiden fable
#

Weird

#

Try deleting that line

#

BTW why u using a for loop?

#

It won't work

pliant gulch
#

Your subclassing commands.Bot from your earlier stuff, so I assume you are still in the subclass. You would do self.get_channel(...)

#

self is an instance of commands.Bot

#

You are doing Bot which is a class

#

Not an instance

maiden fable
#

Because it isn't iterable

maiden fable
#

!d discord.TextChannel.threads

unkempt canyonBOT
#

property threads: List[discord.threads.Thread]```
Returns all the threads that you can see.

New in version 2.0.
maiden fable
#

U need to update to 2.0

#

Weird

pliant gulch
#

Probably a type-checker error since you are using a type checker

maiden fable
#

Mind showing the error?

pliant gulch
#

get_channel can return VoiceChannel | TextChannel | etc

maiden fable
#

discord.__version__

pliant gulch
#

You need to make sure the instance is an instance of TextChannel

#

Your type-checker won't know unless you validate it

maiden fable
#

Yea

sonic flax
#
@bot.command(pass_context = True)
async def alts(ctx, username):
    altApi = requests.get(f"http://api.antisniper.net/altfinder?key={key}&name={username}")
    hpApi = requests.get(f"https://api.hypixel.net/player?key={hpkey}&name={username}")

    altjson = altApi.json()
    hpjson = hpApi.json()

    if hpjson['player'] is None:
        embed = discord.Embed(title="Dewier Bot", description=(f"Cannot find a player with the name ``{username}``"), color=(0x0b0909))
        await ctx.send(embed=embed)
    else:
        for alt in altjson['results']:
            embed = discord.Embed(title = "Dewier Bot", description = (f"(alt{'_id'})"), color = (0x0b0909))
            await ctx.send(embed = embed)```
#
    else:
        for alt in altjson['results']:
            embed = discord.Embed(title = "Dewier Bot", description = (f"(alt{'_id'})"), color = (0x0b0909))
            await ctx.send(embed = embed)```
for this part how do i make it so instead of sending each _id in a new message it sends it all in one
so like
"Dewier Bot"
1
2
3
4
pliant gulch
#

!d discord.TextChannel.archived_threads

unkempt canyonBOT
#

archived_threads(*, private=False, joined=False, limit=50, before=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") that iterates over all archived threads in the guild.

You must have [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") to use this. If iterating over private threads then [`manage_threads`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_threads "discord.Permissions.manage_threads") is also required.

New in version 2.0.
pliant gulch
#

Note, returns an async iter

sonic flax
maiden fable
#

Would have been better imho if dpy instead makes a subclass of Thread which is ArchivedThread and just return all the threads with channel.threads imho

#

Are there any limitations due to which this isn't possible?

pliant gulch
#

Perhaps the gateway doesn't give this information?

maiden fable
#

Hmm could be

pliant gulch
#
        "THREAD_CREATE",
        "THREAD_UPDATE",
        "THREAD_DELETE",
        "THREAD_LIST_SYNC",
        "THREAD_MEMBER_UPDATE",
        "THREAD_MEMBERS_UPDATE",
``` You only get these thread events
#

I'd assume THREAD_UPDATE will be dispatched on archive I have no clue

#

I'll test it rq

maiden fable
#

!d discord.on_thread_update

unkempt canyonBOT
#

discord.on_thread_update(before, after)```
Called whenever a thread is updated.

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

New in version 2.0.
maiden fable
#

!d discord.on_thread_remove

unkempt canyonBOT
#

discord.on_thread_remove(thread)```
Called whenever a thread is removed. This is different from a thread being deleted.

Note that you can get the guild from [`Thread.guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Thread.guild "discord.Thread.guild").

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

Warning

Due to technical limitations, this event might not be called as soon as one expects. Since the library tracks thread membership locally, the API only sends updated thread membership status upon being synced by joining a thread.

New in version 2.0.
maiden fable
#

!d discord.on_thread_delete

unkempt canyonBOT
#

discord.on_thread_delete(thread)```
Called whenever a thread is deleted.

Note that you can get the guild from [`Thread.guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Thread.guild "discord.Thread.guild").

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

New in version 2.0.
maiden fable
#

What are these both tho?

pliant gulch
maiden fable
#

Sad

pliant gulch
maiden fable
#

!d discord.Thread.edit

unkempt canyonBOT
#

await edit(*, name=..., archived=..., locked=..., invitable=..., slowmode_delay=..., auto_archive_duration=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the thread.

Editing the thread requires [`Permissions.manage_threads`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_threads "discord.Permissions.manage_threads"). The thread creator can also edit `name`, `archived` or `auto_archive_duration`. Note that if the thread is locked then only those with [`Permissions.manage_threads`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_threads "discord.Permissions.manage_threads") can unarchive a thread.

The thread must be unarchived to be edited.
maiden fable
#

archived = False

true moon
#

how can i make cooldowns like if a user is donator his cooldown will be 5s if he is not then cooldown will be 10s

maiden fable
#

message.author.mention

#

No

#

!d discord.Member.mention

unkempt canyonBOT
final iron
#

Oh yeah

#

I should really go to sleep

maiden fable
unkempt canyonBOT
#

@discord.ext.commands.dynamic_cooldown(cooldown, type=BucketType.default)```
A decorator that adds a dynamic cooldown to a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")

This differs from [`cooldown()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.cooldown "discord.ext.commands.cooldown") in that it takes a function that accepts a single parameter of type [`discord.Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") and must return a [`Cooldown`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Cooldown "discord.ext.commands.Cooldown") or `None`. If `None` is returned then that cooldown is effectively bypassed.

A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").

If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") and the local error handler.

A command can only have a single cooldown.

New in version 2.0.
maiden fable
final iron
#

I'm going to finish my wallpaper command and then sleep

maiden fable
#

What's that 👀

slate swan
maiden fable
#

PoV: He missed your answer

slate swan
#

Lol

#

2 more people replied to him, he ignored all

true moon
maiden fable
#

@pliant gulch I got the way

slate swan
maiden fable
#

!d discord.Message.pin

unkempt canyonBOT
#

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

Pins the message.

You must have the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to do this in a non-private channel context.
true moon
# unkempt canyon

this is better i can take message and then check if the user is donator and return the seconds

pliant gulch
maiden fable
# pliant gulch What

We can use thread.archived or smth in the update event, ig? I don't really know much about thread events

vernal parrot
#
@client.command(aliases = ["sc"])
async def save_cords(ctx, name,*, cords):
   
    uploader = ctx.author

    data = {"Uploader":uploader,"Cords":cords,"Name":name}
    dataa = json.dumps(data, indent=4)

    with open(f"Data/cords.json","w") as f:
        f.write(dataa)
        f.close()

    await ctx.send(f"Successfully saved cords. | Name: {name} | Cords: {cords}")

i have this code which just writes some data into a json file but the problem is that the code is not working and its not giving errors. and i tried making another python file and i tried writing data and it worked. but it is not working here

maiden fable
#

Wait, how does dpy return archived_threads then? Fetches from the API?

sonic flax
#
    else:
        for alt in altjson['results']:
            embed = discord.Embed(title = "Dewier Bot", description = (f"(alt{'_id'})"), color = (0x0b0909))
            await ctx.send(embed = embed)```
How do I make it so, instead of it sending a new message for every id, it puts them all into 1 message example:
Dewier Bot
324-3243124-3214312
2314-5231321-321245
32432-234124-3241
pliant gulch
vernal parrot
slate swan
maiden fable
unkempt canyonBOT
#

discord.on_thread_update(before, after)```
Called whenever a thread is updated.

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

New in version 2.0.
pliant gulch
slate swan
#

!d json.dump

unkempt canyonBOT
#

json.dump(obj, fp, *, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, default=None, sort_keys=False, **kw)```
Serialize *obj* as a JSON formatted stream to *fp* (a `.write()`-supporting [file-like object](https://docs.python.org/3/glossary.html#term-file-like-object)) using this [conversion table](https://docs.python.org/3/library/json.html#py-to-json-table).

If *skipkeys* is true (default: `False`), then dict keys that are not of a basic type ([`str`](https://docs.python.org/3/library/stdtypes.html#str "str"), [`int`](https://docs.python.org/3/library/functions.html#int "int"), [`float`](https://docs.python.org/3/library/functions.html#float "float"), [`bool`](https://docs.python.org/3/library/functions.html#bool "bool"), `None`) will be skipped instead of raising a [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError").

The [`json`](https://docs.python.org/3/library/json.html#module-json "json: Encode and decode the JSON format.") module always produces [`str`](https://docs.python.org/3/library/stdtypes.html#str "str") objects, not [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "bytes") objects. Therefore, `fp.write()` must support [`str`](https://docs.python.org/3/library/stdtypes.html#str "str") input.

If *ensure\_ascii* is true (the default), the output is guaranteed to have all incoming non-ASCII characters escaped. If *ensure\_ascii* is false, these characters will be output as-is.
vernal parrot
maiden fable
#

Oh nvm

#

Yea u right

maiden fable
vernal parrot
maiden fable
#

Don't follow them then

#

(:

vernal parrot
slate swan
#

Geeksforgeeks have a lot of different methods

#

;-;

vernal parrot
#

okay

sonic flax
#
 else:
        for alt in altjson['results']:
            embed = discord.Embed(title = "Dewier Bot", description = (f"(alt{'_id'})"), color = (0x0b0909))
            await ctx.send(embed = embed)```
How would I make it so it puts all the ids into 1 message like:
Dewier Bot
(_id)
(_id)
(_id)
slate swan
#

In the description

maiden fable
#

!join

unkempt canyonBOT
#

Joining Iterables

If you want to display a list (or some other iterable), you can write:

colors = ['red', 'green', 'blue', 'yellow']
output = ""
separator = ", "
for color in colors:
    output += color + separator
print(output)
# Prints 'red, green, blue, yellow, '

However, the separator is still added to the last element, and it is relatively slow.

A better solution is to use str.join.

colors = ['red', 'green', 'blue', 'yellow']
separator = ", "
print(separator.join(colors))
# Prints 'red, green, blue, yellow'

An important thing to note is that you can only str.join strings. For a list of ints,
you must convert each element to a string before joining.

integers = [1, 3, 6, 10, 15]
print(", ".join(str(e) for e in integers))
# Prints '1, 3, 6, 10, 15'
keen talon
sonic flax