#discord-bots
1 messages · Page 698 of 1
await message.reply(link.url)
i remember having this error before though
Invite implements __str__ to return self.url
hm
discord/invite.py lines 433 to 434
def __str__(self) -> str:
return self.url```
oh mb
discord/abc.py line 1332
content = str(content) if content is not None else None```
@heavy folio Just ping me once you're ready : )
!d discord.TextChannel.create_thread
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.
!d discord.TextChannel.create_invite
await create_invite(*, reason=None, max_age=0, max_uses=0, temporary=False, unique=True, target_type=None, target_user=None, target_application_id=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates an instant invite from a text or voice channel.
You must have the [`create_instant_invite`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.create_instant_invite "discord.Permissions.create_instant_invite") permission to do this.
were there any errors btw
<@&831776746206265384> one of you dm me i need something important to say
just for you to take note you should fix the dict's indents
If you'd like to report something to the moderation team, please DM @novel apex.
We will not do that, please find a way to DM the bot.
i can not do that
Why not?
You only need to turn it on for the length of the conversation.
i need to report a user
Is there anyway to see your webhooks past message history?
Like everything your webhook has said, even in deleted channels?
idts
This should be correct ```py
@client.command() #v1
@commands.has_permissions(kick_members=True)
async def alert(ctx, *, msg):#ALERT
data = {
922874978528034886 : [922875504959295579, 922874978528034888], #Banger Alerts / Server ID, Channel Name, Role ID
884931761610563595 : [921234942405525504, 884974424468623411], #Bangers Den / Low Float
884931761610563595 : [921890822100758528, 884974424468623411], #Bangers Den / Bangers Mid Large
}
for guild_id in data.keys():
guild = discord.utils.get(client.guilds, id=guild_id)
channel = discord.utils.get(guild.channels, id=data [guild_id][0])
role = discord.utils.get(guild.roles, id=data [guild_id][1])
embed=discord.Embed(title= ':moneybag: **Alert** :moneybag:', description= (msg), color=0x00FF00, timestamp=datetime.datetime.utcnow())
embed.set_thumbnail(url='https://cdn.discordapp.com/attachments/872295537544679484/922881014852898826/IMG_20211221_001839.jpg')
embed.set_footer(icon_url = ctx.author.avatar_url, text='Powered by Duck Programming',)
await channel.send(content=f"{role.mention}")
await channel.send(embed=embed)
are there any errors
do you have an error handler?
K got it but it prints out "None" eventho I have a accent color
@heavy folio No errors and no error handler. It just prints out "None"
@bot.command()
async def mutes(ctx):
print(ctx.author.accent_color)
Nope
I was thinking is it because how i Loop it?
think i found out why but now i'll test it out
Ahh alright ^^
it's only loading 1 channel per guild
can i know why you need the button btw
ButtonStyle.URL doesnt exist, neither does ButtonStyle.url
!d discord.ButtonStyle.link
Represents a link button.
Oh ignore that button, I forgot to remove that ^^
oh alr
Oh
Shit
How do I replace that to make it multiple?
sorry for the confusion i get what your trying to do now
so in the dict, key is guild id, then for the value, there's a list, 1st would be channel id, 2nd would be role id, am i right?
Yes.
data = {
922874978528034886 : [922875504959295579, 922874978528034888], #Banger Alerts / Server ID, Channel Name, Role ID
884931761610563595 : [921234942405525504, 884974424468623411], #Bangers Den / Low Float
884931761610563595 : [921890822100758528, 884974424468623411], #Bangers Den / Bangers Mid Large
}
For this, Left is GUILD, middle is CHANNELS, right is ROLES
alr
just tested and it only sent to one channel for me as well, i'll try and find some fix
I also wanted to add multiple roles aswell and i knew an issue would persist so I'm troubleshooting this one too currently
Man ur goated if u could solve that, I've been reseraching since yesterday no luck. Led me here
FYI, you overwrite the key 884931761610563595, so that the value is always [921890822100758528, 884974424468623411]
That would be why it's only sending in one channel
!e ```py
mydict = {"A": 1, "A": 2}
print(mydict["A"])
@pliant gulch :white_check_mark: Your eval job has completed with return code 0.
2
hey guys
i need help
how do i make an on_reaction function that also gets a reaction object, and user/member object?
i tried to do this-
but it didn't run the event when i reacted
so what do i do then?
discord.on_reaction_add(reaction, user)```
Called when a message has a reaction added to it. Similar to [`on_message_edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message_edit "discord.on_message_edit"), if the message is not found in the internal message cache, then this event will not be called. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") instead.
Note
To get the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") being reacted, access it via [`Reaction.message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Reaction.message "discord.Reaction.message").
This requires [`Intents.reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.reactions "discord.Intents.reactions") to be enabled.
Note
This doesn’t require [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") within a guild context, but due to Discord not providing updated user information in a direct message it’s required for direct messages to receive this event. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") if you need this and do not otherwise want to enable the members intent.
Similar to on_message_edit(), if the message is not found in the internal message cache, then this event will not be called. Consider using on_raw_reaction_add() instead
i did
but when i passed user as an argument it just said user is an pos argument that wasn't passed
look at the docs for the raw event (to see what arguments it takes)
Yeah thats what i found out too, do you know any work around for it?
Perhaps change the way you store them
E.g ```py
data = {guild_id: {channels: [1, 2], roles: [1, 2]}}
This way, you just need to access data[guild_id], get iterate through channels and roles
Oh wait so with doing just this
I wouldn't need these anymore ```py
channel = discord.utils.get(guild.channels, id=data [my_list][0])
role = discord.utils.get(guild.roles, id=data [my_list][1])
Mhm, instead of hardcoding you'd iterate
This also means you can send multiple roles now as well
OHHH
Also consider sending your two messages in one call
This saves an API call
which is always good,
You can just do send(mention, embed=embed)
so I can just safely remove ```py
await channel.send(content=f"{role.mention}")
await channel.send(embed=embed)
and replace it with
send(mention, embed=embed)
await channel.send
Yep
Make sure you pass role.mention as well, not just mention it was a placeholder for my example
You don't need to f-string it either, mention already returns a string
await channel.send(content=f"{role.mention}" ,embed=embed)

await channel.send(role.mention, embed=embed)
Yep
So you'd suggest this way right
Yes, then iterate through channels, call utils.get etc same as you did earlier, instead of hard coding the index you iterate that is all
@client.command() #v1
@commands.has_permissions(kick_members=True)
async def alert(ctx, *, msg):#ALERT
data = {922874978528034886: {channel: [921234942405525504, 921890822100758528], roles: {884974424468623411,84974424468623411 }}
for guild_id in data.keys():
guild = discord.utils.get(client.guilds, id=guild_id)
channel = discord.utils.get(guild.channels, id=data [my_list][0])
role = discord.utils.get(guild.roles, id=data [my_list][1])
embed=discord.Embed(title= ':moneybag: **Alert** :moneybag:', description= (msg), color=0x00FF00, timestamp=datetime.datetime.utcnow())
embed.set_thumbnail(url='https://cdn.discordapp.com/attachments/872295537544679484/922881014852898826/IMG_20211221_001839.jpg')
embed.set_footer(icon_url = ctx.author.avatar_url, text='Powered by Duck Programming',)
await channel.send(role.mention, embed=embed)
Something like this right, but i just gotta fix the indentation?
@pliant gulch
and can u refresh my mind with what iterating is again? I'm sorry I haven't really coded for a few months now. I've been focusing on trading stocks and i wanted to create a bot so i could alert to multiple servers
!e ```py
data = {1: {"channels": [1, 2], "roles": [1, 2]}}
for guild_id, alert_data in data.items():
channels = alert_data["channels"]
roles = alert_data["roles"]
print(guild_id, channels, roles)
I have 2 on_message events but one of them doesn't work? Like it doesn't react to anything. The other one works fine
@pliant gulch :white_check_mark: Your eval job has completed with return code 0.
1 [1, 2] [1, 2]
@final garnet CC
Now you have the guild_id, the channel ids, and the role ids
You then get the guild instance via utils.get
Then iterate channels & roles to get their respective objects
Then send
wait let me try it
@pliant gulch
@client.command() #v1
@commands.has_permissions(kick_members=True)
async def alert(ctx, *, msg):#ALERT
data = {1: {"channels": [1, 2], "roles": [1, 2]}}
for guild_id, alert_data in data.items():
channels = alert_data["channels"]
roles = alert_data["roles"]
guild = discord.utils.get(client.guilds, id=guild_id)
embed=discord.Embed(title= ':moneybag: **Alert** :moneybag:', description= (msg), color=0x00FF00, timestamp=datetime.datetime.utcnow())
embed.set_thumbnail(url='https://cdn.discordapp.com/attachments/872295537544679484/922881014852898826/IMG_20211221_001839.jpg')
embed.set_footer(icon_url = ctx.author.avatar_url, text='Powered by Duck Programming',)
await channel.send(role.mention, embed=embed)
Something like this?
Iteration are loops right? SO i can use for loops ? @pliant gulch
yes
for channels in roles
something like this? @pliant gulch , working on it
I’m making a help command, but when the user mentions the bot, it sends it in dms but it’s not working can I have help
@commands.Cog.listener()
async def on_message(self, message):
if self.client.user.mentioned_in(message):
await message.channel.send(MyHelp)```
!e
for number in range(6):
print(number)
@final garnet :white_check_mark: Your eval job has completed with return code 0.
001 | 0
002 | 1
003 | 2
004 | 3
005 | 4
006 | 5
@pliant gulch Not defined?
then define channel
How do you iterate it?
I'm kinda embarassed with myself rn for tonight, The knowledge I used to have isn't rolling in
whats not working? errors?
also what i understand here is if someone mentions the bot, it'll send the help command? in dms or in the channel
show
In dms
It just sent this
so ping anywhere, it'll send in dms?
Yeah
yeah because you cant just send a class 
That’s what I want it to do
So what I put there
!d discord.ext.commands.Bot.get_context
await get_context(message, *, cls=<class 'discord.ext.commands.context.Context'>)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Returns the invocation context from the message.
This is a more low-level counter-part for [`process_commands()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.process_commands "discord.ext.commands.Bot.process_commands") to allow users more fine grained control over the processing.
The returned context is not guaranteed to be a valid invocation context, [`Context.valid`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context.valid "discord.ext.commands.Context.valid") must be checked to make sure it is. If the context is not valid then it is not a valid candidate to be invoked under [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").
use this to get context, py ctx = await bot.get_context(message)then ```py
await ctx.send_help()
Oh
Where do I put the first one?
in your listener...
hmm
Sorry for the ping 
not sure bout that
Oh
no.
first of all
you can do it like that
?
don't see anything wrong there
but
the easiest way to do
is by calling it in your async
like so
he is though?
?????
it will excluded all the checks you have in your help command
every single discord.py bot ive seen, calls ctx in the async.
sigh
not with a variable
lmao.
It's an on_message event.......
why'd i be dumb enough to use get_context if i can pass ctx as a param in the func
I don't even know why I get this lol , no idea what bot they are talking about
idfk.
but ctx works the same as if you made it a variable
!d discord.on_message
discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") is created and sent.
This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.
Warning
Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
now tell me where the ctx comes from
@slate swan clear your pings pls 🙏
lmfao
Too lazy to do that lol
shut the fuck up
if it's a command i wont even touch get_context 
no you :p
bruh
alr.
i didn't realize it was in on_message so i apologize.
xD dudes getting mad because he gives misinformation
stop line splitting btw
me and him are friends lmao
chill out, you dont wanna get muted like the last guy 💀
💀
imagine checking #message-change-log lmao
!d discord.Member.avatar
property avatar```
Equivalent to [`User.avatar`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.avatar "discord.User.avatar")
This only even works because of the existence of get_context so either way you are doing the same thing except one is used for lower level cases
How can I get a WHOLE file's text?
hi
open the file , and use reading operations depending on the type of file
if its a txt file , read/readlines will be enough
wrong channel
waits for "but its for a discord bot"
People always say that, and I always reply if you would call your plumber because you broke some tiles in your bathroom
how to add hyperlink on embed footer
i dont think you can hyperlink in footers
!e
for guild_id, alert_data in data.items():
channels = alert_data[channels[0]
roles = alert_data[roles[1]
guild = discord.utils.get(client.guilds, id=guild_id)
print(channels)
@final garnet :x: Your eval job has completed with return code 1.
001 | File "<string>", line 3
002 | channels = alert_data[channels[0]
003 | ^^^^^^^^^^^^^^^^^^^^^^^^^^
004 | SyntaxError: invalid syntax. Perhaps you forgot a comma?
!e
for guild_id, alert_data in data.items():
channels = alert_data[channels[0]
roles = alert_data[roles[1]]
guild = discord.utils.get(client.guilds, id=guild_id)
print(channels)
@final garnet :x: Your eval job has completed with return code 1.
001 | File "<string>", line 3
002 | channels = alert_data[channels[0]
003 | ^^^^^^^^^^^^^^^^^^^^^^^^^^
004 | SyntaxError: invalid syntax. Perhaps you forgot a comma?
@final garnet #bot-commands bruh
oh shi
if not message.author.bot:
return
if "hello" in message.content :
await message.channel.send(message.content)
else:
return
why return
whats wrong?
guys this makes bot the start spamming hello
remove the not keyword
then try again
i want it only respond if the message sent by a webhook
the if statement will proceed if the condition was true, message.author.bot was true
how do i do that
check if its a webhook
!d discord.Webhook
class discord.Webhook```
Represents an asynchronous Discord webhook.
Webhooks are a form to send messages to channels in Discord without a bot user or authentication.
There are two main ways to use Webhooks. The first is through the ones received by the library such as [`Guild.webhooks()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.webhooks "discord.Guild.webhooks") and [`TextChannel.webhooks()`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel.webhooks "discord.TextChannel.webhooks"). The ones received by the library will automatically be bound using the library’s internal HTTP session.
The second form involves creating a webhook object manually using the [`from_url()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Webhook.from_url "discord.Webhook.from_url") or [`partial()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Webhook.partial "discord.Webhook.partial") classmethods.
For example, creating a webhook from a URL and using [aiohttp](https://docs.aiohttp.org/en/stable/index.html "(in aiohttp v3.7)"):
yo kale
yo acey
can i have some kale?
im out of kale
;-;
You're missing a ] and you cannot do what you're doing
if message.webhook_id:
if "hello" in message.content :
await message.channel.send(message.content)
is this correct ?
i guess
ok thx
How would this even work?
the webhook link can be anything
what would work
Where would you get the web hook instance firstly, secondly that syntax isn't right
And how does this even allow for you to check if a message was from the webhook?
message.author
thats what the equality operator is for?
Message.author will be a webhook instance???
🤔
Also fourthly that's not how you check if a object is a type of object
You'd use isinstance
it will be a User obj
check if its a user then? i havent even confirmed this yet and obviously sarthak did
Why are you giving information that you didn't even bothered to check then
i wouldnt have time to check even
because they needed help
And then you decided to give false information and correct on them when they were doing the right thing in the first place
Great help
¯\_(ツ)_/¯
is it ok to check for the guild id in sqlite databse inside on_message function ? its gonna query the database everytime somebody send some message in the server
can sqlite handle it ?
Yes it can very much handle that
Databases are meant to be queried a lot /can be
If you want to save resources you can also cache the database
i am thinking of querying the database after checking if the message is a webhook and it contains what i want...that cut the queries by a lot.
i dont know about it...i will try to read on it
Basically just make a dict, inside of your on_message check if the guild’s id is inside of the dict if it is return that else query the database, add a new key value pair (guild id, data) to the dict
Now any future on_messages from the guild have the data cached and can just return that
You just need to make sure you update the cache everytime you make an operation on the database that modifies the corresponding data so that is it “up to date”
👍
Is there a bool to check if an invite is valid?
channel = discord.utils.get(bot.get_all_channels(), name="title-status")
its not working for me...its mixing differnt servers
Then define your Guild
Get all channels gets every channel in every server the bot is in
Do guild.channels or something
@bot.listen()
async def on_message(message):
if not message.webhook_id:
return
if "hello" in message.content :
channel = discord.utils.get(bot.get_all_channels(), name="title-status")
await channel.send(message.content)
channel = discord.utils.get(bot.guild.get_all_channels(), name="title-status")
like this ?
So what r u trying to do
if there is a webhook with message hello comes in the server...send that webhook to channel named title-status
And what’s happening?
its mixing all servers
it detects message from other servers and send that message to channel names title-status
discord.utils.get(message.guild.get_all_channels(), name="title-status")
is it correct ?
Is the channel in a specific guild?
it should be in every guild
since you want the channel from only in the server message was sent use message.guild.channels
^^^
no
Take out the parenthesis after channels
its a property . not a method remove the braces
pleasure
user = get(bot.get_all_members(), id="1234")
is this correct way to get a username by its id
if you have id , just use bot.get_user(id).name
ok thx
Ummm how is that related to discord bots
why not use the bot.get_* methods? rather than iterating through everything?
get_* methods are O(1) while utils.get is much much slower
it's also unwieldy and frankly unnecessary
Not true sorta
All get_ methods are O(n) not all but a decent chunk*
I'll check again it might not be all but I do remember most of them being
Pretty sure they are O(1) cause they are just getting something out of a dictionary
Checked get_guild get_emoji get_member get_user are O(1)
Just checked some more they are O(n)
I do remember somewhere about people saying how most get_ methods are O(n)
And get_stage_instance
Kinda weird how some of them are O(n) when they could be O(1)
And get_sticker
I was checking the pre 2.0 docs so I missed out on those
Fair
https://github.com/Rapptz/discord.py/blob/45d498c1b76deaf3b394d17ccf56112fa691d160/discord/state.py#L1381-L1393 No reason for this to be O(n) though
discord/state.py lines 1381 to 1393
def get_channel(self, id: Optional[int]) -> Optional[Union[Channel, Thread]]:
if id is None:
return None
pm = self._get_private_channel(id)
if pm is not None:
return pm
for guild in self.guilds:
channel = guild._resolve_channel(id)
if channel is not None:
return channel```
This could be easily O(1)
As in discord you don't need the guild's id which the channel is present in
You just access via discord.com/api/v9/channels/channel_id
You should be able to just store a global cache of channels
Guess this is the reason why get_channel is O(n)
scraping?
The bot uses the github API
hm
Hi
is there any code for the new timeout feature ?
disnake/pycord has it
oh alright
so would await ctx.guild.timeout work?
Timeouts are like mutes for members
!d disnake.Member.timeout
await timeout(*, duration=..., until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Times out the member from the guild; until then, the member will not be able to interact with the guild.
Exactly one of `duration` or `until` must be provided. To remove a timeout, set one of the parameters to `None`.
You must have the [`Permissions.moderate_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.moderate_members "disnake.Permissions.moderate_members") permission to do this.
New in version 2.3.
no?
hi
import discord
from discord.ext import commands
import asyncio
a=0
class MyClient(discord.Client):
def
__init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# create the background task and run it in the background
self.bg_task = self.loop.create_task(self.my_background_task())
async def on_ready(self):
print(f'Logged in as {self.user} (ID: {self.user.id})')
print('------')
async def my_background_task(self):
await self.wait_until_ready()
channel = self.get_channel(12222222111)
while not self.is_closed():
# counter += 2
await channel.send( a)
await asyncio.sleep(2) # task runs every 60 seconds
#stop sending messages after 10 messages
client = MyClient()
for i in range (0,10):
client = MyClient()
client.loop.create_task(client.my_background_task(i))
client.run('xxxxxxxxxxxxxxx')
Hi, I'm trying to sent a message with the value of i to a discord chanel, but I don't know why isn't working
is that even a valid channel ID
I just put random numbers, just as example for here
R u getting any errors
yes
What errors?
How do I make this send to dm and respond with “you’ve got mail!” or something in the channel?
@commands.Cog.listener()
async def on_message(self, message):
ctx = await self.client.get_context(message)
if self.client.user.mentioned_in(message):
await ctx.send_help()```
ctx.author.send and ctx.send?
my_background_task() missing 1 required positional argument: 'i'
What line?
20
Can u write the code for the line. I’m on my phone so I can’t see the code well
I see
Can you screenshot the error @stuck parrot
it requires an argument
alright thx a lot
In the def __init__ you call it without any arguments
wdym
you don't have an example so I can maybe use it for reference??
pass in an argument when calling the function
since discord wants every verified dev to have slash commands in his bot and discord.py doesnt supports slash commands is there any other library where I can combine dpy and add slash commands in my bot?
you know how to call a function but not pass args to one
Yeah he’s not passing in any arguements
slash_util, forks (disnake, pycord)
can you pls pass me an example??
@stuck parrot so u have a required arguement in my_backgrounf_task. In the def init ur calling it without passing in the arguement
typos
Just pass in an arguement
ok,thanks
Btw which intent for on_guild_channel_delete event . Anyhelp?
guild intents
import pyautogui
from win32 import win32gui
import discord
import requests
def screenshot(window_title=None):
if window_title:
hwnd = win32gui.FindWindow(None, window_title)
if hwnd:
win32gui.SetForegroundWindow(hwnd)
x, y, x1, y1 = win32gui.GetClientRect(hwnd)
x, y = win32gui.ClientToScreen(hwnd, (x, y))
x1, y1 = win32gui.ClientToScreen(hwnd, (x1 - x, y1 - y))
im = pyautogui.screenshot(region=(x, y, x1, y1))
return im
else:
print('Window not found!')
else:
im = pyautogui.screenshot()
return im
im = screenshot('Calculator')
if im:
webhook = discord.Webhook.partial(123456, 'hide for now', adapter=discord.RequestsWebhookAdapter())
webhook.send('HOHO IT WORKS!', file=im)
help me ;-;
😐
It's not a dpy error
why not use commands.Bot
how to use the new timeout thingy
skeppy
what lib are you using
did you enter something in the bot description?
what's the description
nvm, it got resolved after i changed it now
oof
Oof
How do I check if a member has an avatar or not
didnt i say it clearly enough tho
i wanna check
if a member
has an avatar or not
every member has a avatar
no
u mean the
i wanna check if they have the default one
defaultdiscord pfp?
thats considered no avatar
hmm oki wait
yes
how do i timeout a member in disnake?
!d disnake.Member.edit
await edit(*, nick=..., mute=..., deafen=..., suppress=..., roles=..., voice_channel=..., timeout=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the member’s data.
Depending on the parameter passed, this requires different permissions listed below...
!d disnake.Member.timeout
await timeout(*, duration=..., until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Times out the member from the guild; until then, the member will not be able to interact with the guild.
Exactly one of `duration` or `until` must be provided. To remove a timeout, set one of the parameters to `None`.
You must have the [`Permissions.moderate_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.moderate_members "disnake.Permissions.moderate_members") permission to do this.
New in version 2.3.
i put await member.timeout(**args) but it said member object has no attr timeout
you can use the method
whats ur disnake version
its supposed to be 2.3
is it possible to make a discord activities command in python
yes
lmao
does discord.py have support for it
or do i have to use another package
await create_invite(*, reason=None, max_age=0, max_uses=0, temporary=False, unique=True, target_type=None, target_user=None, target_application_id=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates an instant invite from a text or voice channel.
You must have the [`create_instant_invite`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.create_instant_invite "discord.Permissions.create_instant_invite") permission to do this.
@night berry
ty
it has like 2 kwargs for making an activity
im not sure how to use it though, looks like you'd have to get the application id
!d disnake.Member
class disnake.Member```
Represents a Discord member to a [`Guild`](https://docs.disnake.dev/en/latest/api.html#disnake.Guild "disnake.Guild").
This implements a lot of the functionality of [`User`](https://docs.disnake.dev/en/latest/api.html#disnake.User "disnake.User").
x == y Checks if two members are equal. Note that this works with [`User`](https://docs.disnake.dev/en/latest/api.html#disnake.User "disnake.User") instances too.
x != y Checks if two members are not equal. Note that this works with [`User`](https://docs.disnake.dev/en/latest/api.html#disnake.User "disnake.User") instances too.
hash(x) Returns the member’s hash.
str(x) Returns the member’s name with the discriminator.
how to use the new timeout thing
what lib are u using
didnt you ask this earlier?
o
discord.Member.edit in pycord has a kwarg for timeout communication_disabled_until
you can use that to timeout someone
alright, thank you
Do interactions only last for 5 seconds? Or am I stupid?
well, for some reason some of my interactions only seem to work for 3 seconds
even if the user has interacted with it in the first three seconds, he can't interact with it again
show code
the user has interacted with it in the first three seconds
the user doesn't need to interact within 3 seconds, but the bot needs to send a followup (callback) to the interaction within 3 seconds
Is timeout basically user.timeout or is it different?
member.timeout(...) yes
Oh right member
oh, shit, really? that is annoying
alright, let me see if I can fix it
And how do you set time?
await member.timeout(duration=10) or await member.timeout(until=datetime.datetime(...))
thanks!
btw, what if I have a ticket support system thingy, will I have to send out a new panel every 15 minutes, because the interaction token supposedly times out?
Or will it be fine, and would still work forever, as long as the bot is online?
@visual island
umm, if you're doing things in the callback method then yes 15 minutes
if you're doing it somewhere else then no
like,
async def my_other_callback_that_will_work_forever(self):
while True:
# do stuff
async def callback(self, ...):
# do stuff
await self.my_other_callback_that_will_work_forever()
```probably?
i've never seen what ticket tool really does, but iirc they use reactions instead of buttons?
yeah, alright, thanks, I'll try to research it more
why doesn't this trigger the if statement?
@ bot.command()
@ commands.guild_only()
async def report(ctx: commands.Context, member: discord.Member, *, reason):
if member.roles in ['staff', 'Bot Developer']:
await ctx.reply("You cannot report a staff or the bot developer itself :mikebruh:")
else:
await bot.get_channel(921048882346078279).send("{} has been reported for {} by {}".format(member, reason, ctx.author))
reportSuccess = await ctx.send("Yo! Your report was sucessfully send to the staff of this server, we will get it reviewed.")
btw, shouldn't there be some kind of way to ping the panel every 15 minutes, so that the interaction token doesn't timeout?
is it possible to
first send a normal message msg = ctx.send("hello")
then edit it and add embed msg.edit(embed = myembed)
yes it is
await ctx.send
ok thnx i will give it a go then
!d discord.InteractionResponse.defer probably this will make a new session of token, I'm unsure tho, you could try (this is probably what ticket tool use)
await defer(*, ephemeral=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Defers the interaction response.
This is typically used when the interaction is acknowledged and a secondary action will be done later.
💀
try using the IDs
is hex code usable in embed ? #33CCCC this
hmm, alright
I hope it works
ok but what could role be defined as
because i think you misread my command, or does it just need a definition
remove the hashtag and add 0x before the code, your result will be 0x33CCCC which is how hex codes can be formed in embeds
how to remove this adding
yup...i tried that it worked
do content="" at your .edit
ohhh thnx
can't confirm if it works though
@velvet tinsel
oh i get what im meant to define role as now
btw, I think I just found the answer, I think I could use bot.wait_for('button_click")
and then put it into some while loop or something
!d discord.ext.commands.Bot.wait_for
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
@visual island 🧢
it works
can it be moved at the end ?
it creates this ugly gap
some event to do with buttons definitely exists, let me check
have no idea, that's just how discord goes, most people aren't probably gonna notice it anyways.
you could delete the message and send a new one, but that is just gonna take up more code space, and it is gonna be more noticeable
hey are you good at discord.py
!d discord.ext.commands.Bot.wait_for
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
because i need help
with this
yeah..its gonna cause confusion too...its takes 1-2 sec before edit happens
give me a sec
40 minutes
Lmao
If I need to store stuff in a json file for instance { "name" : ctx.author "id" : ctx.author.id } Why does it say its not serialized
@zealous dagger What do you mean take multip[le commands?
Means like
I am making a pammer
spammer bot
which spams
so I want that
If should take commands like this
s!spam "This is a spam message" 60
like multiple command line arguements?
s!spam starting command
And the quote is the message
and 60 is the number of times
that should be spammed
@hexed timber
Youll have async def spam(ctx, args1, arg2, args3) Where args1 will be spam args2 will be the message and args3 will be the time
Ok
just pass in multiple variable to the async function
Can you send a snippet
FOr bettter undertsanding
@hexed timber
I mean a sample code
That is the snippit above
if you print args1 that will print spam if you print args2 it will print the quote and if you print args3 it will pring the time
Ok
will someone help :c
You are trying to check if a list discord.Role object is in a list of strings
i tried with ids 🚎
async def on_guild_update(self, before: Guild, after: Guild):
if before.name != after.name:
db.execute("UPDATE Guild SET Name = ? WHERE GuildID IS ?", after.id, after.name)
db.commit()
Guys I have this function here inside a Cog which is supposed to be called when a guild update but nothing happens, why?
still didn't work
It should be a role object on both sides , or a int on both or string on both sides
you are checking if a list is in a list, i don't think that it work or i'm wrong?
no, im checking if an item in the list is in member.roles
atleast thats what i think
im getting no tracebacks btw
make a variable that contains the list of role names then check if one of the roles is in the list then also check if the other role is in the list
@shadow wraith do you have any error handling?
no no you are doing like this:
lst1=[1,2]
lst2=[2,3]
if lst1 in lst2:
#something
member.roles is the list of all roles that a member has
!e
list1 = [1, 2]
list2 = [3, 2]
if list1 in list2:
print("works?")
@shadow wraith :warning: Your eval job has completed with return code 0.
[No output]
see? xD
didn't i add an else statement?
shouldent it be something like roles = [role1, role2] if(role1 in role or role2 in role)
you can check if a variable is in a list but not if a list is in a list
someone has a solution for this?
!e
list1 = [1, 2]
list2 = [3, 2]
for item in list1:
if item in list2:
print("test?")
I got no clue for that one bruv
@shadow wraith :white_check_mark: Your eval job has completed with return code 0.
test?
huh so for loop would be working in this case
load it
what's wrong
wym?
no i fucking figured out something 💀 btw what happened to js in python you havent coded in that repl for a while
It is loaded bro...
well......I was hungry
anyone know this problem?
~~bro 💀 ~~
full traceback
Because in the query you check where the GuildID is guild.name
why tf is it not loading
@velvet tinsel ```Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/usr/local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/usr/local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Object of type Member is not JSON serializable
"name" : ctx.author,
"id" : ctx.author.id,
"money" : 0
}
print(my_json)```
Running setup...
loadin general
general loaded
loadin test
test loaded
running bot...
bot connected
general ready
test ready
Bot ready
See? when i run the bot i have this function that tells me if the cogs i have are loaded or they have some error, the coge in that function is general
a quite creepy smile do I consider myself dead?
no bro the function never executes, i checked it with debug
Do you have the listener decorator above it ? And guild intents
coge 😭 and ok
I still get an error when I tried that
I looked at the overflow already
can I not serialize it the way im doing it?
? lol
what's the full code
you wrote coge 🚶♂️
insert str(ctx.author) into it,. Not the object
i'll send from paste bin
https://pastebin.com/0dQnu9rn here @velvet tinsel
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
You miss the listener decorator
@slate swan my_json = { "name" : str(ctx.author), "id" : str(ctx.author.id), "money" : str(0) } print(my_json) Like this?
As I said earlier
Yea sure
i tried with it too lol same thing
i'll add it again
Apply the decorator , and in the code change py db.execute("UPDATE Guild SET Name = ? WHERE GuildID IS ?", after.id, after.name) to
db.execute("UPDATE Guild SET Name = ? WHERE GuildID IS ?", (after.name , after.id))```
tried using a for loop
role = [912631582681092117, 914534709986467890]
for item in member.roles:
if role in member.roles:
await ctx.reply("You cannot report staff :mikebruh:")
break
else:
h = bot.get_channel(921048882346078279)
await h.send("{} has been reported for {} by {}".format(
member, reason, ctx.author))
await ctx.send("Yo! Your report was sucessfully send to the staff of this server, we will get it reviewed.")
break
apparently, you can still report peopple with the roles, the if statement cannot and will not be triggered for some reason :c
No it is not that i will show you in a minute why, btw it don't call even with the decorator
hurr?
what
for role in member.roles:
if role.id in [the list].....```
Basic python
just use ` ` instead of ```
what's wrong
fuck your right 💀
def execute(command, *values):
cur.execute(command, tuple(values))
This is the execute script, it turns my values into a tuple
so it is not that, as i said the on_guild_update doesn't even run
values is already gonna be a tuple tho
Lol that's true xD
!e
def b(*x): return x
print(b(1))
@boreal ravine :white_check_mark: Your eval job has completed with return code 0.
(1,)
And do you have guild intents?
whats the point of casting it
They are enabled by default
Yes i checked, I have enabled them all xD
Ok It was the order of the variable
wait what would role be defined as because lists in discord.py don't really have a .id default value no?
but why in the debug i haven't never seen it step up into the function?
it's the id of the role?
reread, i don't think role has a definition in this case (in terms of code 💀 )
unless your talking about that list
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
member.roles is a list of roles and in iterating thru it
bro what
true true
im not asking for help
lmao I know
!e py for meh in [1,2,3]: print meh is what I'm doing
it looks ugly if you don't use ```
bro it's not python 1.0 🚶♂️
Kill me already
<@&831776746206265384> ban!!
What role is that?
did you just fail to joke ping mods?
yes
Nah , edits don't actually ping a role/user
^
lma
they do ping but dont send the voice notif or phone notif
I thought it was the GuildID , to ping everyone
bro 😭
Not the ping either
are you gonna code in the repl tho or something
it "tags"
Ofc
good morning
it's almost night (not in my native country rn 💀)
5 pm for me too
yeah
for me it's 5:08 pm
you in india?
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
yeah NVM me
who's fronto now 
@commands.command()
async def to(self, ctx, member: disnake.Member, duration: int, reason: str = None):
if reason is None:
reason = "You have been timed out from guild due to moderation actions."
await member.timeout(duration)
await ctx.send("Working")
``` I tried passing a reason as well but it did not work. error: https://paste.pythondiscord.com/xaqesanoya.sql
Docs are here if anyone wondered: https://docs.disnake.dev/en/latest/api.html#disnake.Member.timeout
oh
oh
thx! it worked, now I just need to get the correct perms
it takes an int?
float or event a datetime object would work ,with until= datetime
works with int*
now I have working timeout system!
Maybe I need to add some db logs to it sadly
await timeout(*, duration=..., until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Times out the member from the guild; until then, the member will not be able to interact with the guild.
Exactly one of `duration` or `until` must be provided. To remove a timeout, set one of the parameters to `None`.
You must have the [`Permissions.moderate_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.moderate_members "disnake.Permissions.moderate_members") permission to do this.
New in version 2.3.
so the other kwarg in the edit method takes a datetime.datetime object? or am i missing something
disnake docs are supported by python?!
can take both an int and a datetime object
o
yes
yes
nextcord's too
oo
!d
not pycord tho because it's a shit lib that no one should use 
Does this message look good or should it be smth else?
good grammer.
oh I must add duration to message
kinda sucks how timeouts only work up to 28 days, reason why i'll keep using the mute i was using until now 
I will use both features, for short mutes and stuff I think timeout is good, but longer ones should be handled by muted role
?
amazing grammer of corse
i don't like correcting but it's grammar, not grammer
it was sarcasm but ok
oh my bad then, didn't understand it
I don't like correcting but it should be a capital "I", not a lowercase "i" at the start of a sentence
why are you so offended lmao
naww I was joking lmao
.
anyways we are getting a little bit off-topic let's talk about discord bots before minaberry kicks us out
.catify
.catify
and that's true... lol
lib?
what lib r u using
Library , and Library version?
lib 🙂
what do I need to use?
disnake, latest version
what are you using?
Disnake v 2.2.3
What you want to do?
so i need to import disnake?
v2.3*, 2.2.3 doesn't have it
i was using discord ;-;
Oh
It's already dead uk
yeah
dpy- that's outdated and dead asf why u still using it 💀
i was too used to it
you ain't gonna get anywhere if you don't switch because of that 
shall I just uninstall and install disnake again to update it or is there a better way? Yes I know this is a dumb question
!e
from random import choice
class Cat:
def catify(self):
cats = ["fat cat", "short cat", "long cat", "pop cat", "thin cat"]
return choice(cats)
kraots = Cat()
kraots.catify()
print(kraots)
pip install -U disnake
alright thanks
shit
How can I get path to those cogs folder? ```py
───MyBot
│ ├───cogs
│ │ ├───moderation
│ │ │
│ │ ├───other
#bot-commands
Got confused by this lol
@velvet tinsel :white_check_mark: Your eval job has completed with return code 0.
<__main__.Cat object at 0x7f9d72147c10>
ah
it depends from where you load the cogs
"https://github.com/Nipa-Code/NipaBot/MyBot/cogs/{filename}#L{first_line}-L{end_line})"
``` I need to use it to find a correct folder after `cogs` folder
you can use glob or other package to get all files from the directory which has the .py extension
files? I have to get the folder after cogs
So you have other folders inside your cogs folder?
yes,
this is the structure
some cogs are in folder cogs others are in those 2 folders, moderation/other
yeah but that says nothing lol
if you have other cogs in that folder inside your cogs folder then you have to load them from that folder
ok so you need a script which read everything inside the cogs folder and then if it finds another folder, get in it and then read the name of the cogs and load it from that folder path
https://docs.python.org/3/library/glob.html this package maybe can help you do that
my_command = self.bot.get_command(command)
``` I got the command, but how do I get the cogs folder name it is in
wdym by loading?
Wait it is not clear what you want to do bro
command.callback.__code__.co_filename maybe?
I'm making a source command for my bot
yeah use that
Well then the discord.py package has some methods for that, i will search them wait
this gets the cogs folder where command is in it?
yes
oo
!d discord.ext.commands.Command.cog
The cog that this command belongs to. None if there isn’t one.
@tawdry perch
Or this
it gets the cog class not cog folder
it's the same except that this one get all the commands from that cog
returns something like this
And this one get the cog lol
oh thx I'll try them out
so it would be smth like this? ```py
folder = commands.command.Cog
^
this returns the Cog object not the filename/path
I'm trying to get the category part in the help command to work, but seems like it doesnt
why wont it let me import client from discord.ext ?
because it's not a valid file/folder?
actually wait
it's because
you need to change it to this:
how does the timeout command work?
from discord import client
what does the until argument take
!d disnake.Member.timeout
await timeout(*, duration=..., until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Times out the member from the guild; until then, the member will not be able to interact with the guild.
Exactly one of `duration` or `until` must be provided. To remove a timeout, set one of the parameters to `None`.
You must have the [`Permissions.moderate_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.moderate_members "disnake.Permissions.moderate_members") permission to do this.
New in version 2.3.
so there's duration also huh
Ye
It's just a datetime obj
new to datetime but what input do you give for the until argument? 🤨
You give it a datetime obj, the docs explains it better
For duration you give a int or a float
oh so you say time out someone until say 5:30?
If it's a datetime obj it would work
appreciate it man thanks
Np, gl
Are you sure? In the docs online it is said that duration needs a datetime obj
what docs are you saying
I'm sure
See what?
duration
and duration takes in seconds?
Ye, you can pass for example 10 and it means 10 seconds timeout
Thanks
class Commands(client.Cog):
AttributeError: module 'discord.client' has no attribute 'Cog'
dont know whats wrong
!d discord.ext.commands.Cog
class discord.ext.commands.Cog(*args, **kwargs)```
The base class that all cogs must inherit from.
A cog is a collection of commands, listeners, and optional state to help group commands together. More information on them can be found on the [Cogs](https://discordpy.readthedocs.io/en/master/ext/commands/cogs.html#ext-commands-cogs) page.
When inheriting from this class, the options shown in [`CogMeta`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CogMeta "discord.ext.commands.CogMeta") are equally valid here.
It's not a part of Client
@bot.command(help="Play with .rps [your choice]")
async def rps(ctx):
rpsGame = ['rock', 'paper', 'scissors']
await ctx.send(f"Rock, paper, or scissors? Choose wisely...")
def check(msg):
return msg.author == ctx.author and msg.content.lower() in rpsGame
user_choice = await bot.wait_for('message', check=check)
comp_choice = random.choice(rpsGame)
if user_choice == 'rock':
if comp_choice == 'rock':
await ctx.send(f'Well, that was weird. We tied.\nYour choice: {user_choice}\nMy choice: {comp_choice}')
elif comp_choice == 'paper':
await ctx.send(f'Nice try, but I won that time!!\nYour choice: {user_choice}\nMy choice: {comp_choice}')
elif comp_choice == 'scissors':
await ctx.send(f"Aw, you beat me. It won't happen again!\nYour choice: {user_choice}\nMy choice: {comp_choice}")
elif user_choice == 'paper':
if comp_choice == 'rock':
await ctx.send(f'The pen beats the sword? More like the paper beats the rock!!\nYour choice: {user_choice}\nMy choice: {comp_choice}')
elif comp_choice == 'paper':
await ctx.send(f'Oh, wacky. We just tied. I call a rematch!!\nYour choice: {user_choice}\nMy choice: {comp_choice}')
elif comp_choice == 'scissors':
await ctx.send(f"Aw man, you actually managed to beat me.\nYour choice: {user_choice}\nMy choice: {comp_choice}")
elif user_choice == 'scissors':
if comp_choice == 'rock':
await ctx.send(f'HAHA!! I JUST CRUSHED YOU!! I rock!!\nYour choice: {user_choice}\nMy choice: {comp_choice}')
elif comp_choice == 'paper':
await ctx.send(f'Bruh. >: |\nYour choice: {user_choice}\nMy choice: {comp_choice}')
elif comp_choice == 'scissors':
await ctx.send(f"Oh well, we tied.\nYour choice: {user_choice}\nMy choice: {comp_choice}")
command does not respond to rock, scissors or paper
get the command first
I alrd did
it returned the whole path, how do I get the folder name that the command is in?
Output was C:\Users\nipa\projects\project\MyBot\cogs\moderation\admins.py
path.split("\")[-1]
File "main.py", line 286, in on_message
await client.change_presence(status=discord.Status.do_not_disturb, activity=activity)
File "/home/sami/.local/lib/python3.7/site-packages/discord/client.py", line 1062, in change_presence
await self.ws.change_presence(activity=activity, status=status, afk=afk)
File "/home/sami/.local/lib/python3.7/site-packages/discord/gateway.py", line 625, in change_presence
await self.send(sent)
File "/home/sami/.local/lib/python3.7/site-packages/discord/gateway.py", line 587, in send
await self.socket.send_str(data)
File "/home/sami/.local/lib/python3.7/site-packages/aiohttp/client_ws.py", line 150, in send_str
await self._writer.send(data, binary=False, compress=compress)
File "/home/sami/.local/lib/python3.7/site-packages/aiohttp/http_websocket.py", line 687, in send
await self._send_frame(message, WSMsgType.TEXT, compress)
File "/home/sami/.local/lib/python3.7/site-packages/aiohttp/http_websocket.py", line 598, in _send_frame
raise ConnectionResetError("Cannot write to closing transport")
ConnectionResetError: Cannot write to closing transport
Bot is offline
await client.change_presence(status=discord.Status.do_not_disturb, activity=activity)```
?
what
Adx , show full code
what you did there seems weird
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
you are changing your status on every message?
you're sending to many requests, dpy ratelimit handler cant handle that much request
ah
actually you are changing your status on every message 2 times
that's because of this line
user_choice = await bot.wait_for('message', check=check)
you're comparing a Message object with a string in the if statements
try changing it to this
user_choice = (await bot.wait_for('message', check=check)).content.lower()
thx,but i fix :3
and I like to speed it up sometimes by running the code on 2 diff servers
well no wonder discord hates that bot
damn its on 65 servers even tho its offline cuz of crashes 60% of the time
docs said to do so 🤷♂️
ok maybe it was stackoverflow but its almost as trusted as docs right haha
no
Stackoverflow is full of outdated and bad code
file = open("30 years old discord users"+str(ctx.guild.id), "w")
file.write("enabled")
file.close()
file = open("channel"+str(ctx.guild.id), "w")
file.write(str(ctx.channel.id))
file.close()
and what that
dude what
nice name change dude
I read the stuff and now I regret it, too many things that I did not want to see
file.write > cursor.execute
Wut no
TXT files aren't even meant to be used as database
well no shit
but it works so I use it
okay but that was not my point 😦
Sure , but this opinion is invalid
.
that's true
hm
I also prefer databases
meh, I never even learned to use dbs in python
tho I'm too lazy to make one most of the time
and my raspberry wouldn't do nothing with a database
it just crashed after downloading 55MB in 1 hour
yes
...
no you're not gonna bully the raspberry
I have used dbs, they are quite nice
scam romanian 20€/year vds 4gb ram > 20$ rasperry pi 500mb ram
Is it normal that attributes and methods of discord.Emoji don't work on emojis that are on a guild that the bot isn't on?
(I am trying to get the animated attribute of a emoji that is on a guild that bot isn't on)
raspberry is good, isn't it?
it's actually 1GB ram-
They have your token , and if you use raspberry Pi , only you have it 👌
use aioaqlite, quite easy
bro u think they gonna datamine my shit for 1 damn token?
True
incase they want an ||autoporn|| system for their discord server
I guess not, it should work if you have the object
not saying they wouldn't but I really dont care, its just a token (i have my reddit account password there too)
token which they could use to nuke 65 servers*
always better to setup yourself a physical server
!d discord.Emoji.animated
Whether an emoji is animated or not.
I have a 8gb i5 pc with ubuntu server 21.04 on it rn but haven't bothered to move all my files loll
to host a discord bot?
nah I'm gonna move my website and gameservers there too
when I have time
Don't you code the bot and stuff on the same device?
huh
I use a laptop for coding, way more comfortable to sit in bed while writing code than sitting on a damn chair
and the pc is unusable rn cuz it aint got a desktop env, only cli
I disagree, at least from my POV.
bro ur bed like one of those american prison beds or how can you think chair is more comfortable than a bed
It's more relaxing for my neck and back tbf. Btw, that's so off-topic innit?
btw can I put activity= in commands.Bot()
!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.
**options
Set the default value to none or use typing.Optional
whats the exception for
discord.ext.commands.errors.CommandNotFound: Command "commandhere" is not found
is there a way to log the timeout feature yet
?
I need try:
except:
discord.ext.commands.errors.CommandNotFound

