#discord-bots
1 messages · Page 44 of 1
isn't there also top?
eheh
what would the command be though
That's like the task manager for linux right?
yes
yeah, smth like that
Ah 🙂
btw there is also lsblk -a but there is usually no ram param
If your specifically looking for memory vtop is probably gonna be better
what is this 😳
nvtop
oh nvtop
For Nvidia and AMD
his vps is using ubuntu
gotop 🐈
what is this
For VPS's I would've probably done something like open suse
Actually ubuntu is a good choice too
isnt it the best
(Googled image, not on my system rn)
hm, no debian is probably better ig
ubuntu is debian based
ik
alpine
i wanted to react with a duck
Depends on the parameters
If you need something robust, and something for a team of people fedora would probably be the optimum
Etc, etc with different parameters
Their all good, as long as it's not windows 💀
And counted, proper securing of the server takes place
all games are written for windows:(
imagine not being able to play some games because youre on linux, dualbooting😳
I can just use wine or proton
i prefer debian bases distros, seems easier to use than arch and redhat
Sir this is a #discord-bots
The only popular games I cannot play are ones that use EAC
my wine doesnt work:(((((
*#ot3-discord-bots
Arch is so easy though
I don't do much maintenance on it cause It's all setup to be automatic when I installed
So it's kind of like, set it and forget it
Although I do need to clean my packages
the installation process tho 💀
I installed it in like 2-3 minutes not including compiling time
The wiki is very easy to understand
@pliant gulch imagine playing only online games and minesweeper (my situation)
If you can't setup wine just install steam and use compatability mode
You can also just install lutris as well
i have no money :pain:
which uses wine :morepain:
:kekw:
But doesn't lutris automatically set it up for you?
Also there is a lot of free steam games
it does but wine doesnt work for me in any way :evenmorepain:
Are you on ubuntu bare metal?
gonna search... i dont think there is a game i'll like
Okay nevermind
Anyways if you really that desperate you can try to setup a KVM and then use GPU passthrough
Basically a VM but not that slow cause of GPU passthrough
Enough to allow you to play games
wth 😳 all that to play games
Blame the game developers
I'll just continue playing fly or die and minesweeper
In unity all you do is press a setting IIRC to allow linux compatibility when building 💀
Guys like i use a command called ?test so i want that when i use it the bot deletes the message
How can I do that?
modular extensions
they can also be disconnected and edited and connected again uppon run time
cleaner and organised code
depends😳
also ur help command can be made categorical using cogs
just don't make mixed bag commands for cogs
if you are learning python just to make.bots, you get to learn more about OOP
imagine learnig python for just bots

The modularity of cogs are great
Means people can upload standalone cogs to GitHub, PYPI etc
And have it work when people install and load it
Granted, unless some extra setup is required like setting variables
as seen with redbot
make them use environment variables 🐈
so the bot can be online and u can disconnect a command then then make changes then reconnect all while the bot is on?
jishaku is a great cog too
agreed
yes
damn
can someone link me to a good cogs tutorial
what library are you using rn?
and version if discord.py
most recent
2.0 is on pypi now no point asking now
^^ no 2.0
yeah for latest version
goes making a 2.0 yt tutorial with client=commands.Bot

discord.http We are being rate limited. PUT https://discord.com/api/v10/applications/1010174873236156446/guilds/1008758498789695508/commands responded with 429. Retrying in 16.05 seconds.
sed
replit?
many people don't want to migrate yet, or haven't updated
so how can u load and unload a cog
you can still use discord.py 1.7.3
it shows how to load but not unload
bot.unload_extension("path")
!d discord.ext.commands.Bot.unload_extension
await unload_extension(name, *, package=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Unloads an extension.
When the extension is unloaded, all commands, listeners, and cogs are removed from the bot and the module is un-imported.
The extension can provide an optional global function, `teardown`, to do miscellaneous clean-up if necessary. This function takes a single parameter, the `bot`, similar to `setup` from [`load_extension()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.load_extension "discord.ext.commands.Bot.load_extension").
Changed in version 2.0: This method is now a [coroutine](https://docs.python.org/3/glossary.html#term-coroutine "(in Python v3.10)").
it is :p
the problem comes when most of the people just do pip install discord like they see in the video and it installs 2.0
yes
yeah, discord is not even the actual package lmao
It's discord.py
!pip discord its a mirror
A mirror package for discord.py. Please install that instead.
no need to unload and load just reload
lol
lets just all do pip install discord.py==1.7.3
Ye
.....................
!d discord.ext.commands.Bot.reload_extension
await 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/latest/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/latest/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.
🐈lets not use pip but poetry
replit?

is it okay for a bot to send messages to a person as to why they were banned
that wont get the bot banned will it
its fine if you do that
What would you guys say is the easiest way of getting slash commands (not dpy 2.0)
Like with the least amount of time needed to change up commands to slash
in dpy you could do hybrid commands but ok...
yeah that's probably the easiest
nope
discord
await channel.send(member)
AttributeError: 'NoneType' object has no attribute 'send'
The above exception was the direct cause of the following exception:```
@commands.hybrid_command(name='formaccept' , description = 'Accepts the form')
@app_commands.guilds(1008758498789695508)
async def formaccept(self,ctx, * , member : discord.Member):
channel = self.client.get_channel(723990989841003520)
await channel.send(member)
code
That channel doesn't exist
channel with id 723990989841003520 was not found
That might happen when the bot has no viewing access to it, I think?
might
import discord
from discord.ext import commands
from itertools import cycle
from main import client
class Bot_Status(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_ready(self):
print("Bot status cog loaded")
@commands.event
async def on_ready(self):
change_status.start()
@commands.loop(seconds=3)
async def change_status(self):
status = cycle(["I Love Luna", "❤️", ".help"])
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name=(next(status))))
async def setup(bot):
await bot.add_cog(Bot_Status(bot))```
error: change_status is not defined
can someone help me with this
make sure you saved the file
because the error says change_status
full exception please
You're calling it weirdly
oh ok
Cogs use commands.Cog.listener(), not 'commands.event', whatever that may be...
And you are defining two on_ready functions
btw @commands.event is not a thing i guess
i made it
I came up with something similar while helping someone
lmao
The first line in change_status's body needs to be outside of the function
And you are using client instead of self.bot for some reason
What even is main.client
Why are you importing it?
whenever someone says self.bot, self bots come to my mind welp
dont worry, be happy
The setup function in extension files gets called with a bot as a parameter (when the extension is loaded). The cog's __init__ function which you define takes it and assigns self.bot the value of that parameter in the end, which lets you use the bot instance thru self.bot
so theres no need to use client
discord.py server: What is being nice like?
even more, you mustn't use it
?rtfm nice
no
use it in main.py of course lmao
ah ok lol
LMAO
You never need/ought to import a client instance
im so confused rn
Neither should you do so with a bot instance
Never import your bot
ok noted
Welcome to #discord-bots
*#ot3-discord-bots
That too
what do cogs use instead of @commands.event
aight aight just kiding
@commands.Cog.listener()
which
noid is right
dont be so paranoid lol
*paramaniac
Why does noid gives away andy's vibes 😔
who is andy vibes
Make sure you're not accidentally running your bot four times
hows that even possible
It is possible when you forget to close a terminal window in which you've run the bot
And you open another
Might also be because you have from main import client in 3 files
i took that out
Importing runs the module
Well then you're importing main or client from main in 3 files
i deleted that
the only thigns imported are ```py
import discord
from discord import Embed
from discord.ui import Button, View
from discord.ext import commands```
Actually this won't make it so you have 4 running instances of the bot
So I don't know what's causing it to happen other than you have 4 bot processes running
i closed vsc from task manager and now it only does it 3 times which is improvement lmao
do you have an on message somewhere?
Just reset the token
can someone invite me to discord js server
discord.gg/djs lmao
show it
So what
@commands.hybrid_command(name='response' , description = 'Gives The Response')
@app_commands.guilds(1008758498789695508)
@app_commands.checks.has_role(1010100433538273300)
async def response(self,ctx, * , member : discord.Member , response : Literal['accept', 'reject']):
channel = self.client.get_channel(1010106207865933934)
if (response == 'accept'):
await channel.send(f'{member.mention} has been accepted')
await ctx.send(f" {member}'s Form ||Accepted|| By {ctx.author.mention}")
if (response == 'reject'):
await channel.send(f'{member.mention} has been declined')
await ctx.send(f" {member}'s Form ||Rejected|| By {ctx.author.mention}")```
it could be @commands.Cog.listener() with bot.proccess_commands at the end
and btw reset the token as exenfix said
response user accept
this command not working
@commands.Cog.listener()
async def on_message(self, message):
slurs = ["i took them out"]
msg = message.content or message.content.upper()
for word in slurs:
if word in msg:
await message.delete()
await message.channel.send(f"<@{message.author.id}> said a racial slur smh")
await self.bot.process_commands(message)
return```
thats the code
This looks functional enough to me
reseting the token didnt do it
Maybe you have multiple on_message listeners/events that call and await process_commands
If I'm not mistaken, you can have multiple cog listeners for one event
Then those are not the instances but your code
ohhh
i have two on_message
does anyone know how to make your bot create a new channel with just you and the owner of the server when you click on a button below bascially a ticket tool function?
someone let me know if you can help
Guys how can we mute and unmute in dpy?
!d discord.Member.mute
No documentation found for the requested symbol.
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...
permission overwrites
Like this?
await ctx.author.edit()
yup
or you can add_roles and give them a muted role
Thanks
can i make it where it auto sends in tickets?
if that makes sense
wdym
if muting chat than timeout is here for you
yep
i want my bot to auto send embeds in tickets created by ticket tool
idk how to do that
guild.create_channel returns a TextChannel obj so you can just put it in a var and send what you want
tickets created by ticket tool
oh
well, you can do on_guild_update event iirc and check if that's a channel creation and if that's a ticket channel creation, and then send your embed there
wot
i want it to auto send a message in every ticket
what to do? if i await it, it is giving error, if not, it is giving error ;-; endless loop bruh pls help
what error do you get if you await it?
you must load your extensions in an async function in dpy 2.0
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
await bot.load_extension(f'cogs.{filename[:-3]}')
print (f'Successfully loaded {filename[:-3]}')
else:
print(f'Unable to load {filename[:-3]}')```
oh-
for example setup_hook of your Bot
(probably the best place)
ight thx, i will try
does anyone know how i can make my bot send embeds as soon as tickets are made by ticket tool let me know
Check when a channel gets created in a certain category and then send embed in it
+ use on_guild_update event for that
async def load():
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
await bot.load_extension(f'cogs.{filename[:-3]}')
print (f'Successfully loaded {filename[:-3]}')
else:
print(f'Unable to load {filename[:-3]}')
async def main():
await load()
await bot.run('i took my token out')
asyncio.run(main())```
help 💀
wdym?
There are channel_create events
1: why not setup_hook
2: aight, whatever, bot.run is not async method, use await bot.start(token) then
3: are you importing load from somewhere, or is there anything else named load in this file?
I'm pretty sure there are
!d discord.on_guild_channel_create or smth
discord.on_guild_channel_delete(channel)``````py
discord.on_guild_channel_create(channel)```
Called whenever a guild channel is deleted or created.
Note that you can get the guild from [`guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.GuildChannel.guild "discord.abc.GuildChannel.guild").
This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
load()
sus 💀
On guild update would work too but It’ s like shooting urself in the foot 😂
i thought there is no on_channel_create
i have 0 idea on setup_hook
listening it for the first time
if theirs a CHANNEL_CREATE gateway event why wouldnt their be a namespace in dpy?
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
ayo what does it want me to do ffs ;-;
!d discord.on_guild_channel_create
discord.on_guild_channel_delete(channel)``````py
discord.on_guild_channel_create(channel)```
Called whenever a guild channel is deleted or created.
Note that you can get the guild from [`guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.GuildChannel.guild "discord.abc.GuildChannel.guild").
This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
wouldnt
Oh didn’t see
Are masters multiplying or smth
No I was here first
😂
In a week there are gonna be 4 of them ig
Yeah I just said that without reading anything
Geometric masters progression
imagine getting totally ignored
Relatable
yes
sigh
What the hell
In 2.0, Bot.load_extension is now a coroutine.
https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.load_extension
All you have to change is to:
- await
load_extension(), e.g.await bot.load_extension('jishaku').
If you have cogs: - Change
setupfunctions to be async
And, if you have aCog.cog_loadfunction: - make sure to make it async as well!
Read more here: https://discordpy.readthedocs.io/en/latest/migrating.html#migrating-2-0-commands-extension-cog-async
whats jishaku?
!pypi jishaku
A discord.py extension including useful tools for bot development and debugging.
i dont know myself
debugging and development extension
never looked at it, i think i should
Cool cog
Imagine not making one from scratch
Making what
Imagine not being lazy
A bot in a team I'm a member of has async eval support
Although I don't like how it's implemented
I made that thing once and I use it everywhere
It needs to be refactored
The only thing I don't like about my implementation is the actual code gets put to the string and then that string is executed
Yeah, it should also use a sandboxed environment
I wonder if there are any free ones
It's owner-only so idrc
Right but exec is not asynchronous
So it would be fun sending an asynchronous request to a sandboxed environment to run the code and await results
And this is why I have this cring https://github.com/Exenifix/AIAS/blob/master/ext/system.py#L187-L228
AIAS (Artifical Intelligence AntiSpam) is an open-source Discord bot that has innovative moderation features, such as nextgen word filter and AI-based spam detection. - AIAS/system.py at master · E...
I mean I guess you can start a new process
You pass an environment which includes the context
Yes
And maybe other modules
Because it's for my purposes
But running asynchronous code would be pain then
You'd have to use asyncio.run and call it on a coroutine which you have to define
Code:
@bot.command(aliases = ["lb"]) #LEADERBOARD COMMAND
async def leaderboard(ctx, x = 10):
users = await get_bank_data()
leader_board = {}
total = []
for user in users:
name = int(user)
total_amount=users[user]["souls"]
leader_board[total_amount] = name
total.append(total_amount)
total = sorted(total, reverse=True)
em = discord.Embed(title = f"Top {x} Most Soul Collectors!",description = "These are the (current) top soul collectors",color = discord.Color.random())
index = 1
for amt in index:
id_ = leader_board[amt]
member = bot.get_user(id_)
name = member.name
em.add_field(name = f"{index}. {name}" , value = f"{amt}", inline=False)
if index == x:
break
else:
index += 1
await ctx.reply(embed = em)
For amt in index is the issue
U cant iterate through int
i saw it from a tut
Bad tutorial
maybe in the tutorial was for amt in range(index)?
oh i did a mistake oops-
Error:
Ignoring exception in command leaderboard:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\user\Desktop\Vaggelis\Coding\Bots\Ghost Bot\main.py", line 91, in leaderboard
name = member.name
AttributeError: 'NoneType' object has no attribute 'name'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'name'
I changed the for amt in index: to for amt in total:
bot.get_user(id_) returned None
how can i fix that
Why do I get this error?
async def config(self, option: app_commands.Choice[str], get_or_edit: Optional[app_commands.Choice[str]], role: discord.role):
TypeError: unsupported type annotation <module 'discord.role' from 'C:\\Users\\yonii\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\discord\\role.py'>
dircord.Role
need help
!d discord.ClientUser
class discord.ClientUser```
Represents your Discord user.
x == y Checks if two users are equal.
x != y Checks if two users are not equal.
hash(x) Return the user’s hash.
str(x) Returns the user’s name with discriminator.
can anyone help me please?
I can't fix this
!d discord.ClientUser.avatar
property avatar```
Returns an [`Asset`](https://discordpy.readthedocs.io/en/latest/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/latest/api.html#discord.ClientUser.display_avatar "discord.ClientUser.display_avatar").
!d asyncio.run_coroutine_threadsafe if you look at my implementation I use this
asyncio.run_coroutine_threadsafe(coro, loop)```
Submit a coroutine to the given event loop. Thread-safe.
Return a [`concurrent.futures.Future`](https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.Future "concurrent.futures.Future") to wait for the result from another OS thread.
This function is meant to be called from a different OS thread than the one where the event loop is running. Example...
Use this @slate swan
now this
TypeError: choices are only supported for integer, string, or number option types
property_avatar like this?
Why property_
Property is like a function you can get the result of without calling it
Logs_embed.set_footer(text=f"{bot.user.name}", icon_url=f"{display_avatar}")
it shows
undefined name 'display_avatar'
!resources python
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

Send ss of code
click the reply and there is the error and stuff i changed
Print out leaderboard
print what-
leader_board
where do i print that
Before u get member
this? id_ = leader_board[amt]
print(leader_board)?
Yesss
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'name'
what's your code
Making programs for others is against the rules of this server
What would you guys say is the easiest way of getting slash commands (not dpy 2.0) Like with the least amount of time needed to change up commands to slash etc dpy 1.7.3
dpy 2.0
Or any of the other forks
But if you’re already on d.py I don’t see why you can’t just update and migrate to slash commands quickly
ModuleNotFoundError: No module named 'discord.utils'
Make sure you don’t have any folders or files named discord
why am i getting 'str' object has no attribute 'name' when trying to do client.user.name or client.user
Im trying to print into console whenever the bot is online that is its username along with its discriminator, however it doesnt seem to work. It always give me 'str object' has no attribute 'name when i use client.user or client.user.name.
Adding on, it seems to work fine in the rest of programs but its having issues in this one.
Any help would be greatly appreciated.
What fork would be the easiest?
Disnake
With disnake you gotta change up a lot of the commands right?
anyone?
Can you provide the full traceback? I’ve a feeling that the error is somewhere else or the name attribute is getting shadowed
yea just gimme a moment
how can I get a structure like this with slash commands from discord.py v2?
@sick birchhere
it changes from nonetype to str and then back bruh
idek whats happening
altermnatively if i use client.user then this happens:-
that means its not able to read username?
or what
Ah yeah the bot won’t be ready at that time
You need an on_ready in which you can print
oml
groups
thanks so much dude 😭
No prob
Is there any documentation about it?
ah
@sharp geode
thx
np
can i use it without on_ready in a class or def?
Depends on the class or def
If the class is a cog and it’s been loaded properly yes
If the def is an event then yes
uhm? token? reset?
can anyone tell me why i cant send a message to a user after ive banned them
You can’t message users you don’t share a server with
nvm im dumb its done ty robin
Or if the user has DMs disabled
he blocked the dm or you dont have any mutual servers with that user after banning him
Or a few other reasons I can’t think off the top of my head
I think I'm just being dumb rn but for some reason my bot refuses to get input from servers. It works perfectly fine for DMs, I've added the bot to the server with text permissions and am using "async def on_message(message):" to get an event
nah the bot wasnt ready
melate:(
i mean you revealed the token... you should reset it...
xyznotthefulltoken
oh bruhh man
oh so i should do it before i ban them and add a try statement that passes if something goes wrong
ohwellok
yes
bosh
Is javascript bots faster then python ?
ModuleNotFoundError: No module named 'discord.utils' could someone help me fix this?
use python
its easier
Not really
Why not js 😂
"from discord import utils" ?
I've done that
because speed depends on different factors, and even if there is a little speed up it is veryyy small and doesnt worth it
it depends on allot of things
then maybe try just using "utils.[...]" instead of "discord.utils.[...]"
Yeah, plus it saves you the hassle of using anything other then python
@sick birchand wat about this error?
do you have?:
- py-cord installed
- any folder or file named
discord
If I wanted to give my users the ability to claim free daily rewards.. Would it be a decent solution to keep track in a database of when the last time my user claimed a reward was? Then when they try to claim check against that time and so on..?
Feels kinda gimicky, but also the only idea I got
like claiming a daily balance or something
hassle? python isnt a hassle, it depends on tasks as well
if were talking about hassle lets talk about JS syntax
yeah that's what he said
"anything other than python"
That's what my joke was about lmao, python is easy
oppinions on this?
why compare languages that arent the same? that just shows you dont know what youre talking about
..?
i know you can compare speed, abstractions etc, but not completely, some languages are better than others but not better, it depends on allot of things
That would be my first thought as well, although depending on if you want to scale it or not, a dictionary may be enough
better than other but not better wh
Chill out bro, it was a joke
this is a discord bots channel its not about jokes.
eh I always like building this with scalibility in mind+ db seems pretty stable
I don't use Python for everything, every language has it's purpose
@tiny cave ... ;-;
i mean, every work should have some fun mixed in, you dont wanna end up like a boomer do you?
Fair enough then
you probably type casted it into a string
check where you defined client
and what you defined it as
Too bad I guess
by making controversial subjective jokes that arent even on topic?
Then could you maybe help me with this? @primal token
ah imma check
it wasn't thaaat controversial
do you own those langs? why u getting that offended, you clearly need help that wasnt even so controversial
@client.command(aliases=["sr", "addrole"])
@commands.has_permissions(manage_messages=True)
async def setrole(ctx, level: int, *, role: discord.Role):
async with client.db.cursor() as cursor:
await cursor.execute("SELECT role FROM levelSettings WHERE role = ?", (role.id, ctx.guild.id,))
roleTF = await cursor.fetchone()
if roleTF:
return await ctx.send("A role or level setting for that value already exists")
await cursor.execute("INSERT into levelSettings VALUES(?, ?, ?, ?,)", (True, role.id, level, ctx.guild.id,))
await client.db.commit()
await ctx.send("Updated that level role")
``` Any idea anyone? Not too sure about this
you would need to be more specific, show code
What relation does that question have about my point?
see the SELECT statement, you passed in two parameters when there is only one placeholder
(+client.run, obviously)
From
https://discordpy.readthedocs.io/en/stable/quickstart.html
2.0?
Oh I think it should be guild instead of role
What do you mean?
dpy 2.0?
dpy 2.0?
discord py
version
ver
v
v supremacy
I am using the latest version of the discord.py library, my problem is that I haven't coded with it in a while
So yes, 2.0
you need to get the latest from github
you dont
oh
youre missing the message content intent
2.0 is on pypi
yes
yesterday
ooooh
Fair enough, thought it was included in the defaults. How can I add it?
!d discord.Intents.message_content
Whether message content, attachments, embeds and components will be available in messages which do not meet the following criteria:
• The message was sent by the client
• The message was sent in direct messages
• The message mentions the client
This applies to the following events...
it's a priveleged intent, why would it be
not priveleged yet but still needs enablation
you didnt even answer his question lol
Hey @limber bison!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
Hey @limber bison!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
Hey @limber bison!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
what is that? i heard about application commands, but never heard about about slash commands
@limber bison use hastebin bruh
same thing different names
!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.
more code
i can dm u my small code so u can suggest me some cahnges to make it more efficent
seems valid without seeing more code
why not just use hastebin to post here?
shy >.<
what's the problem 👉 👈
whats it ?
having ur code exposed to thousands of people 🥺
!paste read...
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 wait
import asyncio @slate swan
for what?
.
ok
😮
oof
nothing wrong with this
i think glitch replit
yeah nothing
so demanding
extra (
o yeah
command_prefix = ( "
wdym extra
good eyes
ayo cool
you forgot the ) that only master32 can see it 
intents=discord.Intents.all()
how can i access server roles in order to give someone a muted role
now we use intents
next to cmd prefix
command_prefix = "", intents=discord.Intents.all()
boomb cat
i got a error to big to put into a ss
where
i can't see anything
Never in my entire life have I seen a traceback this long
capture the bigger image and capture the client.run for me
my code had a stroke 💀
Actually it looks like logging
yes
logging wrong
You logged HTML
you are old or new?
seems like youve been ratelimited
new ish
yes
something like discord stopped the bot working
if that so wait some minutes or some hours
it'll unlock again
so what's the error
"not working" isnt the best pick of words to describe being ratelimited, the word says it all
role = await cursor.fetchone()
await cursor.execute("UPDATE levels SET level = ? WHERE user = ? AND guild = ?", (level, author.id, guild.id,))
await cursor.execute("UPDATE levels SET xp = ? WHERE user = ? AND guild = ?", (0, author.id, guild.id,))
if role:
role = role[0]
role = guild.get_role(role)
try:
await author.add_roles()
await message.channel.send(f"**{author.mention}** has just leveled up to **{level}** and got the **{role.name}** role!")
except discord.HTTPException:
await message.channel.send(f"{author.mention} has leveled up to level **{level}**!")
await message.channel.send(f"{author.mention} has leveled up to level **{level}**!")
``` Why does this not give the role to the user?
- line 18, naming
commands.Botinstanceclientis just... not good, just name itbot... - remove unnecessary commentaries (commented code like
#@commands.check(check_channel)) - line 35-37,
on_readyis triggered when the bot is ready, not cog, you can print that cog is loaded in yoursetupfunction - line 47, you don't have to use brackets in ifs, it's not js
- line 43, it's better to put this variable in
__init__by defining it likeself.message_cooldown = ..., but if you really want to, you can leave it as a class var - line 54-58,
if condition: pass,else:can be replased withif not condition: - line 81, I don't think there is a reason to typehint user as a converter, you can just typehint it as
discord.Member
that's not all advices, just sent a couple of them so you can work on it
i'm bad at literature
leveling sytem
nice
Yeah?
Everything works just got a issue with giving the role as its not erroring and just not giving the role
Got any idea what the error could be?
this leveling is hard
i can't fix this
It ain't that hard?
Then don't say it's hard
it's hardddd
Are you giving it to a discord user or a discord guild member?
guild
Idk then I remember role giving being kinda finicky before when I used dpy. Can’t remember how I fixed it.
seems like an issue of permissions or higherarchy possibly
OOOH
Idk I haven’t used dpy in forever I was just asking because I had issues with that at some point
It throws permission error if it’s hierarchy I believe
not sure on that myself
isnt the argument required in the coroutine?
It should be
Alright thank you very much, I blindly trusted pyCharm and removed it for some reason
how did that slip lol
well technically pycharm is right but the attr error isnt correct
I think it's mistaking the variable "intents" for the actual "discord.Intents"
are we allowed to ask for help in this channel?
Yeah
help channel not for help so what to use it for
why would you activate privileged intents you arent using? its a waste of resources and a waste of dispatching events that wont even be handle by the client?
im trying to make a command on my bot require a certain role in a private server i have but that isnt working
so basically people would join the server i give them the role then the command should work for them
Is there an error?
no
what do you mean
can you explain more clearly?
i don't understand
ok ill explain better
maybe my english still too bad
More like show your code
ok ill send
He wants to give a role to someone when they join the server
And have a command that only works if you have said role
uhh json again
@limber bison
- line 63, you do
if condition: return, so you just don't need that else - line 83-84, this can be replaced with
user = user or ctx.author - line 108, this f string is just weirdness
f"{ctx.author.display_avatar}", just doicon_url=ctx.author.display_avatar.urland feel good - line 118,
error.retry_afterwill always be float, so there is no need to domath.ceil,int(...) + 1would be easier - line 131, ...display_avatar**.url**
- line 132, why not define user before line 131, to use it also in
set_authorthing - line 149, user can withdraw 0, if you want to prevent that, do
< 1or<= 0(btw in line 185 you do that correctly)
aight, im tired already, i think you got that you need to doctx.author.display_avatar.url, because there is a lot of it as I see
hope this was not useless...
:kek:
that explains allot
maybe old discord py
try to get the new video
in 2022
the top part is from tutorial
i cant tell if youre trying to help or troll at this point
top sometimes from 2016 or 2017
that's old
:kek:
there are no videos 
Last time I used discord.py intents weren't a thing I had to deal with in the code, and I just assumed that default intents would include message_content, since it seemed like an essential
Stackoverflow is a great resource
uhh i don't know
if i use google or youtube tutorials i always find newest
Instead of a video
I want to build a bot to message in every 120 mins and I don't have much idea how to do it with which module.
thats where i was going to
but its not working so im here now
!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/latest/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
im late
hmmmm...
wow discord really got it covered
lol nerds read documentation
Docs are great resources…
@leaden cosmos are you trying to put yourself into that trash can you are clicking?
put you first
Lmfao, how do you write code?
you mean people who actually want to learn a libraries abstractions over watching garbage videos that are old and arent up to date as the documentation made by the people who made or contributed to the library?
^^^
I mean I have read 30% of it
As you can see i hate jokes.
🤓 same
80 20 rule checks out
...
what's this
what's 80 20 rule
With software tools, generally speaking 20% of the tools can be used to make 80% of things
oh i understand
Should've specified the entire documentation then, lol
thank you so much master , its mean alot ,, btw any ganeral suggetion in my coding styp ?
you can read a libraries documentation completely and still not understand, its the understanding and learning how to read documentation that matters
the name of the emoji is blue heart?
what
well, about style... i think too much blank lines...
a colorblind test doesnt cost allot yk
i ignore
ohh k k , i will try to make it more clean
:kek:
cyan heart is real name
PEP 8 has everything about how to properly use blank lines in order to make your code clean, and also PyCharm has a built-in function to detect PEP 8 problems so you can easily manage to detect them @limber bison
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default discord.py has all intents enabled except for Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
2nd paragraph
in dev portal bruh
async def setup_hook(self) -> None:
self.pool = await self.loop.run_until_complete(asyncpg.create_pool(dsn=self.get_env("URL"), min_size=1, max_size=5))``` I am trying to do this but it says "This event loop is already running
try doing asyncio.get_event_loop() instead of self.loop
is moderate_user=True a valid arg for @commands.has_permissions
moderate_members*
same error
i meant that
!d discord.Permissions.moderate_members
Returns True if a user can time out other members.
New in version 2.0.
but it works cool
hmm... weird
what is your self.loop?
and full traceback pls
I mean, what do you put inside bot.loop
oh wait there is a default value of it
me stupid
so what's the full traceback @pale turtle
Just await the connection normally
You have a running loop so no need to do run_until_compelte
oh btw yes that's also a thing
in async you can do await
wait, you do await loop.run_until_complete 💀
so just await self.loop(something)?
no
No just await the create_pool coroutine
self.pool = await asyncpg.create_pool(dsn=self.get_env("URL"), min_size=1, max_size=5) it would be iinm
is there iinm btw?
if i'm not mistaking
await
bruh
I got this command to add a role in my role for a level in my database, now I'm trying to make a command that removes it:
@client.command(aliases=["sr", "addrole"])
@commands.has_permissions(manage_messages=True)
async def setrole(ctx, level: int, *, role: discord.Role):
async with client.db.cursor() as cursor:
await cursor.execute("SELECT role FROM levelSettings WHERE role = ? AND guild = ?", (role.id, ctx.guild.id,))
roleTF = await cursor.fetchone()
if roleTF:
return await ctx.send("A role or level setting for that value already exists")
await cursor.execute("INSERT INTO levelSettings VALUES (?, ?, ?, ?)", (True, role.id, level, ctx.guild.id))
await client.db.commit()
await ctx.send("Updated that level role")
This is what I am trying to do but it's probably wrong
@client.command(aliases=["dr", "deleterole"])
@commands.has_permissions(manage_messages=True)
async def delrole(ctx, level: int):
async with client.db.cursor() as cursor:
await cursor.execute("DELETE FROM levelSettings WHERE guild = ? and role = ?", (ctx.guild.id, level))
await client.db.commit()
await ctx.send("Removed the role")
Is there a question there?
Yes, am I doing it right, as it's not working for the delete command. It sends the Removed the role but does nothing in the database and no error either
think about it WHERE role = ?2 ?2 = level
how can i add a user pfp in a image like this one?
whats poll in mysql ?
now combine and get WHERE role = level
poll?
there is no pool
image manipulation
its not postgres
where did you see it?
in pg
In asyncpg a pool is just a connection manager
Yeah idk what it needs to be for the delete one tho
the add one works fine
It saves resources by handling when to give out connections, etc
definitely not role = level
where's logic?
Where does it say that?
you should at least have role too as a parameter
Sure
("DELETE FROM levelSettings WHERE guild = ? and role = ?", (ctx.guild.id, level))
# lets convert into f string (dont do that in code)
(f"DELETE FROM levelSettings WHERE guild = {ctx.guild.id} and role = {level}")
But idk what the execute in the database gotta be
Use the f string in the code or not?
look into the pillow library
are you... not smart?
that's basically the same?
# lets convert into f string (dont do that in code)
Don’t use f strings in SQL queries
yeah I am not using it
SQL injection attacks
Since level is a user input you def wanna sanatise that
But it's using an int converter so it'll probably error before someone could attempt an injection
3; DROP TABLE levelSettings;
I just wanna do like .delrole 5 (5 means the level and it would just delete that)
still better not to use f strings
No need for role: discord.Role then?
Some of your executions aren't being sent in as tuples btw, remember to add that , at the end
some 7216592831532 base int and you are dead (idk what did i say)
Okay
@bot.event
async def on_member_join(member):
em = discord.Embed(color=0x12d600, description=f"Thank you {member.mention}, you're the member number {len(list(member.guild.members))}!")
em.set_footer(text=f"{member.guild}", icon_url=f"{member.guild.icon_url}")
em.set_image(url=f"{member.avatar_url}")
em.timestamp = datetime.datetime.utcnow()
channel = client.get_channel(962043355645247508)
await channel.send(embed=em)``` i want my bot to send welcome images/messages ive tried this but it didnt work how can i make this command work?
if things have , at least once it's already tuple
!e print(type(('yes')))
@silk fulcrum :white_check_mark: Your 3.11 eval job has completed with return code 0.
<class 'str'>
or not
💀
But what would the execute be in to the database?
"Doesn't work" how?
as I think that's the issue
!e py print(type(('yes', 'no')))
@silk fulcrum :white_check_mark: Your 3.11 eval job has completed with return code 0.
<class 'tuple'>
at least here im not dumbass
any1 know how make a pokemon bot
!e print(type(('yes',)))
@heavy swift :white_check_mark: Your 3.11 eval job has completed with return code 0.
<class 'tuple'>
code
invite RDanny :lmao:
idk
@client.command(aliases=["dr", "deleterole"])
@commands.has_permissions(manage_messages=True)
async def delrole(ctx, level: int):
async with client.db.cursor() as cursor:
await cursor.execute("DELETE FROM levelSettings WHERE guild = ? and role = ?", (ctx.guild.id, level,))
await client.db.commit()
await ctx.send("Removed the role")
``` Still just got this now but unsure on what the execute into the database needs to be
Give me something to work with
like what
An error message?
code jam, other events, your project
it doesnt have an error message
add some prints
If you don't have error message, it means one of 2 things:
- It's working as you have coded it (not necessarily how you intended)
- You have a bad error handler
im using replit
avatar_url isn't valid anymore, my assumption is that member.guild.icon_url might have something to do with it
Should error though
yeah
Check for any on_command_error or on_error
Probably a bad error handler
how are ur intents setup
Anyone got any idea what the execute should be?
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix='!', intents=intents)```
valid
w
i need to replace client with bot?
shouldn't you use the role instead of the level?
you need to not use them both
await cursor.execute("DELETE FROM levelSettings WHERE guild = ? and role = ?", (ctx.guild.id, role.id,))
``` like that?
Are you storing everyone's roles in your database?
Nonono
capitalize the 2nd Bot
ok
discord.Bot
I think yes? try it
If this is pycord, discord.Bot. If it's discord.py, commands.Bot
discord.Bot is not a thing
Try this before await channel.send()
channel = get_channel(bot.get_all_channels(),'channel name')```
Just the id from each and the role id which are used to give out on levels if that makes any sense
its discord py2.0
.get_all_channels() is an iterator
Idk it works for me so I suggested 😶🌫️
https://cdn.discordapp.com/attachments/966022735916585007/1010273525032046682/rank.png
how can i create this for every member ?
Currently what happens is it deletes the row with the guild ID and the role ID. Do you have these 2 columns in your database?
any site link ?
Look into PIL/LOW
@novel prairie do you have from discord.ext import commands as an import
got it
Use pillow
ofc
commands.Bot then
Yeah, I got it to work now, but I still got this:
isn't it painful to implement it asynchronously?
does anyone know how I can make a Bot like this?
Pretty sure that's tos
it is?

I do believe so, but you can probably get away with running it in executor or a seperate thread
ile "main.py", line 16, in <module>
bot = commands.Bot(intents=discord.Intents.default())
TypeError: __init__() missing 1 required positional argument: 'command_prefix'```
I doubt TikTok exposes an API for automated account creation
!pypi tiktok
yeah, I've read a stackoverflow thread 😏
bruh( there must've been(
!d discord.ext.commands.Bot see the arguments
class discord.ext.commands.Bot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, intents, **options)```
Represents a Discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
Unlike [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client"), this class does not require manually setting a [`CommandTree`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CommandTree "discord.app_commands.CommandTree") and is automatically set upon instantiating the class.
async with x Asynchronously initialises the bot and automatically cleans up.
New in version 2.0.
@sick birch ^ With that I probably have to delete it by level instead of role
!pypi TikTokApi
finale
Sorry, I'm not understanding the problem fully. Do you have a table with levels and their respective roles?
this doesn't make sense
@bot.command()
async def add(ctx, userID)
if I do "add @<sampleuser>" will my bot recieve a user object? Or the user id?
yes
bot = commands.Bot(command_prefix=prefix, intents=intents)
And you have the role ID stored in that table?
I had roles there but deleted them so they are now at None
I deleted the roles
So now it shows as None
So put them back
does somebody know?
wdym?
you should do member: discord.Member
Typehint, then yes
alright thanks
I don't need them, I just want the levels that have a None removed
yeah
ty
Can you explain your overall problem from the start? I'm not following and am having a hard time understanding the problem
So I got a command which adds a role if you reach x level and it will give it to you, now I added a few roles. I got a command which shows which each level gives x role. I added some test roles at some levels but after deleted them, at the command which shows them all instead of the name they now show as None as the roles is deleted.
Well yeah, so what's the problem? If you deleted them obviously it's going to be none
Yeah I just want those that say none removed
So you want to change None to Removed?
Can you send the code for the command that displays all the roles?
No just removed from the database so it doesn't show
Sure
@client.command()
async def rewards(ctx):
async with client.db.cursor() as cursor:
await cursor.execute("SELECT * FROM levelSettings WHERE guild = ?", (ctx.guild.id,))
roleLevels = await cursor.fetchall()
if not roleLevels:
return await ctx.send("No role levels have been setup for this guild!")
em = discord.Embed(title="Role Levels", description="Role Levels for this server")
for role in roleLevels:
em.add_field(name=f"Level {role[2]}", value=f"{ctx.guild.get_role(role[1])}", inline=False)
await ctx.send(embed=em)
@client.command(aliases=["dr", "deleterole"])
@commands.has_permissions(manage_messages=True)
async def delrole(ctx, role: discord.Role):
async with client.db.cursor() as cursor:
await cursor.execute("DELETE FROM levelSettings WHERE guild = ? and role = ?", (ctx.guild.id, role.id,))
await client.db.commit()
await ctx.send("Removed the role")
This works fine
I just want the None gone on that list
And I can't set a role for those where it says None as its already in use for that level
Yeah but then when adding it will also show that it already has something on that level
@slate swan Gives that response
As that were old roles that are deleted now
what code did you write for the command that displayed that embed? if you deleted the corresponding role from your db, how are you querying None values?
oh your rewards command is doing that
from discord.ext import commands
bot = commands.Bot(command_prefix=",",intents=discord.Intents.all())
@bot.event
async def on_ready():
print("Bot is online")```
roleLevels = [first, second for _, first, second in roleLevels if first is not None]
does anyone know what this error means ^
If this happens after you send SIGINT you can ignore it
It's just a windows related error
I'll try
can you show the full code of your main.py?
thats all I have in main.py besides my token
no difference
@glad cradle
maybe the easiest solution would be a method that prunes any deleted roles from your database after you query your levelSettings, but there's no foolproof solution to make sure the database isnt referencing deleted roles before you make your query
