#discord-bots
1 messages ยท Page 759 of 1
Some people are just.....born different
lol
Internals of dispy are also really bad
Most of us suggest Nextcord or Disnake
Some also Hikari
But arent both forked and work on the same internals?
Movie cinematic vibes
They edited it
oh
Iโve hardly seen anyone come in here for hikari
That means you are not active enough ||jk||
Don't recommend it.
Why not ๐คทโโ๏ธ
Hikari is a pretty nice library tho. I prefer tanjun over lightbulb tbh.
Depends but processing power ;-;
External process okay but not combined.
I would make an API that handles the request and off-loads it to another process since it is highly blocking.
You are using an API for Discord wdym?
Candy wrapper?
api wrapper
Lmao, nvm my message

an api isnt the same as a api wrapper
Omg, you're so intelligent
idk why you said and api tbh
doesnt make sense
Can you tell more detailed? Like for generating rank cards or smth more complicated
Uhhhh, I never said that
logs can prove me right tho
lol
No comments

Actually rank cards + pfp color change etc.
I think PIL would be enough wouldn't it
i didn't use any API
With numpy
Epic combo
Its not ideal always lmao
Yea maybe but i was learning open cv nowadays :d
Cv can be a bit uh too heavy
Yea so heavy
You dont incorporate anything within your bot
Wdym?
Use an API as pandabweer said
so who are coders form here that runs disnake? admins or regulars?
wut
||!ot||
Okay i will search on google for APIs
We were talking about your own API-
@slate swanthem who runs disnake, i heard is from this community but are they normal discord users or mostly admins?
wdym by run disnake
those who contribute
Ideal, otherwise using opencv within your bot could ensure potential crashes
what about them
runs the fork
wdym run the fork?
What
What is going on
ahhhh
yes maintain, sorry bad english
to many
anyone has link for disnake discord, i might join there now when i moved over from discordpy
ty brother
yw
Disnake server has less than 1k members?
yes
weird
not really
its just underrated
Yeah
which some forks are really overrated
pycord
Yeah already 100% CPU usage thanks to opencv on my pc lol
Lets save pycord further humiliation and change the topic
nextcord > all
bro what?
wdym lmao
We dont discriminate, tysm for your statements
hikari > any dpy fork
(i dont use hikari)
i like my dpy forks but the statements that danny have said are true
Some random unmaintained dpy fork >>>>>>>>>>>
LMAO
๐ง
guys its obvious just go with discord.rb
not tryna fight just trying to state nextcord is my preferred
We discuss
We dont fight, lmao
^
Discord has a ruby version?
nah DSharp+
I mean same thing, you understood my point
dont see much discussion ๐
ยฏ_(ใ)_/ยฏ
more like namedropping
||@slate swan Ruby sucks, make a discord API wrapper in Assembly x86||
shes got a point
how about GO?
but ruby doesnt suck
Stay humorous
is GO doing good? i nvr used it but i knew a guy made a irc bot in it while i did in python
GO?
average ruby hater
googles own language
its like pythonish
Lmao
what i suspected, i had hard seeing GO takeover py
go is just dead
Python-ish* ||With a hyphen, thank me later||
Discord is not supporting go for ``` messages :///
is there any lib for discord.go lel?
apologize?
what u mean?
Me stubborn
discord.cobol
discord.cpp tho? ๐
no
imagine making a bot in cpp
check pins
Lets save discord API further humiliation and end this discussion
why not aint cpp just fun code to write, never ending story
cpp is just so over complicated
my point ๐
Not really
yes really
decleration n decleration and files n files n codes of codes for simplest shit ever
someone plz check #help-cupcake im new to discord.py and im trying to learn, i need help.
I mean, assembly >>>>>
hardcore assembly fan respect it
asm n cpp is complicated
Ah ๐คฆ๐ป๐คฆ๐ป but it is complex....
Nvm
welp
but fun learning smash the stacks n shit
theirs a better lan then asm
Welp
Use binaries, doesnt matter smhh
minecraft command syntax
Lmao
lua
lua is for World of warcraft
LMAO
or no use
HTML best
Case closed
isnt even a lan
html with hardcaded styles โค๏ธ written in notepad
Welp
good old times
cobol
So much uwu
whats uwu?
yall dont program in cmd?
Git bash
DOS
ew
Um
imagine not programming in binary ๐ฌ
Lemme guess 37?
no
discord mods are mostly 50>
Lol
Lmao
not mods
lol
your talking to yourself rn its funny
I know its cute ๐
happens just know im always lurking
not much going on here atm hopefully i dont disturb anyone
lol
@honest vesselHows ya day been?

It was shit at first, but then smoothed out. Its decent atm.
bros talking to himself
fr
Nice to hear brother!
๐
Donate me command ideas please
I am special dont mind me.
Im running out of ideas
use an api to get the top movies this week
or the weather
bot -> voicechat functions | db -> add remove webstations, and swap channels and see a list of channels
webradios are public n very legal
its basicly u open a browser n listen to webradio
ofc i am
if the song is copyright no
is it illegal turn radio on at work?
no
then no
if i ripped songs that would be illegal
like ytdl
why i think outofbox n make webradio functions
It all depends on the content your bot is streaming
hey andyyyyyyyy
So as long as they allow/have licenses that allow you to redistrubte/stream
Perfectly legal case^
^
thing is i nvr safe actual music, i tho save song titles cause we have function like .dj ss (saves song being listenined to at a personal db list)
Nothing wrong with not saving the music, even better probably
But the problem stems at whether or not you have the rights to stream
@pliant gulchsee it this way, i am in a car... turning music on those in my car hears it...
copyright laws lol
because they have the right to distribute the song
Yes but your not in a car, and instead use the discord API to stream this music
its like i turn radio on at work
Completely different in legality
they ask for permission
they pay license for play it
yes
To explain further as well, downloading the music isn't the only issue it also including the streaming of the music
But your bot is streaming the audio/music
Specifically in youtubes case their ToS says no bots
I'm not sure about radios though
theirs a difference between listening and streaming it lol
in the car
The radio from your car is streaming the audio from the radio, your bot streams the audio from the radio
Do you see the difference here
Like it's perfectly legal for me to watch a youtube video, on the other hand I cannot stream the video via third source
As per their ToS
Its quite simple,
your listening to it in a car which has a radio which the songs come from a radio station which a radio station asks the artist or team for permission
So your bot somehow runs without hardware
but what happend,
thats pretty much it, and i display what url playing radio atm
youtube stream is diffrent cause copyright
radio pay for play songs
Not to accuse you of anything but one of the biggest causes of that is when you use a modded discord client and reply to a deleted message
so youre steaming the radio from the radio station?
Copyright plays a part, but also youtubes ToS itself says not to bot their services, E.g use a discord bot to stream
i use orginal client
Same would go along for whatever radio you are utilising here

If it's allowed by their policy/ToS perfectly legal and fine
Otherwise your in greywater
Your not streaming radio audio through a radio
Your streaming audio from the radio from the bot
so i stream radio from phone plug into a big speaker
basicly
Sure, if the phone has the licensing to permit it
i dont host a website n take all their listneers n cost bandwidth
Your radio in your car, has a license from the radio company to play
Otherwise the car company wouldn't sell it together
Sure you can plug it into a big speaker and listen to it
The issue though is streaming said audio back into the internet or other unauthorised places defined by the licensing agreement
my first idea was to play only nocopyrigthed music for streamers and others on discord
Basically going back to the grey water
i think its a gray zone tho
i think they dont care aslong i dont make money or steal bandwith
Yea this is perfectly fine, just download the mp4s from the offical noncopyright music website and stream those
i dont think i doing naything bad or wrong tho
but i quitted that cause so unclear copyright rules
some call it noncopyright but if u make money its copyright
Are you making money??
Streaming podcasts would be interesting
i pay for bot host
Do you have anything in your bot that can make money off of
no
Then how does this case apply
its a small place like 10 users n sometimes we listen to alls diffrent radios
@pliant gulchi ment youtube songs, some are hosted by lets say nocopyrightsongs, but in small text its not copyright free, if u make money u gotta pay
it can be same channel but diffrent rules
very gray
๐ Noncopyright doesn't have youtube songs they have songs
Youtube is a hosting platform for them
If you, I don't know; take the time to pick out a mp4 and a license from their website
omg stop be so specific how i talk
Maybe you'd get somewhere, instead of complaining
point is same
u the one complaining ๐
I just told a guy he can make a webradio player like i did
Not sure where I was complaining
Simply explaining the legality of the topic is complaining now I gues???
๐ค
You were just explaining 
Is there a default policy that applies if a website doesn't have their policy listed?
no its my english
Not sure, but if it works the same ways as licensing; No license means absolutely no use unless otherwise authorised by the owner of said content
There always will be 
Not officially, but yes there are some
but yall are right its a grayzznoe but - their commercial aint blocked etc
its not illegal for me to record it n play it at my friends house
or is it?
maybe that is, but if stream its fine
cause nto savedn realtime

Whatever man you take it however you want lol
Seems like you haven't read a single thing I said
i atleast gave one inspiration of podcasts
@pliant gulchi did but i just wanna say it prob is a grayzone
i cant answer it
i think its more about if $ in it
steaming netflix on voicechat is prob not good.
but netflix is locked radio is public
oh 5 listeners sue me 5 millions usd
i think its all fine, they can ipblock bot if any
@pliant gulchi get arguments but i think its same both same
if any i give that radio new followers
You do you ยฏ_(ใ)_/ยฏ
A while back I heard that the developer of discord.py was going to stop developing because discord was changing their API in a few unfriendly ways. Anyone know the latest developments on this? Is discord.py getting abandoned soon? Is the new API going to cause issues?
it was discontinued in august 2021. There are other forks out there like !pypi nextcord
!pypi nextcord
A Python wrapper for the Discord API forked from discord.py
!pypi disnake
!pypi pincer
- Development on Discord.py has already pretty much stopped, it's unmaintained but still usable and there are also some forks (or entire rewrites) available as listed above.
- It may cause some issues once some of the more breaking changes (like enforcement on slash commands) go through sometime in April.
Makes sense, thanks @wispy spade @slim ibex
welp the first yeah discord was just ignoring devs and making promises for the api that never came and danny(the creator) stopped maintaining it since he works in a hospital he didnt have much time
he had many responsibilities which he didnt want to keep on going with
he doesnt want to comeback but so many forks with bad implementation are just calling him to fix all these messes forks have made but he doesnt want to comeback
more info in this gist -> https://gist.github.com/Rapptz/4a2f62751b9600a31a0d3c78100287f1
!pypi pycord
Or is it py-cord
Basically froze my computer for 5 minutes
Was doing this [''.join(element) for element in list(permutations(data))] to a list of like 25k indexes
dang
Lets just say I overlooked that bit
I copied all these in to a file
And started doing that list comp on it
Was not a good idea
yeah thats allot of elements
guess whois back ur fav
It is quite a bit
oki.miiiii

I'm making an anagram command
nice
So I need a ton of words
whats the thing with japanese besides be japanese`?
bro wut
why u like japaneses`?
!ot ๐ณ
Off-topic channel: #ot2-never-nesterโs-nightmare
Please read our off-topic etiquette before participating in conversations.
๐ถ
list
?
that is called list
How do I dissolve the list?
dissolve ? what do you mean
how is this dpy related๐งโโ๏ธ
i was gonna say that lmao
theres nothing wrong ?
del discord
your checking if a int is in a list of ints what about it
๐
wat is it real
list = [id1, id2]
if ctx.author.id in list:
yes ?
dont call it list
just thinking now how i unimport a lib?
list is a class
As an example mmf
well i mean you can still do [] which that is usually what ur gonna do, so not much of big deal
or b
yes but its not a good example
good point
evening okimii
list is a builtin, but using list doesn't affect anything
it shadows it
yeah but im saying that when u use symbols directly, it gets original one
evening
True = False
Except you can't do this since True is a reserved keyword
!e True = False
@pliant gulch :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | True = False
003 | ^^^^
004 | SyntaxError: cannot assign to True
you can assign stuff to variables that shadows names of builtins and stuff
a = await ctx.send("msg")
await a.add_reaction("emoji")
message is?
If "message" is a message object then yes.
Veriable
that has?
it is just for example
ah
Definitely
yeah
Alright thx :)
!d discord.Message.add_reaction
await add_reaction(emoji)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Add a reaction to the message.
The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji").
You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission to use this. If nobody else has reacted to the message using this emoji, the [`add_reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission is required.
okimii going god mode ๐ค
no
yes
no
yes
fine
do you want me to selfbot and then say yes whenever you say no
no pls
and then okimii goes report-
big bren
๐งโ๐ฆฏ
yes
import disnake
from disnake.ext import commands
bot = commands.Bot(command_prefix=".", help_command=None)
@bot.event
async def on_ready():
print("ok")
@bot.listen()
async def on_message(message):
if message.author.id == 637458038915203127 and "no" in message.content:
await message.reply("yes")
will this work?
why another if statement
nesting it ๐
no pls
hehe
good
you can
panda help okimii help
just subclass the Bot class๐ง
SUUUU
no because "bot not defined" ๐
๐
SUUUUU
selfbots are only client so no
what
oh i didnt even read what he was trying to do๐ญ
commands.Bot for most part is literally Client but handles message parsing and stuff
the bot class is the subclass of client
Just because you can doesn't mean you should
so it will have everything that the client class has and more
tell that to people who still self bot
cause they do and abuse ppls lives with t sadly :(
Can i add reaction to embed with embed.add_reaction() ???
no, but u can add to message
yes!!!!!1!!1
h?
you cant add reaction to embed, but u can to message itself
you get what we mean
oh, you mean you can't do discord.Embed(...).add_reaction(...)?
yes but man said embed.add_reaction
that yes
what
its a coro
make your mind(s) up
Everyone confusing me ROFL
๐
i think you can add a list im not sure
yes
lol
HI I just want ot know where I would go to learn pythonI don't know anything as of know and am trying to decipher old code
the man who answered that question is stupid though
he forgot to put len()
lollllll
done
I told him
the docs ๐ you are saviour
theres nothing lol
nothing like that exists and besides, embed is in message, so adding reaction to embed basically means you want to add reaction to message
embed is a instance of a msg
thats what i was saying
can someone help me please
dont ask to ask, just ask
I asked earlier no one responded
here
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
Thank you
So this might be a bit of a abstract explanation but I think if I start adding in lots of my code it will cause more confusion.
I have a lists (key_words) and 'thing'. I want to know if anything from my list appears in the 'thing' so I'm doing if key_words in message.embeds[0].title: (the latter being the 'thing'. Is there a way to know which item of the list triggers the code to execute the code within the if statement? Or would I need to break it down and check each item of the list individually?
can you show us the full code?
should i return this or add an "if" ? (i have 4 emojis so idk)
@commands.command()
@commands.has_permissions(administrator = True)
async def moderation_logs(self, ctx):
snowyjaguar = self.bot.get_user(self.bot.config.developerid)
key_words = ["WARN", "MUTE", "UNMUTE", "KICK", "BAN", "UNBAN"] # Add in Captilised versions of each word to account for the Dyno logs
checked_logs = []
case_count = 0
last_checked = 0
moderation = self.bot.get_channel(id = 885569667861717042)
clifford_log = self.bot.get_channel(id = 500768218257031168)
with moderation.channel.typing():
messages = await clifford_log.channel.history(oldest_first = True, limit = None, after = last_checked).flatten() # 10000
for message in messages[0:]: # Making bot search history chronologically
if all([
message.id not in checked_logs,
message.author.id == 776782769312628746,
len(message.embeds) > 0,
key_words in message.embeds[0].title,
]):
embed = discord.Embed(title = f"Case {case_count} | {action}", colour = self.bot.config.error_colour, timestamp = message.timestamp)
embed.set_author(name = f"{message.embeds[0].fields[0].value} | {message.embeds[0].fields[0].value.id}", icon_url = message.embeds[0].fields[0].value.avatar_url)
embed.set_footer(text = f"{message.embeds[0].fields[1].value} | {message.embeds[0].fields[1].value.id}", icon_url = {message.embeds[0].fields[1].value.avatar_url})
embed.add_field(name = "Offender", value = message.embeds[0].fields[0].value, inline = True)
embed.add_field(name = "Moderator", value = message.embeds[0].fields[1].value, inline = True)
if message.embeds[0].fields[3]:
embed.add_field(name = "Duration", value = message.embeds[0].fields[3].value)
if message.embeds[0].fields[2]:
embed.add_field(name = "Reason", value = message.embeds[0].fields[2].value)
checked_logs.append(message.id)
await moderation.send(embed = embed)
await snowyjaguar.send(f"`{len(messages)}` were checked in {clifford_log.mention}, `{case_count}` logs were logged in {moderation.mention}")```
can you simplify your code? 90% of the stuff is pretty much unrelated to your question
Can i change presence with command?!?!?
ofc
change_presence
is the method you're looking for in the docs
yup, now check the arguments of that method in the docs and voila
you cant await in non async function
also true, the indentation is just wrong
i know arguments for it
i'm using 2 spaces.
that is completely fine
Hmm
!d commands.Bot.change_presence || I'm bad at these commands
No documentation found for the requested symbol.
well
let me guess, you have a wait_for, and depending on the user 's reaction, you want to change the presence of a bot?
outside of that check is async function right ?
you did miss an activity kwarg
do it AFTER the wait_for, not in the check
what are you trying to do?
you can either do loop.create_task or set some variable then change it to outside check
A sec
#discord-bots message
90% sure
he didn't use a wait_for?
change_presence is coro
and there you have it ^^ xd
change presence is coro btw
don't you need a activity kwarg to change presence?
just do one of those ^
probably
Hmmm
is this better?```py
key_words = ["WARN", "MUTE", "UNMUTE", "KICK", "BAN", "UNBAN"] # Add in Captilised versions of each word to account for the Dyno logs
checked_logs = []
case_count = 0
last_checked = 0
moderation = self.bot.get_channel(id = 885569667861717042)
clifford_log = self.bot.get_channel(id = 500768218257031168)
with moderation.channel.typing():
messages = await clifford_log.channel.history(oldest_first = True, limit = None, after = last_checked).flatten() # 10000
for message in messages[0:]: # Making bot search history chronologically
if all([
message.id not in checked_logs,
message.author.id == 776782769312628746,
len(message.embeds) > 0,
key_words in message.embeds[0].title,
]):
# Make a embed
checked_logs.append(message.id)
await moderation.send(embed = embed)```
man needs to be introduced to stack overflow smh https://stackoverflow.com/questions/59126137/how-to-change-discord-py-bot-activity
(idk what is coro lol)
basically thing that needs await to be ran
Ah okay
some questionable things like
why are you flattening the list while you're looping through it right after
you can just use the async iterator...
But if i add await it is being red :/
what does it say?
cause ur doing that in non async function and check this out #discord-bots message
why....why?
don't make him do that
he just has to do the shit he wants AFTER the wait_for
i was giving him 2 choices on what to do for this
Actually it may be
i'll try
Ah
Smh , that's right :/
ah
I mean wait_for is something you'll probably need to know?
it's possibly inevitable not to use it when developing a discord bot
@devout iris yeah just return called change_presence and you can await it eventually, or better return the status to what to change, then change_presence outside check and set that
unless of course...you made one, it doesn't work, you give up.
I mean the activity kwarg and the wait_for()?
doesnt wait_for return what check returns as far as i remember ?
and ye about activity
why what? why am I doing it that way or why do I want to know what causes the if statement to trigger or something else
PEP8 for crying out loud
and
!e print(len("messages = await clifford_log.channel.history(oldest_first = True, limit = None, after = last_checked).flatten()"))
@slate swan :white_check_mark: Your eval job has completed with return code 0.
112
yep it breaks pep8
because I hadn't thought of doing it that way, I would like to tackle my initial questions before tackling the points you've juts made, or would not doing it the way you've suggested hinder my ability to tackle my initial question?
the limit of char are 72 iirc
clifford the big red dog
I remember reading it when I was like 3 or 4
I think he died in the end
bro wut
its a kids show
why would he die
idk
๐ญ
bruh wut
I remember hurting myself when I was singing tellytubbies
it was disturbing
and curious george poisoning himself
!ot
Off-topic channel: #ot2-never-nesterโs-nightmare
Please read our off-topic etiquette before participating in conversations.

I
๐ญ
wtf is the problem
the PEP8
what is the PEP8
also did you define activity somewhere?
sure
!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:
where
here
yeah, there's a simple fix for that
[ele for ele in list_of_shit if ele in your_title]
=> this will return a list of all the ele's that are in your title ( in your case, you probably always expect just one
can't you just do activity in the change_presence?
hey, im using discord.py to interact with my bot, tho i just need to send a message and dont need the whole waiting until an event happens. is it possible to somehow only send a message and not wait? ive tried searching for this but couldnt find anything
i'm gonna use activity for 4 times
ok
Wdym
for every status
ENSLO!!11!1!!!
Hi
it's just extra lines of code but ok
Hyd
tired
Same
what is ur sugg?
just change it with the presence
i didn't understand :/
!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 kwarg
status?
your trying to change the status right?
idfk keep the status
right now client.run(token) keeps running until it receives an event like on_message, but i have a twitter listener that when a tweet gets placed it needs to post the tweet, so i dont need discord.py to wait for an event to happen, but just to send a message
I was just demonstrating activity
then use what has been given to you but
but what
!d discord.ext.commands.Bot.wait_until_ready
await wait_until_ready()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits until the clientโs internal cache is all ready.
use that
my guy

ngl your repetitive use of ele is kinda throwing me but if i'm understanding right you mean py thing for word in key_words if key_words in message.embeds[0].title if I base it off my variables?
Just do a direct api call ig
damn was trying to avoid coding all that myself
Itโ s just one request
check out "list comprehension"
you'll love it
it's actually
[<what you're keeping> for element in <your list> if <your statement>]
so the <what you're keeping> could be for example an attribute of the element, or the whole element
like
[member.name for member in guild.members]
or let's say I want all the bots in a guild
[member for member in guild.members if member.bot]
not really hard
Like if you are only sending a message Itโ s probably easier that way
Depends on use case
ill need more stuff from discord api, but will check it out if theres no other way
I've uhh.. never read PEP8, the majority of my python knowledge is self taught and from online courses so ik I've heard of PEP8 and I've likely got parts of it down but I've never read it, guess I'll add it to the top of my to read list
!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:
you should
yeah I googled it already ๐
nice
[action for word in key_words if key_words in message.embeds[0].title]```don't think I'm quite grasping it yet but it does seem incredible useful ๐. I want to keep `action` as that's what I'm putting in my embed
Or webhook
nah, you probably just want to keep the word
your if statement is also bad
it's
if word in message.embeds[0].title
Loop a task
!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").
Create a task to do whatever you're doing with the twitter api
i have a listener for twitter and when a tweet has been made by a certain person i want it to get all guilds its, loop over it and post the tweet in those
i think i wouldnt be able to get it working with a task
You might be able to use a webhook
Barely ever used them though
Why?
im not sure how it could work since id still need to have some listener running for the tasks right?
am I getting closer?py [action for word in key_words if word in message.embeds[0].title]and I'm keeping action partly because that's what I've already called it in the embed and partly because giving each part it's own name helps me identify what each part is doing
thanks, gonna check it out
you're not keeping the action, keep the word that it matches, that was your first plan
They dont need to listen for events
Using a task would be much simpler
I understand why you recommended a direct api call
But for most people it would be complicated and take a fair bit of time
You just do a post request with authorization header
Idk how task would work in that case
I think they want to send message when something on twitter happens
Assuming its for only 1 channel they could just fetch it
Wouldnt be real time
so a little more like this if I want action to be part of my embed?py action = [word for word in key_words if word in message.embeds[0].title]
Does it really need to be real time?
now we're talking
this returns a list, mind you!
so first check if the list is not empty, then just get the first element out of it I'd say
Well, you can just make an api call where the twitter event gets triggered instead of checking every couple of seconds to see if something has changed
action = [word for word in key_words if word in message.embeds[0].title]
if len(action) > 0:
embed = discord.Embed(title = f"Case {case_count} | {action[0]}")```any glaring mistakes in this?
What's up with the indention?
if action := [word for word in key_words if word in message.embeds[0].title]:
embed = discord.Embed(title = f"Case {case_count} | {action[0]}")
``` why not this?
apart from the confusing variable name, I'd say no
cause I wasn't aware that could be done
Don't always trust your ide
lesson learned๐ณ
Pycharm gives me strong warnings for using bot attributes
dang
LOL
It took me so long to figure out how to use them because pycharm was saying it was wrong
return sorted([package for package in [package_tuple[0] for package_tuple in packages]][:25])
Rate the readability
Hi everyone does anyone know if I can program my discord bot with Microsoft Visual Studios
you referring to action when you mean confusing variable name, if so it's because this for a supplementary moderation logging system and i'm using action as a umbrella term to cover different moderation actions. hope this makes my reasoning for calling it action more understandable
I am new to it
yes
you can
thanks
yw
I don't see why not
its a ide so me either
I am just new to the interface I will need help setting that up tomorrow it is so late where I am
pretty easy no need to even need help imo
vsc is very beginner friendly
really??
yes
That's the appeal of it
yeah i guess so
I would still suggest you learn about venvs though
Dependencies clashing can be a pain in the ass even for beginners
still dont know about envs๐
i use a py file
Open up terminal, type in conda create <venv name> python=<your python version>
At least I think thats how you do it
Haven't done it in a while
here's your one-line you've been looking for
possible_words_in_title = ['MUTE', 'WARN', 'STINK']
stinky_embed_title = 'blablaWARNblabla'
result = next(iter(set(possible_words_in_title) & set(stinky_embed_title)), None)
print(result)
# result will be None if no matches found, else the first match is the value
anagram command is actually a pain in the ass
I've been working on it for like an hour
Anaconda no good. Itโs a hostile environment for asyncio since it with how the loop works. Itโs really only supposed to be used with data science stuff.
if you want a venv go with python-venv Go to project working directory and initialize one and activate it and you're good. ๐
It works for me just fine so I'll keep it but I wont recommend it to people anymore
What is Ultron
Yes
Ok. Fair enough
Hello could somebody help me out ? I have a problem with a reaction role code
โข Ask your Python question, not if you can ask or if there's an expert who can help.
โข Show a code sample as text (rather than a screenshot) and the error message, if you got one.
โข Explain what you expect to happen and what actually happens.
ok
First of all the bot doesnt react with the emoji on the message, second when a member reacts it pops up on console that Role not found.
@bot.event
async def on_raw_reaction_add(payload):
message_id = payload.message_id
if message_id == 933128328360099871:
guild_id = payload.guild_id
guild = discord.utils.find(lambda g : g.id == guild_id, bot.guilds)
if payload.emoji.name == '':
role = discord.utils.get(guild.roles, id= 931644345113796668)
else:
role = discord.utils.get(guild.roles, name=payload.emoji.name)
if role is not None:
member = discord.utils.find(lambda m : m.id == payload.user_id, guild.members)
if member is not None:
await member.add_roles(role)
print("done")
else:
print ("Member not found.")
else:
print("Role not found.")
bot.get_guild is more efficient than utils.find here
Guild.get_role is also more efficient than the utils.get with the role id
so i should change it?
no, leave it as is ๐
ofc I do
help me out then
then implement what stocker said
only use discord utils for name and other attributes
use get_x for the id
^ this also applies for how you get the member who reacted
And also show the full traceback that gets printed
guys just tell me how to fix the code above i dont wanna use other ways
if you want to know which line is bad
it's the first else statement
idk why it doesnt work, this code used to work before
just check every expression, it isn't too hard to check which line is wrong
i fixed it
it wasnt the first else statement but thanks for help ๐
btw stress reduced thanks again bro
How can I restart my discordbot with a command?
i wanna make bots but idk how to code, can someone help me/ teach me.
you can make questions here
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.
this shall help you ^
ok thx
!d discord.Client.logout
No documentation found for the requested symbol.
yup, I died
lol
thanks, but will that just lose the connection to discord, or actually restart the bot as well
everyone can
let me guess, you edited code and want to use a command instead of manually restarting every time?
ssst
no 
For emergencyโs if the bot has a meltdown whilst iโm not online
well, you can just close it, instead of shutting it down
because if you restart it, you might have the same result
I mean itโs not going to break that badly, if itโs still not working after a restart than thereโs something wrong with my code
So a restarts fine
nah, if your code "breaks down" there's generally something wrong
A restart will just one way or the other result in a "meltdown" again
best thing to do is maybe have a global error handler and just DM you all the UNHANDLED errors
(because you obviously don't want to get a DM whenever someone uses a command the wrong way by for example not passing an arg)
mhm my error handling is mostly ok, just been a couple times thereโs been no errors, but not functioned as I intended
Usually I just look at the out log/error log
a "remote" shutdown would be your best option tbh
my staff can block certain parts of the bot though so a restart and blocking that area until I get online should be fine
yeah, you mean unload the cogs probably, that seems good
yeah
reload_extension(name, *, package=None)```
Atomically reloads an extension.
This replaces the extension with the same extension, only refreshed. This is equivalent to a [`unload_extension()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.unload_extension "discord.ext.commands.Bot.unload_extension") followed by a [`load_extension()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.load_extension "discord.ext.commands.Bot.load_extension") except done in an atomic way. That is, if an operation fails mid-reload then the bot will roll-back to the prior working state.
I mean I donโt wanna reload them necessarily
maybe with os module you can
import os
while 1:
os.system("python main.py")
print "Restarting..."
exit()
makes sense
Yeah only problem is iโm using a vps
welp๐ถ

not sure how you can tbh
im tired of reading
you want your bot to reconnect to the gateway right?
its kinda useless
not really
Well I want the bot to fully shutdown, then start back up
its useless if you dont read it
well yes what i just said?
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
Right
no
read this
well im not sure if you can
@slate swan theres like 10 choices to select
read the choices ๐ง
just pick the one that you might like ig
all ๐ฑ
still interested?
indeed I am
Have you ever wanted to restart your whole bot just from a command or if some command in your bot is stuck , you would able to restart the bot without physical switching it on and off?
import sys
import os
def restart_program():
python = sys.executable
os.execl(python, python, * sys.argv)
@bot.command()
@commands.is_owner()
async def restart(ctx):
await ctx.message.delete()
message = await ctx.send("Restarting... Allow up to 20 seconds")
restart_program()
This a piece of code will restart your program.
How it exactly works?
what it does:
Fetches the python executable (path got from sys).
After fetching the python executable, it gets directory where the main source file ( your bot's main file) and re-runs the file.
As a result, your bot shuts down and the starts again.
I mean, you could also just use extensions
he has thought of that ofc, I tried to convince him, but yeah
?
ive seen you before
no
yes
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.
ty
yw
the warn command doesnt work, and nothing shows up in the console. https://paste.pythondiscord.com/sesafowuxe.py
wanna know what's wrong?
yes
you've made an error handler for this specific function, but you're skipping ALL the other errors
make sure you have an else statement in that error handler which prints out other unhandled errors
the error will present itself
the Danny bot however on discord.py says this:
Do use:
* run your bot in a process manager such as:
- systemd
- openrc (gentoo, devuan)
- runit (void linux)
- supervisord
- upstart (old ubuntu)
- docker
* manually reboot it
Do not use:
- a bash loop (it can eat your C-c by rapidly spawning python and if your bot fails it won't stop it from constantly failing)
- subprocess.call (you will eat your memory up by not letting your old processes die)
- os.exec*
do not use os.exec?
well, I've basically copy pasted the
?tag better than better restart
as I said earlier, putting a certain cog of your bot in "quarantaine" is better than just restarting it and hoping for the best
yeah alright thanks
oh, how do i fix it?
hold up
you have shadowing function names lol
you have literally 3 clear_error functions
it's not because they have different decorators that they won't shadow each other
what abt this?
def save_warn(ctx, member: discord.Member):
with open('warns.json', 'r') as f:
warns = json.load(f)
warns[str(member.id)] += 1
with open('warns.json', 'w') as f:
json.dump(warns, f)
def remove_warn(ctx, member: discord.Member, amount: int):
with open('warns.json', 'r') as f:
warns = json.load(f)
warns[str(member.id)] -= amount
with open('warns.json', 'w') as f:
json.dump(warns, f)
def warns_check(member: discord.Member):
with open('warns.json', 'r') as f:
warns = json.load(f)
return warns[str(member.id)]```
oh
your problem are just your error handlers
look more into how you make decent ones, because you're basically hiding all your other errors by only printing out 1 'sort'
can i still have them?
I'd suggest you to just look into global error handling tbh
a
since all your error handlers just do the same
you obv don't want to make an error handler for every command
that's ONLY needed if they're specific, which they are not in your case
the only thing that's different about them is the command name in the text, which you can easily code via ctx.command.name
well for the moderation ones, yes
put all your error handlers in codeblocks for now... they're pretty useless
then try the warn command again, and the error will present itself
these functions need to be replaced with a db too asap
but if you want to keep that bad method per se, at least change the parameters
you don't need whole member objects as arguments, you just need the ID every time...
you're also opening a json file for reading, then closing it, and opening it again for writing
just open it once with read AND write access
if message.content.startswith("$fire"):
await message.channel.send(Vehicles["Fire"])
print(message.author, message.content)
if message.content.startswith("$police"):
await message.channel.send(Vehicles["Police"])
print(message.author, message.content)
if message.content.startswith("$ambulance"):
await message.channel.send(Vehicles["Ambulance"])
print(message.author, message.content)
if message.content.startswith("$civilian"):
await message.channel.send(Vehicles["Civilian"])
print(message.author, message.content)
if message.content.startswith("$trailers"):
await message.channel.send(Vehicles["Trailers"])
print(message.author, message.content)
if message.content.startswith("$jeeps"):
await message.channel.send(Vehicles["Jeeps"])
if message.content.startswith("$buses"):
await message.channel.send(Vehicles["Buses"])
Is there a more elegant way of doing this?
yes, by using commands
Use the commands extension
commands?
!d discord.ext.commands.command
@discord.ext.commands.command(name=..., cls=..., **attrs)```
A decorator that transforms a function into a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") or if called with [`group()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.group "discord.ext.commands.group"), [`Group`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Group "discord.ext.commands.Group").
By default the `help` attribute is received automatically from the docstring of the function and is cleaned up with the use of `inspect.cleandoc`. If the docstring is `bytes`, then it is decoded into [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") using utf-8 encoding.
All checks added using the [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") & co. decorators are added into the function. There is no way to supply your own checks through this decorator.
Try reading through this: https://vcokltfre.dev/
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.
hmm is that website down? cant see to connect to it
Works fine for me
oh now it works
it was still stealing your cookies and tracking your IP, give it some time
perfect, thats just the tutorial i needed, thanks guys! @final iron @potent spear โค๏ธ
๐
How is this looking?
I'd add emojis to make it appealing
also, the unix format isn't useful for regular users
I'll change it then
Just a nitpick
I think unix format looks better
It is also normal to call it unix time though

Thats why I put the human readable time first
You mentioned some emojis, which should I add?
a ๐ข โฒ๏ธ one of those for uptime
How do you do emojis again?
haven't used them in a while, can't say
probably something like :emoji_name:
also, I'd just make a info command, nobody cares just about uptime
info should contain stuff like ping uptime, ram, usage, ...
Heya so I wanna make button roles but everytime the bot starts the old buttons get useless and throw Interaction failed error how can I avoid this
will pay someone to make me like a 15 line discord script
!rule 9
L
I mentioned that above
uhhh
Its blocking
hmm?
Looks complicated
It's easy
Which one would I want to use
