#discord-bots
1 messages · Page 617 of 1
Legit ctx author id wait no
Do you want a bot to send you their ID when you reply?
@urban shell would you mind showing your code
I think he means when he replies to someone it gets their ID
like, I wat to have a hug command -
to trigger it, I type - >hug while replying to a person's message
and then I want an embed to be sent saying that "@urban shell is hugging <@idOfThePersonIamReplyingto>" followed by a hugging GIF ofc
That’s message id
oh
Oooooo
after running the code, you need to force the bot to log in to the discord account and after that the bot requests a link to the server and then the following code starts working
I am new to making discord bots with Discord.py
Is there any way to get the message characters of a message that someone replied to?
As in, read the message that someone replied to; not the actual
Here
Ok and?
?
What?
What's the issue
message.reference.resolved so basically
@urban shell
Here is your answer
Leads to a message that you replied to
that's isn't helpful
I've tried going thru SO beforehand
How is that not helpful
breh
^
!d await ctx.channel.fetch_message(ctx.message.reference.message_id)
6.4. Await expression
Suspend the execution of coroutine on an awaitable object. Can only be used inside a coroutine function.
await_expr ::= "await" primary
``` New in version 3.5.
@urban shell so you need to get id of the replied message author?
how do I do this?
yes
Here
is it possible?
That’s probably what you want
message.reference.resolved.author.id
tysm 
You want it to login into a user account?
There's an easier way I just showed
does anyone know how i can add slash commands in a cog?
That doesn’t work?
They are, you’ll have to import them
They are not
In 2.0
in pycord
We are talking about stable version
Like buttons 😫
You need to use extensions
Why did they have to do this
Slash commands doesn’t even exist in 2.0. Danny literally said he was never gonna add them.
Which is 1.7.1 or something
Oh ok
Now I have to migrate all my bots to nextcord
On the master branch of the head repo. There’s no implementation of slash commands anywhere.
yes i need to know how and what extensions to use and what modules to install
should i recode my bot in js
Just use nextcord or any continued python
already installed that and i cant figure out how to use them in cogs
Are there libraries for java btw
do you want just one gif or a api for gifs
Read it
We already answered that
JDA or JavaCord or whatever that shits called
what happens if I run the code with a user token?
ah didnt see
Why are you asking in a python server if you should swap your bots code over to JS. Pretty subjective question.
I'm planning to create a list and store GIF urls in that and use the random library to send random GIFs each time
Won’t work
You get banned for self-botting
Returns with an error
Does anyone know of a simple way to retrieve a channel id from a user/members id?
Ctx channel id
There is some APIs that work perfectly, one is https://nekos.life/api/v2/img/hug if you need that
how can i delete the message with the command?
yeah cuz slash command deadline is april
oh tysm
That doesn’t work but it is ctx channel
Literally the most insufferable help conversation I’ve ever seen in my life.
So its work?
No
By getting a message object and calling delete() on it
await ctx.message.delete() ?
Doesn’t work
Wait I thought it was purge?
You can't just put a user token, there are multiple things you would have to do to make it work, for example bot = False and self_bot = True, which I don't recommend as it's against TOS
Yes it does Jesus Christ man. There’s literally a bot: bool kwarg
No that’s a method for text channel objects
I should’ve been more descriptive, I meant voice channel
Yea
await ctx.message.delete()
discord.Member.voice.channel.id
It’s not user
Users don’t have voice channels
Yay at least we have a expert around here
I’m not really an expert. I just know more than most. And most of the time if you come in here with a big problem and like 200 lines of code I’m not gonna even bother and help. Id just let some other person help.
how to nuke a channel each 3 hours?
By cloning and deleting the old one.
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
Tragic.
Ikr
Hi
Damn
Doesn't matter
Cant assume maliciousness just because he wants channel cleaned
He said he wants to nuke it every 3h
Yeah, thats a common phrase for deleting and recreating the channel
Oh
Mb then 💀
Most ppl do that to bypass client mods with messageloggers
Since they wont have the stored messages anymore
Didn't know that 🤔
what is the best database to use for a large amount of users?
Postgres
postgresql
People do it clear messages
okay thx
oh thx
Do I not exist or something….
I literally sent that a second right after they sent their initial message. It’s baffling that they didn’t see it.
lol maybe they did
but just wanted to respond to one
you never know
please dont go OT
oops
Sorry, u just didnt ping me so I was unsure if that msg was to me or someone else XD
My bad
How can I wait for a voice channel and see when x amount of members join, even if it is a temporary channel
!d discord.VoiceChannel.members
property members: List[Member]```
Returns all members that are currently inside this voice channel.
Consider using length on this for checking the amount of members.
deleting a channel and creating it again is against tos?
i don't think so.......
You don’t need to unnecessarily ping him. He was already told that.
thats not called nuke fyi
That's not what a nuke is called, a nuke is that but repeatedly in short intervals, and without the creating it again part
Atleast that's what I infer the word as
^^
Same
It usually means something malicious to me
It’s basically the same concept. When someone says they're "gonna nuke a text channel" they are gonna re-create/clone(so all the permissions transfer over) and delete the old one.
No, usually it means they're gonna spam the hell out of that channel, possibly even mention spamming
Self botting?
Huh?
The mentioning part is new to me. 🤷♂️
Personally when I see people make nuke commands, they do what I described above. Since nuking is a term for just clearing out a text channel.
does this sever make bots idk i am new plz help me
See this tho. I can see. These are two different things. Nuking a server I can see role and member mentions, banning, consecutively deleting channel and what not.
😕
yes
no, you make it yourself lol
by coding it
watch a tutorial
i saw
https://vcokltfre.dev gud one
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.
If you don't wish to make effort then you won't be able to properly learn
ooof
yes
Nothing comes for free so yes you do
bruh you have to pay @boreal ravine .....
dude
You don't
smh
how should i call the command then... ?
and how can i see the user id who sent the message or user name
you could have just said delete and clone it... As you said later
yeah i know how to delete one and clone one
but i want that action to be ran each 3 hours
tasks
I'm using discord buttons and everything working it just that before it work it says " interaction failed " then it shows this error
Task exception was never retrieved
future: <Task finished name='Task-59' coro=<Command.__call__() done, defined at C:\Users\gcpla\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py:358> exception=NotFound('404 Not Found (error code: 0): Interaction is unknown (you have already responded to the interaction or responding took too long)')>
Traceback (most recent call last):
File "C:\Users\gcpla\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 374, in __call__
return await self.callback(*args, **kwargs)
File "E:\Codes\ticketBot\ticketBot.py", line 159, in new
await controller.respond(embed=embed)
File "C:\Users\gcpla\AppData\Local\Programs\Python\Python39\lib\site-packages\discord_components\interaction.py", line 117, in respond
raise NotFound(
discord.errors.NotFound: 404 Not Found (error code: 0): Interaction is unknown (you have already responded to the interaction or responding took too long)
may i know what is wrong?
use a task loop
!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").
Did you have some timeout = in the wait_for part?
yes i do have
sorry i misread it
The error says that the bot got no response (ie button was not clicked) within the timeframe
the button was click before it shows the error
may i know how can i fix that?
You don't have to pay to learn anything that's free to use
do you click the button after running the command ? If yes , do you have any check for the event?
i'll send the full code, wait
that's the new hastebin xd
how can i get message regardless of whether it is in uppercase or lowercase
where should I insert?
I'm using discord buttons and everything working it just that before it work it says " interaction failed " then it shows this error
Task exception was never retrieved
future: <Task finished name='Task-59' coro=<Command.__call__() done, defined at C:\Users\gcpla\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py:358> exception=NotFound('404 Not Found (error code: 0): Interaction is unknown (you have already responded to the interaction or responding took too long)')>
Traceback (most recent call last):
File "C:\Users\gcpla\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 374, in __call__
return await self.callback(*args, **kwargs)
File "E:\Codes\ticketBot\ticketBot.py", line 159, in new
await controller.respond(embed=embed)
File "C:\Users\gcpla\AppData\Local\Programs\Python\Python39\lib\site-packages\discord_components\interaction.py", line 117, in respond
raise NotFound(
discord.errors.NotFound: 404 Not Found (error code: 0): Interaction is unknown (you have already responded to the interaction or responding took too long)
may i know what is wrong?
Read the error lol
Either u look too long or u r replying twice
you need to respond to the interaction within 3 seconds, if you cant, defer that interaction
Exactly
Since when was there a bot kwarg
I have this command, but when I try to send a emoji from another server using this it wont work as I don't have nitro and it tried to make it emoji before sending it. So how could I send a emoji using <:name:id> or smth else? ```py
@commands.command()
@commands.cooldown(1, 10)
async def echo(self, ctx, channel: Optional[discord.TextChannel] = None, *, message: str):
'''Will be sending message to specific channel NOTE: should only be used in moderation channels'''
await ctx.message.delete()
if channel is None:
channel = ctx.channel
await channel.send(f"{message}")
get the emoji instance > send it
simple
right... but what is emoji instance
idrk try getting the emoji using discord.utils and then send that to the "other server"
get_emoji?
iirc you need the id for that
that's fine I can get it
oh, use that then
I can’t tell the difference between you two
!d discord.ext.commands.Bot.get_emoji <=
get_emoji(id, /)```
Returns an emoji with the given ID.
how could I get a emoji ID from the whole message
I just copy paste it from my server (id of emoji)
if I do smth like ```py
!echo <channel> Hello <id> what's up?
Hm, that I have no idea, but my way worked if you wanted to send a message and the only argument was the emoji
so I need to use some sort of black magic
Maybe
Just get ID by copying it
Bruh
I'll ask in pygen and see if someone can let some black magic out
I got the emoji now, but how would I append it back to message?
no idea
use regex to find it, then do .split(':') on the string inside the list that's returned by the regex and then remove the last > at the end (with .replace('<', ''))
I have never used regex
then to get the Emoji object you just need to do bot.get_emoji(id)
¯_(ツ)_/¯
here's the regex just in case <(?P<animated>a?):(?P<name>[a-zA-Z0-9_]{2,32}):(?P<id>[0-9]{18,22})>
what is that?
regex
I can't understand that
!d regex
regex
Case-sensitive regular expression match.
The regular expression syntax is that of the database backend in use. In the case of SQLite, which has no built in regular expression support, this feature is provided by a (Python) user-defined REGEXP function, and the regular expression syntax is therefore that of Python’s re module.
Example:
Entry.objects.get(title__regex=r'^(An?|The) +')
``` SQL equivalents...
!d re
Source code: Lib/re.py
This module provides regular expression matching operations similar to those found in Perl.
Both patterns and strings to be searched can be Unicode strings (str) as well as 8-bit strings (bytes). However, Unicode strings and 8-bit strings cannot be mixed: that is, you cannot match a Unicode string with a byte pattern or vice-versa; similarly, when asking for a substitution, the replacement string must be of the same type as both the pattern and the search string.
This is the correct one
Type in google regex pythone
that yes
There is good video About it
regex is not to go for me
it's too confusing
The emoji ID is in this format so far```py
['9', '1', '2', '3', '9', '2', '8', '2', '7', '9', '6', '1', '4', '8', '3', '2', '7', '4']
it's the only thing i can think of to do what you wanna do
oh.. well rip
what regex is this?
I mean what for
for emojis i just said that 🤦♂️
you have regex for everything don't you
maybe
🚶♂️
how would I even use that?
do what this guy says
.rp 1 regex
here's an example
Hey guys
is there a way i can make my Bot read embedded messages and depending on what they say, react to them?
with discord.py
;-;
it basically returns a list of tuples, and inside the tuples there's 3 elements, the a or '', depends whether it's animated or not, then the name of the emoji, and lastly the id
a Message object has the embeds attribute which returns a list of Embed objects
alright so would message.embeds work?
yes
!d discord.Message.embeds
A list of embeds the message has.
@bot.listen()
async def on_message(message):
message_split = message.content.split(".")
for message_word in message_split:
for bad_word in Filter:
if(bad_word == message_word.lower()):
await message.delete()
await message.channel.send("I have deleted that message :angry:")
``` I have this function which checks if there is a bad word or not and if there is one then the bot deletes the message
but I want to add another list from which it will check the words How can I do it
simply do another for loop in the other list
alright ive read a bit into it but i dont get how i would make the bot send a message if a particular embed got sent
Don't think you can, but i think you can list comp it though
@bot.listen()
async def on_message(message):
message_split = message.content.split(".")
for message_word in message_split:
for bad_word in Filter:
if(bad_word == message_word.lower()):
await message.delete()
await message.channel.send("I have deleted that message :angry:")
for message_wor in message_split:
for bad_wor in invite:
if(bad_wor == message_wor.lower()):
await message.delete()
await message.channel.send("A invite was posted ")
@slate swan See this
all you gotta do is simply check with an if statement
you can
could you do an example of how a command would look like maybe?
i think you can do
if message.embeds:
embed = message.embeds[0]
if embed.title == "title":
print(...)
``` but im not sure
i know if statements but i just got into making discord bots
bot = commands.Bot("c#", self_bot=True)
@bot.event
async def on_ready():
print(f"All contected, Script is work.")
@bot.command()
async def start(ctx):
await ctx.send("oof")
bot.run("my token", bot=False)
Why is the code not working?
it's really just this easy 😟 🤦♂️ ```py
embeds = message.embeds
for embed in message.embeds:
if embed.title == 'some title that you wanna check':
... # The title matches so do something about it
elif embed.description == 'some description you wanna check':
... # The description matches so do something, idk
==
thank you very much i got it now, i wasnt feeling secure earlier thats why i asked for an example. Sorry if i was annoying or sum
that's what i said 🏃♂️
Lol
Guys, how do I run the code to on behalf of the account discord. after the "c#start" command, I wrote the word "hello"
Hey, I was right
😃
for the most part, yeah
pretty sure that's a selfbot which is against discord's ToS
what's the difference :))
someone maybe can help?
no one will help you with this
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
there might be a problem, the emoji has never been sent to chat before
and I cant send it there
Wdym
in your example the emoji was in the chat alrd, but I can not do that
the emoji is on another server and I don't have nitro
It doesn't matter whether you can't use the emoji, your bot can, and as long as the bot can see a message it'll be fine, even if the bot can't see the emoji because it doesn't have a mutual server the regex will still work on the message
hm
Anyways I'm gonna go take my daily nap 🚶♂️
for some reason i am unable to have a bot.command with the name "help" as its somehow already a command
is there a way i can override this with my own help command? when i enter said help command in chat it shows this -
No Category:
class
help Shows this message
info
test
Type rpg help command for more info on a command.
You can also type rpg help category for more info on a category.
have a good nap
!d discord.ext.commands.HelpCommand
class discord.ext.commands.HelpCommand(*args, **kwargs)```
The base implementation for help command formatting.
Note
Internally instances of this class are deep copied every time the command itself is invoked to prevent a race condition mentioned in [GH-2123](https://github.com/Rapptz/discord.py/issues/2123).
This means that relying on the state of this class to be the same between command invocations would not work as expected.
Subclass it
seems like this happened ```
re.compile('<(?P<animated>a?):(?P<name>[a-zA-Z0-9_]{2,32}):(?P<id>[0-9]{18,22})>')
're.Pattern' object is not subscriptable
anyone got examples for a verification command like one that uses a command and gives role
A verification bot?
Try just prompting user for input and then have a photo of a blurred out image with text and ask the user to input it
code:```py
user_id_list = (int[639551337989931008])
error:```
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 301, in _run_event
await coro(*args, **kwargs)
File "C:\Users\User\Desktop\папка для заказа бота\main.py", line 25, in on_message
user_id_list = (int[639551337989931008])
TypeError: 'type' object is not subscriptable
why its not work?
1 sec
# Setting `Listening ` status
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name="a song"))
just so you know```py
Setting Playing status
await bot.change_presence(activity=discord.Game(name="a game"))
Setting Streaming status
await bot.change_presence(activity=discord.Streaming(name="My Stream", url=my_twitch_url))
Setting Listening status
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name="a song"))
Setting Watching status
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="a movie"))
how can i write the tiny text at the bottom of an embed
!d discord.Embed.set_footer
set_footer(*, text=Embed.Empty, icon_url=Embed.Empty)```
Sets the footer for the embed content.
This function returns the class instance to allow for fluent-style chaining.
This iirc
ooo thx
You're splicing int. What is it?
how can i check if command is being executed in dm?
how to use @commands.check() for allowing only specific people to use ur command?
using
def check(m):
return m.author == ctx.author ...
Thats checking message author
ye, i need to the bot check if the command is executing on dm using this with base but idk
@slate nymph your trying to check members with the @commands.check decorator?
i have a list of peoples id who can use the command
yeah maybe?
You want it to check if its a dm?
yess
Just use a check
Don't add "" since their int
ok
!=, no?
nvm i ll do it
No that means if not
yeah
Yeah that will work
but he want to the command execute only for some ppl
But add the id attr
Hes comparing ids to a list of ids
I think this will work and not mine cuz im comparing a list to a id so yeah your right
^
we cant use commands.check inside a function :/
but using "return" don't will says nothing
will cancel the command
I havent used commands.check sorry
ok
Check docs ig
ye
with it
I think theirs a check for it
good morning
Good morning,Pleasure to see you here mate
use an isinstance in an on_message to check if the message.channel is a DMchannel ?
wait are you wanting it for inside the command itself to switch between uses in DM or server channel?
@brittle ingot bro you know my brain is crazy when i try to compare a int to a list😭
bruhh 😂
lmao
btw no need to say "using this" you can just say "using a check" which is a function 
@dusk dust are you going to use this to restrict certain commands from running in DM's?
@slate swan hes just checking if a command is being invoked in a dm
Which was already answered
right
help pls 🙏
with?
author = await self.thank.find_one({"_id": ctx.author.id})
receiver = await self.thank.find_one({"_id": member.id})
if not author:
await self.thank.insert_one(
{
"_id": ctx.author.id,
"sent": 0,
"received": 0,
}
)
new_receiver = await self.thank.find_one({
"_id": ctx.author.id
})
new_sent = new_receiver["sent"] + 1
await self.thank.update_one(new_receiver, {"$set": {"sent": new_sent}})
if not receiver:
await self.thank.insert_one(
{
"_id": member.id,
"sent": 0,
"received": 1,
}
)
new_find = await self.thank.find_one({
"_id": member.id
})
new_received = new_find["received"] + 1
await self.thank.update_one(new_find, {"$set": {"received": new_received}})
sent = author["sent"] + 1
received = receiver["received"] + 1
await self.thank.update_one(author, {"$set": {"sent": sent}})
await self.thank.update_one(receiver, {"$set": {"received": received}})
``` this is my code, so basically the bot tries to find the ppl, if they werent in the database it'd create something for them, but my bot isn't creating them and giving me a `NoneType` error which I thought I avoided using my if statements at the beginning
error line?
sent = author["sent"] + 1
received = receiver["received"] + 1
idk why its None though
fetch it again from the db, you're currently using the old value of receiver and author
which is probably None
hm
what does "hm" mean?
idk
it worked thanks
People say it as like their thinking
But idk about that one 
help me
im working on a card game/commands but im stuck at the sell commands ( sell buttons in embed )
explain where are you stuck on
when i read it, i read it as huh
I read it as a thinking mmmmmm
the sell command and the sell button didnt work
Code....?
Error.....?
code: ```py
class MyClient(discord.Client):
async def on_ready(self):
print('Logged on as', self.user)
async def on_message(self, message):
# don't respond to ourselves
if message.author == self.user:
return
if message.content == 'ping':
user_id_list = (int[639551337989931008])
for user_id in user_id_list:
user = await client.get_user_info(user_id)
await message.user.send('hello')
client = MyClient()
client.run("")
error:
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 301, in _run_event
await coro(*args, **kwargs)
File "C:\Users\User\Desktop\папка для заказа бота\main.py", line 25, in on_message
user_id_list = (int[639551337989931008])
TypeError: 'type' object is not subscriptable
help?
i can send the code here?
Yea..
you probably just want the [639551337989931008]
not with int[]
oh
Why even that tho, since it's already an int lol
Hey @unkempt jewel!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
._.
Read the embed
at least I guessed what they wanted
welp, no bulli please
guessed
It's open source on GitHub
from random import randint
import discord
from discord.ext import commands
from discord_components import Button, ButtonStyle, Interaction
from classes.Time import Time
import hdb3
class Card(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener("on_button_click")
async def on_button_click(self, interaction: Interaction):
if interaction.custom_id.startswith("dc"):
card_id = int(interaction.custom_id.split(" ")[1])
card = await hdb3.get_card(card_id)
if card['owner'] != interaction.author.id:
await interaction.respond(
content="You Dont own this card"
)
else:
cost, card, vtuber = await hdb3.get_card_cost(card_id)
res = await hdb3.inc_bal(interaction.author.id, cost)
await interaction.respond(
embed = discord.Embed(
title="Balance",
description=f"Sold Card For: {cost}\n New Balance: {res['bal']}",
color=self.bot.color
)
)
here is my code
I think its in github
Oke
how do you get a role for a command
!d discord.Guild.get_role
get_role(role_id, /)```
Returns a role with the given ID.
thanks
what exactly isn't working?
like this?
discord.Guild.get_role(role_id=12345)
No
the sell and button sir
ctx.guild.get_role(1234)
oh
Try adding print statements to every other line to see which lines are being triggered
code:```py
class MyClient(discord.Client):
async def on_ready(self):
print('Logged on as', self.user)
async def on_message(self, message):
# don't respond to ourselves
if message.author == self.user:
return
if message.content == 'ping':
user_id_list = [639551337989931008]
for user_id in user_id_list:
user = await self.get_user_info(user_id)
await message.user.send('hello')
client = MyClient()
client.run("")
error:```py
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 301, in _run_event
await coro(*args, **kwargs)
File "C:\Users\User\Desktop\main.py", line 27, in on_message
user = await self.get_user_info(user_id)
AttributeError: 'MyClient' object has no attribute 'get_user_info'
help?
and message.user doesn't exists
Ye
oh shet
@maiden fable helper when
There's still time for that 🥲
you probably need to be more active maybe? like 12h a day
Tell the error
i send you the error!
Nahhhh... I am already active enough and I don't think I want to leave my studies just cz I want a role
Please provide the full traceback for your exception in order to help us identify your issue.
A full traceback could look like:
Traceback (most recent call last):
File "tiny", line 3, in
do_something()
File "tiny", line 2, in do_something
a = 6 / b
ZeroDivisionError: division by zero
The best way to read your traceback is bottom to top.
• Identify the exception raised (in this case ZeroDivisionError)
• Make note of the line number (in this case 2), and navigate there in your program.
• Try to understand why the error occurred (in this case because b is 0).
To read more about exceptions and errors, please refer to the PyDis Wiki or the official Python tutorial.
See the last line
they got KeyError
what isthat
!d KeyError
means that you are trying to get the key which doesn't exists
exception KeyError```
Raised when a mapping (dictionary) key is not found in the set of existing keys.
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\Administrator\Desktop\bot\cogs\Card2.py", line 183, in sell
description=f"Sold Card For: {cost} vyen\nNew Balance: {res['bal']}",
KeyError: 'bal'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\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: KeyError: 'bal'
Happens when the key isn't in the dict
Made me cry
quick nap as usual?
😐 why
Can't help it, had school today ;-;
key is not in the res dictionary
So responsible 
i see no dict ._.
i dont have json file LMAO
show us the hdb3.inc_bal() function
No I ain't
yeah
else:
cost, card, vtuber = await hdb3.get_card_cost(card_id)
res = await hdb3.inc_bal(interaction.author.id, cost)
await interaction.respond(
embed = discord.Embed(
title="Balance",
description=f"Sold Card For: {cost}\n New Balance: {res['bal']}",
color=self.bot.color
)
)
Hi, I am making ticket system and when I start a discord bot, it will write into TERMINAL this error: async with aiofiles.open("ticket_configs.txt", mode="a") as temp: NameError: name 'aiofiles' is not defined How can I fixed that?
the function, not the one where you called it
Tf anyways leave it. If my parents saw these messages... They be like, u r seeing the MOST WRONG IMAGE OF MINE
define the aiofiles
import aiofiles
parents always sees the bad side of their child tbh
Hehe facts. Anyways leave it
Whops, I forgot, thank you.
can i send u the whole folder in dms
why dms
my parents see me like i am not their children
i cant send file here :/
same tbh
!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.
What is hdb3 here? A module or self-defined func.. or anything else?
Cz why not
best answer to everything isnt it
Fax so inspirational too
YESSS
Maybe cause they feel humiliated or scared due to so much smort people here
DM your files to Moros, he's gonna help you there
Moros helps me all day in dms 😎 
The biggest issue with DM help is that there isn't anyone that might be able to check the validity of your help / code. In the server here, a helper or other dev that has more experience, may be able to interject and propose a different solution that is more efficient and easier to read. Making it a learning process for everyone 😄
lol
Facts
Basically its better to have more minds that think differently and that have different perspectives and solutions
80.000 lines
Do u mean 80k?
how do i generate a 6 digit number using string lib and store it in a variable
Umm do you know what is hdb3...? I don't find any module with such name on internet...
yeah not a package either
self define :/
Share that function then
W H E 4 E
You mean its your own file?
how?????
Imagine class going on
y-ye
!d random
Source code: Lib/random.py
This module implements pseudo-random number generators for various distributions.
For integers, there is uniform selection from a range. For sequences, there is uniform selection of a random element, a function to generate a random permutation of a list in-place, and a function for random sampling without replacement.
On the real line, there are functions to compute uniform, normal (Gaussian), lognormal, negative exponential, gamma, and beta distributions. For generating distributions of angles, the von Mises distribution is available.
inc_bal function from the file please
okie
And your importing it to another file correct?
i dont even remember that i created that function in which files ._.
lemme find it
Ctrl+F in hdb3.py > search def inc_bal(, and send it
random.randint(6, 6)??
are you copying a tutorial or what
to get a 6 digit number?
BTW Misa, try using VSCode instead of sublime if u code often in Python
No thats for a random int
nah, me and my friends made this
pycharm 
now i need to fix his problem
U need a list of alphabets
In a range of (int to int)
Don't bully me, not everyone got super computers like yours. So saying VSC is a safe bet
i use it too
For generating 6 digit no. start from 100000 to 999999 instead of 6 to 6
yeah super computer
too ironic
hey, i am trying to make a discord bot command which uses the github api, to lists all the repos of a user
but i really don't know how can i make something which gives the user ability to control how many repos they want to see, sort them by stars/forks
rn it looks something like this (check the image below)
also i don't want to break the embed description limit will giving the user the ability to choose how many repos they want to see at a time
ping me on reply, thanks
Pycharm is so underrated in this chat people are like scared its to professional idk,coming from a vsc btw
It is one when compared to my laptop
VSC Gang 🥺
i cant run vsc with discord in the same time, vsc will very lag
i used it before
Oh, hmm... I use VSC with Chrome on an 8 year old laptop 😐
Vsc better tho
Yay
Lol you coding during ur online classes..? Anyways this function return a dict which has no bal key
why the vsc gives me an error when i try to run the code?
Check those internals
mine is 12 :)
Can't tell without error
I get an error with the last line which is the bot.run
Hehe understandable
Pycharm <= vsc
yea freac math class
Show
Try seeing your brackets. Most probably u missed a closing bracket somewhere
What api are u using? Btw hi Kira
hopefully I don't regret
Hate math
pycharm has more built-in functions imo
someone give me a easy way to generate 6 digit number and save it in a variable?
Math is love 🥲
yo
Bro, aman just gave u
Yeah ofc
No math == brain pain
random.randint(100000, 999999)
other than using random with big numbers like that
Lol
file = open(r"./main/message.txt", "rt")```
file path:```py
C:\Users\User\Desktop\bot\main
why does the code not find the desired text document?
That’s something I would do
No other way
yo who love this?
hi 👋,
i am using github api
https://api.github.com
No ur users3 func's attr raw_result return something else, tbh ur code is too messy, try to check those functions instead
Fr 🤮
This channel is a chaos now 😐
help
everyone does that don't we?
I'mma go get something to eat, cya
:( k i hope my computer does not go bye bye forever when i try this lol
I hid the token and the small thing because I used my name to recognize my folder
yo can u help me to fix that ._.
It gets 6 random ints isn't that you wanted?
yeah
no one care ur name ._.
No I don't lol, imagine solving differential equations
Have a good meal
where does your base path starts from?
I like you,you cool 
Umm idk what's inside users3 and all other funcs... Check it once
file = open(r"./main/message.txt", "rt")```
file path:```py
C:\Users\User\Desktop\bot\main
also no one cared to see my name so i hid it
show the file tree not just the file path
yo im dumb
oof good point
Same
@unkempt jewel i tried to compare a int to a list earlier so im dumber😭
Same
Ohh.. u using any module to do so or making raw requests..?
now how do i fix this
=]]
Still eating
i think only me come from asian in this channel :/
me
India here
Your db don't return a bal key... Do one thing, just print your res in first file u shared
no i am not using any other modules 😅
yo which country?
how?
print(res)
indo
.... print(res)??
vietnam here
@maiden fable yw
Yups, saw that message (:
where to put the command i means
Nah Indian here, and Hunter and Kira too
Be polite and say yw 
os.environ*
yo i know a lots people from indo and know py
Below the line where u defined res
same 😆
.get
Cause india only got big brain people 
!d os.environ
os.environ```
A [mapping](https://docs.python.org/3/glossary.html#term-mapping) object where keys and values are strings that represent the process environment. For example, `environ['HOME']` is the pathname of your home directory (on some platforms), and is equivalent to `getenv("HOME")` in C.
This mapping is captured the first time the [`os`](https://docs.python.org/3/library/os.html#module-os "os: Miscellaneous operating system interfaces.") module is imported, typically during Python startup as part of processing `site.py`. Changes to the environment made after this time are not reflected in `os.environ`, except for changes made by modifying `os.environ` directly.
This mapping may be used to modify the environment as well as query the environment. [`putenv()`](https://docs.python.org/3/library/os.html#os.putenv "os.putenv") will be called automatically when the mapping is modified.
i dont have an .env file i just hid the token
yeah i know some people here
Then remove the os[]
like this?
Just add the token there
they are calling it
run("token")
using ()
Yea, that

Isnt he using vsc why is he hiding his token?
I know how to call
im almost done the MATH CLASS
Czzz VSC shows the token.....?
Pog
why not
~ hunter
thanks :]
No it doesnt😭
(:
Tf? It does for me
yo help me aman
Hes very questionable 
Cz me dum
Umm I guess yes, try it
Its vsc not replit😭
wait what? how does VSC hide the token for you?
i changed my mind i need a random 3 digit code
@slate swan no offense but what vsc are you on
its not public but still shows if you screenshotted it 
Lmao tell me when u get to know
Yeah
so run random.choice three times append each into a list and join it.
Can we please..... stop this talk?
I stopped 
Im on notpad 
oh i gotcha i thought you mean it literally stores it hidden for you somewhere
Umm why not just random.randint..?
they apparently only wanted strings
oh you wanted the output as a string 😂
aman it still show the same error
ok so too manu asian here, now i think im the youngest :)
Lol just use random.randint then, first param should be from where u need to start, like 100 for three-digit no, and second should be till where, like 999 for three-digits
14 :)
2007?
got it
yeah
wow im tired, i completely misunderstood every part of that question. Thank you for the catch Aman
same
Imagine someone saying 9 in the chat
nah, probably like 16 avg
@slate swan 
Yeah for sure
Same 😭
!ban is waiting
Ahh yes I was trying to search it's docs... Maybe I can't help sorry since idk how to use this api 🥲
Did it print something?
why it says that the command is not found?
check ur funct name
I did the same thing with the command above but only put a reply for test
That's not where u need to use print(), use it in the func which is giving errors
use it in on_button_click
i am not using any tokens, i am just fetching the data like a simple api 
i just wanted to the way how can i give the user ability to control the number of repos they want to see and also sort the repo on the basis of stars and forks
btw here is the docs link:
https://docs.github.com/en/rest
Happens when you type the prefix of your bot and doesnt find such a name
isnt it
@bot.command():
async def commandname(ctx):
await ctx.reply("Test")
i dont understand what u say
Yes (not well indented tho)
can u just tell me how to fix it :)
then why doesnt it work
english is not my first lang so...
gura? hololive eh?
do <prefix>commandname
yea, i made hololive card
You have a function named on_button_click in ur Card2.py. In the function, you probably have a line like res = ......., write a print() statement below it to print res
I think he knows hes just getting a commandnotfound error
nice 
i have the
bot = commands.Bot(command_prefix="v!", intents=discord.Intents.all())
@bot.command: ":" ??
Did u restart ur code after making command?
yes
https://discordpy.readthedocs.io/en/stable/faq.html#why-does-on-message-make-my-commands-stop-working take a look if it solves the issue
no i dont
why a colon ? at the end of @bot.command()
also you have any on_message event ?
If this doesnt work your typing it wrong
You do
Probably the colon i never saw cuz thats a decorator
Are u using search/repositories route?
so i will put the print(res) under the res =... line?
yes
yeah :)
That route returns 100 per page as default, if you need to limit them, pass per_page field in the body
yeah, i did this thing to make it 10 as default
but i want to change it as the user uses this command
%repo <repo-name> 15
this should change the limit to 15
I had a verify command that i used
Command:
@bot.command()
async def verify(ctx):
verified = ctx.guild.get_role(roleid)
notverified = ctx.guild.get_role(roleid)
await ctx.author.remove_roles(notverified)
await ctx.author.add_roles(verified)
await ctx.reply("You have been verified!", delete_after=10)
await ctx.message.delete(delay=10)
I have put the ids on the place where i say roleid so dont say anything about that. also this command is working fine. My problem is, i copied the async def verify(ctx): and put the other command name but nop
Make it a variable
remove the : bruh
pass the value whatever user wants to inside the body of the request
Delete the colon in the bot decorator
It's a decorator
oof i put that by accident
you didn't put the other channels id
but i dont have it in the other command
The bot doesn't see the command as the decorator isnt correct
could you please elaborate
Cuz its wrong
!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.
A decorator doesnt have a colon
take the input from the user and store it in... say x, then pass the x instead of 10 in the per_page field
i mean i put that in the message by accident but in the code i dont have that
on both commands
user isn't in ur cache
@client.command()
async def send(ctx, user: discord.Member):
await user.send(files=.\"file.txt")
how to put one in
did u modify MemberCacheFlags or something else?
lol
no idea
do you have member intents enabled?
Ummm... enabled intents?
no
enable them
fine i ll enable then
socket isn't sending u any data to prepare any cache
How to send a .txt file with my bot
!d discord.File
class discord.File(fp, filename=None, *, spoiler=False)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for sending file objects.
Note
File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")s.
It still not works
The .\ should either be removed, or added in the string
@safe fulcrum ^
Send the code
oh yes
i had told my problem a couple of messages above
code:```py
async def on_message(self, message):
# don't respond to ourselves
if message.author == self.user:
return
if message.content == 'ping':
file = open(r"id_users.txt", "rt")
content = file.read()
file.close()
user_id_list = [file]
for user_id in user_id_list:
user = self.get_user(user_id)
file2 = open(r"message.txt", "rt")
content2 = file2.read()
file2.close()
await user.send(content2)
error:```py
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 301, in _run_event
await coro(*args, **kwargs)
File "C:\Users\User\Desktop\discord\main.py", line 38, in on_message
await user.send(content2)
AttributeError: 'NoneType' object has no attribute 'send'
help?
user is none
I have 2 commands in the same file but the one works and the second one says that doesn't exist
actually how to enable member intent?
!intents
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
i ll do discord.flag.Intents.all()?
Not discord.flag...? Just discord.Intents.all(), yes
oh ok
all will enable all the intents especially the presences one, which takes a considerable amt of memory
If u don't need presences, I prefer enabling only member one
inside commands.Bot(intent=Intents.all())
i ll enable all whats the problem xd
ok ty
how do i fix my problem
Haha sure you can do, also enable them on dev portal too
ok
hmm, i have stored the values of stars and forks count of the default repo in variables,
now if the user updates the page limit then how can i update the stars and forks count for the new repos in that page ?
nevermind
Ahh I guess user can only update the page limit by executing a new command, and ur gonna make a new request to fetch it again...
Will u share some code, it's probably hard to understand what ur trying to do without some reference
code:```py
class MyClient(discord.Client):
async def on_ready(self):
print('Logged on as', self.user)
async def on_message(self, message):
# don't respond to ourselves
if message.author == self.user:
return
if message.content == 'ping':
file = open(r"id_users.txt", "r")
content = file.read()
file.close()
user_id_list = [content]
for user_id in user_id_list:
user = self.get_user(user_id)
file2 = open(r"message.txt", "rt")
content2 = file2.read()
file2.close()
await user.send(content2)
error:
```py
Logged on as Jocks#0932
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 301, in _run_event
await coro(*args, **kwargs)
File "C:\Users\User\Desktop\discord\main.py", line 38, in on_message
await user.send(content2)
AttributeError: 'NoneType' object has no attribute 'send'
why can't I connect the text file id_users.t?
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
well i know it but i just like learning only
well youtube doesnt care about that so we cant either
help
Good to see you here and fax
Facts = fax
a slang for "facts"
oh
Yeah
I want to make a submit bot command how can i check if the id given is a real bot?
Wdym a real bot you mean a bot?
!d discord.User.bot
Specifies if the user is a bot account.
That^
!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.
thanks
@slate swan getting the same error after enabling member intents....
😭
oof
discord.User.mention
will return the str that can be used in a message to mention them
help
you're not supposed to make your bot like that in 2022
Why?
@sullen shoal are you a time traveler 
i mean it looks like theyre making their ping command using the event
when commands extension exists
https://paste.pythondiscord.com/haseqafodu.py @slate swan
||sorry for the really poor code 🥲 ||
i am trying to do this:
First the user types %repo <repo-name>, the user sees a list of repos of total number 10
The user wants a list of total 20, if uses the command %repo <repo-name> 20 then the bot should post an new embed with 20 repo search list
If it exceeds the embed description limit then the bot should send an embed saying that it exceeds the embed description limit ¯_(ツ)_/¯
Aman is getting pinged so much poor guy😭
iscord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embed.fields.2.name: This field is required
how can fix this error?
add field name
i did
show code
embedVar=discord.Embed(title='To-Do:',color=0x00ff00) for i in json_read(str(message.author),'work.json').split('\n'): embedVar.add_field(name=str(i)+' ',value='\u200b',inline=False) await message.channel.send(embed=embedVar)
if i put await inside the loop it works
check value of i
no it works if i put await inside the loop
then show the code tjat doesnt work
but it embeds and sends each element as they get added
thats the code that doesnt work
you said it works tho
If your using a for loop for a word it will send all the characters in it
just put the message send method outside
embedVar=discord.Embed(title='To-Do:',color=0x00ff00)
for i in json_read(str(message.author),'work.json').split('\n'):
embedVar.add_field(name=str(i)+' ',value='\u200b',inline=False)
await message.channel.send(embed=embedVar)
this works but if the await is outside the loop it doesnt
!e
a = "hello world"
for b in a:
print(b)
@slate swan :white_check_mark: Your eval job has completed with return code 0.
001 | h
002 | e
003 | l
004 | l
005 | o
006 |
007 | w
008 | o
009 | r
010 | l
011 | d
it is a list containing strings
@glass rock
ugh fuck it
If its a list it will print all the elements then
its a list of strings not a string tho
is this code right?
@bot.command()
async def submitbot(ctx):
if discord.User.mention == userNotFound:
ctx.reply("User not found")
elif discord.User.mention != userNotFound:
ctx.reply("Success!")
else:
ctx.reply("An error occured...")
Where are you gonna take user from bro
and OOP
ye but it does them induvidually as they get added, like:
#1 pass:
1.potato
#2 pass
1.potato
2.tomato
but i would like it to do only the last pass
From where
wait
i wan the user to put the bot id to check if it exists
dont eat me i dont know much python
eat me 😳
Cough cough
k
My finger slipt
how do I check if message.author is any bot?
you need to use a discord.User instance and not the class , add a variable with discord.User typehint in your command
message.author.bot
Member.bot
oh
!d discord.Member.bot
property bot```
Equivalent to [`User.bot`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.bot "discord.User.bot")
is a bool
author can be User so keep that in mind
Yes
User also has this attribute
it will be User when Guild is None
meaning dms basically
ModuleNotFoundError
import subprocess
from typing import List
import discord
from discord.ext import commands
from disbot.myToken import SECRET_TOKEN
client = discord.Client()
bot = commands.Bot(command_prefix='$')
@client.event
async def on_ready():
print("We have logged in as {0.user}".format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith("$hello"):
await message.channel.send("Hello!")
@bot.command()
async def test(ctx, arg):
await ctx.send(arg)
client.run(SECRET_TOKEN)
i cant get my test command to work, no response from $test hi. $hello works fine though
Replit am i right😭
yes
await bot.process_commands(message) in the last line of on_message
I think you didnt get it i ment like replit with its errors not asking if it is replit😭
oh yeah replit suck
Ofc bruh
fixed it. The last element was the one that was causing trouble (it was ""). Ty for the help
Yw
like this? i get an error when i run $hello now
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith("$hello"):
await message.channel.send("Hello!")
await bot.process_commands(message)
# if self._skip_check(message.author.id, self.user.id):
# AttributeError: 'NoneType' object has no attribute 'id'
are you planning to make your discord api wrapper public someday i wanted to see how you handled those heartbeats and stuff
those are giving me pain in the ass
I ain't making a Discord API Wrapper tho
Isn't a replit error though..
i mean whatever that is, doesnt it have websockets
Yups
!d discord.utils.snowflake_time
discord.utils.snowflake_time(id)```
hm replit error it is then
help . . .
Lemme tell u the core of websockets
yeah please
dpy is open source lmfao
We say that cause replit has those types or errors
Most times
"Those"?
So I have something like
self.listeners = {"event-name": []}
for msg in self.ws:
for function in self.listeners[msg]:
await function()
it will take 2 days just to locate the stuff i need there
Like module errors
It's black magic 😂
yup
!d aiohttp.ClientWebSocketResponse
class aiohttp.ClientWebSocketResponse```
Class for handling client-side websockets.
im using something called websockets that came first when i searched websockets python lol
Ik, that's the first result, but use aiohttp module
Most of the time, it's just replit being oudated, modules not being updated on pypi, module versions etc.
also it was popular so i thought it would be better
But the only problem is, your dispatch method would become async
But that's fine, since u can always do loop.run_until_complete()
yeah
But preferred is to keep it async
Yeah ik lmao its just most module errors that people get are from replit being outdate or sm
thanks
Later guys have a good day or night
gn