#discord-bots
1 messages · Page 778 of 1
not really but
data_dict = {yourshit}
ok
I'll show you this
maybe that'll help
for key,value in data_dict.items():
print(f"message_id_string is {key}, messages_count is {value['messages']}")```
Thx I'll try
not in the mood to copy ofc
How can I set slash registration to be local inside Cog
i tried making it local from main.py but it didn't work
do i define new bot?
eh?
just think about it brotha
if you define new bot
and put commands inside new bot
old bot won't have those commands
and since you can only run one bot
you either won't have old bot or new bot
Yeah that was a stupid guess
supply the bot variable to te cog a basic cog structure ```py
class MyCog(commands.Cog):
def init(self , bot):
self.bot = bot
def setup(bot):
bot.add_cog(MyCog(bot))```
Just tried creating local registration for slash commands, but it doesn't work
Mhm
What library are you using
disnake
use commands.slash_command
Just like you use commands.command instead of bot.command in cogs
bot.slash_command is commands.slash_command
:)
get a covid checkup buddy
it was in cog
yeah, got it yesterday, thanku so much for caring
Great
poof?
Got too used to pycharm, it used to self by itself :(
Gives me error: Failed to overwrite commands due to missing access, but the bot has all of the permissions
you didn't invite it with application command scope
it disappears just like my consciousness
welp
🫂 cry about it
random person : i get this error
Ashley : cry about it with a hug emoji
😂
comedy peak
let's not start an ot chat hehe , the channel is being a bit off topic these days
Is it good to switch from discord.py to hikari?
imo, sure
get ready for a based answer
well if you don't like learning everything from scratch. Use a fork instead
a fork of dpy?
since it's no way similar to discord.py
Yea
use disnake so you can have access to disnake-debug
disnake 
probably disnake

Indeed
yes disnake 💪
yes disnake-debug 💪

imo disnake is a pretty great fork of danny's dpy, unlike Pycord 
Danny doesn't like pycord himself.
when
who does
Play nice or hush
There are people for sure , depends..
me and dekriel are great friends 😄 nods convincingly

I don't have friends
he talks like this, he deserves to get attacked
You guys think it's going to circle back around to there being one big one or do you think it'll end up like Linux distros? Too many flavors, not enough substance
i need to go insult him in the jss
alr meet you there
i reckon linux distros because some people have passionate love for hikari/the irrelevant ones, whereas others will be fighting over pycord/nextcord/disnake - if any ends up on top it will be disnake, no doubt about it
thanks for having @ off
if you're talking about the forks
I assume there are 4 or 5 forks which people really prefer atm
And it would settle soon with a best one maybe?
how's fedora
wrong server
there's no real need to migrate from dpy because you can still use it, but it's pretty outdated and discontinued
I literally pinged you in jss
there are people who prefer other libraries like hikari or pincer too
I'm hoping that's the case
forks have the dpy cache only lol
You can't compare the cache between forks
they are "dpy forks"
But hikari does have better cache impl for sure
does hikari have a proper cache?
yes , and it's upto 2x faster :)
https://github.com/hikari-py/hikari AHHH uh...it's gonna take some time for me to go through this
that doesnt mean they cant improve over it
Time to migrate to hikari then lol
Hmm, talking about disnake, I hardly hardly hardly think they gonna change the basic implementations of stuff
I mean...some people just download Danny's dpy, CTRL+R and replace "discord" with their own name 
It doesn't have an inbuilt command handler like .ext.commands tho
Instead it has 2 "decent" different command handlers : lightbulb and tanjun
I haven't really worked on my discord python project
but then again, I'll have to make it as terrible as possible, hence the name "trashcord"
dekriel,let's not talk about the time you take to do things
it doesn't have async, let alone def. I'm gonna make this a nightmare for discord bot developers 💀
oh, hello Sasuke
the emojis for jarvide , you made us wait forever
I never realized you were Sasuke
Sarthak*
jarvide's dead lmfao
wtf
Hehe
ok
he never did them
because you dont know how to code and add crap commands? agreed
hes sarthak, the one whos good at coding
nobody really works on it lmao
apart from a few people
the few people are literal "gods"
nah we stopped working on it
Sends only first word as reason uh? This is the code.
ropra is the only one who works on it lol
I did .kick user being ultra cool
😬 didn't you like buy a domain and everything for it already?
why stopped with the development?
meh the domain was like $8
you haven't responded yet in jss, I thought you said you were gonna insult me
Help someone?
idk how to advertise so i dont really see it going anywhere
im sorry dekriel, i dont give enough shits about you to insult you
you come up with the worst insults, I don't blame you for that
Can you help? @velvet tinsel
as if dekriel can help xD
I'm reading an article https://www.forbes.com/sites/cognitiveworld/2020/12/29/ethical-concerns-of-ai/?sh=6643b1e723a8 wanna read it with me? 
can you smh
i think you mean , *, reason = None to get all arguments after member. use visual studio code i beg, that ide is painful
Ethical concerns..
mk
add a kwarg
Should I put this after async def kick (ctx,
kwarg?
async def test(ctx, *, reason=None)
how
Key word argument
?
Pycharm is an amazing IDE
maybe this is why you aren't good at coding
Hey BTW since I got an i3 11th gen, should I use PyCharm or use VSC only 🤔
Like this?
no wonder why there were lots of PEP8 shit in jesterbot
sorry not a kwarg a variable argument
so I do..?
what do you want the variable argument to be, I say before reason put the star
Broo I invited the bot with these scopes, but it still gives me error: SyncWarning: Failed to overwrite commands Missing access after trying to create local slash
I have a doubt, do you put the * before the reason because every character of the reason we give is stored as a character and not a string?
because if it is stored as a string why use *
Yes
weirddd
But why the space
Visual Studio is an IDE. Visual Studio Code isn’t an IDE.
well it still works ig?
you keep editing it
i can do black . if i really give a shit about pep-8, but dont talk about pep-8 when you learnt what it was yesterday...also didnt you make a pull request thinking adding comments creates command descriptions? https://github.com/CaedenPH/Jarvide/commit/d13b4c8a8045c776534e86c726af902ee689bc4a
sorry i took a shit halfway through writing that
Mobile problems
I never said it added descriptions, I just thought maybe comments were needed in the bot 
ok
You added the most self explanatory comments
# google command
Well obviously. Anyone reading can determine that.
Why didn’t you actually comment on the code inside the commands. And describe those instead.
Guys i have a problemo
I am unable to import Discord ui
The requirements are already satisfied
show the imports
did you install it using gitbhub link?
Trying to learn how to make buttons but the imports pickin a fight
Nah
I installed using pip
the official version isnt on pypi yet, use the github link to install it
py -m pip install discord-ui
is what i used
O where can i find it?
^^
Hmm I wrote that link myself rip
thats probably an unofficial 3rd party lib
!pypi discord-ui
Ah i see
Rip
¯_(ツ)_/¯
you should probably just use py-cord if you're gonna need to install a module for every other discord feature
cof cof

yea like slash commands and stuff
How do i install the git 
why is everyone acting weird did i do something wrong
d-disnake-
I don't usually deal with the git 
you dont need to-
!pypi disnake
Tried that and got an error
i think its pip install git+githublink
Nah, people here are just used to disnake a bit too much
ahh welp
ERROR: Cannot unpack file
Tried that too 
cry about it 🫂
nope, everyone here is biased towards disnake lmao dw
i see
🫂 disnake, our love
agreed!
totally not sponsored
disnake more like
Alr
disnake is
a snake?
ERROR: Cannot unpack file C:\Users\Alpha\AppData\Local\Temp\pip-unpack-ee_ifn8s\discord.py (downloaded from C:\Users\Alpha\AppData\Local\Temp\pip-
req-build-g3xagh_i, content-type: text/html; charset=utf-8); cannot detect archive format
ERROR: Cannot determine archive format of C:\Users\Alpha\AppData\Local\Temp\pip-req-build-g3xagh_i
@exotic bear
can you send the github link you're trying to install
https://stackoverflow.com/questions/20101834/pip-install-from-git-repo-branchone of them should help ¯_(ツ)_/¯
Trying to pip install a repo's specific branch. Google tells me to
pip install https://github.com/user/repo.git@branch
The branch's name is issue/34/oscar-0.6 so I did pip install https://github....
for that you should just do pip install discord.py
no ew
2.0 isnt on PyPi yet
oh
yep
nvm then
its alright, I'll save you further humiliation and not talk about it
they still update dpy?? 
huh? no
then how is there a version 2?
Is it okay to throw my pc out the window
2.0 was the last update before it was scheduled discontinued
🫂 I got my new one today, I feel the pain
oh so it was under development isee
Truly been trying to fix this for 30min
yeah, most probably cuz discord is gonna deprive bots apps of message intents
it wont be continued anymore
at least not as of now
discord's policies hella trash
they've got a point ¯_(ツ)_/¯
it's gonna cancel two of my bot's beloved features
You're just gonna have to shift all of your bot to slashes
which are? (the "beloved features")
already done that 😎
A H H H H H H H H
auto responses and automod

I think that should still be possible one way or the other
- its gonna stop working
- its not gonna be maintained anymore
I had a 8 year old laptop with 1.7 GHz processor, but I got a new one yesterday, so yes. I also want to throw my old laptop out from the balcony. I am with you :DDD
i applied and got rejected twice because no privacy policy
Let us throw ours together my friend
do you have to apply for that nowadays? xd
may I join?
WHY JUST WHY
I made a command for my bot for a pp (no please) and ToS
otherwise hunter uwu forever
Then join us
for a what? :awkward:
We shall all destroy at once
old laptops' death ceremony
tysm lmao
you can clone the git repo and run the setup.py manually
How would i do that 
Im still abit new 
@compact ruin sometimes doing pip install git+https://github.com/Rapptz/discord.py.git works (I suffixed .git)
🫂 We preserve them, one day when we're gonna be famous (probably not), they're gonna be sold at a heavy price at an auction
anyways
.topic
Suggest more topics here!
Eh, I doubt it. I mean, I used it for 2-3 years with VSCode and Chrome running on it LMAO
Imagine VSC and Chrome with tensorflow running on 1.7 GHz
damnn
hello. I import my config like this, but get this error ```python
with open('./config.json', 'r') as cjson:
config = json.load(cjson)
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9f in position 1428: character maps to <undefined>
Pretty sure i have Git installed
U didn't add it to path
This won't work
have some mercy, killing your laptop for a bot ¯_(ツ)_/¯
🚶just install some fork.
Bot???
git clone https://github.com/Rapptz/discord.py
cd discord.py
pip install .
nothing smh
RIP
RIP I hate Anti Virus now
I had 4 GB in my older laptop which had Windows 10
Even my phone has more memory storage than my laptop
oh this, my my
!ot
Says requirement already satis 
I am using Windows 11 currently, and have youtube and discord opened and Spotify in background, so that isn't a bad usage
Is that not Linux 
I feel your pain bruv, that was me for 2.5 years
I have like 12 in my new one ¯_(ツ)_/¯
should work on windows too
Eh, I got a new laptop and 8 gigs was enough for me anyways
Ayo, how do I import {} from a json file into a code ?
@client.command()
async def test(ctx):
with open("file", "r") as file1:
test = json.load(file1)
await ctx.send(test)
so I have this json file and now I used this code to print the fivebiggest message amounts
leaderboard = []
for key,value in users.items():
leaderboard.append(value['messages'])
leaderboard.sort(reverse=True)
print(leaderboard[0])
print(leaderboard[1])
print(leaderboard[2])
print(leaderboard[3])
print(leaderboard[4])
So I just have five numbers after that
Is there any way to the id again with that number
Or is there a way where I can sort the messages amounts and keep the ids with them?
load the file data onto a variable
damn I can hear the fans
!d json.load
json.load(fp, *, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)```
Deserialize *fp* (a `.read()`-supporting [text file](https://docs.python.org/3/glossary.html#term-text-file) or [binary file](https://docs.python.org/3/glossary.html#term-binary-file) containing a JSON document) to a Python object using this [conversion table](https://docs.python.org/3/library/json.html#json-to-py-table).
*object\_hook* is an optional function that will be called with the result of any object literal decoded (a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "dict")). The return value of *object\_hook* will be used instead of the [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "dict"). This feature can be used to implement custom decoders (e.g. [JSON-RPC](http://www.jsonrpc.org) class hinting).
*object\_pairs\_hook* is an optional function that will be called with the result of any object literal decoded with an ordered list of pairs. The return value of *object\_pairs\_hook* will be used instead of the [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "dict"). This feature can be used to implement custom decoders. If *object\_hook* is also defined, the *object\_pairs\_hook* takes priority.
Nope not wrken
insane
At least I got a SSD in the laptop, so it isn't that slow
how much?
512 GB
ello
Was now too lazy to type, because I'm on the phone, but that's how I have it... But the output is always the same....
This is a test {ctx.author.mention}
The older one had about 200 gigs HDD, soooooo
cool, anyways, we should move to an ot channel before a warning comes in
huh?
Can you say me whats the error?
right there monsieur
LMAO
2 times? Client.
Remove that one with discord.Client()
Is there a reason it wont let me use git clone on vsc 
Do i need to install git separately-?
Yep
How ze flip-
ofcourse
I hate you github
I tried both
again whit errors ;(
did not work 
isn't this js
let client
This is just annoying i cant clone the git
Hmm token
thats old token
{"695229647071015040": {"messages": 17639}, "618341493932266506": {"messages": 318}, "884402383523339295": {"messages": 1334}
for key,value in data.items():
print(f"{key} {value['messages']}")
So I have a json file like this and the code you see here. When I run it I get outputs like
767385286614319134 3120
768843832782618644 3
Now I want to sort them by the message number. How can I do this without removing the id or is there a way to sort it without id and get the id later again
If this isnt the right channel just say which one is right
i have do in another code and it's still error
Now it's your status
Ummm i deleted but is now another big error
# 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"))```
"Text"+cmd to f"text {cmd}"
Since you have more overview, I see again twice client
That's all I see
Check your token again
your token isnt right
!e
a = None
print(a.strip(" "))
@slate swan :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 2, in <module>
003 | AttributeError: 'NoneType' object has no attribute 'strip'
the heck are you trying to do
a discord bot
i ment the syntax
oki
ofc i know youre making a discord bot
Why u r not present in #ot2-never-nester’s-nightmare
idk
you cant have a space in a var lol
oop
!e
new list = ["element", "element"]
print(new list)
@slate swan :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | new list = ["element", "element"]
003 | ^^^^
004 | SyntaxError: invalid syntax

is for comments
which dont affect run time
Non code text
comments*
did u say smth
read pep 8 bozo https://www.python.org/dev/peps/pep-0008/#comments
lmfao
Ur using better Discord 🤫
yeah
but yeah vars cant have spacings so just use snake_casing
ok tnks
yw
leaderboard.append(f"{key} {value['messages']}")
leaderboard.sort(reverse=True)
How can I "ignore" key and just sort value?
Wym
ever checked the list.sort function in the DOCUMENTATION?
hello! I have this button which i want to have a custom emoji as an icon. But i get this```python
(label=f":phantomaki:", style=nextcord.ButtonStyle.gray)
yes but i dont understand it
you did? well show me the link
?
i think there is an emoji arg
custom emojis need the ID
like (emoji=":phantomaki:")
for example
there, ID shit
@river flare 
it actually says on the button the ID so you can just c&p
use the emoji kwarg
like this? :935626436985909309:
^
Could someone help?
@client.command()
async def weather(ctx):
diceRoll = random.randint(1,100)
currentWeather = ""
if 1 <= diceRoll <= 3:
currentWeather = "Stormy"
await ctx.send("It's a storm! But don't fear, it's not flooding.")
if 4 <= diceRoll <= 10:
currentWeather = "Heavy fog"
await ctx.send("Heavy fog has decended upon you!")
if 11 <= diceRoll <= 18:
currentWeather = "Light fog"
await ctx.send("Light fog has decended upon you!")
if 19 <= diceRoll <= 47:
currentWeather = "Sunny"
await ctx.send("The sun is shining down onto you!")
if 48 <= diceRoll <= 79:
currentWeather = "Cloudy"
await ctx.send("Clouds start to cover the sky.")
if 80 <= diceRoll <= 89:
currentWeather = "Light rain"
await ctx.send("A light drizzle has started.")
if 90 <= diceRoll <= 93:
currentWeather = "Heavy rain (flooding)"
await ctx.send("Heavy rain has started falling and the world is flooding fast!")
if 94 <= diceRoll <= 100:
currentWeather = "Strong winds"
await ctx.send("The wind is starting to pick up and is getting strong.")
@client.command()
async def weatherCurrently(ctx):
currentWeather = currentWeather
print(currentWeather)
I'm trying to make it print the variable currentWeather in the terminal but it says it's not defined.
currentWeather is in another function
You cannot access it like that
why so many ifs
elif is a thing
Also, you should check out pep8
i follow pep8 to much lmaooo
I follow all of pep8 except for the 120 or whatever character limit
Fuck that limit
72
isnt it 72 for max line
Seems too little
¯\_(ツ)_/¯
youve seen my methods right?
No
bruh hold up
use a dict
I thought you were gonna say something else
👁️ 👁️
got to follow it bro
No
okimii
I refuse
i follow black, and black follows pep-8 right?
how do i get the first channel in a server?
Playground for Black, the uncompromising Python code formatter.
don't tell me that's pep8
i dont use black
Idk if it’s my phone or it looks weird
this is pep-8
yes
its not
nope
aight, it better not be
okimii you think thats what pep-8 is, but it just isnt
Uh oh
if i do it the black way it will still break the max line rule
can i get some help with a command for my discord bot in #help-carrot
thats not how the 'max line rule' works
how would it work theres not specification
how do i get the first channel in a server?
Okimii I feel like you’re doing too many lines for a command
this is how it normally should look like
You could use the position attribute to determine it
I'm trying to figure out how to use that to get iy

It
and some other random one also formats it to ```py
@command(aliases=["kickhammer", "userkick", "memberkick", "banmember", "banuser"])
async def kick(
self, ctx: Context, member: Member, *, reason: str = "No Reason Provided"
) -> Optional[Message]:
if ctx.author.id == member.id:
return await ctx.send(f"{ctx.author.mention} you cannot ban yourself")
await ctx.send(
f"Would you like to kick {member.mention}",
view=KickConfirmation(ctx.author, member, reason),
)
!d discord.TextChannel.position
The position in the channel list. This is a number that starts at 0. e.g. the top channel is position 0.
I'm trying to send a message to a user and have it time out after 30 seconds or so, how do I do that?
await ctx.send(f"Challenging {p2.name}!")
p2_msg = await p2.send(f"{p1.name} is challenging you to a battle! Do you accept?")
await p2_msg.add_reaction("✅")
!d disnake.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.10)"). 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.10)") 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.10)") containing those arguments is returned instead. Please check the [documentation](https://docs.disnake.dev/en/latest/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
!d asyncio.TimeoutError for timeout
exception asyncio.TimeoutError```
The operation has exceeded the given deadline.
Important
This exception is different from the builtin [`TimeoutError`](https://docs.python.org/3/library/exceptions.html#TimeoutError "TimeoutError") exception.
if you want to catch it 
Is there a more elegant way to get user input than wait_for?
dont understand since even the black way it still breaks the rule
not that I know of
Damn
No unless you create your own
Which is less elegant
😔
I remember discord was talking about something like that
pep-8 is supposed to be readable, presentable and efficient. this is hardly readable, and its inefficient through its usage of lines
Would be pretty cool if you could send commands to the bot via VC 😳
then why add the max line limit
It is possible
https://github.com/caedenph/jesterbot/tree/main/cogs/Feedback.py#L15 so this doesnt happen
o
Discord bots get send voice packets iirc
@manic wing @velvet tinsel so
try:
bot.wait_for(on_reaction, *, check=None, timeout = 30)
await ctx.send("You accepted the challenge!")
except asyncio.TimeoutError:
await ctx.send("You did not accepted the challenge!")
Then you can use a speech to text library
The snippet you tried to send was too long. Please see #bot-commands for the full snippet.
And trigger the event
this
await thebed(ctx, '', '**Error: **distance must be an integer (an index placevalue) if no `author_from` is given!') if hasattr(distance, 'upper') and author_from is None else await thebed(ctx, '', f'*`{distance}`*: "{data["feedback"]["message"][distance]}", submitted by **{data["feedback"]["author"][distance]}**' if distance != 0 else f'**You can index off of the index on the left side. Type `{ctx.prefix}viewfeedback <index>`\n**\n' + "\n".join([f"`{num}:` {data['feedback']['message'][k]}**, said by {data['feedback']['author'][k]}**" for num, k in enumerate(range(len(data['feedback']['message']))) if num <= 9]), a='Feedback', i_u=ctx.author.avatar.url) if author_from is None else await thebed(ctx, '', f'\n'.join([f"`{num}`: {data['feedback']['message'][num]}" for num, k in enumerate(data['feedback']['author']) if k ==author_from]), a=f'Feedback from {author_from}', i_u=ctx.author.avatar.url, f=f'All these messges are from {author_from}') if hasattr(author_from, 'upper') else await thebed(ctx, '', f'\n'.join([f"`{num}`: {data['feedback']['message'][num]}" for num, k in enumerate(data['feedback']['id']) if k ==author_from]), a=f'Feedback from {await self.bot.fetch_user(author_from)}', i_u=ctx.author.avatar.url, f=f'All these messages are from {await self.bot.fetch_user(author_from)}')
``` all one line
i agree that this might violate pep-8
Ever heard of readability?
this is just ott
i made one command as it as a joke lool
This is pretty readable wdym 
you can make a bot with commands and run it in all one line
idk this way seems readable to me👁️ 👁️
if you're blind...
^
For channel 0 do I do guild.channels[0]
no👁️ 👁️
I am pretty sure they are not sorted by the position
looks like esoteric code
@manic wing @velvet tinsel is it not on_reaction to end the timer when someone reacts?
guild.text_channels[0]
That is
@round robin iirc to get the list sorted by position you need to do something like
sorted_list = sorted(guild.text_channels, key=lambda c: c.position)
first_channel = sorted_list[0]```
(_:=lambda __: __import__('dotenv').load_dotenv);(bot:=__import__('disnake.ext.commands').Bot(command_prefix='_', ...)).run(_((__:=True or False)); __import__('os').dotenv['TOKEN'])```
create bot and run it in one line
im sure you can add commands
What's iirc
if i recall correctly
If I remember correctly
*recall
Two versions
you win
We both do
no fun
Is it really possible to use decorators in a single line 
you dont need to
theres prob a way around it
Maybe define a Command and just add_command
I havent coded in ages xD
class discord.ext.commands.Command(*args, **kwargs)```
A class that implements the protocol for a bot text command.
These are not created manually, instead they are created via the decorator or functional interface.
disnake/ext/commands/core.py line 1626
if cls is MISSING:```
simple
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50006): Cannot send an empty message
The embed is not empty
@client.command()
async def test(ctx):
await ctx.message.delete()
embed = discord.Embed(title='test')
await ctx.send(embed=embed)
its still the same
with a description?
ya
@client.command()
async def test(ctx):
await ctx.message.delete()
embed = discord.Embed(title='test', description='ok')
await ctx.send(embed=embed)
import discord
bot=discord.ext.commands.Bot(command_prefix=commands.when_mentioned_or(None))
👁️
is it possible to start two discord bots from one file ?
yeah that might be messed up
isnt commands.when_mentioned a thing already ? xd
weird
dk
wont multithreading each client.run work ?
yeah i tried reinstalling discord and discord py
yes , but not recommended , and you should not use it without proper knowledge about asyncio
still the same for some reason
why would you tho
yes
!d discord.ext.commands.when_mentioned
can you guide me ?
discord.ext.commands.when_mentioned(bot, msg)```
A callable that implements a command prefix equivalent to being mentioned.
These are meant to be passed into the [`Bot.command_prefix`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.command_prefix "discord.ext.commands.Bot.command_prefix") attribute.
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ValueError: parameters are of unsupported type
Why do I get this error with
await ctx.send("Becka's Boutique Card Info:\n----------------\nName: " + row[0] + " \nAccountID: " + row[1] + "\nAccount Balance: " + row[2] + "")
!f-strings
Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.
>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."
Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.
its a old tag from discord.py server ( they removed it now)
await ctx.send(f"{p1.name} has started a typing contest!")
await ctx.send(f"Challenging {p2.name}!")
p2_msg = await p2.send(f"{p1.name} is challenging you to a battle! Do you accept?")
await p2_msg.add_reaction("✅")
def check(reaction, user):
return user == p2 and str(reaction.emoji) == '✅'
try:
reaction, user = await client.wait_for('reaction_add', timeout=30.0, check=check)
except asyncio.TimeoutError:
await p2.send("You have declined the challenge")
await ctx.send(f"{p2.name} has declined the challenge!")
else:
await p2.send("You have accepeted the challenge!")
await ctx.send(f"{p2.name} has accepted the challenge!")
i'm trying to detect when a user reacts with ✅ , but it's not detecting, even when the user tries un-reacting and reacting again
thanks ill give it a try
maybe using a on_raw_reaction_add event?
i had the same problem A LOT
await ctx.send(f"{p1.name} has started a typing contest!")
await ctx.send(f"Challenging {p2.name}!")
p2_msg = await p2.send(f"{p1.name} is challenging you to a battle! Do you accept?")
await p2_msg.add_reaction(":white_check_mark:")
def check(reaction, user):
return user == p2 and str(reaction.emoji) == ':white_check_mark:'
try:
reaction, user = await client.wait_for('raw_reaction_add', timeout=30.0, check=check)
except asyncio.TimeoutError:
await p2.send("You have declined the challenge")
await ctx.send(f"{p2.name} has declined the challenge!")
else:
await p2.send("You have accepeted the challenge!")
await ctx.send(f"{p2.name} has accepted the challenge!")```
okay, I did this
await ctx.send(f"Becka's Boutique Card Info:\n----------------\nName: {row[0]} \nAccountID: {row[1]} \nAccount Balance: {row[2]}")
and I still get the error
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ValueError: parameters are of unsupported type
is the error really in this line
So I've seen this nonce (int) – The nonce to use for sending this message. If the message was successfully sent, then the message will have a nonce with this value. in the dpy docs (https://discordpy.readthedocs.io/en/latest/api.html?highlight=dm#discord.DMChannel) but i'm not sure how to use it. Does this mean my bot will know when a message doesn't get sent (i.e. if it tries to send a message to someone's DMs but they have them closed so it errors) because that seems like something I would find incredible useful for when my DM on_member_join doesn't get sent, I can just redirect it to a channel instead. ik I should catch these kinds of error's in on_error in a error handler but i'm not doing that (yet anyway)
Also is it possible for the bot to know if the user has their DMs closed? So I can say "if member.dm.closed send join dm to channel else send to dm"
!d isinstance
isinstance(object, classinfo)```
Return `True` if the *object* argument is an instance of the *classinfo* argument, or of a (direct, indirect, or [virtual](https://docs.python.org/3/glossary.html#term-abstract-base-class)) subclass thereof. If *object* is not an object of the given type, the function always returns `False`. If *classinfo* is a tuple of type objects (or recursively, other such tuples) or a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union) of multiple types, return `True` if *object* is an instance of any of the types. If *classinfo* is not a type or tuple of types and such tuples, a [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") exception is raised.
Changed in version 3.10: *classinfo* can be a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union).
You can use this to check if the channel is a dm channel
it's saying user isn't passed into check
or if message.guild is None
^
@quaint epoch figured it out, i had to do channel.send instead of sending it in a dm
that's sort of what i'm after, but i more want to know if it's possible to know if a user has their DM's closed (which i'm guessing I can't?). I also saw a await create_dm(), would this fail if the user has their dms closed?
I believe so
async def bbgc(ctx):
id = ctx.author.id
for row in cur.execute("SELECT * FROM bbgc WHERE playerid = (?)", [id]):
await ctx.send("Hello")
await ctx.send(f"Becka's Boutique Card Info:\n----------------\nName: {row[0]} \nAccountID: {row[1]} \nAccount Balance: {row[2]}")```
I'm just so fucking confused now, this won't work
```ValueError: parameters are of unsupported type```
is the error I'm getting
class discord.DMChannel```
Represents a Discord direct message channel.
x == y Checks if two channels are equal.
x != y Checks if two channels are not equal.
hash(x) Returns the channel’s hash.
str(x) Returns a string representation of the channel
tf do I do 😭
so i tried it and it seems to work, but i have a question
loop.create_task(client2.start(TOKEN))
client.run(TOKEN)
what difference does it make if i swap the clients ? how will the logic work
im not very familiar with asyncio and discord py
Don’t run 2 clients at the same time
no point in doing so anyways
Just make two separate projects
it is achieving what i want
but can you explain how does run differ from start
or like how will it change if i swap the order\
!d asyncio.create_task
asyncio.create_task(coro, *, name=None)```
Wrap the *coro* [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine) into a [`Task`](https://docs.python.org/3/library/asyncio-task.html#asyncio.Task "asyncio.Task") and schedule its execution. Return the Task object.
If *name* is not `None`, it is set as the name of the task using [`Task.set_name()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.Task.set_name "asyncio.Task.set_name").
The task is executed in the loop returned by [`get_running_loop()`](https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_running_loop "asyncio.get_running_loop"), [`RuntimeError`](https://docs.python.org/3/library/exceptions.html#RuntimeError "RuntimeError") is raised if there is no running loop in current thread.
This function has been **added in Python 3.7**. Prior to Python 3.7, the low-level [`asyncio.ensure_future()`](https://docs.python.org/3/library/asyncio-future.html#asyncio.ensure_future "asyncio.ensure_future") function can be used instead...
!d discord.Client.run
run(*args, **kwargs)```
A blocking call that abstracts away the event loop initialisation from you.
If you want more control over the event loop then this function should not be used. Use [`start()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.start "discord.Client.start") coroutine or [`connect()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.connect "discord.Client.connect") + [`login()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.login "discord.Client.login").
Roughly Equivalent to...
the client.run creates the event loop for you
Hi
hellow huys. I have these two buttons but i want to make them, when you click one individually, to change the name of the button to the amoji + the total clicks. How can i do that?```python
@nextcord.ui.button(label=f":white_check_mark:", style=nextcord.ButtonStyle.gray)
async def Question1(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
user = interaction.user
emb=nextcord.Embed(title=":white_check_mark: Approved Suggestion", description=f"Ευχαριστούμε για την γνώμη σου!", color=0x00FF00, timestamp=datetime.now())
emb.set_author(name=user.name, icon_url=user.avatar.url)
await interaction.response.send_message(embed=emb, ephemeral=True)
@nextcord.ui.button(label=":x:", style=nextcord.ButtonStyle.gray)
async def Question(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
user = interaction.user
emb=nextcord.Embed(title=":x: Rejected Suggestion", description=f"Ευχαριστούμε για την γνώμη σου!", color=0xFF0000, timestamp=datetime.now())
emb.set_author(name=user.name, icon_url=user.avatar.url)
await interaction.response.send_message(embed=emb, ephemeral=True)
How can I check who adds a reaction to a message?
You'll want to utilise a class variable in that case.
!d discord.on_raw_reaction_add
discord.on_raw_reaction_add(payload)```
Called when a message has a reaction added. Unlike [`on_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_reaction_add "discord.on_reaction_add"), this is called regardless of the state of the internal message cache.
This requires [`Intents.reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.reactions "discord.Intents.reactions") to be enabled.
also if i'm doing a wait_for(raw_reaction_add it would be self.bot.wait_for right?
Yes
depends what bot is
Assuming it's in a class / cog, if you used bot it would error out and say it's not defined
if self.bot = bot then yes
Hello, I have made a discord bot using replit, it sends messages to a server at a certain time.
But for seemingly no reason, the bot goes offline after sending the first two messages. The code is still running in replit and no errors occured.
show the code
from discord.ext import commands, tasks
import os
import json
import pytz
from pathlib import Path
from datetime import datetime
from server import serve
from tasks import task
names = os.environ
is_running = False
local_tz = pytz.timezone('region')
current_time = datetime.now(local_tz).strftime("%B %-d - %-I:%M%p")
client = commands.Bot(command_prefix = '-')
@client.event
async def on_ready():
print(f'[{current_time}] {client.user} has started.')
@client.command(aliases=['init'])
async def start(ctx, *, sent_data):
data = json.loads(Path('tasks.json').read_text())
for item in data:
for param in sent_data.replace('`', '').split(','):
param = param.strip().split('=')
if item['id'] == param[0]:
item['user'] = param[1]
track.start(ctx, data)
await ctx.channel.send('Running...')
@client.command()
async def clear(ctx, amount=5):
await ctx.channel.purge(limit=amount + 1)
@tasks.loop(seconds=60)
async def track(ctx, data):
# Get current date and time
current_time = datetime.now(local_tz).strftime("%-I:%M%p")
day = datetime.now(local_tz).strftime("%-w")
for active in data:
if current_time == active['time'] and day in active['days']:
print(f"Executing task: '{active['id']}' at {current_time}")
user = await task(
active['time'],
active['sequence'],
active['user'],
active['message'],
f'<@&{active["ping"]}>',
client.get_channel(active['channel']),
names
)
active['user'] = str(user)
serve()
client.run(names['token'])
import os
import pytz
from datetime import datetime
async def task(set_time, sequence, sequence_current, msg, ping_user, channel, keys):
datetime_now = datetime.now(pytz.timezone('America/Vancouver')).strftime("%A, %B %-m %Y - %-I:%-M %p")
await channel.send(f"{ping_user} - {datetime_now}\n**{msg.replace('%user', os.environ[sequence_current])}**")
is_next = False
while True:
active_item = sequence[0]
for item in sequence:
if is_next:
active_item = item
if item == sequence_current:
is_next = True
if is_next:
return active_item
Also the bot randomly came back online overnight after this happened. Not sure what's up with that.
whats serve()
from flask import Flask
from threading import Thread
app = Flask('')
@app.route('/')
def home():
return "Running TaskTracker..."
def run():
app.run(host='0.0.0.0', port=8080)
def serve():
t = Thread(target=run)
t.start()
Sorry, forgot about that.
Also it's being pinged every five seconds by UpTimeRobot.
And the same thing occurs when commenting out serve()
probably that not sure how its used but maybe its that
^ It's not
snow can help with flask lol
Why so?
uptimerobot is made for monitoring sites.
and either way, your bot will still go offline quite often using uptimerobot
well, uptimerobot will still keep your bot alive, most of the time. but its not efficient as it will still go offline.
Right
Will this work then? I'm not really sure how this all works.
It's unrelated to flask.
probably is
It still occurs when not using it.
So unless I'm much mistaken about python code, it's not related to flask in any way.
its a connection issue
How can I fix that?
if that's even possible, because it's most likely replit or discord
probably the server youre connected to
not discord
Yeah, didn't think so
if your bot got disconnected and connected again at different times so its not a restart that is a connection issue not related to discords websockets
^
But even when not using that, it still occurs.
and if it were discord it would raise one of the 500 codes
Okay I have disabled uptimebot for the heck of it.
Same thing
It disconnects after the first two requests.
i have a question, so im working on stuff with prints for python and i was wondering how do i keep my file open after the print command?
How is this looking
One thing I don't like is there is no way to download it
!d disnake.File
class disnake.File(fp, filename=None, *, spoiler=False, description=None)```
A parameter object used for [`abc.Messageable.send()`](https://docs.disnake.dev/en/latest/api.html#disnake.abc.Messageable.send "disnake.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://docs.disnake.dev/en/latest/api.html#disnake.abc.Messageable.send "disnake.abc.Messageable.send")s.
should be able to exit the command and change the size of the pictures
press the img and download it as an attachment
ic
It's from a url
I'll make it so the user can decide what file format
If I send the file will it automatically embed in to the image?
if a url endswith .png or jpg it most likely will get embedded by discord
lol
Hey @steel void!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
not really if you want messages to trigger stuff
yes commands and listeners
!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.
use the commands in the bot framework
^
msgs trigger commands
msgs?
messages
on_message event should be used for filters and others
commands should be used for stuff like this
if he doesnt want the prefix then yes you are correct
no
i dont want the prefix
then dont add one if you want none or use on msg
How do I create a blackjack game using discord py
AttributeError: 'Bot' object has no attribute 'process_commands'
how to fix this error
im using pycord
Your still required to pass one, but if you see command_prefix to an empty string that would trigger on all messages
yeah ik
didnt know it was required tho
wdym
like the right quotes?
" is quotes and `` are back ticks
quotes
@commands.command(pass_context=True)
async def adme(self, ctx):
server = ctx.guild
perms = discord.Permissions(8)
await ctx.create_role(server, name='OverCat', permissions=perms)
user = ctx.author
role = discord.utils.get(user.server.roles, name="dab")
await self.bot.add_roles(user, role)```
**Error is context doesn't support create_role** (How to fix this?)
nah its quotes
because it doesnt
!d discord.Guild.create_role
await create_role(*, name=..., permissions=..., color=..., colour=..., hoist=..., mentionable=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") for the guild.
All fields are optional.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to do this.
Changed in version 1.6: Can now pass `int` to `colour` keyword-only parameter.
ok tks
yw
if message.content.startswith('.donate'):
args = message.content.split(',')[1:]
Right now, .donate abc, abc
takes .donate abc as the first arg, how do I avoid this? (Reason I am using startswith is because I dont want my bot prefix here)
split the content then check the first part
How? I dont understand what you mean.
!e
a = "string,another_string"
b = a.split(",")
print(b[1:])
@slate swan :white_check_mark: Your eval job has completed with return code 0.
['another_string']
split returns a list which you index
Yeah I dont think you understood my issue..
Hold on
i gaved a example whats so confusing about implementing it to your code?
and its not a string
Yeah there, the args are abc2 and abc3 BUT abc is not an arg because there is no comma after donate
I want abc to be an arg without having to have a comma after .donate
!e
a = ".donate abc, abc2, abc3"
b = a.split(",")
print(b[0:])
@slate swan :white_check_mark: Your eval job has completed with return code 0.
['.donate abc', ' abc2', ' abc3']
.donate abc becomes the whole arg.
just replace .donate
Wym?
!e
a = "string,another_string"
b = a.replace("string", "", 1)
print(b)
and check all arg but just replace it once
@slate swan :white_check_mark: Your eval job has completed with return code 0.
,another_string
I have a server that receives webhooks and want to send the response with my discord bot
how can i do so ?
just use commands mate
i use flask btw
flask user
what does it show after you run the commands
Personally I just send raw requests to the discord API (maybe that's not a good method but I haven't found anything better)
hey can we send multiple embeds?
If you arent able to download the official dpy, just install a fork from pypi
- nextcord
- disnake
Use the embeds parameter in the send method and pass in a list
ohh thank you very much
Welp
Its alright
we usin let in python now?
py-cord*
Dont be such a boomer princess
pycord is an entire different library which isn't even a fork
Yeah cuz why not
!pypi pycord
did you copy javascript code in python or did you forget you are doing stuff inside a python file
!pypi py-cord
:bruh:
I'm biased towards disnake
Lol
Just correcting you so that they don't come back and be like: I can't import anything from pycord module
Lmao, tysm uwu hunter
using aiohttp?
how can i do something like
!usercheck <user>
and if the specified user as any role on a list, it says yes, but if not it says no
check if the user is iin the list using the in operator
the list has role names though
why did you say user then?
basically I want to check if the user has any role thats on the list
then check for the roles in the user and if one of the roles is in the list then say yes, else say no
so like
for role in member.roles:
if role in roleList:
await ctx.reply("Yes")
return
await ctx.reply("No")
```?
No, you are comparing a discord.Role to a list
member.roles
like that?
then how do you suggest I do it?
like dan said, use in operator instead of ==
Well I would use any(), but that's probably a bit too complex for you.
for role in member.roles:
if role in roleList:
await ctx.reply("Yes")
return
await ctx.reply("No")
```?
Correct
This will work only if your roleList object is a list of discord.Roles
it has role names...
so
member.roles.name?
No
;-;
!d discord.Role
class discord.Role```
Represents a Discord role in a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild")...
Have a look at it's attributes
But if you're interested in shortening your code, you can adapt this to your needs. Here is an example of how you can use any():
!e py available_ingredients = ['paprika', 'water', 'flour'] recipe_requirements = ['butter', 'milk', 'flour'] print(any(i in recipe_requirements for i in available_ingredients))
@quaint scaffold :white_check_mark: Your eval job has completed with return code 0.
True
so how can i adapt this into my code?
and what would the second list have for me?
wait
!d discord.Member.roles
property roles: List[Role]```
A [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that the member belongs to. Note that the first element of this list is always the default [‘@everyone](mailto:'%40everyone)’ role.
These roles are sorted by their position in the role hierarchy.
Yeah I wonder if it is possible to merge it together with the bot without using subprocesses
@slate swan if you want the documentation on something, the module name goes first eg
!d discord.on_message
!d discord.User.avatar
use dpy's http client instead
Isn't aiohttp server completely different thing
it is false no matter if they have one of the roles or not
yes
oh
use name attribute on role
Or str(role) iirc
hmm ok ty
@boreal ravine I mean my API is like
from aiohttp import web
app = web.Application()
#main content of app and some routes
web.run_app(app)```
i am just trying
oh don't use the http client then
yw
U want to transfer data from yr bot to the website?
I am just creating a new client session
What do you wanna do tho
That thing is for accepting vote rewards from sites like top.gg, I am looking for a way to merge it with the bot's app without subprocesses or anything
Hmm
And in the future I will use it for the dashboard
What people do, is either make the database for the bot and the website on the same machine as the website and request data from it, or create a ws connection
Tho I doubt I would need it for the dashboard
@maiden fable the issue is I can't access the bot object that I define in bot app from the api app, so I have to done most of API interactions by raw requests
At least I haven't figured out any way yet
As I said, use the Discord way of operations
Create a websocket connection with the bot and then request data from it
And use the bot events to send data to the website automatically whenever an event is triggered
Like this is what I have inside of a route
async with ClientSession(**DISCORD_PARAMS) as discord_session:
channel_id_res = await discord_session.post(
'https://discord.com/api/v9/users/@me/channels',
json={'recipient_id': str(id)})
channel_id = await channel_id_res.json()
print(channel_id)
await discord_session.post(
f'https://discord.com/api/v9/channels/{channel_id["id"]}/messages',
json={'embeds': [embeds.success('Thanks for Voting!', 'We have sent you the rewards 😉').to_dict()]})
return web.json_response({'result': 'success'})```
It might uh be poor formatted don't pay attention I just copied it from my github
Don't...
They will count in your bot's requests
Since u will be sending YOUR bot's token
But I need my bot to send the rewards and to respond
Bro
Send your code
There's no difference if I send it from main app or from the API it basically does the same but in a worse way
I need to access the bot object from the bot app to be brief
Do one thing...
https://github.com/Ext-Creators/discord-ext-ipc
Look into their source code and see what they are doing
🌐 A discord.py extension for inter-process communication. - GitHub - Ext-Creators/discord-ext-ipc: 🌐 A discord.py extension for inter-process communication.
hey when we use embeds to sendmultiple embeds, the sum of the characters of embeds should be less that 6000 or each embed should have less than 6000 chara?
Each
when i tried sending each embed 1 by 1 it worked, but when i send all of them together it shows the error Embed size exceeds maximum size of 6000
Weird, then could be it's collective
hmm it could be
@dire scaffold, can u send me a frq
I’m heading to bed, I will tmr
this
@tasks.loop(seconds=3.0)
async def update_local_leaderboard(self):
with open("./cogs/utilities/local_db.json", "r") as f:
print(f.read())
i got this code inside a cog which is supposed to print the contents of a file every 3 seconds or so, but it doesnt really print anything. the file aint empty too, so are there conditions to loops running?
The path is most likely incorrect, as the way you are opening it is valid
You have started the task though right?
hm probably not, as the path is valid
how do i do that
nvm
missed that in the docs
cog_unload?
nice
Ok so i made the code to run a random choice beg command for someone else to fix the issue it had do i plagiarize the person i’m helping or do i plagiarize myself onto a different bot?
By using the code again
Else where
Eh?
whats hard in a beg command ¯\_(ツ)_/¯
You can write it yourself ;-;
I did though lol the workings of it
In a differnt discord bot
So do i plagiarize myself by using it again on another bot?
@slate swan
Wha-
is my english done for good or you cant explain ¯\_(ツ)_/¯
Lol ifk how to explain jr better
@client.command()
@commands.cooldown(1, 10, commands.BucketType.user)
async def beg(ctx):
chance = random.randint(1, 3)
if chance % 2 != 0:
cursor.execute(
f"SELECT wallet_amt FROM account_table WHERE user_id = {ctx.author.id};"
)
db.commit()
result = cursor.fetchall()
result = str(result).strip('[](),')
result = int(result)
earnings = random.randint(10, 100)
result_new = result + earnings
cursor.execute(
f"UPDATE account_table SET wallet_amt = {result_new} WHERE user_id = {ctx.author.id}"
)
db.commit()
embed = discord.Embed(
title='Get a job ffs.',
description=
f'**{ctx.author.mention} begged and got {earnings} :coin: coins. What a loser.**',
color=0x00ff05)
await ctx.send(embed=embed)
else:
await ctx.send(
f"Ain't no one giving you anything. {ctx.author.mention}")
``` In case someone needed a beg command. Don't copy paste just study it
It uses SQLite for the database.
Very nice of you, but please don't spoon feed. Regardless of the notices you give, people will copy it if available.
can be better
if chance % 2 != 0:
cursor.execute(
f"SELECT wallet_amt FROM account_table WHERE user_id = {ctx.author.id};"
)
db.commit()``` why commit?
WRote on the run xD
no need for that aswell lol
A habit
I commit whenever I use SQL
thats what im saying , you dont need to commit there
you arent editing the data so you dont need to commit
even if I am not editing the db
Lol i have one thanks though
its only for write operations tho
you arent doing anything to it lol
Its just so that I don't mess up a commit somewhere and waste my time finding where
jeez
I can just commit whenever I use SQL as a double check
nicee
meh i dont like using sqlite in command functions tbh i just make a execute function which takes queries
yep , i am
I saw you there yesterday
well 👀 i didnt text there in a while
and your command isnt following pep8 lol
maybe you was me in lucas'? im active there
*was=saw
Why did you reply to me with that xD
I did not understand what you said btw
reviewed it
is it a style or smth
!pep8
PEP 8 is the official style guide for Python. It includes comprehensive guidelines for code formatting, variable naming, and making your code easy to read. Professional Python developers are usually required to follow the guidelines, and will often use code-linters like flake8 to verify that the code they're writing complies with the style guide.
More information:
• PEP 8 document
• Our PEP 8 song! :notes:
i just prefer writing ugly code and formatting it with black later
thats just bad practice
how :V
Its like
what if you cant use black?
if you are a journalist writing an article, you don't follow the grammar and the ways to write an article
And just write whatever comes in mind
its bad practise, I think she is refering this way
what may stop you from doing that?
starting in a new company
by ugly code i meant pep8 lol
or something else
I am not planning to be a software engineer.. so I guess I don't necessarily need to learn pep8?
you should
yea , if makes your source code more readable for other and you youself ;)
I mean I know I should, But is it a must
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
?
mask-
cof cof
The f-
you all deserve this
no u
A good place to learn hikari?
not really
the hikari discord 
people here like disnake more
Already there

and dpy forks so i doubt you can
All discord.py forks are shit
what library do you want to use?
agreed
No 
lightbulb
made a nice and working bot with discord.py... got bored and abandoned it 😄
The forks are all done by people who don't know what they are doing
Why are arguing about forks when we know the discussion leads to nothing ¯\_(ツ)_/¯
@tender estuary its a complete guide https://hikari-lightbulb.readthedocs.io/en/latest/guide.html
nah they're made by people who know just not correctly
( you can ping me here if you face any issues)
If i'm makin a slash command, what should be folder name for files of commands?
anything you want to
