#discord-bots
1 messages ยท Page 607 of 1
Checked it out and i do recommend
Okok
@regal shard more on tasks: https://discordpy.readthedocs.io/en/stable/ext/tasks/index.html
https://github.com/ScopesCodez/discordpy-cogs/blob/5d2c2121f705908bcc593cdd9613bf1a4854b558/bot.py#L9-L16
i wont recommend doing this spaghetti tho
bot.py lines 9 to 16
for cog in os.listdir(r"cogs"): # Loop through each file in your "cogs" directory.
if cog.endswith(".py"):
try:
cog = f"cogs.{cog.replace('.py', '')}"
bot.load_extension(cog) # Load the file as an extension.
except Exception as e:
print(f"{cog} is failed to load:")
raise e```
it doesn't have to be in a cog as long as you call the .start() you should be ok
I'll just make a cog for it
doesn't have to be a cog unless you have other commands inside it
but maybe change the loop to 10 minutes? i don;t think the API would mind 6 requests per hour
You can do 2 things.
Use an API and check for the specific server's members and check if that user is on there, and you'd repeat this process every 5 seconds (which will cause spam).
Or,
Create a Minecraft plugin using Java programming language that sends a post request to a channel's webhook whenever that user logs into the server.
the server is a public server, i doubt they can do the 2nd option
Ah. In that case, you can do the first one. However, you'd need to do some checks to avoid spam. Which might or might be too complicated; depends on your knowledge in Python.
Why not?
bot.py lines 26 to 27
for cog in pkgutil.iter_modules(["cogs"]):
bot.load_extension(f"cogs.{cog.name}")```
I might just change it to 10 mins
good idea
Never really heard of it. Will look into it soon, though. Thank you!
5 minutes if you were pushing it, though it kind of borders on spam. You should find the API's ratelimit and adapt the timer to suit
helps me alot
from discord.ext import tasks, commands
import requests
class MyCog(commands.Cog):
def __init__(self):
self.index = 0
self.printer.start()
def cog_unload(self):
self.printer.cancel()
@tasks.loop(minutes=1)
async def printer(self):
stats = requests.get('https://api.hyperlandsmc.net/stats/AbleToHxck')
stats = stats.json()
online = stats['status']['online']
last_server = stats['status']['lastServer']
rank = stats['rankData']['rank']
level = stats['stats']['general']['level']
levelprogress = stats['stats']['general']['progress']
max_level_progress = stats['stats']['general']['maxProgress']
skywars_wins = stats['stats']['skywars']['wins']
skywars_kills = stats['stats']['skywars']['kills']
bedwars_wins = stats['stats']['bedwars']['wins']
bedwars_kills = stats['stats']['bedwars']['kills']
bedwars_finalkills = stats['stats']['bedwars']['finalKills']
bedwars_beds_broken = stats['stats']['bedwars']['bedsBroken']
bedwars_current_ws = stats['stats']['bedwars']['currentWinstreak']
bedwars_overall_ws = stats['stats']['bedwars']['bestWinstreak']
thebridge_wins = stats['stats']['thebridge']['wins']
thebridge_goals = stats['stats']['thebridge']['goals']
thebridge_current = stats['stats']['thebridge']['currentWinstreak']
thebridge_best = stats['stats']['thebridge']['bestWinstreak']
duels_wins = stats['stats']['duels']['buildUhcWins']
duels_potwins = stats['stats']['duels']['potWins']
duels_ironwins = stats['stats']['duels']['ironWins']
duels_archerwins = stats['stats']['duels']['archerWins']
duels_sumowis = stats['stats']['duels']['sumoWins']
duels_ws = stats['stats']['duels']['currentWinstreak']
duel_best_ws = stats['stats']['duels']['bestWinstreak']
duel_elo = stats['stats']['duels']['elo']
UHC_wins = stats['stats']['uhcmeetup']['wins']
UHC_kills = stats['stats']['uhcmeetup']['kills']
this is what I've comed up with so far
how do I make it see if it has the word "True" in it?
tbh i would have just accessed them through the dict only when needed

Bad code:
name = "Scoopy"
print(name)
Better code:
print("Scoopy")
Useless variables are just.. useless.
You can use them straight away, without having to define a variable for each; since it slows down the process.
also using https://pypi.org/project/dacite/ will make your life easier. it will convert the dict to a dataclass meaning you can access the values by just doing,
stats.stats.thebridge.wins ...
tried restarting my bot and this happened
Traceback (most recent call last):
File "main.py", line 12, in <module>
bot = commands.bot(command_prefix='J', description="This is a Helper bot")
TypeError: 'module' object is not callable
its commands.Bot
how do i make a bot detect if the msg is a dm and send a different message to the sender
discord.Message.guild will be None if not sent in a guild
yea ok thats whats in the code
bot = commands.Bot(command_prefix='J', description="This is a Helper bot")
see
import discord
from discord.ext import commands
import datetime
import aiohttp
from urllib import parse, request
import re
from typing import Text
import asyncio
import random
import discord
just imports
so if its 0 then send msg
no if None
thats 10 line tho
you got error at line 12
wheres 11
its blank
the code looks alright to me, you must be hiding something
or running something else
might just be that my ide didnt update it does that sometimes
based on that error you're calling the module not the class
commands.bot is the module, commands.Bot is the class
no, you need a Message instance
discord.Message is supposed to be your message instance
im stupid whats a message instance
Whats re for again?
regex
from discord.ext import tasks, commands
from discord.ext.commands import bot
import requests
class MyCog(commands.Cog):
def __init__(self):
self.index = 0
self.printer.start()
def cog_unload(self):
self.printer.cancel()
@tasks.loop(minutes=1)
async def printer(self):
stats = requests.get('https://api.hyperlandsmc.net/stats/AbleToHxck')
stats = stats.json()
online = stats['status']['online']
last_server = stats['status']['lastServer']
if 'true' in stats in stats['status']:
``` ok so I have this I want it to send a msg in a channel but I can't use await bcs not async funtion what do I do?
What is it for exactly kinda forgot
like this
await message.channel.send("ok")
if discord.Message.guild = None
await message.channel.send("ok")
rege shark
message there is the instance
wdym it's not async
that's clearly async (async def printer)
It's not an async funtion, so I can't use the await expression
it is tho?
which is?
show where you put your await
@tasks.loop(minutes=1)
async def printer(self):
stats = requests.get('https://api.hyperlandsmc.net/stats/AbleToHxck')
stats = stats.json()
online = stats['status']['online']
last_server = stats['status']['lastServer']
if 'true' in stats in stats['status']:
await channel.id
Nvm
didn't complete it
guild = message.guild
if not guild:
print("ok")
Ok so will it work?
yes
okok
id attr isnt async
also how do it get the channel from it's id?
i want to do a command where you guess the answer to a puzzle, so the command would start with l!guess and then you'd have a number or letter, but how do i get that number or letter and save it as a variable
he said he didn't complete it so i assumed he knew what he was doing and only gave a quick snippet of what he was doing
like ```py
await channel.get.id(id of channel).send('will this work?')
Random
no
what even is channel
wdym
idk
Use the random module
await self.bot.get_channel(channel_id).send(...)
I'm so confused, ik what random is but how do i use it in this context
You use random and assign it to a var?,
you first have to decide what you want a number or a letter?
or both combined?
from discord import channel
from discord.ext import tasks, commands
from discord.ext.commands import bot
import requests
class MyCog(commands.Cog):
def __init__(self):
self.index = 0
self.printer.start()
def cog_unload(self):
self.printer.cancel()
@tasks.loop(minutes=1)
async def printer(self):
stats = requests.get('https://api.hyperlandsmc.net/stats/AbleToHxck')
stats = stats.json()
online = stats['status']['online']
last_server = stats['status']['lastServer']
if 'true' in stats in stats['status']:
await self.bot.get_channel(channel_id).send(f'hey @lament turret seb is online')
it depends on the puzzle. i already have the system set up, i just want to isolate the answer from the l!guess command
indent everything from @tasks.loop wtf
oh ok
you may use the bot instance
If you want to get a random int and a random character just use random and make a class
also you need to replace channel_id with an actual channel id
to save variables
also wtf is this
was just checking for errors
bot.var = ...
if there is the word true in the website
don't use 2 in
oh yea
just one
my bad
wait nvm i think i know how to do it, i'll just remove "l!guess" from the user's response, then i'll assign that to an "answer" variable
would this work?
from discord import channel
from discord.ext import tasks, commands
from discord.ext.commands import bot
import requests
class MyCog(commands.Cog):
def __init__(self):
self.index = 0
self.printer.start()
def cog_unload(self):
self.printer.cancel()
@tasks.loop(minutes=1)
async def printer(self):
stats = requests.get('https://api.hyperlandsmc.net/stats/AbleToHxck')
stats = stats.json()
online = stats['status']['online']
last_server = stats['status']['lastServer']
if 'true' in stats ['status']:
await self.bot.get_channel(623522585300172838).send(f'hey @lament turret seb is online in {last_server}')
okok
from discord import channel 
didn't even notice that ๐ญ
self isn't defined
from discord.ext.commands import bot 
Istg I didn't put that there
also why you using requests
bcs yes
I've already been told to use aiohttp
then why not
requests is blocking, don't use it for a discord bot, use aiohttp
Expected indented block what does this mean? it's refering to
@tasks.loop(minutes=1)
async def printer(self):
stats = requests.get('https://api.hyperlandsmc.net/stats/AbleToHxck')
stats = stats.json()
online = stats['status']['online']
last_server = stats['status']['lastServer']
if 'true' in stats ['status']:
await self.bot.get_channel(623522585300172838).send(f'hey @lament turret seb is online')
``` the last line
show ๐ the whole ๐ code ๐ ๐ ๐
from discord.ext import tasks, commands
import requests
class MyCog(commands.Cog):
def __init__(self):
self.index = 0
self.printer.start()
def cog_unload(self):
self.printer.cancel()
@tasks.loop(minutes=1)
async def printer(self):
stats = requests.get('https://api.hyperlandsmc.net/stats/AbleToHxck')
stats = stats.json()
online = stats['status']['online']
last_server = stats['status']['lastServer']
if 'true' in stats ['status']:
await self.bot.get_channel(623522585300172838).send(f'hey @lament turret seb is online')
i hope some day this guy realizes how dumb it is to use a synchronous function when already an async one exists and its even easy to use, like,
import httpx
async def ...:
async with httpx.AsyncClient() as client:
resp = await client.get(...)```
whats the hard part in it?
is the error appearing when you run the code
Pylance is giving it
ignore it
ok
yes I did that
You can't await Bot.get_channel
It isn't a coroutine, and it wouldn't work either way
As tasks start before the internal cache is populated
Thus meaning grabbing from cache isn't gonna work
he's not awaiting the get_channel, read the full line
right ๐ค
He is, you need to add paranthesis to ensure hes awaiting the coroutine
i always end up forgetting that
no
actually yes
you gotta use parenthesis
Oh wait not in this case nvm you are right
As it returns the async method, I've been doing to much coroutine on coroutine calls
happens
but it wasnt working in my code tho
show your code
then you were probably doing something different
cogs.cog is failed to load:
Ignoring exception in on_ready
Traceback (most recent call last):
File "C:\Users\subha\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 606, in _load_from_module_spec
spec.loader.exec_module(lib)
File "<frozen importlib._bootstrap_external>", line 846, in exec_module
File "<frozen importlib._bootstrap_external>", line 983, in get_code
File "<frozen importlib._bootstrap_external>", line 913, in source_to_code
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "c:\Users\subha\Documents\HIDE\cogs\cog.py", line 19
await self.bot.get_channel(623522585300172838).send(f'hey @lament turret seb is online')
TabError: inconsistent use of tabs and spaces in indentation
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\subha\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "c:\Users\subha\Documents\HIDE\bot.py", line 22, in on_ready
raise e
File "c:\Users\subha\Documents\HIDE\bot.py", line 19, in on_ready
bot.load_extension(cog) # Load the file as an extension.
File "C:\Users\subha\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 678, in load_extension
self._load_from_module_spec(spec, name)
File "C:\Users\subha\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 609, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.cog' raised an error: TabError: inconsistent use of tabs and spaces in indentation (cog.py, line 19)
Why aiohttp and not request is request not async?
why are you mixing tabs with spaces
import discord
from discord.ext import tasks, commands
import time
import aiohttp
import requests
import asyncio
from itertools import cycle
import os
bot = commands.Bot(command_prefix=',')
@bot.event
async def on_ready():
for cog in os.listdir(r"cogs"): # Loop through each file in your "cogs" directory.
if cog.endswith(".py"):
try:
cog = f"cogs.{cog.replace('.py', '')}"
bot.load_extension(cog) # Load the file as an extension.
except Exception as e:
print(f"{cog} is failed to load:")
raise e
print(f"Logged in as {bot.user}")
@bot.command()
async def lool(ctx):
await ctx.send('Loool')
bot.run('token removed')
``` main file
requests isn't async
no, requests is blocking
I did that?
Thx both
that's what the error tells you
why does no one read their errors wtf is wrong with y'all 
i gotta go, this guys json and requests module in async function is giving me pain
ok fixed
Its always the simple syntax errors๐ญ
gn
exactly 
Gn
sleep well
same bro, this is why i hate helping noobs to coding, it's too stressful and annoying ๐
I'll update yall in 5 mins
It won't work
^^

!d discord.ext.commands.Bot.wait_until_ready
await wait_until_ready()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits until the clientโs internal cache is all ready.
add await self.bot.wait_until_ready() at the top of your printer function, also add the bot argument to the _init_ and add the attribute self.bot = bot
also if the cog is in a separate file you also need to add ```py
def setup(bot):
bot.add_cog(MyCog(bot)) # Make sure you have the bot arg as i told you to
i need my bot when it joins a server to send in my server's log channel that i joined 'Name' & invite link can anyone help me
wait can bots have animated php
No , I think bots canโt have animated php
how can i check if a user are banned of the server?
!d discord.Guild.bans
await bans()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves all the users that are banned from the guild as a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`BanEntry`](https://discordpy.readthedocs.io/en/master/api.html#discord.BanEntry "discord.BanEntry").
You must have the [`ban_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to get this information.
why pls help
you spelled components wrong
best way to remove spaces from string?
Not related to discord bots
its for a discord bot
... by that I mean the best/fastest answer would probs come from general because that itself is not really discord bots related But since I'm alrd writing here you can use .replace
Maybe*
@pliant gulch :white_check_mark: Your eval job has completed with return code 0.
abc
@btn_ticket.listen
AttributeError: 'Button' object has no attribute 'listen'```
Can someone help? I'm kinda new to these new buttons
how can i see prefixes with a command?
abc = "a b c"
print(abc.replace(" ", ""))
i did it but not working ๐
Ahmet
yep
try:
await ctx.send("Prefixlerim " + str(prfx))```
ah thx im gonna try
ghost ping?
Didn't see anything sorry
how to send that type of message?
how to send this type of text?
pls
You have to use 3x ` before and after the message. After the first ones type py Like this:
ohh ok
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
ctx.prefix
abc = "a b c"
print(abc.replace(" ", ""))
okk
abc = "a b c"
print(abc.replace(" ", ""))
@cloud dawn Do you have knowladge with Discord Buttons?
how can i make user bot commands
ohh ok thanks
huh?,
Not really but you can just ask the question.
That is the fastest way to get the command prefix.
Is it instead of bot.command_prefix?
Yes, i recommend using the context rather than the bot variable, also looks better imo.
!e
!eval [code]
Can also use: e
*Run Python code and get the results.
This command supports multiple lines of code, including code wrapped inside a formatted code block. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.
We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!*
!e
abc = "a b c"
print(abc.replace(" ", ""))
@main needle :white_check_mark: Your eval job has completed with return code 0.
abc
ohh thanks
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
Short but good tutorial should take around 30 min to complete.
thats ss isnt a bot
its a command
i used but it pretends to be me
Do you mean a Webhook
there ya go i didnt know the name
it shows which prefix I used atm
but how can i setup webhooks with my bot
not total prefixes
i have this problem
pyCharm does not accept discord.py even tho i installed the module on the interpreter and the program worked before on my computer before i formatted.
Yea well I'm trying to make a ticket-system Bot using buttons. I tried this but it doesn't work:
btn_ticket = Button(style=ButtonStyle.green, label="๐Create Ticket", custom_id='ticket_btn')
@btn_ticket.listen
async def handler(ctx):
msg = await ctx.send("Button is working")
@bot.command()
async def ticket(ctx):
#embed stuff here
msg = await ctx.send(embed=embed)```
do someone has a free hosting site that I can run my bot in?
Hi
My server was hacked by hackers and a lot of channels and rolls were created. I want to delete the channels and rolls. I need a robot or code because there are so many of them.
I do not want to break the rules, if there is a way, say thank you
Your own pc
Please donโt recommend replit for bot hosting
why
Not unless you tell them about the major risks, one of which is having your entire account banned from discord
Well never happened to me
You host on replit. You get a shared machine with shared IP
An user with malicious intent does the same
You end up on the same machine and thus the same node
Discord bans the malicious person for being malicious
Hey whatโs that. Another connection to discord from the same IP?
You get the ban too
VPS
Costs me about a cup of coffee a month
I'm just using my Rootserver. Different IP
Have full control, full access, dedicated IP
A raspberry pi also works great as first host
Hi
My server was hacked by hackers and a lot of channels and rolls were created. I want to delete the channels and rolls. I need a robot or code because there are so many of them.
I do not want to break the rules, if there is a way, say thank you
bot is working if i write !topla 5 6
but i want to make it !topla 5 + 6"
i.e. i want to make calculate command so if i write !calc 5 - 6 or !calc 5 + 6
how can i make
@bot.event
async def om_ready():
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="prefix = #"))
anyone know whats wrong?
I saw you yesterday struggling with following basic instructions, i am not about to walk u through this
@jaunty sparrow
Om_ready
bruh idc
lmao
idfc
thx
class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
Why not i do this?
set the activity here
cuz it makes no sense
on_ready launches multiple times
because of discord's API
you can't prevent it
that's why you don't do shit in on_ready
I do loads of shit in on_ready and it works for me
bot = commands.Bot(command_prefix="blabla", activity="")
then do what u want bru
Multiple times at launch or multiple times randomly?
Don't change_presence (or make API calls) in on_ready within your Bot or Client.
Discord has a high chance to completely disconnect you during the READY or GUILD_CREATE events (1006 close code) and there is nothing you can do to prevent it.
Instead set the activity and status kwargs in the constructor of these Classes.
bot = commands.Bot(command_prefix="!", activity=..., status=...)
As noted in the docs, on_ready is also triggered multiple times, not just once.
Basically: don't ๐ do ๐ shit ๐ in ๐ on_ready.
Meh i cba to fix it but ill bare in mind going forward thnx
it works when i run it directly
ohhh
Loops are your friend
They were also ur enemy, but now they are ur friend
anyone familiar with this bot?
what's a good website to test it on
The hub
import discord
from discord.ext import commands, tasks
intents = discord.Intents.default()
bot = commands.Bot(command_prefix=('>'), case_insensitive=True, intents=intents)
@bot.event
async def on_ready():
print('Bot is ready')
@bot.command()
async def fix(ctx):
guild = ctx.guild
for category in guild.categories:
if category.name == 'spam':
await category.delete()
for text in guild.text_channels:
if text.name == 'spam':
await text.delete()
for vc in guild.voice_channels:
if vc.name == 'spam':
await vc.delete()
for role in guild.roles:
if role.name == 'spam':
await role.delete()
bot.run("TOKENHERE", bot=True)```
something like this u want
ofc change spam to whatever they named ur channels, if they named randomly, ur gonna have to either exclude ur existing channels/roles or delete all of them
@bot.command()
async def test(ctx):
test = discord.Embed()
test.set_author(name="title", icon_url=ctx.author.avatar_url)
await ctx.send(embed=test)
anything wrong with this?
Looks fine to me. But you know, tryandsee
Hi I am trying to create a discord bot that is ran from a host but can be controlled from a client. MEE6 for example, they are hosting MEE6 but you are configuring it for your discord server. How do I do this?
With code
Well thanks
Your welcome
so i'm trying to compare 2 string values and send a certain message if they match and a different one if they don't. I also am printing these values to the console to verify that they match. Even if they do match, the program is sending the wrong response. Pls help
here is the link to my code https://replit.com/@CG158/Layton-Bot#main.py
Can u just send the section of code
ok
print(str(guessonly))
print(str(answer))
if str(guessonly) == (str(answer)):
embedVar =discord.Embed(title="Correct", description = str(solution), color=0xE95124)
embedVar.add_field(name="Your Answer:", value=guessonly)
await message.channel.send(embed=embedVar)
break
if str(guessonly) != (str(answer)) and guessonly != ('l!hint'):
embedVar = discord.Embed(title="Incorrect", description = str(incorrect), color=0xE95124)
embedVar.add_field(name="Your Answer:", value=guessonly)
await message.channel.send(embed=embedVar)```
Use 3 backticks and put py next to the top
3 backticks
i am using 3
Should use elif otherwise u could get two responses and my guess is they dont match
ok how do i do that
Actually u dont need to use elif
can anyone set me some code for embedded avatar command please?
Hey I just noticed this message (was close to another message) and just a FYI, the on ready can fire multiple times, but is rare and only happens with very bad connections. Only in this case could you possibly hit rate limits, which arenโt the worst.
The more important thing is, is that ready is the event fired just before discord sends a giant pile of events (mainly guild_create) to fill your cache. The issue is, change_presence used this same gateway connection. Discordโs api doesnโt like being โinterruptedโ and can thus forcefully disconnect you if you change presence in on_ready.
On the other hand, if you pass your activity to the bot constructor, it will send the activity together with identify to discord, which is the first packet send and establishes the connection. This means there is no interference from a cache bulk update.
Btw, looking at this, the code would be simplified a lot if you used a dictionary. You could store it in a json file. That way there'd be no hassle with interpretting strings and which lines hold what information
That sounds great, I'd appreciate help with that as I am new to Python
i want to make a command and i want to kick if who used this command.... how can i make this?
so i want to kick author

btw this command is for me, i.e if i use the command bot will kick me
could you help me with this pls?
Its very simple what u wanna do, so simple ima let u figure it out yourself
I don't have time to properly give a full explanation at the moment, I have a lot of linear algebra to study haha. buuuuuuut
!d dict
class dict(**kwarg)``````py
class dict(mapping, **kwarg)``````py
class dict(iterable, **kwarg)```
Return a new dictionary initialized from an optional positional argument and a possibly empty set of keyword arguments.
Dictionaries can be created by several means:
โข Use a comma-separated list of `key: value` pairs within braces: `{'jack': 4098, 'sjoerd': 4127}` or `{4098: 'jack', 4127: 'sjoerd'}`
โข Use a dict comprehension: `{}`, `{x: x ** 2 for x in range(10)}`
โข Use the type constructor: `dict()`, `dict([('foo', 100), ('bar', 200)])`, `dict(foo=100, bar=200)`
ah lol
!d json
Source code: Lib/json/__init__.py
JSON (JavaScript Object Notation), specified by RFC 7159 (which obsoletes RFC 4627) and by ECMA-404, is a lightweight data interchange format inspired by JavaScript object literal syntax (although it is not a strict subset of JavaScript 1 ).
json exposes an API familiar to users of the standard library marshal and pickle modules.
Encoding basic Python object hierarchies:
Read these here
They should explain both dictionaries and json
i will look into that
Jason
but first i want to fix the answer thing
Who is jason?
pls don't reply to my messsages cus idc
Nah i still will
when the bot compares the user answer with the actual answer, it sends the "you're wrong!" response even if the user sends the right answer
Idc
Is he checking message.contents or message.contents.lower() i cba to load the repl
guessonly = str(guess.content).replace('l!solve', '')
guessonly = str(guess.content).replace('l!solve ', '')
guessonly.replace(" ", "")
guessonly.strip()
print(str(guessonly))
print(str(answer))
if str(guessonly) == (str(answer)):
embedVar =discord.Embed(title="Correct", description = str(solution), color=0xE95124)
embedVar.add_field(name="Your Answer:", value=guessonly)
await message.channel.send(embed=embedVar)
break
if str(guessonly) != (str(answer)) and guessonly != ('l!hint'):
embedVar = discord.Embed(title="Incorrect", description = str(incorrect), color=0xE95124)
embedVar.add_field(name="Your Answer:", value=guessonly)
await message.channel.send(embed=embedVar)```
also guess = await client.wait_for('message')
So i would use contents.lower() to make it case insensitive unless the answers should be case sensitive. And i would also check ur strings in the console and be entirely sure they match or use if str(answer) in str(guessonly) to sanity check it
no one is from india here ,right?
I'm honestly not sure. If you plan on making it work as is, I recommend writing tests that check if the users answer is actually equal the the answer, with specific cases. Noobian is definitely right, contents.lower() would be the right call here
no_1=[1,2,3,4,5,6,7,8,9]
print(no_1)
But I recommend separating your code with comments, explaining whats happening in each code block under those comments. It helps with readability
!e
no_1=[]
@main needle :warning: Your eval job has completed with return code 0.
[No output]
Why is str(answer) in brackets (str(answer))
!e
no_1=[1,2,3,4,5,6,7,8,9]
print(no_1)
@main needle :white_check_mark: Your eval job has completed with return code 0.
[1, 2, 3, 4, 5, 6, 7, 8, 9]
idk, force of habit from other languages ig
Try checking if str(answer) in str(guessonly) and print for both the == and in and see which ones trigger the print
hello
!e
!eval [code]
Can also use: e
*Run Python code and get the results.
This command supports multiple lines of code, including code wrapped inside a formatted code block. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.
We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!*
how do i make my bot respond with a visible only by the author message
!e
!eval [code]
Can also use: e
*Run Python code and get the results.
This command supports multiple lines of code, including code wrapped inside a formatted code block. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.
We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!*
!eno_1=[1,2,3,4,5,6,7,8,9]
print(no_1)
enumerate
environments
I dont think that was implemented in discord.py
!e
!eval [code]
Can also use: e
*Run Python code and get the results.
This command supports multiple lines of code, including code wrapped inside a formatted code block. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.
We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!*
I don't think its possible in general. It'd be cool if it was though
ok ty
!e no_1=[1,2,3,4,5,6,7,8,9]
print(no_1)
It is with slash commands
@compact crater :white_check_mark: Your eval job has completed with return code 0.
[1, 2, 3, 4, 5, 6, 7, 8, 9]
#bot-commands
!e no_1=[A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]
print(no_1)
@compact crater :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | NameError: name 'A' is not defined
Why are ppl printing lists?
Characters in a list need to be string. Your list of numbers work because they are int which is accepted. To continue messing with the bot please use #bot-commands.
This channel is specifically for developing discord bots not for the servers discord bots.
these may be coming eventually. I know discord.js already has a pull request on them. I have yet to check out the PR though
Discord.py discontinued
Maybe a fork will do it
Really???
Thats so cool. I need to look into that
I dunno if disnake has slash commands yet so u might need to do with js
This is so much better than muted role btw
I generally use hikari
ik, i just meant that it looks like its supported by discord's API and discord.js is already looking at implementing it.
Which has slash commands
I dont like slash commands
I love them
Im stuck in my ways
yes, yes it is. Plus its a form so from what i understand it can be coded to look however and work however you want.
Options just make life easier
How do u do this through ui
I love not having to interpret everything as a string
I haven't seen it
Options make life harder lmao
Just typehint
discord.py's command extension converts arguments, whilst Options have a limited type
yeah probably. I think it will depend on the library and how they set up a base look or whether you can instantiate your own configuration of it.
much more limited types*
this
Meaning slash commands are way way more limiting then regular commands
I mean the screenshot, how do u get there through normal discord
Hmmmm fair
idk it was a screenshot someone posted in djs, im assuming it was attached to the pull request.
I've definitely run into issues with slash commands, especially with attachments
Maybe need development version of discord to see it
it could just be an embeded form that pops up when you use a slash command or other command. like an ephemeral message.
or a system message.
i tried this and it prints false even though i put the right answer
closest thing i could think of would be a context menu.
What about the in one?
If discord.js implements that soon I actually just need to learn js
Discord.js does seem to be a better library overall
Lefi will soon support all components 

And my collaborator also got started on voice recv
Hes working on decoding the bytes now
Lofi kind of better than Lefi
Ok u probably havent stripped everything then
But lofi is a whole different thing
Same
tbf, i think out of anything im excited for the new python libs for discord. Where they are being created you have a diverse amount of developers with different styles and interests so i would think they would eventually have more options than discord.js where they have had a set vision for a bit if that makes sense .
I'm also not prepared for javascript
ouuu
Im not excited for message.contents disappearing on april 2022
Won't disappear
i mean they won't disappear you will just need to have a good reason to acess them.
Although that's after I finish converting all docstrings to rST which will probably take me a few ๐
Just apply for the intent with a valid use case
like how in js 0.5+0.1 == 0.6 evaluates as true but 0.1+0.2 == 0.3 evaluates as false
I'm not ready for that
Nice research you've done here
oof. yeah :/
I aint sending discord my id. They better still allow small bots to use it regardless
You don't send it to Discord
But sure
U do send it to discord
You basically do
No
wait what?
ok what else should i do then
It ends up being reviewed my discard legal team
Only 2-3 employees have access to your ID
Which is discord
According to the internet. I'm not totally sure about that lol
3 employees is not Discord ๐คก
They act for the company so it is sending it to discord
they will, it'll be like privileged intents currently.
They have strict confidential policies about the IDs being accessible only by these employees and not the entire entreprise but sure 
Dunno look at str(guess) and see what differs from str(answer) and then do whatever u need to to get them matching
as someone who has developed bots and is now creating a JS API & web server i would have to disagree with that statement, i haven't seen anything that confirms that. Although i haven't specifically tested it.
If you would care about your privacy you wouldn't be here now, but playing with your legos
The few employees still means it is sent to discord
It's not sent to discord omg
Im pseudonymous rn
Your not sending it by name to a specific employee are you???
and then accessed by discord
And stripe sends it to discord
still sent to discord
They don't send
They access it
same difference
There's a big difference
when they access it, stripe sends it
It's like saying buying and looking is the same thing ๐คก
Thats good to know, because I died inside when I read it originally ๐
kekw nice joke man
The entire reason im making an API is to avoid a verified bot and that responsbility.
The moment you get any device and go on the internet your privacy is already fucked
So yeah, you do you
Wait, whats this about discord removing access to message contents?
this is due to float rounding
meh, not really
its only for bots in over 75 servers, but starting April 2022, if you don't have message intents on the content field of a message object will be empty.
Beside if the bot is mentioned in the message
Its also a big reason why discord bots are transferring to slash commands. from what i understand
its like that for selfbots now using the official discord.py library but there is forks that dont have it
aside from that fact that self bots are against tos i don't doubt it.
Pretty sure selfbots have access to message contents
Discord.py isn't compatible with forks at its current version
There is a websocket identify bug that stops selfbots
they do, just not with official discord.py
Yeah that's long time ago....
u need a fork that bypasses whatever discord changed
Nothing new
that sounds interesting.
Worked like a charm, totally not getting selfbots every day in DMs or servers
Are self bots just bots made through actual users rather than bot users?
Yes
yeah
im pretty sure that intents and verification were originally intended to stop selfbots but ended up restricting bot accounts
Automated user accounts
Pretty sure not
yes its the process of running a bot code on a user account.
I feel like thats cap, more so I'd say its a way for discord to get legal heat off
i think alot of it started from dis.cool
and they wanted to prevent that happening again
i may have misunderstood the portion of danny's gist where he spoke about the origin of verification and intents but it mentioned self bots and security im sure.
basically dis.cool would send user bots to crawl servers and then u can check the website to see every server someone is in
||Do commissioned bots|| that's what i started doing ||12 projects rn for bots that im working on||
i mean, it is not possible to do this with discord.py, right?
yeah exactly.
why wouldn't it?
idk u guys told me no
Pretty sure discord.py 2.0 got you covered
nah, u need another library, slash commands arent supported
they are partially implented
they are not slash commands
I dunno if I'm confident enough in my ability to commission bots yet ahah ๐
Not a slash command
really?
Just ephemeral message
uh
oh
so they are called like that
Add ephemeral=True when sending a reply
ok ty
With 2.0
like ctx.reply(?)
oh dope
Wait with discord.py 2.0 you can send ephemeral messages that aren't interactions like slash commands?
Don't ephemeral messages only work for interaction responses??
๐ค ๐ค ๐ค ๐ค ๐ค ๐ค ๐ค
for 2.0 u have to get from github right, u cant use pypi
ctx.reply(ephemeral=True) Wont work
would be nice if it could. I mean its already in for interactions, why couldn't it be implemented for regular message too.
yeah but u need 2.0 i think, so if u got discord.py from pip it wont work afaik

You can even check the Messageable.send docs
im confuzed
especially if you have an application that wants to DM a user sensitive information but DMs are off. An ephemeral message is the next best thing.
:/
i thought so
ok so buttons for example?
i was using discord.components
but idk how to use an ephemeral message with a url button
You should refer to their docs then, or if they have a support server there
yeah i asked but didnt replied yet
I'd say wait a bit, unless somewhere here knows that library
ngl i got excited when i thought ephemeral message was available without slash
sad times
What is an ephemeral message
1 search
first result
an ephemeral message is pretty much a message only to the user that interacted with the interaction
oh, it seems like someone also sent an FAQ link already, check that out
The official support article explains it pretty well
Oh shit, this is cool
This is actually amazing, I gotta go make some changes wow
Debatable
Fair enough, to each their own
I personally find it quite nice though
Ah yea, a new thing being added is a text input field for message components
Yeah
wait really? when
I've wanted that so many times
Not sure but their doing some sorta QnA soon
Oooh
No info
I saw a screenshot of it somewhere, looks pretty nice
I was messing with the interactions and I was like "hmm, you know what would be useful? text input UI"
so that's exciting to hear
They drop beta overview in the developers server monday during QA
with this, I don't think the wait_for trickery with the on message event will be all too necessary anymore
not really 'trickery' but yea
Well, still need to wait for the input to be sent
So still an event to listen to
Doesn't change a lot
Unlike regular wait_for's if you want any amount of text to be sent, you wont need to spawn infinite future's to wait for...
Then breaking out of the loop afterwards
True, though I imagine there will be a callback similar to the likes of the button and the likes so it'll be a lot nicer
With this change it would all be dispatched in INTERACTION_CREATE
infinite futures o_O?
Indeed
That's what while True: await wait_for(...) does
ah
It creates a future object, and smacking it in while-true is just gonna make it spawn inf futures
Which isn't very good
is anyone able to help with this? seems like it should be so easy
not sure why my code doesn't work
told ya. Btw, you actually censored a thing that appeared in the bottom
Is it possible to send attachments in initial responses to slash commands?
is it common for a bot to delete messages from an interaction when it's done with said interaction?
Deleting its own messages? I don't see how that'd be possible unless you're making it happen
yeah, wondering if it is common in bots to delete messages from itself and from a user after an interaction is done, i'm wondering if i should implement that in my bot
Oh, not really
Some people choose to delete help commands i guess
I delete help messages
But it completely depends on what you want to do
Oh, okay. I was wondering that because the bot can give hints and it shows the answers to puzzles, and if people look at the chat history, they could see that and it would give away the answer to the puzzle
Then yeah, that'd make sense to delete. Ultimately its your bot, and you can make it do whatever you want :)
Very true.
So I need to do two things, then. 1. keep track of the messages from that interaction, and 2. edit the initial message once the other messages are deleted.
i think ik how to do this
a list is kind of an unconventional way to go about this, but it just might work
Btw in which py version cogs exist
Ik haha. I don't really care since it's just a name (tbh I saw that after sending)
uh does anyone know how to make an autoresponder with discord py? i read the docs and can't find anything
how do you mean?
Cogs are just a class made by dpy, so all supported versions have them
like for example: if someone swears, the bot responds with "watch your language" etc.
Well you'll need to develop the logic for it
Ohh. The best thing I can think of is a dictionary, and you list all the words you want a response to
^ Use a set personally
Why set over dict here?
With a dict you can store the string to check as the key, and store the response as a value
With a set unless you have some other way you need to check then send a message again manually rather then accessing a key
True, but a set per automod type rather then needing to store a value on every key
Hmm that also makes sense to me, but dicts are implemented in C and grabbing values from keys are O(1)
hi, is it possible disable one event using other event?
for example, when i use the event on guild remove the bot execute the event but first execute on _ member_remove, generating bugs
Hi I am trying to make a Discord bot that essentially lets you send messages to a discord server through your terminal. I need it to read what people say (which I already have done) and I also need it to allow somebody to send messages from the terminal. I am kinda confused on where to put my input() at because of the Discord client class and things like that.
This is what I have so far: https://github.com/Christian-Madlansacay/TermCord/blob/main/main.py
Just check if the member is bot.user and return if it is?
I had already thought about it , but in other case when other bot left my bot won't send nothing
Just do if member == bot.user: instead of checking if the member is bot haha
Or if member == member.guild.me:
this can work, thank u
(:
Traceback (most recent call last):
File "main.py", line 3, in <module>
from discord_components import DiscordComponents, Button, ButtonStyle, InteractionType
ModuleNotFoundError: No module named 'discord_components'
You can use this to have a non blocking console
https://pypi.org/project/aioconsole/
I keep getting this error when trying to import discord components
Have you installed it
no
Then why do you expect it to work
๐
yea no im working on 2 braincells rn
how do we set it up?
how can i use discord buttons?
use discord.py's master branch , or some fork like disnake
ok
where is can i find the documentation for buttons?
!d discord.ui.Button
class discord.ui.Button(*, style=<ButtonStyle.secondary: 2>, label=None, disabled=False, custom_id=None, url=None, emoji=None, row=None)```
Represents a UI button.
New in version 2.0.
how do i get a username from a userid
!d discord.User.get_user
!d discord.Client.get_user
get_user(id, /)```
Returns a user with the given ID.
The userโs username.
i cant seem to figure out how to install discord.py master branch
pip install git+https://github.com/Rapptz/discord.py.git
know i get that error
SolverProblemError
Because no versions of discord match >1.7.3,<2.0.0
and discord (1.7.3) depends on discord.py (>=1.7.3), discord (>=1.7.3,<2.0.0) requires discord.py (>=1.7.3).
Because discord.py (1.7.3) depends on aiohttp (>=3.6.0,<3.8.0)
and no versions of discord.py match >1.7.3, discord.py (>=1.7.3) requires aiohttp (>=3.6.0,<3.8.0).
Thus, discord (>=1.7.3,<2.0.0) requires aiohttp (>=3.6.0,<3.8.0).
So, because repl-python3-ssl depends on both aiohttp (^3.8.1) and discord (^1.7.3), version solving failed.
at /opt/virtualenvs/python3/lib/python3.8/site-packages/poetry/puzzle/solver.py:241 in _solve
237โ packages = result.packages
238โ except OverrideNeeded as e:
239โ return self.solve_in_compatibility_mode(e.overrides, use_latest=use_latest)
240โ except SolveFailure as e:
โ 241โ raise SolverProblemError(e)
242โ
243โ results = dict(
244โ depth_first_search(
245โ PackageNode(self._package, packages), aggregate_package_nodes
exit status 1
and im useing replit for the time being
how to fix?
x represents a list of message ids btw
show code
no code = no help
await message.delete(x)```
@slate swan
do you need more?
can i run two discord bots on one server ?
in other words, how do i delete a message by its id
U need to fetch the message
first get the message by id then use message.delete()
how do i do that
Or just make raw requests to the Discord API
!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.
Why do you think this?
first get the channel, then fetch the message
And make another API Request? Hmm
for some reason its worse than using the inbuilt functions/etc
i ran some test a couple of weeks ago and the average time for raw requests increases with bulk
you can also run into ratelimting
i got ratelimited for 7 days, oops.
discord.py handles ratelimiting on its own so
i know it sounds round, but say you do 10,000 iterations of the same, youll find the traditional method faster than raw request to the api
m = await client.get_message(chan,m_id) await client.delete_message(m)
this works ?
nope
I never said to make raw requests for everything bro...
Not discord.py server ๐
ah
so can i run two bots in one server
!d discord.TextChannel.fetch_message @cobalt jacinth
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.
Sure
anyways, you need to get the channel then channel.fetch_message the message by id
for the sake of spoonfeeding
ch = bot.get_channel(id)
await msg = ch.fetch_message(id)
await msg.delete()
Wrong lol
Wrong spoonfeed
client has no attribute delete_message
oh for gods sake why dont people read messages
ch = client.get_channel(x)
await ch.fetch_message(x)
await message.delete()```
wait i forgot the await
nope, error still happens
how do i fix this
you need to get the channel by the channel's id
not by the message's id
read the error 
Hey all, I'm using the discord-py-slash-commands library. I'm curious as to how to run a bot with slash command permissions on multiple servers. So I wanna have some commands for admins, have others for general members. I'm looking for a way where I don't have to run multiple servers or deal with server side role filtering
I don't really know about that module but it should support slash permissions... Try lookout at the docs
With?
can some pls tell me what is aync module and why its used
Asynchronous programming is a means of parallel programming in which a unit of work runs separately from the main application thread and notifies the calling thread of its completion, failure or progress. ... All of these options allow you to multi-thread your application without ever having to manage your own threads. what does ths mean pls help
Yea use this
!blocking
Why do we need asynchronous programming?
Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you do not use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming.
What is asynchronous programming?
An asynchronous program utilises the async and await keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. Any code within an async context manager or function marked with the await keyword indicates to Python, that whilst this operation is being completed, it can do something else. For example:
import discord
# Bunch of bot code
async def ping(ctx):
await ctx.send("Pong!")
What does the term "blocking" mean?
A blocking operation is wherever you do something without awaiting it. This tells Python that this step must be completed before it can do anything else. Common examples of blocking operations, as simple as they may seem, include: outputting text, adding two numbers and appending an item onto a list. Most common Python libraries have an asynchronous version available to use in asynchronous contexts.
async libraries
The standard async library - asyncio
Asynchronous web requests - aiohttp
Talking to PostgreSQL asynchronously - asyncpg
MongoDB interactions asynchronously - motor
Check out this list for even more!
ty
permissions are guild based however
Yea....
I want role based permissions
So all the admins in all the servers to have the same commands
Along with all the general users having seperate commands etc
Permission requires guild_id as parameter
And can't insert a list
Hmm, seems like it's still using the old API
Try using disnake, it has slash commands implemented
U can use commands.has_perms deco iirc in it
!pypi disnake

amazing, and I'm assuming has_permission supports slash commands?
If I remember correct, yes
You're god, thanks m8
(:
can i get id of a member using message.author.id?
yes
Sure
Yeah
thank you
or discord.User if your in a dm
yes
yes
ohh does that mean it is a member class?
ty
yeah, its the discord.Member instance of the author
but if it was sent as a dm, it will be discord.User
oke thank you!
these stuff can be checked in docs, check the return type of, discord.Message.author
does anyone know how i can revoke a discord webhook from just the url
!d discord.Webhook.from_url
classmethod from_url(url, *, session, bot_token=None)```
Creates a partial [`Webhook`](https://discordpy.readthedocs.io/en/master/api.html#discord.Webhook "discord.Webhook") from a webhook URL.
ah
user = client.get_user(my_id)
why is it returning none?
try fetch if it is still None, id is wrong
no i literally copy pasted my ID
do you mean client.fetch_user(id)?
yes
ty
after fetching i think it will cache it so you can use get_user after that
does anyone know how slice embed
wdym
it doesnt seem to work ๐ฆ
TypeError: can't send non-None value to a just-started coroutine
i think you copied wrong id
This error could be from two things, you didn't await fetch_user or you didn't await send
wait wdym?
user = client.fetch_user(692332103773454356)
await user.send('h')
this is the code btw. My ID seems to be copied as it is.
fetch_user is a coroutine, as I said in my earlier message you need to await it
Just like how you awaited send
oh lol
ohh
wow ty
@client.event or @bot.event
user = client.get_user(381870129706958858)
await user.send('๐')
This is from the FAQ section of https://discordpy.readthedocs.io/en/latest/faq.html#how-do-i-upload-an-image. Is this like a specific exception or something? Cus it doesnt await get_user
Depends on your bot var
whats better? i use client
Bot is better
Should i change the whole script then
@client.event
async def on_ready():
print("Comrade Ain't Dead")
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('Hello'):
await message.channel.send('Hello Comrade')
if message.content.startswith('Hi'):
await message.channel.send('Hi. Did ya nuke USA?')
if message.content.startswith('Comrade'):
await message.channel.send('Shut Up Fool')
if message.content.startswith('hello'):
await message.channel.send('Hello Comrade')
if message.content.startswith('hi'):
await message.channel.send('Hi. Did ya nuke USA?')
if message.content.startswith('comrade'):
await message.channel.send('Fuck You')
if message.content.startswith('LMAO'):
await message.channel.send('You Dont Laugh In Russia')
if 'i solemnly swear that i am upto no good' in message.content.lower():
role = discord.utils.get(message.guild.roles, id=904021392998146118)
await message.author.add_roles(role)
elif 'mischief managed' in message.content.lower():
role = discord.utils.get(message.guild.roles, id=904021392998146118)
await message.author.remove_roles(role)
await client.process_commands(message)โ
what changed do i make
is there something to change all of it instantly
There is so such thing as an awaitable get_user
Just client and delete the message check and you have to use the bot instance
get_user isn't a coroutine, thus you cannot await it
print('sus')
Not at all but alr
And make all of that stuff commands and youll be good
like sus gives Comrade u are ultra sus
lol
oooo thank you
๐
if i dont want it to start with should i remove message.content.startswith and do message.content()
how are y'all so patient with these questions lol no offense
I am just a Rookie dum dum
Idk about andy but i just like helping others
I dont even know ||print cmd||
lol jk i know a lil
Idk never done it
||again i dont use client||
Not really
iirc
@bot.event
async def on_message(message):
if "msg" in message.content:
...
Not indented well btw on mobile
actually i have checked the source code, the Bot class is,
class Bot(discord.Client):
pass```

i am trying to add row to sqlite database and its asking me to enter the index number but how do i know. i just to add the row at the end.
Good jk
nah you can check the link
100% true

async def reactrole(ctx, emoji, role : discord.Role, *, message):
if ctx.author.guild_permissions.manage_roles == True:
if emoji == None:
await ctx.send(embed=discord.Embed(title="Reaction Roles", description="**Syntax** : `gm<reactrole (emoji) (name or role) (message)`", color=discord.Color.blue()))
elif role == None:
await ctx.send(embed=discord.Embed(title="Reaction Roles", description="**Syntax** : `gm<reactrole (emoji) (name or role) (message)`", color=discord.Color.blue()))
else:
emb = discord.Embed(title=f"React for {role.name} Role!", description=message, color=discord.Color.blue())
msg = await ctx.channel.send(embed=emb)
await msg.add_reaction(emoji)
with open('reactrole.json') as json_file:
data = json.load(json_file)
new_react_role = {'role_name': role.name,
'role_id': role.id,
'emoji': emoji,
'message_id': msg.id}
data.append(new_react_role)
with open('reactrole.json', 'w') as f:
json.dump(data, f, indent=4)
else:
await ctx.send(embed=discord.Embed(title="Missing Permissions", description="You dont have permission to use this command!", color=discord.Color.blue()))
!reactrole Please react to โ
to gain full access to the server
This doesnt seem to go with the code?
is that right
i have no idea what your problem is
Hes using his bot var as client thats the problem

Who?
Cause if its me your correct i dont bother
Ok so what am trying to do is putting out an embed message for members that join and they react to the emoji and when that happens they get a role to have access to the rest of server
Short term -A verify command
if anyone want a private bot gimme nitro and I'll make u a one with 24/7 hosting
Get out
Lol
Just no
I even didn't ask u
Idc thats just dumb
pretty sure they're gonna end up hosting on heroku
Make it yourself
heroku?
they said they're gonna make someone a 24/7 bot for nitro
btw is it possible to ping a user from their ID?
Yeah
Soo?
Soo what?
how tho
Do you know if thats right?
Im not a psychic sorry
is something wrong with this one
whats the error
!codeblock
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
also use that
No error do u know how the command works to let the bot send the embed message?
You get the user id and then you mention him
:/
discord.User.mention or <@id>
Sm like that
Dont quite remember
@sullen shoal any commands ideas
!d discord.Embed
class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, 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.
Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
make this command
Done it
i've done it too
Nice
but the caching suck
The what?
i wanted to cache the results every 3 hours but couldn't
Oh
Never done it before so idk
i want my bot to do something like, if i write a command, then the bot responds, and then i upload a file and it responds
i always try to make a good structure than somehow making it work, but i couldn't and ended up with some crap caching and made it somehow work
Dang
help here pls
like for eg
me: a!image
bot: send a file and i will respond
me: sends a file with no command involved
bot: okay
how to do like this
!d discord.ext.commands.Bot.wait_for
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
now i have stopped wasting time on discord bots
Why?
wut
cuz ik i can make one so i gotta waste my time on something idk to do
like leet code challenges
its not time waste
Yeah same
I wanna try something different but idk what exactly
i dont wanna be called just a discord bot developer lol
nothing wrong in that
I wanna be a backend software engineer so me either lmao
Wbu?
not sure yet
I see
gotta think about it after im 18
Yeah
leet code challenges are frustrating asf tho
you should try thats what they will ask you in interviews
I see how do i?
one sec
Alr
Alr
Guyz I need help
you wont get private support here, ask your question if someone knows they will help
yes
And please don't ask to ask or say i need help just state the problem
Hi There,any one Know how to snd Message like this?
No need to bully people
There is no need to do that?
ik Emilie since 2 months she is meant to be bullied
Especially when you yourself don't know the basic python syntax
in disnake to send ephemeral messages, you have to do,
inter.response.send_message(content=..., ephemeral=True)```
Bruh
Not funny btw*
Even if its your friends its not neccessary
then just do it in dms ๐
This channel is about discord bots


