#discord-bots
1 messages · Page 963 of 1
If you are a she
styling as?
You have a deep ass voice that can fool anyone
right youve heard my streams lmfao
💀
Lmfao did you forget
yes
We talked about this a couple days ago
nope😔
Lmao
Which part of discord?
you can change fonts
Maybe that's your font?
Imagine they add a uwu special font in discord
"my" font?
...?
Like it just adds random uwu to your messages
lmao
Useful for ashley
Your..
- client font
- PC/Mobile font
oneplus
Lmao i read that as do you do an iphone?
sus
Blame okimii
my device's font is the default one
I didn't word it
heh
fuck, if you had an iphone it would be funny if you had the setting where it converts ily into uwu
get me one uwu
You do know that my mental voice of you whenever i read your messages is the uwu voice
I think I will just die now
tf is an uwu voice
i cant even get one for myself after i bought my pc😔
rich okimii
Hold on
im not rich runs in 3060😔
Dms
!rule 7
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
Talk in the off-topic channels.
And chat will be dead
#ot1-perplexing-regexing come guys!
hi can someone give me the ban and kick code
await ban(*, delete_message_days=1, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Bans this member. Equivalent to [`Guild.ban()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.ban "discord.Guild.ban").
!d disnake.Member.kick
await kick(*, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Kicks this member. Equivalent to [`Guild.kick()`](https://docs.disnake.dev/en/latest/api.html#disnake.Guild.kick "disnake.Guild.kick").
so I just need to include this?
Interesting you used both disnake and discord
lol, didn't noticed, usually i look over disnake docs but here i change to discord because some who ask for help use dpy
For most things it’s the same
!d disnake.Member.kick
how can i let my bot load a cog on startup?
Use the setup_hook provided to you in 2.0
Or have a main asynchronous startup point for your bot
@commands.Cog.listener()
async def on_message_delete(self, message):
channel = self.client.get_channel(954837357239091260)
deleted = Embed(
description=f"Message deleted in {message.channel.mention}", color=0x4040EC
).set_author(name=message.author, url=Embed.Empty, icon_url=message.author.avatar_url)
deleted.add_field(name="Message", value=message.content)
deleted.timestamp = message.created_at
await channel.send(embed=deleted)
``` is anything wrong with this? it says that it has a invalid form body
Sho error
I'm guessing someone sent an image and deleted it, which technically doesn't have any content
so the value field was empty which is invalid
Hello, I'm new to discord bot dev and I'm kinda stuck in the middle of a program to find a word in a message and make the bot reply to it, I tried following a tutorial but it didn't work.
you would be using the python in statement ```py
message: discord.Message
if "word" in message.content:
...
do your stuff```
yes, I tried this but it doesn't work
may i see your code
Ohhh that might be it
alright
sad_words = ["depressed, unhappy, hate, miserable, pathetic, depressing, sad"]
encouragements = ["You are amazing!", "Happiness!", "You can get through it!"]
def quotes():
response=requests.get('https://zenquotes.io/api/random')
json_data = json.loads(response.text)
quote = json.data[0]['q'] + " -" + json_data[0]['a']
return quote
@client.event
async def on_message(message):
if message.author == client.user:
return
msg = message.content
if message.content.startswith('!quote!'):
quote = quotes()
await message.channel.send('')
if "sad" in msg:
await message.channel.send(random.choice(encouragements))
This is the main part of the code
I included the token and other necessary functions
I'm trying to make the words loop through the sad_words lists, check it and reply if any of those words are found
Here it is
What can I do get all the guilds my bot is in
(Not guild name)
try making the content lower first
msg = message.content.lower()
ok
!d discord.Client.guilds
property guilds```
The guilds that the connected client is a member of.
does bring a change?
Hold up, it's still loading
Unfortunately, no, case sensitivity doesn't seem to be the issue
How can I use it inside a command?
It also seems to override the commands of the bot
I don't know why
bot.guilds
it would be a list of discord.Guild objects
ok
so just do this and your commands will work
Ummm, nothings happening
import dis
from tokenize import String
from turtle import setundobuffer
import discord
import random
from discord.ext import commands, tasks
import os
import requests
import json
client = commands.Bot(command_prefix = '.')
sad_words = ["depressed, unhappy, hate, miserable, pathetic, depressing, sad"]
encouragements = ["You are amazing!", "Happiness!", "You can get through it!"]
def quotes():
response=requests.get('https://zenquotes.io/api/random')
json_data = json.loads(response.text)
quote = json.data[0]['q'] + " -" + json_data[0]['a']
return quote
@client.listen
async def on_message(message):
if message.author == client.user:
return
msg = message.content.lower()
if message.content.startswith('$inspire'):
quote = quotes()
await message.channel.send('')
if "sad" in msg:
await message.channel.send(random.choice(encouragements))
@client.event
async def on_ready():
await client.change_presence(status=discord.Status.online, activity=discord.Game("Ready"))
print("Bot is ready")
@client.event
async def on_message(message):
if message.author == client.user:
return
msg = message.content
if message.content.startswith('$inspire'):
quote = quotes()
await message.channel.send('')
if any(word in msg for word in sad_words):
await message.channel.send(random.choice(encouragements))
client.run('TOKEN IS HERE')
This is the entire program, edited the @client.listen part
Oh, ok
Possible to change the format?
All events?
as in @client.event to @client.listen()
yes ig?
iterate thru it and use .name property
ok
It worked! Thank you so much!
pleasure
Thanks again, I gotta go now, bye
Just a reminder, don't use requests but aiohttp
use commands
Get-wiki-function -> 0.8879458000010345s
main programm -> 2.478715300007025s
timed my function, and it takes about 1.6s to send the data to discord (main program the sending to discord), any tips on how to improve discord ping, the ping of my bot is like 300ms
you have multiple on messages for nothing
self host?
ya
o
Be closer to discord servers
...
Or get faster net
just walk up there and you'll get it
Nothing else
my net is fast, i dont have ethernet, sad moment
Networking can't be almost instant if it involves remotes
wait you guys dont sleep in the discord servers basement?
@client.command()
async def interest(self, ctx):
roles = {"Coder": 100, "Gamer": 100, "Anime Weeb": 100, "Superior Coder": 150, "Mods": 100, "Partners": 50,
"Owner": 999999}
channel = self.client.get_channel(891318288859140096)
guild = self.client.get_guild(guild.id)
em = discord.Embed(title="Interest By time : ")
total = 0
for members in guild.members:
try:
em.add_field(name="Member Name: ", value=members.name)
for role in [role for role in members.roles if role.name in roles.keys()]:
em.add_field(name=f"{role} : ", value=roles[role])
total += roles[role]
em.add_field(name="Total : ", value=total)
em.set_footer(text="Type .role_shop to See how you can spend Money",
icon_url=channel.guild.owner.avatar_url)
await ctx.send(embed=em)
except:
pass
this is my code and,
im getting invalid syntax error for except:
^
tab
u didnt indent it properly
It must be on the same indent level with try
bot has admin perms disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
bot cannot perform moderation operations on owner/users with higher roles
I think you need to put something aftrr except
i forgot to add try except
a kind of error or a catchall for any error
It works
But now the error is discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: ‘Context’ object has no attribute ‘client”
Is your command in a cog
.
nope
so what do you think that means?
Context is not having an attribute called ‘client’
exactly
Then wtf for do you have the self arg
I've never used aiohttp before, how do I use it?
then what should I do
Wait I can check the documentation
Remove (self)?
I'll get back if I have any doubts
Yes but the question is do you know OOP basics in py
nope
I’m new to d.py
He is talking about Python itself, not dpy
This 'client' is what you called the bot when you told it what prefix to use
client is the bot
Have you read the docs for discord.py? They usually have examples.
agreed
OOP is above functional
One of the main programming methods in today's world in many languages including python
can we take this to an ot channel
Oh you mean that
Well not gonna argue too it won't change anything anyways
OOP includes functional doesn't it
Objects have methods
The only difference I can see is they interact with instance as well
Shortly in functional the function is the main unit and in and in OOP the object is
But objects do have methods
Yes discord bots
How can I get a guild Id?
The guild’s ID.
Depends what exactly do you mean
If you mean get it from discord UI you need to enable developer mode
And from code this
Anyone know how I can make a custom command command using json
What
using json? wha-
Json is data storage format how can you make a custom command with it
So e.g !addcmd [command name] [your message]
But only for that server
So that’s why I want to use json
hm ic, but, why not use sqlite?
I’m not trying to learn db
alright....
I’m trying to learn json more
opposing the opposition
Would that be for one server
Because I don’t want the tag to be in every server
I want to connect it to a json file
Can someone help me with creating the ban and kick cmd?
I am using replit
well my bot is basically a normal chat bot
it doesnt have any features like ban or kick or mute
But if you would like to you could do something like
{"guilds": {
"12345": {
"command_name": "command_response"}
}
}```
Hello I need help. I am a beginner and I would like to make a command that interacts with what we enter. It's for a Discord bot.
For example I create the command >recipe and in fact it will be necessary to do >recipe + what we want behind (pasta, fries) to have an answer from the bot. And the bot will adapt to the request. If the person wants pasta then the bot will print the pasta recipe. I know how to do that but what I don't know how to do is to make the bot take into account what is behind the order so not >recipe but the dish behind
well I have searched the internet for the code
but its still doesnt work
uhhh Idk it doesnt say on replit but before today i tried getting codes on github and it says 3.3 i think
So you know how to make API call and don't know how to fit its result into a command did I get it right?
He meant the library not the python
which discord library?
Yes
Most likely it'll be one of discord.py, nextcord, disnake, pycord
And what have you tried making (code)
nothing for the moment because I'm waiting to know how to do it
discord.py 1.7,3
Alright what library are you using for requests @lofty tinsel
oh ok let me check
My command is >recipe
The people want to know how to do pasta so he will do >recipe pasta and the bot will print the recipe of pasta. But if he does>recipe fries he have the fries recipe not the pasta recipe
It's not for requests
Could you state in which of these steps are you having issues
make a command -> send a request (get recipe data) -> convert returned data -> send data as a message
@slate swan :white_check_mark: Your eval job has completed with return code 0.
one egg, etc..
get recipe data
You said you know how to make API call lol
Well personally I don't know any recipes APIs but I can search for it
I'm not english So I'm expressing myself badly what I just want to know is how to take into account what is after the command and not just <recipe
I'm a beginner ;)
I just didn't get you right I think (I am not english too)
np
ty i'll try
My first time i see this https://media.discordapp.net/attachments/937323881058938921/962009905961766953/unknown.png
How do i fix the indent cause I am very new to python just start using it when my friend told me a few months ago so can someone help me
Oh heck
!indents
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
Yerlikaya😳
So if u have 2fa then you'll need to "enter ur AUTH code"?
hi, im known for being quick
I have been authorising an application yesterday and there wasn't such thing
not always good to be quick
😳
i did😔
take my place! its not like im gonna be missed
😔 😳
Uhh so I fixed the indent but now it is saying name "bot" is not defined
anyways gtg later
Well my acc doesnt have 2fa so i can add that bot without the Auth code🤷🏾
Ima check rn
ight
oh ok
Don't they require you to enable 2FA when registering on dev portal?
Eh nope? They require you to enable it when you want to join a team or sum like dis
i'm pretty sure that 2fa is a required standard, at least for verified bot devs
I changed all of the bot to client in the code to give me now the error is "Bot" object has no attribute "has_permissions"
probably that's another layer of security
Its bc u have 2fa enabled right?
Yes
When I was signing up with my alt on dev portal it said "please enable 2fa to sign up"
Thats weird tbh
Maybe you registered before it was added
Probably
i just tried rn and for me it doesn't ask for code even if i have 2fa 🗿
mmmmm
Wth for would they need to ask for the code if we are already logged in and its not a destructive action
I changed all of the bot to client in the code to give me now the error is "Bot" object has no attribute "has_permissions"
Unless you are adding nuke bot
How can I make a command to def a channel
well, it might be a destructive action
But how would they know if thats a nuke bot or not
they don't, that's why you need to enter your 2fa, or it's supposed to
async def channel (ctx, channel):
Is it channel or something else
but if your server has 2fa enabled then the bot cant nuke ur server (except if the owner of the bot has 2fa enabled)
Let's say hacker gets into your account and starts adding nuke bot to every server you have rights in but they don't have access to 2FA (but how tf would they login into an account without it)
I don't really see a point in adding it to there
Mmm using ur token?
well, a bot can't delete a server, so, nuke in this case will mean erase all channels and ban people
Same tbh
can you transfer the ownership to a bot? 
Myeah
To def a role you do async def role(ctx, role: discord.Role):
But I want to def a channel
Nope lmao
I think you can
At least there's a button
i shall try
Nope u cant
I succeeded in making the order but let's imagine that the person makes a mistake and instead of writing pasta she writes pastas with an "s" (we can imagine other possible mistakes) how to make the bot understand that the person wants pasta. Another example, if the person wants pasta and writes (>recipe pasta please sir) how to do to answer the request of the lady because the bot does not understand because there are several words
That's more complicated, would include regex or AI recognising (or you could just use in condition with for loop)
Yes it's a way to answer but isn't there a way to understand what she's asking without answering her with an error message?
Or other comparison method
@bot.command()
async def defrole(ctx, role: discord.Role):
hmm okay i'll try other way
That’s defined a role
So I changed all of the bot to client in the code to give me now the error is "Bot" object has no attribute "has_permissions"
And to use it you would do defrole [your role]
Ok i scientifically proved that you can't, there's no transfer ownership button on bots
But instead of role I want to do a channel @slate swan
What exactly does your defrole command do?
👏
It will get a role and do something with that role
But I want it to get a channel
So just typehint to channel?
And do something with it
@bot.command()
async def channel(ctx, channel: discord.TextChannel):
...
@formal basin I think you need this typehint
from typing import Union
async def command(ctx, something: Union[TextChannel, Role])```
Yes.
If you meant alternative between channel and a role
@slate swan that’s what I was looking for
nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: KeyError: 'test'
``` I have this error message
What does a Attribute error mean?
yes
It means you're trying to access an attribute that a class doesn't have
!e
class MyClass:
def __init__(self):
self.x = "Hello, world!"
instance = MyClass()
print(instance.y)
@sick birch :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 6, in <module>
003 | AttributeError: 'MyClass' object has no attribute 'y'
It’s ok
I changed all of the bot to client in the code to give me now the error is "Bot" object has no attribute "has_permissions" here is my problem rn
@client.command()
async def recipe(ctx, dish):
dishes = {"pasta":"water, salt", "fries":" potatoes"}
await ctx.send(dishes[dish])
if not dish in dishes.keys():
await ctx.send("hi, we dont have that dish")
return
Yes, that's not how you use it
like that?
Here's an example from the docs:
@bot.command()
@commands.has_permissions(manage_messages=True)
async def test(ctx):
await ctx.send('You can manage messages.')
ohh let me check it
if not dish in dishes.keys():
is equivalent to
if not dish in dishes
@client.command()
async def recipe(ctx, dish):
dishes = {"pasta":"water, salt", "fries":" potatoes"}
check await ctx.send(dishes[dish])
if not dish in dishes.keys():
await ctx.send("hi, we dont have that dish")
return
It isn’t, dict.__contains__ is O(1), checking for it in keys() is linear
idk where i must put the check
Oh. So using in is faster then?
there is no check in ur code?
Also it makes it more readable
Faster than checking for it being in keys() yes
It’s a hash map
That’s why it’s O(1)
Constant time
Algorithm difficulty measure thing or smth
Time stays constant regardless of number of instructions
whenever andy starts explaining something, I always get a stroke
Hash maps are usually O(1) when it comes to looking up items. I just wasn't aware __contains__ used a hashmap
"Algorithm complexity measurement" would be valid definition
that's work ty
I think
time complexity. Space complexity also exists so we need to specify
and if the Dish is missing how Can i send a error message?
O(1) is the best you can get
As well as amount of comparisons
Yes when i write pastas
When writing algorithms, you always want to get as close as you can to O(1) even if that's not always possible
@slate swan :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 2, in <module>
003 | KeyError: 'P'
Typically this term is used in sorting algs
the get method returns None if the key isnt in the dictionary
according to the documentation keys() gives a set-like object, so i think this may not be true
https://docs.python.org/3/library/stdtypes.html#dict.keys
(tested with a dict of 10 million integers and looking up the last integer was instant for both methods)
(sidenote: i initially tried 1 billion keys, but that crashed my terminal emulator... and every other app)
Is .lower() gonna work fine for the dish arg?
its possible ?
It just so happens that hash maps have O(1) so if you used hashmaps within your own __contains__ override you can get O(1) lookup time complexities with your own datastructures
set.contains is O(1)
!e
def command():
dishes = {"pasta": "water, uwu", "fries": "potatoes"}
_res = dishes.get("uwu")
if not _res:
return "no dish"
return _res
print(command())
@slate swan :white_check_mark: Your eval job has completed with return code 0.
no dish
Yes
@lofty tinsel I made a closest matching item searching alg 😏
"uwu"
working on the dashboard :D
I didnnt understand what u mean
It happens
Though list.contains is O(n)
!e ```py
from typing import Sequence
def get_closest_item(seq: Sequence[str], item: str) -> str:
best_entry = (0, None)
sample_letters = set(item.lower())
for s in seq:
letters = set(s.lower())
n = len(sample_letters & letters)
if n > best_entry[0]:
best_entry = (n, s)
return best_entry
stuff = ["cheese", "bobux", "another stuff"]
print(get_closest_item(stuff, "chees"), get_closest_item(stuff, "bux"))```
@vale wing :white_check_mark: Your eval job has completed with return code 0.
(4, 'cheese') (3, 'bobux')
i don't understand, there are so many options 
time complexity?
The question is if the Dish is missing how Can i Send the same erreur message "Hi WE dont have this Dish"
Should be O(len(seq))
hmm everything, my first bot was for artists, there's a huge gap there where no one has made anything @slate swan
or anything good
Not quite how it works I don't think
is it linear? logarithmic?
I think you meant it to be linear
you dont even need to use .keys tbh
O(amount_of_operations) I am talking about alg complexity not the time
The error message is telling Dish is a required arg that is missing
Ah cool!
I'm not one for algs myself
Ahhh Okay
@sick birch do you think it's good
well, its inefficient still 🤷♂️
It would be better to compare order as well but um it would be bigger
Fair point
Not much sense in haggling over minute time complexity details in an I/O application
lol
Does anyone know a great source of spam messages samples
wdym
Ah yes, I over-looked that part on the documentation, in anycase, yes best case set.contains is O(1) worse case being O(n). But keep in mind dict.__contains__ here is "faster" than doing dict.keys().__contains__ because you would need to call the method and get the set-like object, I'm not sure if it creates it
The time difference is neglible though
I am training an AI model for a hot antispam bot and I need samples of spam messages
ic
I got 1200 records of spam and non spam so far
@client.command()
async def recipe(ctx, dish):
dishes = {"pasta":"water, salt", "fries":" potatoes"}
if not dish in dishes.keys():
discord.Embed(title = "Error", description = "Please specify a dish")
await ctx.send(embed = discord.Embed)
return
im trying to send as an embed
Vise versa if condition
if not dish in dishes.keys()```
I am using a function self.disable_all_buttons() in my view class, to disable a button after it is clicked. How can I disable a button in my command function, without it being clicked? I use msg.edit(view=self) afterwards but my code just stops at self.disable_all_buttons()
Ah
ty
Objects/dictobject.c lines 4735 to 4741
static int
dictkeys_contains(_PyDictViewObject *dv, PyObject *obj)
{
if (dv->dv_dict == NULL)
return 0;
return PyDict_Contains((PyObject *)dv->dv_dict, obj);
}```
are we still at dishes
I made a closest matching string search alg but nobody would use it lmao
It has some cons ofc but it has more functionality compared to that thing
Maybe not a thing they need
TypeError: to_dict() missing 1 required positional argument: 'self'
Anyways forget that
i have this error
Put the embed into the variable
when i write >recipe pastas
And "send the variable"
embed = discord.Embed(...)
await ctx.send(embed=embed)```
You can skip the variable as well and put the instance straight into params do as you like
discord.Embed itself is a class
You need an instance of class
Which is discord.Embed(...)
OOP 👍
i do after return?
Nah you put class not an instance
how?
Your instance is right above but you do nothing to it
You need to put that into a variable
why not use the get method on the dictionary rather than looping through it 😔
I am using a function self.disable_all_buttons() in my view class, to disable a button after it is clicked. How can I disable a button in my command function, without it being clicked? I use msg.edit(view=self) afterwards but my code just stops at self.disable_all_buttons()
How does your disable_all_buttons look like
def disable_all_buttons(self):
for button in self.children:
button.disabled = True
It works in my button class
But not my command class
Ok full code from view creation to msg.edit please
That is the entire file
Lmk when you see it so I can delete😅
Please help me what do I put instead of this
Btw I’m getting the data from a json file
@slate swan I didn't see that you are editing message after disabling buttons
wdym id isnt a kwarg
and what is that structure
of getting data
Oh sorry I just deleted that part and tested it, ill edit it
What the hell
It’s getting the id of a channel from the json file
But idk if I did it right
Okay, after I disabled the buttons I did await msg.edit(view=self)
channel = bot.get_channel(int(data_record))```
If it's not int already
Idk your json
channel = (bot.get_guild(data['channel_id']) or await bot.fetch_channel(data['channel_id']))
I mean, its still a good idea to do that but okay
@slate swan oh wait I spotted an error
channel = (bot.get_guild(data['channel_id'])
Do you know how to leave a blank in an embed. When you have to choose the name of the field, you can't leave it empty. Is there a way to do it or not?
!d disnake.InteractionMessage.edit
await edit(content=..., embed=..., embeds=..., file=..., files=..., attachments=..., view=..., components=..., allowed_mentions=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the message.
Note
If the original message has embeds with images that were created from local files (using the `file` parameter with [`Embed.set_image()`](https://docs.disnake.dev/en/latest/api.html#disnake.Embed.set_image "disnake.Embed.set_image") or [`Embed.set_thumbnail()`](https://docs.disnake.dev/en/latest/api.html#disnake.Embed.set_thumbnail "disnake.Embed.set_thumbnail")), those images will be removed if the message’s attachments are edited in any way (i.e. by setting `file`/`files`/`attachments`, or adding an embed with local files).
Can I send screenshots here?
Well you can k
sure
“\n” makes a new line making it empty
why do you have two run methods
If I type anything else with hello no rep,y
nah i tried
@slate swan do you have an error handler
because you only set it for replying with hello
Oh yeah you do
Yes, its under my command, @ Crash.error
One sec
Don’t think that works
How to fix it so it can work with for example, hello bob
missing a parenthesis
Sorry for the ping crash if you see this
@slate swan change all the ifs after the first to elifs because many of ifs make no sense and add
else:
raise error```
At the end so it doesn't eat your errors
if "hello" in message.content
Will it work? If it does I am the biggest idiot on this earth
What parenthesis?
What about the else that I use to keep the loop running, the one that’s edits the message if num is not less than x
Oh never mind I can change that to elif
(bot.get_guild(data['channel_id']))
you dont even need the outer parenthesis tbh
alright
It works thank you sooo much but the thing is I also want it recognize upper case h in hello too
if "hello" in message.content.lower()
you can use the lower method on the string
Why didn't it work when I used vwriable
Also the lists yeah it was an attempt I removed those commands
wdym?
Oh my gooood it works
I asked in another server they just told me to learn more about the language and then ask questions
dpy server?
I mean, thats the first thing that comes to my mind
Tcd
well
The coding den
If u excuse me imma go flex on them later
Also why did user_message not work?
So doest it mean I can remove the command line where I declare it too?
I mean the error handler
How does your data look like @formal basin
wdym
Use bot.get_channel why are you getting the guild
I replaced message.content with user_message it didn't work in the if statement
did you define user_message?
lmao
hey does anyone know how a bump reminder can be coded due to the new /commands?
but how can i see if they bump? do i just wait for a message from the bot? cause on_message doesn't pickup commands to other bots
like how could i see if there was a bump command runned?
you can actually make them
just remove the conditional if message.author.bot: return
if you are adding it
sorry what?
Ohh okay
but i thought my bot cant see any slash commands i run to other bots
hey are you busy?
from what i tested stuff like on_message isn't triggered if i run a slash command to a different bot
alright
thats why i came here asking if anyone knew anything about it
@vale wing it says CrashCommand object has no attribute disable_all_buttons. I think it is because I use self.disable_all_buttons, how else am I supposed to call it?
disable_all_buttons() by itself doesn’t work
okay thanks for your suggestions ill look into it, enjoy your movie
Hey guys, so I made a discord bot but the commands only work for me and not other people, the bot is currently on my pc
your bot doesn't have access to other bot's slash commands so no way u can detect whenever a slash command by any other bot is used
oh lol
I am looking to make a command that gives the origin of the first name using the length of the first name and the first letter. I have this list:
Lxxxxxx = France
Pxxxxxx = Norway
Cxxxxxx = Italia
Vxxxxxx = Deutshland
Yxxxxxx = Morroco
Jxxxxxx = Algeria
Kxxxxx = USA
And in fact when the person will want to know the origin of his name he will do >origin Laurent and the bot will reply "France" because the name start with L and the lenght is 7 letters
do you have an on_message event?
Well my question is about the code you help me with recently, is it possible for the bot to update the count for one channel name?
lets say channel is renamed #bug-done
it will update for Bug only
Bug - 1
@bot.command()
async def Info(ctx, oc: str, database: str):
id = str(ctx.guild.id)
os.chdir(id)
with open(f'{database}.json') as file:
Content = json.load(file)
try:
character = Content[oc]
except KeyError:
await ctx.send(f'No character named {oc}')
return
character = Content[oc]
age = character['age']
gender = character['gender']
hex = character['hex']
Url = character['picture']
desc = character['description']
universe = character['universe']
embed = discord.Embed(title=oc, color=int(hex,0), description=desc, mp=datetime.datetime.utcfromtimestamp(1649356775))
embed.set_thumbnail(url=Url)
embed.add_field(name="Age", value=age)
embed.add_field(name="Gender", value=gender)
embed.add_field(name="Universe", value=universe)
await ctx.send(embed=embed)```
database.json again
wdym by that?
nothing nothing, I asked for an on_message event not a command
it's a command
@client.event
async def on_guild_channel_update(before, after):
if isinstance(after, discord.TextChannel):
if after.name in ["bug-done", "bat-done"]:
data = {"count": 0}
data["count"] += 1
channel = client.get_channel(955113139576385576)
embed = discord.Embed(
title="MM Tracking",
description=f"**__Middleman__**\n Bug - {data['count']}\n Batt - {data['count]}"
)
await channel.send(embed=embed)```
Is it possible that when the bot detects the channel name being renamed to `#bug-done` it will update for Bug only
yes
yes
I am working on that
My command works fine for me
I mean, not only can your data get corrupt, it’s insecure!!
not others and it raises the error that file is inexistent
So how would I do that
well just for me, not other people on my server
yes I am doing that right now
was just looking at potentially reproducing this but just not sure how to
I have a problem
It just checks if disboard bot sends an embed
And manually compares the embed content
that has been removed
but how does it know who triggered the bump?
in the pic it's pretty visible it has been used a slash command
disboard is removing the prefix commands too
he shouldn't be the only person that bumps
well said had
he would've needed to tell everyone
This doesn't work for anyone other than me and it says that the file doesn't exist as well and I don't understand how
im just wondering how they find out who triggered the bump?
Would anyone know why
Message author ID command
a what
Hi guys!
I need help on using Google sheets Api's on a bot discord !
I'm stuck at this step on the console
"Please visit this URL to authorize this application: ..............."
our jobn't
you cant do that
does the message the bot sent reply to the slash command?
or how does that work
I see it works for me only because the bot doesn't answer and in the terminal it gives me an error
and it works fine when I run the command
oh that might be it ill look into that
@lofty pecan Oh a french guy
This is a big ask, but does anyone have stats on the amount of active daily users for a bot as big as owobot or similar game type ones
it's not about permission so i'm very confused
there is no error about that
the error is in english though 🙂
see
I told you, it works fine for me, but when someone else uses it it breaks the bot
i'm doing stats on game play for my bot and if each person spends 5 mins per session before they run out of energy and have to wait that means roughly 14k+ play sessions per day before discord craps out
so how long can i make the play sessions 
Can someone help me on #help-corn
if i make the play sessions 10mins each then that's 7k sessions and if the average is 2 sessions per person per day it means it can only handle 3.5k players
hard to find where to balance it
Everytime it dumps somthing it deletes the other dump above it
maybe when someone else uses the command I have to add the total path ? because when I'm in VS code the folder is set to the correct one
it shouldnt
It does tho
oh wait, it should
How do I fix
25k votes a day for owo bot 
you need to create a new object inside the file
does sharding increase the rate limit above 50 per second for discord?
found the problem I had to set the entire path
ahh i see they offer higher rate limits if your bot gets that high
so i don't need to think about it so much
I am looking to make a command that gives the origin of the first name using the length of the first name and the first letter. I have this list:
Lxxxxxx = France
Pxxxxxx = Norway
Cxxxxxx = Italia
Vxxxxxx = Deutshland
Yxxxxxx = Morroco
Jxxxxxx = Algeria
Kxxxxx = USA
And in fact when the person will want to know the origin of his name he will do >origin Laurent and the bot will reply "France" because the name start with L and the lenght is 7 letters
batt_done = int(data("batt-count"))
bug_done = int(data["bug-count"])
if after.name.startswith("bug"):
bug_done +=1
embed.description=f"Bug - {bug_done}\n batt - {batt_done}"```
because you are resetting the dictionary by dumping data into the same dictionary
dump({"key": "value"}, f) #this will set the json file to the following |
|
'''json file''' |
{"old_key": "old_value"} = {"key": "value"} <----------------------------
'''WHAT YOU ACTUALLY NEED TO DO'''
{"old_key": "old_value"} = {"old_key", "old_value"}, {"new_key": "new_value"}
^
'''HOW YOU CAN DO IT''' |
data = load(file_path) |
data[str(guild.id)] = {} |
data[str(guild.id)]["channel_name"] = channel.name |
data[str(guild.id)]["channel_id"] = channel.id |
|
dump(data, f) #this will create this ---------------------------------|
'''HOW YOU CAN ACCESS THE channel_id KEY FROM THE JSON FILE'''
data = load(file_path)
welcome_channel = data[str(guild.id)]['channel_id'] #returns the integer id of the channel, you can now use this to get/fetch channels
sorry for the amount of time I took
It’s fine
ill cry if you didnt understand 😭
guess you are in for a long conditional tree
channel.fetch_message(id) doesnt work with discord.py version one, what is the thing for that?
you need to await it
since its a coroutine
I awaited it
!d discord.TextChannel.fetch_message
await fetch_message(id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a single [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") from the destination.
or the message simply doesnt exist
or the command is run in another channel
it says this ```C:\Users\Administrator\Desktop\detection bot>python index.py
Bot is ready!
Ignoring exception in command queue:
Traceback (most recent call last):
File "C:\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\Administrator\Desktop\detection bot\index.py", line 181, in queue
message = await chnl.fetch_message(queue_message)
AttributeError: 'NoneType' object has no attribute 'fetch_message'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Python39\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Python39\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Python39\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'fetch_message'```
the channel is returning None
Why is it an invalid synax
dont use that code, use what i sent in the next message, I realized that the previous one was wrong and re-wrote it
Oh
What do I do to stop it deleting dumps
I wrote that whole big message to make you understand and you aren't breaking a single sweat in reading that
data = load(file_path)
Yeah I don’t understand
Actually I might
people be like to be 
bruh, did you read the error
cant help you much then, good luck, I even gave you most of the code
Ok
chnl is NOT a channel object, you probably didn't fetch/get it properly, so it is a NoneType.
and ofc if you hadnt been using json and a proper database, it wouldnt have been an issue
inarguable
how to make an discord bot (almost all in one) using python?
i want to make a bot & want to know the learning process.
Do you have prior experience with python? I.e basic understanding of oop and asyncio?
It’s still deleting
I've OOP knowledge but no asyncio
I did what you said
Okay, well oop is all you need to get started. But it’s best that you understand basic async concepts so you don’t encounter blocking
Here lemme try to find a video
hmm.. that's not bad.. like getting grip of asyncio is preety easy

you're not doing what i said anyways, so i cant help -_-
@broken axle https://youtu.be/t5Bo1Je9EmE here’s a vid that can help you understand those basic concepts
In today's video, I'll be talking to you about asynchronous programming in python. This Python Async tutorial will cover the 'async' and 'await' keyword, coroutines, futures and tasks, and some basic features from the asyncio module in Python. This video is for intermediate programmers, and it's recommended you have Python 3.7 or above.
💻 Algo...
actually I'm a student of CSE. I've some basic knowledge about OOP. bcz I did a OOP course using java.
now I'm thinking to build a discord bot.
❤️
Yeah, well I can give you a library suggestion for when you are ready to make a bot would you like that?
But I don’t understand
yes sure
Why is it deleting the dump
disnake
I dont know, just dont know
I gave the code
I explained
both didnt work out with ya
nor are you trying
what I did and you did are totally different
Hold up I think I understand
thats what you said 5 minutes prior
You didn’t explain it properly
this whole visual representation...was shit?
😂
why u deleted ittt
:'/ i ws reading that :/
deleted what?
lmao
Bruh
:'/
All I need to do is stop deleting the dumps that’s all
I feel like jumping out of the window now
Where do I put them
😭
pats pats, u tried well bro 😭
😂 i'm literally feeling like laughing lmfao
and I feel like dying in my ownself now
😂
overall thing is
i need to get better
he's tryna use json as db... and we all know.. tryna use json as db is a fucked up decision :")
Ashley
aree 😂 you're good
said that twice, got back a rough reply
:'/
not anymore unfortunately :<
who's sussy

eren hmm
hmm
he's gonna die anyways, so who cares
lol xD
😭 bro, that's a secret.. world shouldn't know that
u revealed.. u betrayed us
:'/ now we gonna kick u out of the cult
and that exclamation mark made it all worse
😂
staph
:'/
bro, python file itself is the best db.. what do ya think? 😏
csv files got left out 😔
😭 ** ** uff sed
true
just dont use a db, change my mind
💀
LMFAOO
lmaooooo, good one
wait....imagine flipping through pages to find a specific record, awesome
💀 i'm gonna die doing tht
how do i host a bit on a raspberry pi
but like do i just run the python file form terminal
do i have to install my modules
obviously :")
k
paying for making them?
I acc should try hosting my bot on a cmd for some time
so I check how much RAM it takes
cuz my raspberry pi ain't enjoying this
How do I fix this lol
And what is that
well to be honest json is the only thing I am used to as far as a little db is concerned
I know json isn't a db
that's alright & understandable. but uk. json is meant for configuration or to store some data that isn't going to change (in some cases)..
How do I check
and as for db.. u can spend some time learning sql.. once u learn it a bit.. u can easily play around mysql or postgresql shit
Where do I look
alright sir :'/
And I’m pretty sure it’s welcome_file
Hey, how do i get all bot on the discord server?
https://docs.pycord.dev/en/master/api.html?highlight=edit#discord.Message.edit this should help u ig
@bot.command()
@commands.has_permissions(manage_roles=True)
async def welcome_setup(ctx, channel: discord.TextChannel):
data = json.load(welcome_file)
data[str(ctx.guild.id)] = {}
data[str(ctx.guild.id)]['channel_name'] = channel.name
data[str(ctx.guild.id)]['channel_id'] = channel.id
with open('welcome.json', 'w') as f:
json.dump(data, f)
await ctx.send("welcome channel setup")
@bot.event
async def on_member_join(member):
with open('welcome.json') as welcome_file:
data = json.load(welcome_file)
channel = data[str(member.guild.id)]['channel_id']
await channel.send(f"{member.name} has joined the server")
@slate swan
ye just trying it out haha
at last
and ther is also some embed.copy() thingy that u can use (idk if it's available in current version or whatever).. so like u can copy the embed as it is & just edit its description there
Yes like when hosting it
My brain goes crazy sometimes
dude
?
!d discord.Embed.copy is a thing?
copy()```
Returns a shallow copy of the embed.
idk even i found it randomly in dpy server like months ago.. some certain person told me
What do I put inside
!d disnake.TextChannel.fetch_message
await fetch_message(id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a single [`Message`](https://docs.disnake.dev/en/latest/api.html#disnake.Message "disnake.Message") from the destination.
I can’t see an object
I mean, thats the mostest uselessest method
uselesser* relatively, also uselessest isn't a word
cringe
😭 bro imagine you've an embed with multiple fields and u just wanna edit it's description.. so u think u gonna rewrite all of it again or u gonna copy it? :>
I agree, cringe
lmfao
!d disnake.Embed.edit_field
😂
huh
Could I make a command that sends the embed then fetch the message?
@bot.command()
@commands.has_permissions(manage_roles=True)
async def welcome_setup(ctx, channel: discord.TextChannel):
data = json.load(welcome_file)
data[str(ctx.guild.id)] = {}
data[str(ctx.guild.id)]['channel_name'] = channel.name
data[str(ctx.guild.id)]['channel_id'] = channel.id
with open('welcome.json', 'w') as f:
json.dump(data, f)
await ctx.send("welcome channel setup")
@bot.event
async def on_member_join(member):
with open('welcome.json') as welcome_file:
data = json.load(welcome_file)
channel = data[str(member.guild.id)]['channel_id']
await channel.send(f"{member.name} has joined the server")
embed = message_embed 👀
Idk what to put in loadf
class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") for you.
Changed in version 2.0: `Embed.Empty` has been removed in favour of `None`.
oh, here's a question
Create a dictionary, loop through it to set name and value, probably gonna save a ton of lines
set_field_at(index, *, name, value, inline=True)```
Modifies a field to the embed object.
The index must point to a valid pre-existing field.
This function returns the class instance to allow for fluent-style chaining.
remove_field(index)```
Removes a field at a specified index.
If the index is invalid or out of bounds then the error is silently swallowed.
Note
When deleting a field by index, the index of the other fields shift to fill the gap just like a regular list.
if you pass in color AND colour, which one overrides what? and which takes priority?
🤔
bro.. i said u wanna keep all the fields & just wanna change the description.. so embed.copy() is a good choice there
just use one of them, easy peasy
but what if you do both
inarguable
nice
lemme test lol
unarguable,
I'll call you a nonsensicle bastard
that's an interesting question
too late, im doing it
inarguable is a word dude, dont be such a princess
@bot.command()
@commands.has_permissions(manage_roles=True)
async def welcome_setup(ctx, channel: discord.TextChannel):
data = json.load(welcome_file)
data[str(ctx.guild.id)] = {}
data[str(ctx.guild.id)]['channel_name'] = channel.name
data[str(ctx.guild.id)]['channel_id'] = channel.id
with open('welcome.json', 'w') as f:
json.dump(data, f)
await ctx.send("welcome channel setup")
@bot.event
async def on_member_join(member):
with open('welcome.json') as welcome_file:
data = json.load(welcome_file)
channel = data[str(member.guild.id)]['channel_id']
await channel.send(f"{member.name} has joined the server")
im doing it because it's funny
💀 no idk about it
What do I put?
its annoying
wow hunter was right where did your humor go?
discord/embeds.py line 168
self.colour = colour if colour is not None else color```
ok so i tried and.. ig colour overrides color
still not sure
impossible, color is superior
that wasnt humourous
it's gonna be colour
😭 then my bot is gae
hehe
Help.#
add the name of the file
Ok
Can you try it with colour infront of color?
I wonder why you save every id as an str
alright
can ya blame me, for feeling a little hubris?
bro
And my fame for making things a bit more humorous?
I'll tickle your bones, to the tibia toes, unless your my bro jokes flow over his head.
discord/embeds.py line 168
self.colour = colour if colour is not None else color```
huh wow i do remember the lyrics
it's only gonna be color if colour is None
colour overrides color :'/
o
order of kwargs also doesn't change anything, it's not how python works
but, but
😿
:'/
is this question going to remain forever unsolved?
what question
💀 which question?
color or colour, which take priority?
colour takes priority
BRO
oh i misread that then
I sent it two times
discord/embeds.py line 168
self.colour = colour if colour is not None else color```
i thought it read color takes priority
yeah .. btw bro? do u really read the code of the lib that u sent it within few minutes when the question was asked? 💀
in the end, if you have got common sense, use just one of them
so technically, using colour is very slightly faster
okay but curiosity
💀 bruhh
uh... ig
that's long term memory
so which is faster, color or colour
colour would be faster in terms of ram ig
😂
😂 omg wtf
i need something to do
1 byte
if im not memorizing morse code im here creating pandemonium, it's kinda my whole thing
8 bits
so what
which would be a lot more, because to see bits you would need a font
and since a font has usually more than just 0 and 1
it would take a lot more memory
checkmate
It doesn’t work
I struggle to understand your logic but sure
ok bro.. discuss with these ppl.. and tell me the conclusion.. ;bout which one is faster.. cuz i gotta do some school shit rn :"/
WHAT
DAMN
i swa that message
that was a self checkmate
I SAW THATATT
you aren't getting away with that
Help
just did
💀 idk from where u got it.. ubt looks like i've seen it somewhere
nothing
corrected your to you're
horrible frrr
no i didn't
I've seen that before
frick bro
who wrote this and what is their address?
128 stars? that's base 2
fuck
Help
line 531, in _run_event
await coro(*args, **kwargs)
line 30, in on_guild_channel_update
message = await after.fetch_message(962066408768958505)
line 1581, in fetch_message
data = await self._state.http.get_message(channel.id, id)
line 416, in request
raise NotFound(response, data)
disnake.errors.NotFound: 404 Not Found (error code: 10008): Unknown Message```
bro do you not have a life?
oh yeah
💀
can we put cursed code behind and help this poor sod?
💀 me too
did you read the error?
it says, the message doesn't exist
and we can't help with that
yes but it does
copy the id again and try it
btw can i share this repos to #ot0-psvm’s-eternal-disapproval
why not colour or color
bro
the error is on line 290, and you shared line 450?
aye my bro
heard of libs
no
tell me the conclusion... which one is faster? colour or color? lol
it does not matter
yesn't
No that’s the wrong error
then. what
HAHA U DIDN'T UNDERSTANDTHE ASSIGNMENT
that isn't an error
:'/
that's just a line
colour saves you a condition
im so annoyed now, it had to be done like this
with open('welcome.json') as f: data = json.load(f)```
understand



