#discord-bots
1 messages Β· Page 958 of 1
oops i called xe a him again sorry!
i don't know how else we can simplify more
π
not sure what the last line is
the await ctx.send..
yeah im talking about it
I thought my mistake was on the points = .. no?
i mean you shouldnt even store tags in a first place
you should store ids as they never change
and use a db!
am using json
json isnt a db!
im done with you
not a database
π
ok!
xo
zezemzey
πΏ
not again with the bro..
he got offended again π
mans just trying to help you
about to again
XE !!!
π
keep up this behavior and you will be reported to administrators
oh no
last warning there buckaroo
buack
honestly i think that human is a troll
same
I have no intent to troll
i honestly cant take you serious, sorry
how do you import phub
π
lmao
not here!
i wonder what that is
my friends told me to import it for a cmd idk how
is it import.phub?
still not related to the channel!
or import phub
so stop asking pls!
#βο½how-to-get-help @slate swan
how do import fuzzywuzzy
why do you have Wireshark installed? @slate swan
i dont?
cmd? π³
xes looking through your youtube
ah well i uninstalled it a while ago so i dont have it
anyways isnt that a bit weird asking such a question about my desktop?
*e-stalking
^
I like ur background
yeah i remembered seeing wireshark on your desktop when i looked at your stream
thanks!
you look like an osu player
lol now everyone is stalking me
this is getting creepy
bro what you hacked my webcam?
HOW IMPORT YOUTUBED1
no i'm just saying like how you talk and your profile
ah i dont play osu
??
trollers
gone
up ur ass
π
!ban 867284733879386152 troll
<@&831776746206265384>
:incoming_envelope: :ok_hand: applied ban to @jolly basin permanently.
this chat is getting worse and worse
still lost
well all of it started when y9su got here
on what
what did I do??
what are you lost on
I recommend taking a closer look at our #code-of-conduct
you tell him mod!
lmao
alright sorry mate
no way you just called me mate
it's like a video i watched
person going behind a bigger person and saying go get them
i literally just apologized
i think im just gonna leave
alright I'll let ya slide
we can't please everyone
Hello!
Hi!
yes
Im new to coding
okay
how do you import 52576726
why are you here
whats import phub how import it
help
someone told me to import it
dont.
ok

whats import fuzzywuzzy
!pypi fuzzywuzzy
yo
@slash.slash(name="roster", Description='Shows members on a team')
async def roster(ctx, *, arg):
property members
colors = ['red', 'green', 'blue', 'yellow']
output = ""
separator = ", "
for color in colors:
output += color + separator
print(output)
colors = ['red', 'green', 'blue', 'yellow']
separator = ", "
print(separator.join(colors))
integers = [1, 3, 6, 10, 15]
print(", ".join(str(e) for e in integers))```
can someone fix this for me
no we cannot, but we can help you with it!
ok
what do i do
erros? why do you have property members after your functions declaration?
someone told me to do it
well that someone is wrong!
and what are you trying to do exactly?
!join
Joining Iterables
If you want to display a list (or some other iterable), you can write:
colors = ['red', 'green', 'blue', 'yellow']
output = ""
separator = ", "
for color in colors:
output += color + separator
print(output)
# Prints 'red, green, blue, yellow, '
However, the separator is still added to the last element, and it is relatively slow.
A better solution is to use str.join.
colors = ['red', 'green', 'blue', 'yellow']
separator = ", "
print(separator.join(colors))
# Prints 'red, green, blue, yellow'
An important thing to note is that you can only str.join strings. For a list of ints,
you must convert each element to a string before joining.
integers = [1, 3, 6, 10, 15]
print(", ".join(str(e) for e in integers))
# Prints '1, 3, 6, 10, 15'
and you should use list comps!
Calm down with the !
never!
so do i use this
and it will work?
may i ask do you know basic python?
no
prolly not
whats python? i use java
bro
python is a programming language
i thought it said java
what
how do i fix this tho
require './lib/tic_tac_toe'
describe TicTacToeRound do
describe '.place' do
it 'places cross on the board the first time' do
expect { subject.place(0) }.to change {subject.board}.to(['X', nil, nil, nil, nil, nil, nil, nil, nil])
end
context '@whos_turn' do
it 'chanes @whos_turn to O after a placement' do
expect { subject.place(0) }.to change { subject.whos_turn }.to('O')
end
it 'changes @whos_turn back to X after two placements' do
expect { subject.place(0) && subject.place(1) }.not_to (change { subject.whos_turn })
end
it 'does not update @whos_turn if placement was already made' do
expect { subject.place(0) && subject.place(0) }.to change { subject.whos_turn }.to('O')
end
end
end
end```
you want me to fix this?
bro isnt that ruby
bro
yeah it is
wtf is ruby
you can see do and end keywords
i found that code off stack website
bruh
This isn't python?
i found it off stack website it said it was python
so it has to be python
its not lol its rb
It's not even close
do and end aren't a thing in python
i mean rb has a close syntax to py
ok ok
so can someone help me fix this, THIS IS PYTHON
local mouse = LocalPlayer:GetMouse()
local Camera = workspace.CurrentCamera
local Debris = game:GetService("Debris")
local UserInputService = game:GetService("UserInputService")
local target = false
local RunService = game:GetService("RunService")
getfenv().lock = "Hitbox" -- Head or Hitbox or Random
fov = 150;
local fovCircle = true;
local st = tonumber(tick());
warn("Loading script...")
if fovCircle then
function createcircle()
local a=Drawing.new('Circle');a.Transparency=1;a.Thickness=1.5;a.Visible=true;a.Color=Color3.fromRGB(156, 0, 0);a.Filled=false;a.Radius=fov;
return a;
end;
local fovc = createcircle();
spawn(function()
RunService:BindToRenderStep("FovCircle",1,function()
fovc.Position = Vector2.new(mouse.X,mouse.Y)
end);
end);
end;
function isFfa()
local am = #Players:GetChildren();
local amm = 0;
for i , v in pairs(Players:GetChildren()) do
if v.Team == LocalPlayer.Team then
amm = amm + 1;
end;
end;
return am == amm;
end;
function getnearest()
local nearestmagnitude = math.huge
local nearestenemy = nil
local vector = nil
local ffa = isFfa();
for i,v in next, Players:GetChildren() do
if ffa == false and v.Team ~= LocalPlayer.Team or ffa == true then
if v.Character and v.Character:FindFirstChild("HumanoidRootPart") and v.Character:FindFirstChild("Humanoid") and v.Character.Humanoid.Health > 0 then
local vector, onScreen = Camera:WorldToScreenPoint(v.Character["HumanoidRootPart"].Position)
if onScreen then
local ray = Ray.new(
Camera.CFrame.p,
(v.Character["Head"].Position-Camera.CFrame.p).unit*500
)
local ignore = {
LocalPlayer.Character,```
Except for indentation what is similar?
methods classes and other things
this is a troll
This is lua...?
This isn't Python
no its python
<@&831776746206265384>
Thanks
not even funny
he's literally just spamming chat
i thought it was python sorry dont ban
bro ^
i started coding 30 minutes ago
im new sorry
a new troll?
!mute 676977528463949856 Trolling and off-topic
:incoming_envelope: :ok_hand: applied mute to @slate swan until <t:1649211806:f> (59 minutes and 59 seconds).
Python doesn't have end, do or then
thanks LX
fuck sakes that dude was cancerous
yeah of course you mistook 3 different languages as python
It has negative indentation!
mina is lurkingπ³
πΏ
Since CokeCane pinged all the mods, soooo
PEP 9001 is my favorite pep
yes
Forget pep8, pep 9001 is my homie
!ot thats crazy but its ot
Off-topic channel: #ot2-never-nesterβs-nightmare
Please read our off-topic etiquette before participating in conversations.
πΏ

Alright, let's get this channel back on track...
thanks
kek
Nvm it is
jewish people?
Huh
just delete the whole command at this point
sounds like he has a... fetish?
it's like getting your base found in 2b2t
π
hello Mina
AttributeError: module 'discord' has no attribute 'Permissions'```
What is this & how do I fix this?
!mute 867932248438104074 
:incoming_envelope: :ok_hand: applied mute to @limpid ocean until <t:1649212558:f> (59 minutes and 59 seconds).
!clean 867932248438104074
Missing cleaning limit.
Lot of trolls here today
!d discord.Permissions
class discord.Permissions(permissions=0, **kwargs)```
Wraps up the Discord permission value.
The properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools. This allows you to edit permissions.
Changed in version 1.3: You can now use keyword arguments to initialize [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions") similar to [`update()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.update "discord.Permissions.update").
Hmm. Tried reinstalling?
Reinstalling what?
I am using nextcord
Then why are you using discord.Permissions? Shouldn't you be using nextcord.Permissions?
import os
from quart import Quart, render_template, redirect, url_for
from quart_discord import DiscordOAuth2Session, requires_authorization, Unauthorized
from nextcord.ext import ipc
import nextcord
app = Quart(__name__) #
app.secret_key = b'subscribe'
os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "true"
app.conig["DISCORD_CLIENT_ID"] = 961029967410520124
app.config["DISCORD_CLIENT_SECRET"] = "SECRET"
app.config["DISCORD_REDIRECT_URI"] = "http://127.0.0.1:5000/callback"
app.config["DISCORD_BOT_TOKEN"] = " TOKEN"
nextcord = DiscordOAuth2Session(app)
@app.route("/login/")
async def login():
return await nextcord.create_session()
@app.event("/callback/")
async def callback():
try:
await nextcord.callback()
except:
return redirect(url_for("login"))
return redirect(url_for("dashboard"))
@app.route("/")
async def index():
return await render_template("index.html")
@app.route("/dashboard/")
async def dashboard():
user = await nextcord.fetch_user()
return await render_template("dashboard.html", user=user)
if __name__ == "__main__":
app.run(debug=True)
That does not exist...
in this code it does not
Send the full traceback
A dashboard in the same as the bot?
Yes.
Perhaps not the best idea
Traceback (most recent call last):
File "c:\Users\Student\Desktop\Dashboard-Bot\dashboard.py", line 3, in <module>
from quart_discord import DiscordOAuth2Session, requires_authorization, Unauthorized
File "C:\Users\Student\AppData\Local\Programs\Python\Python310\lib\site-packages\quart_discord\__init__.py", line 4, in <module>
from .client import DiscordOAuth2Session
File "C:\Users\Student\AppData\Local\Programs\Python\Python310\lib\site-packages\quart_discord\client.py", line 11, in <module>
class DiscordOAuth2Session(_http.DiscordOAuth2HttpClient):
File "C:\Users\Student\AppData\Local\Programs\Python\Python310\lib\site-packages\quart_discord\client.py", line 65, in DiscordOAuth2Session
permissions: typing.Union[discord.Permissions, int] = 0, **params
AttributeError: module 'discord' has no attribute 'Permissions'
PS C:\Users\Student\Desktop\Dashboard-Bot>
I mean, I thought the same thing but for my dashboard I decided to seperate it
Tried reinstalling quart_discord?
Yeah I best try that
Ok well now
I cannot import ipc from nextcord
Error?
PS C:\Users\Student\Desktop\Dashboard-Bot> & C:/Users/Student/AppData/Local/Programs/Python/Python310/python.exe c:/Users/Student/Desktop/Dashboard-Bot/dashboard.py
C:\Users\Student\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\health_check.py:20: DistributionWarning: discord.py is installed which is incompatible with nextcord. Please remove this library by using `pip3 uninstall discord.py`
warn(message, DistributionWarning, stacklevel=0)
Traceback (most recent call last):
File "c:\Users\Student\Desktop\Dashboard-Bot\dashboard.py", line 4, in <module>
from nextcord.ext import Ipc
ImportError: cannot import name 'Ipc' from 'nextcord.ext' (unknown location)
π€·ββοΈ
Oh
DistributionWarning: discord.py is installed which is incompatible with nextcord. Please remove this library by using `pip3 uninstall discord.py`
You might have an issue since discord_quart uses discord.py but discord.py can't be installed along side with nextcord
π
Hmm
Does nextcord-quart exist?
Do you really need them to be in the same application?
Yeah
Probably not. Why not just use discord.py?
Perhaps. Best to consider it strongly as a design choice before moving forward
Well it do the same as nextcord
And still run all my code?
Not sure. discord.py's implementation for certain things is different from nextcord
Just test it out
Well I will see
See what breaks and we'll see if we can fix it
Ok thanks!
you have a dashboard?
For a bot me and a few others are working on
Still a heavy WIP
Written using next.js and tailwindcss :)
but it seemed overwhelming when i learned that i needed to also learn html and css while also learning js
ts is much better
lmao
It comes as you're learning frameworks
And often you won't be writing raw css
You'd be using libraries like material ui, tailwind, or bootstrap
wanted to learn node.js to see what discord.js feels like
Once you become experienced in one language, similar languages come pretty easily
well shit
picked the wrong language to first learn
You seem pretty experienced in Python. I believe that you can pick up js very easily since both python and js are similar
i might try to learn js again
you got any resources you recommend?
my brother is a web designer so that's a plus since i can just ask him to help me if i don't understand something
learn node
its just learning syntax most of the time as most langs have the same things like classes and oop etc
i wanna learn cpp
For sure
Nah. I have faith that you can pick it up pretty easily
Try replicating one of your existing bots using discord.js. It's an excellent way to learn
oh god
Trust me, it's much more intuitive than discord.py
okay
client.on("message", (message) => {});
See?
With being more intuitive the tradeoffs is less functionality
looks like rins implπββοΈ
Yes. Javascript event emitters are basically the gold standard when it comes to event-based, so no surprise rin's implementation looks similar
yeah i don't understand that
but andy kept the original gateway event name
You will :)
Yeah same
i know it's maybe listening on a event message
Eyup
No. Python has to use a hacky way to get it to achieve the same effect
does decos even exist in js?
Love me the reactive paradigm
is it like client on gateway event and then it passes the message object and then it returns something orr???
I wouldn't say that. It's an event-based language so event emitters are perfect
Ah makes sense
More like python has its own thing rather than js
hacky?
Not in the sense you might think
semi colons in my python server 
Not really a hacky way, just a different way
hello Mina
print("no");
Javascript directly uses a function to subscribe a callback to an event
semi colons are good for one liners!
Not that I know of. If they are they aren't used much
Just write all your code in 1 line like a chad
Whilst python uses the decorator syntax, to do the same thing essentially, but making it a bit cleaner imo. Since, of course you don't need to pass the function body directly, instead it does it for you since the syntactic sugar
If you think about it, decorators in Python weren't really meant for calling events. Event emitters, on the other hand, are made exactly for that. The problem with event emitters is that we don't have as much customizability, like checks
Well, decorators are low-level enough compared to other things in this higher level language
Yep. It does its job very well, albeit still wasn't made for that purpose
what exactly is node.js
Why does it need to be specifically designed to subscribe
Engine to run Javascript outside of the browser
It's low-level, it can pretty much do anything
okay
It's just a sugar anyways
You think it would be good to also be able to dispatch events yourself?
Absolutely
Yes
If the library gives control for that, yes 100% without a doubt
Perhaps it's own thing maybe. EventDispatcher or something
This allows for custom objects without monkey patching
Off the top of my head I can't really think of a use case
Which rin has!
whats "monkey patching"
how different is node.js to normal javascript
finish it!
You modify on runtime
ah
Syntax is very close, except nodejs runs on the server-side, so for example your global window object is undefined
i see
Also you can't use fetch()
And a bunch of other stuff
One of the things I really don't like when a language runs both backend and frontend. If you're using a framework, it can be hard to tell where a specific piece of code is running
Mostly just javascript lmao
Fair point
sup
New framework for javascript comes out like every other week
finally unmuted
More like every hour
Then an old framework gets deprecated
We have some gold standards that've been around for a while
mostly your fault though
Best to let the dust settle after a new framework comes out and see where it goes
i am new i was just asking questions and yall thought it was trolling thats unfair
Mmm, like 1 == "1" πΉ
nah im fwy
Don't troll next time and you wont be muted
I don't know why they thought that was a good idea
who said i was trollin
Let's not start this again please
you fought for your answer that those were python
make me a promise
oh god
a promise im js bro
that memory comes rushing back
JS promises are cool, they're like coros but you can run them in regular functions too
wrong chat
do me a promise 
from what i heard
In python we don't need promises because we have the async/await syntax kek
Though honestly feeling like js async makes it feel more sync. Default js feels very async
promises are awaits?
but what if you could call a coroutine in a sync function
coros yes
You can.
Also don't really have the ability to be able to call top level coros
Which I personally do love
what asyncio.runπΏ
def foo() -> None:
loop.create_task(coroutine())
Not all the time
That would just be a module level generator
You have 2 ways of dealing with "coros":
await promise()
or:
promise()
.then(() => {}) // Success
.catch((e) => {}) // Failure
.then(() => {}); // Always
or
coros()
they stole our await syntaxπ‘
wow damn
When it comes to discord bots, this is very interesting:
client.on("message", (message) => {
}):
AND
client.on("message", async (message) => {
});
the first one is really similiar
Quite
that purple highlight tho
π³
@bot.command()
@has_any_role('Franchise Owner')
async def promote(ctx, user: discord.Member):
guild = ctx.guild
HC = discord.utils.get(guild.roles, name="Head Coach")
await user.add_roles(HC)
await ctx.send("Promoted to Head Coach")
if HC in user.roles:
guild = ctx.guild
GM = discord.utils.get(guild.roles, name="General Manager")
await user.add_roles(GM)
await ctx.send("Promoted to General Manager")```
that's how you make it async?
Eyup
is the (message) the function name?
Just wait till you compile modern ES6 async/await to older syntax without it and see the resulting code π
That's the argument.
fuck
?
async def on_message(message):
...
i'll
very confusing for my python senses
You'll what
You get used to it after a while
troll?
Very fun though, especially when you make it to go along with your discord bot
π
i'll explain in a sec
That's why earlier I was urging the other person to reconsider using quart to put both the dashboard and their bot in the same application
If you're going to explain the code I understand what it does
Often times you won't need a live websocket connection to your dashboard
i'll explain what i want it to do
seems like it'll be fun to make a API using js
guess that'll be my goal for now
You'll be pleased to find out that it's very similar:
app.get('/route', (req, res) => {
});
Quite similar to the other ones isn't it?
ok so
i want it to do !Promote then give HC role
then !promote and take away HC role then give GM
yes?
but idk
Anyone got the disnake server invite? Thought I was in the server but seems not
Then you later find out javascript classes are just dict's with no boilerplate
i can see the similarity
yeah
so they can have only attributes and not methods?
faster than mina
lol i show up first on my end
Thanks
!sf 961092294554042378 961092293513871380
961092294554042378
Created at 2022-04-06 02:37:39.253000+00:00 (<t:1649212659:R>).
961092293513871380
Created at 2022-04-06 02:37:39.005000+00:00 (<t:1649212659:R>).
say he owes you a soda
yeah you beat me
haha
Actually, I'm not very sure. I might be mixing up Lua for Javascript rn
Yea I am
Oh
π³
ay
!pypi motor
Motor kind of sucks, it's unfortunate you have to use it
Can someone help me with how i can mention a channel in an embed on to another channel?
!d discord.TextChannel.mention
property mention```
The string that allows you to mention the channel.
Don't have to
Lol Motor is literally an async ready version of pymongo
Why are you using the latter
I mean there's nothing else that's developed by MongoDB officially
How was this not deleted?
any idea how i make this keep updating because rn it doesnt update unless i restart the bot
Thank you
is there something like ctx.guild.member_count that does not count bots?
basically returns the number of users
Use tasks
what
!d discord.ext.tasks.loop
discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True)```
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").
do discord slash commands support aliasing at all?
Aliasing in what sense? Like binding multiple names to the same command?
Guild.member_count is an integer returned by Discord, you can't know the count for sure unless you have the members chunked for that guild and can sift through them.
nope
@discord.app_commands.describe(**parameters)```
Describes the given parameters by their name using the key of the keyword argument as the name.
Example:
```py
@app_commands.command()
@app_commands.describe(member='the member to ban')
async def ban(interaction: discord.Interaction, member: discord.Member):
await interaction.response.send_message(f'Banned {member}')
But I don't think that's what you're after.
yeah just playing around with some other big servers with slash commands and was thinking ...... i like aliases
I can ask in the official server
Well yeah there are no plans to support aliases for app commands.
@bot.command(name="duck")
@commands.cooldown(1, 5, commands.BucketType.user)
async def duck(ctx):
e = discord.Embed(title="Looking for a duckie in the wild...")
m = await ctx.send(embed=e)
r = requests.get(url = os.getenv("DUCK_URL")).json()
em = discord.Embed(title="Found one!", color=discord.Colour(0x2de230))
em.set_footer(text="Powered by random-d.uk")
em.set_image(url=r['url'])
await m.edit(embed=em)
for some reason, it ends up sending the embed twice.
also, requests is not asynchronous amiright?
yes
so its blocking?
you have two instances of your bot running
in an asynchronous context yes
understood. could you name an alternative?
yeah i figured that. can't find the second instance. regenerating the token would stop all instances, am i right?
!pypi aiohttp
yep
ty.
okay, tysm
nice command name
Is there any command to detect if a user has become online?
iirc on_member_update can see if a member's online status changes
!d discord.on_member_update
discord.on_member_update(before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") updates their profile.
This is called when one or more of the following things change:
β’ nickname
β’ roles
β’ pending...
How do I get the id of the member that has left the server for my bot
Oh nvm I have changed from leave to remove, it works now
use the status attribute combined with the event
of the member
!d discord.Member.status
property status```
The memberβs overall status. If the value is unknown, then it will be a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") instead.
Yes
juse use a while True:
then you can use client.loop.create_task(statuschange())
in a event
For some reason my bot cannot join discord voice channels although it has ffmpeg, pynacl and opus as libraries (the server it is hosted on is ubuntu 18.04)
did you give the bot permission to join voice channels
all intents
As far as I remember it was changed to smth in dpy 2.0
it works on my pc not on the server though
!d discord.on_presence_update
discord.on_presence_update(before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") updates their presence.
This is called when one or more of the following things change:
β’ status
β’ activity
This requires [`Intents.presences`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.presences "discord.Intents.presences") and [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled...
like when u inv ur bot
yeah yeah intents activated its working on my pc but not on the server though
cant i just use that
No for god's sake
Why yall like providing misinformation
!d discord.ext.tasks.loop
discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True)```
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").
I used this 1 min
@client.event
async def statuschange():
await client.wait_until_ready()
while True:
await client.change_presence(activity = discord.Activity (type = discord.ActivityType.watching, name = f"{len(client.guilds)} servers {len(set(client.get_all_members()))} Members| .help for commands"))
await asyncio.sleep(25)
await client.change_presence(activity = discord.Activity (type = discord.ActivityType.listening, name = "anything"))
await asyncio.sleep(10)
await client.change_presence(activity = discord.Activity (type = discord.ActivityType.playing, name = "Minecraft"))
await asyncio.sleep(10)
@client.event
async def on_ready():
await statuschange()
client.loop.create_task(statuschange())
No
worked for me last year, idk if things changed
Check the docs for this
I don't need it
im dumb i forgot on_command_error is for all errors hence how i couldnt see an error handler
Weird is i have PyNaCl
clearly you dont
yes, but bearing in mind you could have multiple python versions leading to a clusterfuck
i do have multiple python versions
but installing libraries just downloads it somewhere else i always move it back to the bot folder
you what
thats not how python modules work
this isnβt js, we donβt put modules in a dir in the project
really?
so i seperately install python3.10.4 and run it through there
cant lie youβve gotten to the point where it all goes sideways
sacrifices must be made
and that sacrifice is my mental wellbeing so yes you are right xd
The presence was brought out to on_presence_update
Yeah
Just now learned
That's awesome!
great!
And then there is me who is going crazy to make a discord bot to play poker 
when does commandInvokeError get raised?
Have you checked docs about it
!d discord.ext.commands.CommandInvokeError
exception discord.ext.commands.CommandInvokeError(e)```
Exception raised when the command being invoked raised an exception.
This inherits from [`CommandError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError")
what is client.command() you missed @
does discord.Member.avatar return a URL?
PyNaCl library needed in order to use voice
if not, how do i get it?
so how do i install it?
discord.Member.avatar.url i think
!d discord.Asset
class discord.Asset```
Represents a CDN asset on Discord.
str(x) Returns the URL of the CDN asset.
len(x) Returns the length of the CDN assetβs URL.
x == y Checks if the asset is equal to another asset.
x != y Checks if the asset is not equal to another asset.
hash(x) Returns the hash of the asset.
!d discord.User.avatar
property avatar```
Returns an [`Asset`](https://discordpy.readthedocs.io/en/master/api.html#discord.Asset "discord.Asset") for the avatar the user has.
If the user does not have a traditional avatar, `None` is returned. If you want the avatar that a user has displayed, consider [`display_avatar`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.display_avatar "discord.User.display_avatar").
ty!
Better use display_avatar
the role is not in the member's roles
only for dpy 2.0 and above and its folks, and this may return None too
hi totoro
Hello ashley
Btw i finally managed to get my bot on a hosted server with a db and all included π
fortunately, I have a class in 10 minutes
Is it a good server
300mbit/s upload good enough?
hello Skev
i am in class
Kek
offline class i meant
smh
i mean, the whole world except you?
nahhhhh
well
most people, anyways kinda ot
it is.
nice pfp
ty
Itd help if you tell what's returning none
I mean im europian too
bruh austrians are special then ig
well, maybe when you get the role, it returns none
its just not sending, adding or removing the roles
the command legit does nothing
i live in the uk
but the other one which is basically the same thing but opposite works perfectly fine
i meant myself
What's the code for doing that?
Send it
well well
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
its way to long ill send screenshotsd
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
oh my
i have another codee just like it that works perfectly fine
thats why im so confused
and theres 0 errors
it just does nothing
do you have an error handler?
no
fie fie what the heck is that
what is, for examplem Team_21ID?
Holy fuck
What the fuck is that
Team_1ID =(949781381553197096)```
oh 21
Team_22ID =(424242424242424248)```
i cant fucking type
the worst thing is that I can't think of a better way to do that
its not a real id.
i put an id for certain roles
role 1 which is what i was using has a real id;
96% of the code is if statements and roleid
32 get_roles
Lmao
36*
How would you do that
Doesn't any just check if something is true in a iterable
How would you know what role was in their roles
we dont talk about that uhh, but srsly.....those many conditionals, there must be a way
How does this happen? lol
We must find a way
discord being discord i guess
right
So not my code?
no it responded with the ping
show ur code
you should defer it
from discord.commands import(slash_command)
from discord.ext import commands
class Ping(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_ready(self):
print(f"{self.__class__.__name__} Cog has been loaded\n-----")
@slash_command(name="ping", description="Returns the latency of the bot",guild_ids=[867086205182017536])
async def ping(self, ctx):
message = await ctx.send("Pong!")
await message.edit(content = f"Pong! **{round(self.client.latency * 1000)}**ms")
def setup(client):
client.add_cog(Ping(client))
class SubclassedHelp(commands.MinimalHelpCommand):
async def send_pages(self):
destination = self.get_destination()
for page in self.paginator.pages:
emby = discord.Embed(description=page, colour=0xf2cafa)
await destination.send(embed=emby)
async def send_error_message(self, error):
embed = discord.Embed(title="Error, that command does not exist.", value=error)
channel = self.get_destination()
await channel.send(embed=embed)
)
i found this code in one of my old bots, but i don't seem to remember how this works. does anybody mind explaining?
do the slash command again, see if it errors again
Trying to use pycord
doing that then sends this
u dont have any response msg ig
Lmao did you just delete the message
Uh how do I fix that if thats the problem
i have use views
well yeah, the fact that it was illogical and didnt make any sense nor any reason for it to stay there π
no-
Yeah i was confused how any for help
I was staring at it for a solid 3 minutes
oh ;-;
So what then?
Thinking of ways how any could improve the code
defer the response maybe, thas the only way to ensure that it responds everytime
same
anybody mind?
Trying it on another command now getting this error
avatar.url
oh
Yeah instead of ctx.send it needs to be ctx.respond
how to delete all messages from chat?
or better to say i just need to get all the messages in a chat
is that even possible
you could clone the channel and delete the original channel
too bad
too much of a hassle
just let the peasants delete it for themselves
How do you get rid of long if statements in any python code?
Shit damn i might still think about this problem while i sleep again
Uhhh idk, ill just save my brain for biology class
Okay, good luck cutting up frogs
I-
dont deny thats its fun nor do i accept it
Can't you use a for loop and have a if statement inside
Like have every id in a list
And use a for loop to loop through them
i'd rather use a list comp
Yeah suppose you're right
Would that work and be better though
i mean, iirc list comps are faster than for loops
Yeah i know
But would this idea work
it will if you know how to
Do you know how to
I don't want to sleep without solving this
Hi Blvck
!e
lst1 = ["a", "b", "c", "d"]
lst2 = ["a", "a", "a"]
print(any(char == "a" for char in lst1))
print(all(char == "a" for char in lst2))
@placid skiff :white_check_mark: Your eval job has completed with return code 0.
001 | True
002 | True
i mean i could try but after 2 hours cuz i got 3 classes in a row in 5 mins, but by then someone would probably have done it
nvm bai bai
have a good sleep
I already got it
I can sleep today
how do i make a command where you set a logs channel. and everytime u run a command the command message sends to the log
Ah yes thank you Blvck
idk how to explain it but yea
Shawn can i help you clean your code
God i can't look at it and not want to help
lol sure
!e
code
!e print("lol")
@placid coyote :white_check_mark: Your eval job has completed with return code 0.
lol
#bot-commands
r = requests.get(url = "so and so").json()
em.set_image(url=r.url)
await m.edit(embed=em)
this sends the embed before the url has been retrieved. any way i can send the message only after the url is retrieved?
property me```
Similar to [`Client.user`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.user "discord.Client.user") except an instance of [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member"). This is essentially used to get the member version of yourself.
!d discord.Member.edit
await edit(*, nick=..., mute=..., deafen=..., suppress=..., roles=..., voice_channel=..., timed_out_until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the memberβs data.
Depending on the parameter passed, this requires different permissions listed below...
mute=True
Don't use requests
It's blocking
anyone mind helping out?
Consider this
yes am switching to aiohttp soon
!d aiohttp
but will switching to aiohttp solve the problem?
Ah
the problem is, it sends the embed before it has the url
so the embed is empty and after a few seconds it updates
alr heres the full code
async def cat(self, ctx, *, caption:str = None):
e = discord.Embed(title="Looking for a cat...")
m = await ctx.send(embed=e)
em = discord.Embed(title="Found one!", color=discord.Colour(0x2de230))
if caption:
r = requests.get(url=f"{os.getenv('CAT_CAPTION_URL')}/{caption}", params={"json":"true"}).json()
else:
r = requests.get(url = os.getenv("CAT_URL"), params={"json":"true"}).json()
em.set_image(url=os.getenv("CAT_DOMAIN")+r['url'])
em.set_footer(text="Powered by cataas.com")
await m.edit(embed=em)
You aren't using r anywhere
from discord.commands import(slash_command)
from discord.ext import commands
class Ping(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_ready(self):
print(f"{self.__class__.__name__} Cog has been loaded\n-----")
@slash_command(name="ping", description="Returns the latency of the bot",guild_ids=[867086205182017536])
async def ping(self, ctx):
message = await ctx.respond("Pong!")
await message.edit(content = f"Pong! **{round(self.client.latency * 1000)}**ms")
def setup(client):
client.add_cog(Ping(client))
The variable r
try message.response.edit
Let me try
...i don't understand what you mean. r is what requests.get returns, which is the json response which includes the url. i am accessing it using r['url']
then try message.response.edit_message
Ah my bad. Which embed is empty?
The e or em?
em contains the image from the response.
it is empty for a few seconds THEN adds the image. this suggests that the embed is being sent before the response is received?
thats because the API sends an image response only after the image url is sent
discord.py 2.0a slash command grouping. GitHub Gist: instantly share code, notes, and snippets.
elaborate?
Don't think it's that tbh
I just use 1 command
the image is set inside the embed using its url, but it takes some time for discord to load the image...
@slate swan :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | ModuleNotFoundError: No module named 'discord'
understood. so there is nothing i can do to avoid this delay?
faster internet on the user side
Yeah so what now
oh, alright.
what library?
!d discord.on_message_edit takes 2 args
discord.on_message_edit(before, after)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") receives an update event. If the message is not found in the internal message cache, then these events will not be called. Messages might not be in cache if the message is too old or the client is participating in high traffic guilds.
If this occurs increase the [`max_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") parameter or use the [`on_raw_message_edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_message_edit "discord.on_raw_message_edit") event instead.
The following non-exhaustive cases trigger this event...
Pycord, from discord.commands import(slash_command)
before.content
@slate swan Any idea
@slash_command(name="command", description="desc")
async def callback(interaction: discord.Interaction):
await interaction.response.send_message(...)
await interaction.response.edit_message(...)
is how it should be done
yesir
before&after there are discord.Message objects
I just did ctx.respond
discord.on_message_edit(before, after)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") receives an update event. If the message is not found in the internal message cache, then these events will not be called. Messages might not be in cache if the message is too old or the client is participating in high traffic guilds.
If this occurs increase the [`max_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") parameter or use the [`on_raw_message_edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_message_edit "discord.on_raw_message_edit") event instead.
The following non-exhaustive cases trigger this event...

bro its clear
the event only takes 2 arguments
which before and after are message objects and hes adding a third message object
Yeah I know...
then why do you need he's code
i gotta go to school
Same
Aren't you 1 hour ahead?
Damn your school starts late
then you yes
async def on_message_edit(before, after)
Traceback (most recent call last):
File "C:\Users\rebellion\AppData\Roaming\Python\Python38\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(args, **kwargs)
File "C:\Users\rebellion\Documents\Development\Discord\Selfbots\chapter\cogs\admin.py", line 19, in ban
if member.top_role >= ctx.guild.me.top_role:
AttributeError: 'NoneType' object has no attribute 'top_role'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\rebellion\AppData\Roaming\Python\Python38\site-packages\discord\ext\commands\bot.py", line 903, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\rebellion\AppData\Roaming\Python\Python38\site-packages\discord\ext\commands\core.py", line 850, in invoke
await injected(ctx.args, **ctx.kwargs)
File "C:\Users\rebellion\AppData\Roaming\Python\Python38\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'top_role'
code: ```py
@commands.command(aliases=['deport, b, yeet'])
async def ban(self, ctx, member: discord.Member = None, *, reason: str = "no reason provided"):
await ctx.message.delete()
if member is None:
await ctx.send("missing arguments", delete_after=2.5)
if member.top_role >= ctx.guild.me.top_role:
await ctx.send("i can't ban someone above my top role", delete_after=2.5)
await member.ban(reason=f"{str(ctx.author)}({ctx.author.id}) | {reason}")
await ctx.send(f"{member} has been banned π", delete_after=5)
it dont make any sense
You don't return/ensure that member isn't None after you send the nesssage
You can also not set a default for the argument and use an error handler instead
Why are you making member optional
Use an error handler for missing arguments message
nah cus i have a different message for most things if there is an error
i also have a global message handler tho, but i barely use it
@error```
A decorator that registers a coroutine as a local error handler.
A local error handler is an [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") event limited to a single command. However, the [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") is still invoked afterwards as the catch-all.
Changed in version 2.0: `coro` parameter is now positional-only.
ok fixed it tho, thanks
But as for this command you need to add return statement in case the member is None
Your current one sends the "error message" and continues the command execution
why people don't use return at all
hey, how can I get the roles from other server?
get roles from member.guild.roles
not member.roles
also, logically, the guy won't have any roles when joining a server
maybe you did some special stuff there
I have 2 servers, I have some role in one server and I want the bot to know the ID of the role
@client.command()
async def roll(ctx):
"""Roll some die"""
await ctx.send(embed=discord.Embed(title="**You rolled a {}! π²**".format(random.randint(1, 6)), color=0x104E8B))```
I want it to ping the person who requested the command in the embed
But it keeps giving me an error
Example @wumpus you rolled a 5
so we need to guess the error for you or what
does anyone know a website I can put my bot faq in
No I tried an f string but it gives an error for the {} in You rolled a {}!
@hoary cargo
How to check if someone used a command to edit a certain message from an other command?
Traceback
uhh so im trying to get my discord bot on heroku but it doesnt work
https://hypixel.net/||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β|| https://i.e-z.host/ββββββ ββββ ββββ βββββ β βββββ βββ ββ β
any reasons why?
roll a WHAT
mentions can't be sent in embeds, some models of the embed like titles and footers will print <!@user_id>, others instead even if they can show the mention in the <@user_name#discriminator> format, they will not ping the user
await ctx.send(embed=discord.Embed(title=f"{ctx.message_author}You rolled a {}! π²".format(random.randint(1, 6)), color=0x104E8B))
^
SyntaxError: f-string: empty expression not allowed
Like @hearty falcon you rolled a 5!
I want it like that

??
why use format
You are not allowed to use that command here. Please use the #bot-commands channel instead.
what part of "mentions can't be sent in embeds" you didn't understand?
Someone can help me with that?
To get random numbers on the dice
I used
format (random)
f strings are a thing
I did try an fstring
@slate swan
you are using f string combined with format
and btw you can't use f string and .format method in the same string
So how do I write something to make it ping the person who requests the command
~ $ python main.py
Traceback (most recent call last):
File "/app/main.py", line 10, in <module>
bot = commands.Bot(command_prefix='+')
TypeError: BotBase.__init__() missing 1 required keyword-only argument: 'intents'```
is this just a heroku issue or is it me?
nvm you did but you cant use format and f strings in the same string lol
a = random.randint(1, 6)
print(f'your number is {a}')
OMG this is the third time i tell you. YOU CANNOT PING USER IN EMBEDS. is it clear now?
Ok Im sorry


bro is this a me issue or a heroku issue i just wanna know man
well technically you can, but he will not receive the ping 
not a ping then!
just a mention
That will send <@id> in the embed
not the ping
so you may want to mention it after or before you send the embed
dude the fetched ID the bot puts it in there
<@fetchedid>
πΏ
that would probably show invalid user or sm
Yea
how to make command where you can write some content after it for example -test [member]?
since the member isnt in the guild
mention in embeds aren't well formatted either, in titles and footer if you set f"{ctx.author.mention}" it will appear <!@user_id>
yeah in titles you cant format anything
Indeed, you shouldn't have mentions in title
just have an argument that expects a member obj
!d discord.Member
class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User").
x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.
x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.
hash(x) Returns the memberβs hash.
str(x) Returns the memberβs name with the discriminator.
hm so what to do?
member: discord.Member here member is an argument that is expected to be a Member obj which dpy converts the string in to a member obj
will try to convert*
yes
and it will be done through bot cache
yes
getch


me when i see .format in someone's code

and then you see pass_context=True
π³
πΏ damn
and after all of that they tells you that they are using replit or heroku
The " i'm new to this guys" starter pack
"so i can host my bot 24/7"
any way to stop this xd
did you defer it ?
What's defer? Sorry
so you didn't
I'm not English
im stuck on disnakes docs
πΏ
bro
I am not using disnake
What're you using then
Pycord

!d disnake.InteractionResponse.defer
await defer(*, ephemeral=False, with_message=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Defers the interaction response.
This is typically used when the interaction is acknowledged and a secondary action will be done later.

right
Disnake..
pycord
I am not using that
That's not what I mean lol
what
So how do I stop that rn it's still going
maybe show some code πΏ
Sure.
!Paste
Getting this error
Someone tried explaining me on how to add reactions in pycord but I don't get it at all
Try reading the pycord docs for how to get the message
according to their docs ApplicationContext wraps the Interaction
I tried, I just did not get it
What does that mean?
.original_message() is a method of Interaction, and the ApplicationContext has a .interaction attribute
Yeah?
await msg.interaction.add_reaction("π¦")
await msg.interaction.add_reaction("π§")
``` like this then?
ctx.interaction.original_message
It's that simple
I just read this from the docs also
await ctx.interaction.original_message.add_reaction("π§")
``` this
original_message is a coroutine
m = await ctx.interaction.original_message()
And then m.add_reaction
But I already got msg = await ctx.original_message()
await ctx.respond(embed=e)
msg = await ctx.original_message()
await msg.add_reaction("π¦")
await msg.add_reaction("π§")
yeah thats the line that gave you the previous error
Yes
