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")```
#discord-bots
1 messages · Page 782 of 1
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.
the token is wrong...
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
Sure
Its not
Bruh
i suck at this idk how to fix it
bruh how is "TOKEN" a token
Then u can fix the error for yourself
2 bot instances? 💀 why is everything messed up
how would i fix it
ive only transferred the script, it worked perfectly fine on my pc (with the same python version) plz help :(
code @hearty sierra
Mongo ic
yea
i know this may be off-topic but i got a cool custom cursor chrome extension
I use brave anyways its ot
!d discord.ext.commands.check
@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").
^^
Imagine fake nitro
Imagine fake robux 😭
nice
i told you already
I mean the user has access to this command and the others don't
Yea, read the docs for commands.check
if you would listen to me
Hey @hearty sierra!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
It returns either True or False. If it returns True, then the user can use it, else no
you can do something like
def acheck(ctx):
return ctx.author.id == id
!d discord.ext.commands.Cog.cog_check is also there
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").
and then @commands.check(acheck) i think
Yea
or commands.Cog.cog_check for if u i na cog
idk how to do what u said
I just told u the way
!d discord.Embed.fields
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.
which field exatly
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?
Someone who know how to do so only one id can use a command?
uh you can check if the author id of the command is equal to the id you want a
wait are you new to python or new to discord.py
if ur new to python
dont learn discord.py
anyways bad timing but i gtg 😭 cya later, just make a function which does return ctx.author == id
!d discord.ext.commands.check
@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").
thanks bro
how to get message.content for dm
like if i dm the bot, how to get that message
the content attr gets the content of a msg obj
is there anything like async def on_DM(message):
on msg waits for a msg
just check the type of the channel
!d discord.ChannelType.private
A private text channel. Also called a direct message.
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
;-;
independed from cancle
who are you talking to
@slate swandarth wader ur father
and what are you talking about 😭
who else
no😨
hans solo
it cant be😰
no actually 3 days ago
python good for coding discord bots?
3 days ago, fuck u mature now then
aka my bday was 3 days ago
yes
no
omg this chat
it is
use whichever language you're comfortable with
its the worst community - u ask for help n they all try pull em self up for easy task
hey zeffo
heloo
personal experiences
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
its good communnity just ignore those with anime pfp
you cant judge a community by personal experiences
real funny arent you
funny or correct? thats up to the judges aint it
ignore andy then
anime andy -ignored amen
thats why you can't learn anything
why argue in this channel lmao..
what didnt i learn?
how to babysit u?
okimii you seem nice :)
nice well python is good as a general purpose language 
am nice too
Yes, they are 
thank you guys
you dont seem like it :/
i dont have 4 acounts n
etc so prob not
see people love me even if i have an anime pfp
pfps dont matter at all lmao
its ur alts 😄
^
what are you saying bro
didnt your mom said not to judge someone by appearance 
you never treated anyone harshly

but hes assuming im a loser because of my pfp when im a nice person 
That's not cool
to judge someone by their pfp or face
exactly its called manors 
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
<3
ok first please dont have 2 constructors and dont use requests
use aiohttp
!pypi aiohttp
or httpx
^
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
idk what constructors are
this
bot = commands.Bot(command_prefix = prefix)
client = commands.Bot(command_prefix = 'prefix')
delete one
and use the kwargs i said in
!d discord.ext.commands.Bot
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.
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 :/
how did u do that
ur doing .pin on the task
cant tell much because i dont see code anywhere
So I have my own function like
def test():
(create a embed)
client.loop.create_task(client.mchannel.send(embed=embedwinner))
here I want to pin this embed
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"
I cant. Wait I try it and send you the code
await doen't work outside a async func
Why not make it an async function then
just make async function to do sendin then pinning, then create_task that async funcion ???
what is problem ?
uhm tbh I dont really know whats the difference to a "normal" function. I thought async functions are just for commands
No
lol
!d discord.ext.tasks.loop
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").
Check out some examples
I dont understand what this should say me
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
Okay thanks i will have a look at it.
How can I call my async function then?
It shows you in the examples
okay
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
use the builtin function? 
And that is what function?
nvm
wait
Can u send code
I would guess they want that colour
Like the hexadecimal one
oky then help them, bye
Wait no
discord.Colour.purple()
yea
returns hexcode by name for discord.py and its forks

or u can use from_rgb()
The colour worked for me
there aliases doesnt matter
I meant the colour on the embed
742 colors btw 
Advertising your project I see
im just helping others
use db not json and to have good file structure you must know dpy
what? you're advertising? 😠
or more complicated
nice resp I starred it
which people with experience dont make commands in their bot file and they subclass Bot class
and what was that
no
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
inti
@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'
💀
u never called the super.init
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
oh idk i just popped in just now
not sure wdym
well it does inherit the methods, but init was overwrote when u declared init for the subclass
ah you ment by the super lol
i thought of something else sorry
but yes you are correct
no no
how can i use my embed code from other file?
cogs is a class which you subclass to make an ext for your bot
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
has a cog tab
Lucas be like:
see the whole tutorial its good
fuc-

Is it possible to add two footer to a embed? And not only one?
No
you could do /n for a new line
\n
^
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)
I personally don't like how you're creating an invite to a random server
It's probably against discord developer privacy policy
i mean it just simply invites user to the given server that the bot is connected to, its nothing deep
why would it?
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?
i mean the command will be limited to administrators or bot owner(me) and if they wanted to share any private information that is on the server they could simply take a ss or invite the person themself
yes
I don't think you understood what I said
i mean at the moment the users are simply me few friends and test servers i have made to test this out
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
umm i get ur point in my case it littelerly is just a server with my friends which they are all aware of the bot and what it can do an other server is just test server which contain me, alt to test on thats it
So why do you need to create invites then?
i mean not sure i suppose i just wanted to make it ig, but also if they gave the bot access to what it needs then the user(owner) of server would be aware as they are allowing the bot the permission to do this
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
i mean i could show you prove that i am owner of each and every server the bot is in
also if it would be in some inapropriate server i can simply make the bot leave the server
that is you're opinion so fair enough
sad but oh well
Can anyone help out with this? ^^^^^^^
i have a spotify url, i know how to join a vc, but how do i play the spotify url song?
Probably against spotifys tos
alr
uh oh
The Python moderators have decided that we don't help with this kind of code.
It is.
oh okay...
evening panda
Evening :3
how's the beer coming along
It's Thursday.
o
So no beer today.
aww
i mean i mentioned before that the admins and user are fully aware of it... so slightly confused
We can't take your word for that unfortunately.
step no.1: don't trust anybody
Good start
step no.2: everyone is your enemy
Going great
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
Dekriel is right on some area, we don't know you. So generally we don't make exceptions, if you do want an exception you can message @novel apex and ask for their approval and have one of the mods verify the message to us.
fair enough i suppose
okay
We do care but sadly people have ruined that trust.
we need valid proof to support your statement, else we'd be on thin ice
damn well i contacted them so ill have to wait i suppose
we can't take everybody's word, unfortunately.
yeah i suppose i mean i do have proof so yeah.
Providing proof will be extremely difficult
How do we know you didn't just create that bot to fool us?
will it??
Yes.
what does that even mean?
...
why did i make bot to fool you... how could it fool you i mean
I'm gonna go sleep, goodnight chat
gn
Look, with what's at stake you're going to need some pretty extensive proof
like?
…
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
How do u wanna do it
Most likely since they don't know you either, we're pretty serious about privacy.
It's against tos.
Wdym
who doesnt know me the staff team on this server?
Ohh, with selfbotting
final word to @next wing - we won't start a full scale criminal investigation into your evidence, just some is enough ^_^
is it??
@cedar stream
Well then just make the guild specific, they only reason why it is kinda off putting is that you can input ANY name.
Everyone here.
I dont get it
no? i mean the bot would have to have to be in server, will also have to have server in the db
fair
They are inviting themselves to server via bot?
i mean i dm the modmail but no response so jut waitin
Yes
Why is that against tos
I meant that you can only return a invite from 1 specific guild. A set guild, think of it like linking a support server.
so the user/admin would do ,link Test server the bot in the server called Test server will end inv to the person so they can join
Yeah and that's why the mod team decided not to help with this.
Read what I mentioned you in
That’s against tos?
Yes I read
easy
You sended a vanity link, only works with that.
oh
how?
but i not online 24/7 am i
I recommend reading this -> https://discordapp.com/channels/267624335836053506/343944376055103488/936385193730777099
the bot should
Ohh, they wanna brute force an invite link even if the bot doesn’t have perms?
^^^
...
that would be illegal?
or
Idk what they are even trying to do
i did and all i checked it checks out, it has owners permisssion, etc
I’ m reading the thing from panda
@cedar stream
no the bot has permission
That doesn't matter
I think you are reading it wrong, they disapproved even if the bot has owner perms.
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?
i would read docs
not that I know of
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
I'm still waiting for modmail, sorry.
yeah im aware still waiting for response
they take quite a while but it shouldn't be that long
Step 1: read the docs
what I said ^
done. still spinning my wheels...
Step 2: there is no step 2.
lmao
Step 2: write the code
Then we agree on it
no
Step 2: hippity hoppity your code is my proper-
🗿
Step 2: if you don’t know what ur doing refer to step 1
developers be like
Step 3: Steal code from stack overflow
Any c# dev
step 4: error go brrr
is that an insult🗿
step 5: google the error
deprecation error
nono
"Collaborate with Stackoverflow"
“Collaborate”
Step 5: Complain about 5 year old code not working
"second opinion"
step 8: realize that the module is outdated and still uses print "hello world"
and raw_input()
step 9: cry
step 10: abandon project
pass_context
Step 21: go to second page of google
step 11: repeat step 1
step 12: re evaluate life choices
step 22: wtf
step 23: ask stack overflow
Let's go to #ot2-never-nester’s-nightmare lol
step 24: -69 downvotes go brrr
Step what are we on: !ot
idk anything about hikari, but i found this https://www.hikari-py.dev/hikari/api/rest.html#hikari.api.rest.RESTClient.fetch_channel which returns a channel, im guessing you can use that and then use this https://www.hikari-py.dev/hikari/channels.html#hikari.channels.GuildTextChannel.send to send a message in that channel.
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!
can you send the pypi link of the lib you're using, just to make sure its the same lib lul
!pypi hikari
ye that's it
yea ok its the same
pip install hikari
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
Does anyone have a pros/cons list with hikari vs discord.py?
That isn't really valid since forks are still maintained.
ehhh fair
Disnake and Nextcord are doing goodish.
I dired the event that I was listening for and found methods to get the channel the message was sent in
Hello! I made a warn system, can this only work if you save warns in separate txt files from separate servers?
Should be good from there along with the links Sasuke sent
in whatever storage system you have, you do need a way to differentiate servers, yes
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'
We use databases here sir.
And if there are a lot of servers with bots, does that not interfere with the host?
^
Please don't suggest .txt files as valid storage system.
I did not.
use something like postgres or sqlite
sqlite is a good option for people who make small bots.
and their async bridges
I've never used anything like this before, can you help me?
youll need to learn sql first
^
Basic things like triggers and creating tables
and specific syntax for commands like UPDATE, INSERT INTO, etc
import it
use cogs
#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
bruh
😄
^
Don't you have a Youtube channel?
oo glowstik is here
am i tho?
🗿
only person i know is zyapguy
Not always
in what situation?
Other files can be used for things other than cogs
Like a utils file
And others
hes trying to make a task and adding the time in another file is see no reason why not
Why wouldn't you just use imports at that point?
idk what hes trying to even do lol
Perhaps the teardown and setup hooks for Cogs would be helpful
but mostly in niche cases?
I have no idea what that means
offtopic, but which program do you recommend? I currently use vsc for programming.
!e
!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!*
!e
print("use the bot commands channel")
@slate swan :white_check_mark: Your eval job has completed with return code 0.
use the bot commands channel
you mean editor
Pycharm/vsc. VSC if you have a less powerful machine, pycharm if you have a more powerful machine
vsc is not bad for bot development... it has all the features you need for a casual developer
vsc if you have less ram
E,g Cog.cog_unload, etc
i use vsc cause pycharm doesnt support md files
Seriously?
only the professional
yes i mean, but my translater no
What
vsc eats up a lot of ram loll
VSC can be pretty bloated
pycharm took me 1gb of ram
cuz its powered by electron which uses chromium
I'm looking at it right now and its fine
yeah bruh
weird mine said it didnt support it
buy ram guys.
Try updating
no it was up to date
Whens the last time you've tried?
And what type of keyboard do you recommend?
May of been a recent update adding support
Pycharm is more bloated than VSC but VSC can get bloated dependent on the extensions and what not
havent
yeah
ive been arguing for 1h 20min now😂
depends
Try reinstalling it and seeing
VSC Is alright, but I by far depend on neovim
i use an rk61 v1
nah ill stick to vsc
some how tabnine uses up the most ram for me :I
edge vs vsc
why edge tho
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*
ah ¯_(ツ)_/¯
- a brave ate my ram
31 tabs 1 gb ram.
who uses opera
ram limiting go brr
It's not limited
126mb with neovim
cuz i have an error and it confooses me
👁️ 👁️
sql based syntax so.
yes
didn't they remove all the css and resized all the images to 144p
😂
Are you talking about the same thing I'm talking about?
The tabs aren't loaded in cache
Neovim is a CLI editor
Most likely, chrome does do that. So if i use 31 tabs there i easily have 4gb
Oh.
Notepad++ is 10mb ram, beat that.
ok so I have a task (code for tasks https://mystb.in/DancingSomeTrust.python) and it returns an odd error (https://mystb.in/DustHardcoverMyspace.sql where it says self.client.db does not exist in Bot) but I have used the same attr in a command and a listener and it works fine
Discord is 34.4mb
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
Mine is 0.4gb how
Use Canary smh
This looks like a modified notepad++ imo
There is a notepad++ port for linux iirc
Neovim isn't really close to notepad++ though
db isn't defined, what is odd about that?
What editor is this?
Neovim
Ok
Does this cog have a setup?
it is defined tho... i use the same attr in my listeners and commands which are in the same cog
yes,
class Aimod(commands.Cog):
def __init__(self, client):
self.client = client
self.joinCountClear.start()
self.antiRaidClear.start()
No i mean a setup function
panda is talking about the global setup function for cogs to register
Yeah the code you provided is lacking one
ahh yea... im just being stupid

def setup(client):
client.add_cog(Aimod(client))
here ya go
is it indented outside of the class?
You should give more context, E.g show your client definition and preferably where db is set

Maybe you are deleting the attribute somewhere, who knows we can't really tell
More information is needed
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.
You can just do wait_until_ready
There no need to do all that useless stuff
Isn't that async?
Yes, tasks are async
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)
Well then he has to make an async loop inside init, seems kind of useless since he can use that.
the part that confuses me is that the listeners which are in the same cog, work fine with it, whilst the tasks have a problem
Heres your issue, your using wait_until_ready which waits for cache to be populated. You then set db AFTER the bot is ready
Tasks like the ones you showed START before the bot's cache is populated
Thus at runtime db has not been set yet
ah
I recommend just hooking onto commands.Bot.connect and setting up the connection there to your database
commands.Bot.start also works
i can also just add an on_ready event in the cog and start the cog up there
:I
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
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
hmm... how would i do that though
name=( <-- one bracket to many.
doesnt on ready fire when the cache is populated why wait until ready or does wait until ready wait until the cache is fully ready
on_ready can happen more than once.
ik that
Discord.py does a weird and actually dispatches a fake event. on_ready is dispatched via library abstraction. the real event associated with READY from the gateway is with on_connect
When i make a connection to my DB i don't wait until ready just connect lol
yeah ik but why wait until ready?
It waits for the cache
to be fully ready
That makes no sense.
It waits for all guild_creates to dispatch, then sets the asyncio.Event
It makes perfect sense
Why does a database connection need to wait for the bot to be started fully?
Still says Invalid syntax
I'm so confused, I'm not even saying to connect the database when the bot is fully ready
I'm responding to okimii
Where?


Where did you even create an embed object.
To re-iterate in a clearly way ready is dispatched when the cache is populated. wait_until_ready waits for the internal asyncio.Event to be set which is set when ready is dispatched. wait_until_ready waits for the cache to be fully populated
!d
It is specific though.
Sorry I just fixed it I somehow messed up embed = discord.Embed
ayee they also got nc
Could you send the new code inside a codeblock instead of an ss?
@bold surge Test it out in #bot-commands
i needed the command to check the docs tho... which was relevent to the topic
I showed him my bad :3
but oki
I hope this is right
Discord won't allow you to set empty titles and descriptions, if you do not want them just omit them from the constructor
Could you send the code? Lemme format it correctly.
Hey @slate swan!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
Sorry @cloud dawn, do you want the code that was deleted?
Yeah retyping lol
Yes please :3
👍
@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)
The link can be removed it was meant as example for formatting.
Thanks LX :D
Why does discord even render the invite in the first place when inside of a codeblock
I think bot has a specific attribute for guild count, I’ m not sure tho
¯_(ツ)_/¯
That would be a new one for me.
I’ m not sure if it exists
Would be a pretty small function lol.
It doesn't, but they should as it would save a lot of compute-time instead of len(self.guilds)
Nvm, there is a member_count tho
Yeah but idk why they did that.
Put it in ur wrapper
Oh wait
Isn't len O(1) not O(n)???
I remember hearing about it from someone because I thought len was O(n)
Just have it counted once and not each time u need it 🤷🏼♂️
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)
?
Don't mind Andy he likes to ask questions here and then come up with the solution himself lol
Still ly andy
I’ m more impressed by the fact that u managed to make a table using codeblock and it still looks good on mobile
This was a warranted question though ok
Lmfao
That got generated xD
Ah I see why it's O(1) now
It calls a dunder method __len__ instead of working like enumerate
Ah makes sense.
U just ruined my childhood
Aren't technically all dunder methods O(1)
Imma pretend like ik what O(1) is and say yes
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```
This guy just invented pep9
😂
No, I don't think so atleast? Because imagine __next__
It would be O(n)
Whats O()
Time complexity
Have to look that up tbh
Looking up rn
Oh yes yes, I’ m 100% familiar with that concept and def not looking it up rn
Why not just use numbers, saved a headache.
Soap
i agree
What about __setitem__?
That's O(1) don't even need to google
__contains__?
Not sure about that one
Those were my 2
Idk what you mean by combine.
can i make it accept "one", "two", "three" using a dictionary
How do I make a bot
ohh yeah sure
how
Lists O(n) Sets O(1)
!e ```py
answer = "two"
correct = 2
l = {"one": 1, "two": 2}
if l.get(answer) == correct:
print("yes")
@cloud dawn :white_check_mark: Your eval job has completed with return code 0.
yes
thanks
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
Function like what
If you use replit you're still using discord.py. Replit is just an online text editor/ide
still wanna know?
discord.FFmpegPCMAudio("filename.mp3")
use this as audiosource in your voice_client.play(audiosource)
first of all, have you checked the docs? 😉
thanks
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
why subclass Client
and not use the bot framework which is already a subclass of Client
!d discord.ext.commands.Bot
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.
Can somebody explain to me the advantages of subclassing your bot constructor file?
just your bot class in general?
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
Can't you do this without subclassing your bot class?
you sure can, but that's like not really as clean
Agreed
also, adding a method AFTER creating an object of that class? idk about that 🤢
You can add attributes but it's better to include them.
I know add_command exists, but that's a different subject
better handling overall
Provides an easier way to extend the class
^
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
on interaction edit the msg with the author
Hey I have a flask server that receives webhooks, how can i send the webhooks data through a discord bot
That the button will be private only to a certain voice
iirc
await interaction.response_edit_message(f"{interaction.author.mention} has pressed the button")
flask is sync code though
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
should probably be in here somewhere
https://gist.github.com/InterStella0/b78488fb28cadf279dfd3164b9f0cf96
Ok thank you
!d discord.CategoryChannel.channels
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.
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
Why is it **args when It's keyword-arguments due to the double asterisk?
that aswell
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
check this bot
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.
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
the message needs to be a discord.Message object, so just pass message variable in the create_thread for the message kwarg
!d discord.TextChannel.threads
property threads: List[discord.threads.Thread]```
Returns all the threads that you can see.
New in version 2.0.
Uh
Not sure if you wanted that
Just took a blind guess
@slate swan It's not
!d discord.Thread
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.
There
You can check out all the attributes
No, you'll need a discord.Thread object
discord.py is oop
Not entirely sure but it might be this
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
how do i mention a role and it actually ping people
!d discord.Role.mention
property mention: str```
Returns a string that allows you to mention a role.
IIRC your bot needs to have perms to ping the role though
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".```
No clue. Never worked with them
That's not how you type hint
alright
you type hint a obj
You would have mention: discord.Role and then you would mention it with mention.mention
But rename your variables
ok
and you arent following pep8
If you're going to say that you should probably specify which part
the closing ) shouldnt be in the same line as the color kwarg it should be in a new line

alright
Returns an object responsible for handling responding to the interaction.
Are you looking for something specific?
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
Just checked you can
Inter Process Communicating
It's the method used by auto sharded bots and for making dashboard exchange data
Maybe its too late for this
same
I'm just working on my wall paper command
I'm avoiding my custom help command
You need an id
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
Ik, was just telling you
Nah I meant that I should probably go to sleep
Haha
No, as long as they defined bot
Mind hovering over the red line?
It will tell the error
!d discord.Client.get_channel
get_channel(id, /)```
Returns a channel or thread with the given ID.
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
Because it isn't iterable
Never knew they are doing it
!d discord.TextChannel.threads
property threads: List[discord.threads.Thread]```
Returns all the threads that you can see.
New in version 2.0.
Probably a type-checker error since you are using a type checker
Mind showing the error?
get_channel can return VoiceChannel | TextChannel | etc
discord.__version__
You need to make sure the instance is an instance of TextChannel
Your type-checker won't know unless you validate it
Yea
@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
!d discord.TextChannel.archived_threads
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.
Note, returns an async iter
may u help me?
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?
Perhaps the gateway doesn't give this information?
Hmm could be
"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
!d discord.on_thread_update
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.
!d discord.on_thread_remove
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.
!d discord.on_thread_delete
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.
What are these both tho?
Got no dispatch when I archived a thread
Sad
!d discord.Thread.edit
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.
archived = False
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
property mention: str```
Returns a string that allows you to mention the member.
!d discord.ext.commands.dynamic_cooldown
@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.
Indeed
I'm going to finish my wallpaper command and then sleep
What's that 👀
Told you yesterday, or you can implement a cooldown by yourself
PoV: He missed your answer
that didn't work out
@pliant gulch I got the way
Then self-implementation of a cooldown, easiest solution
!d discord.Message.pin
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.
this is better i can take message and then check if the user is donator and return the seconds
What
Cool then
We can use thread.archived or smth in the update event, ig? I don't really know much about thread events
@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
Wait, how does dpy return archived_threads then? Fetches from the API?
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
Use the json module, oof
But I just tested it, logically how would you check thread.archived in THREAD_UPDATE if it isn't dispatched on archive
i am using it
;-; write and read arent ideal for json files
!d discord.on_thread_update gives u the thread objects of before and after
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.
Did you read the last part of my message
!d json.dump
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.
how so? it worked when i tried using it outside the file. anyway could you help me with my issue then?
json module is just an easier interface to work with JSON files
https://www.geeksforgeeks.org/reading-and-writing-json-to-a-file-in-python/ in this website they used the normal writing and reading function
so how do i write my data then
okay
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)
Use the join method on the list
In the description
!join
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'
😬
wdym
