#discord-bots
1 messages ยท Page 683 of 1
@slate swan :white_check_mark: Your eval job has completed with return code 0.
works
why not?
how do i fix it
you dont have name as a key in the dictionary
hmm, cz I had to do await (await bot.fetch_channel(...)).send once on something similar
no name key in your dict
they used get_channel tho
@slate swan
ah i c
what
Nvm ignore me
would this work
exec("@bot.event\nasync def on_ready():\n await bot.get_channel(int).send('msg')")
?
๐ this no doubt work
noooo
you were right lol
shopp = [
{"name":"something","price":3000},{"name": "some other thing", "price":2000}]``` @upbeat otter @slate swan
interesting
fetch isnt async so you would need 2 awaits
it would be shop[0]['name'] or smthing...
so hunter you are correct
index the list first
ยฏ_(ใ)_/ยฏ
they're using a for loop
anyways, imma keep quite
i will now learn a bit more about sqls syntax later
Did I just... scrape google's homepage ๐
๐
yea , but the if py if itemm.lower() in shopp[i]: item = shopp[i]
item = shopp[i]```
```py
name = item["name"]``` isnt it the same?
idk did you?
wow
oh yeah
it is , but your if statement is not satisfied
yea my console is filled with some garbage HTML now
hahaha
how should i put it?
HTML not garbage
markup go brrrr
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
you dont put it , you just provided a wrong item while using the command...
I always install pip install -U git+https://github.com/Rapptz/discord.py to use buttons but
When i restart my bot i always get the error module discord has no attribute ui
@slate swan command idea
? sorry i dont understand
wtf
nice
is they some kind of next level "minification" lol
it is a popular bot on discord with which I have had some.... horrible experiences in the past
soo uhhhh will be better not to make something like that
that's nice
you probably got divorced
she took the kids..............
wait.....lol huh
(laughs in single)
I am with you
ill make it better trust
this is getting derailing pretty fast
Off-topic channels
There are three off-topic channels:
โข #ot2-never-nesterโs-nightmare
โข #ot1-perplexing-regexing
โข #ot0-psvmโs-eternal-disapproval
Their names change randomly every 24 hours, but you can always find them under the OFF-TOPIC/GENERAL category in the channel list.
Please read our off-topic etiquette before participating in conversations.
I trust you (:
you started the convo
I didnt
guys this is my second discord bot my first was horrible and did not function, so technically this is my first actual discord bot -https://github.com/HRLO77/Bot-source-code
I gave you multiple command ideas at once
jk im going to make a good relationship advice bot for you
self advertising
ill check it out
Nah I suck at those soo uhhhh we don't talk about it
ill be honest tho
careful i had around 3-6 sets full of swear words for the bot to detect
thats what im making him so i can help you
I'll make one to take care of weirdos ||like all of us||
Okay okay let's get back on topic
Better would be to delete this message, thanks (:
just get an api that has quotes on relationships and fetch random quotes
before a mod sees it
programmer humor
๐ถ
Nah I am cool, thanks ๐
Tried those, still sucked so uhhh
im not going to give relationships advice because the last time i did they broke up
@quaint epoch what is this
client = discord.ext.commands.Bot(command_prefix='>>>', intents=intents)
wut?
๐งโโ๏ธ
LMAO
Youtube?
yup
In this video, we go over how to setup a discord bot in python using discord.py v1.0.1 (rewrite).
If you have any suggestions for future videos, leave it in the comments below.
GITHUB: https://github.com/Rapptz/discord.py
DOCUMENTATION: https://discordpy.readthedocs.io/en/latest/
OFFICIAL DISCORD.PY SERVER: https://discord.gg/r3sSKJJ
JOIN MY ...
uhhh this is outdated
@quaint epoch wtf are those imports?
import random
import ctx
import disnake as discord
import Functions
import datetime
import subprocess
from datetime import datetime
import requests
import sys
import profanity
from profanity import profanity
import tracemalloc
import ctypes
from disnake.ext import commands
from datetime import datetime
And B A D
ctx?
i dont see anything wrong with it , except for client variable name , and intents (if undefined) tho
@prisma wolf ๐
a bunch of imports i did not use and too lazy to delete
wait only thus much?
show off
its not lucas code for sure
oh my alt id still here nice
bruh im too lazy to delete them
also that tutorial is bad and outdated
Ah I thought that was another Myxi
cap๐ญ
nah srsly
import dpy
import pip
import asyncio
import general
import levelling
import imagecmds
import configfile
import mod
import server
import discord
from discord.ext import commands
import json
from googlesearch import search
from discord.ext import tasks
import os
from discord_components import Button, DiscordComponents, ButtonStyle
import random
import requests
import discordSuperUtils
from discord.utils import get
i was playing around with pastebin api and stuff and didn't delete the imports afterword
my imports
๐งโโ๏ธ
import requests . why ๐
My imports: import fetch from "node-fetch" ๐
you should sort them, its horrible
at least you use half of those
no need
i never use them, ever
mine
# all imports
import datetime
import disnake
import buttons
from disnake.ext import commands
from disnake import Intents
from disnake.ext.commands.cooldowns import BucketType
from googlesearch import search
import random
import filter
all
who?
from disnake.ext.commands import Bot , when_mentioned_or
from disnake import (
Message ,
Intents ,
AllowedMentions
)
from aiosqlite import connect
from os import getenv
```meh
each one of them is used
this lol
๐ถ
i used datetime and the functions module here idk why they don't show up
and I never said I am a guy
dude
import disnake as discord
๐ถ
oof, no
im too lazy
why would I import cogs
i literally cannot go through all that effort again
just find replace
no
umm.....fine, I'm fine with both
i thought they were cogs lol
lol
i import cogs lmfao
I am not going to say what they are to save myself from further humiliation
cause my bots never find the cogs path
shit my teacher was talking about Algae-BRUH and i wasn't paying attention
so i import them
๐ญ
๐ซ atleast you never tried this py import aiohttp as request res=request.get(....
how
what does that do?
never used req
import discord as disnake```
illusion 1000
:bleh:
looool
programmer humor
hahahahaha lmao funneh import go brrr
just do
from os import *
if you make that work then hats off to you
search replace exists
it didnt ofcourse
it literally does the same thing
but faster...?
search and replace = py import disnake as discord
and with less effort
oh I didn't read u did this
im having a seizure trying to read your message
try try
uh brainfart moment
read u said*
wut?
what is even happening here
0 iq stuff
https://reddit.com/r/woooosh for either of us i literally do not understand anything
lmfao
!ot exists for all these talks
Off-topic channels
There are three off-topic channels:
โข #ot2-never-nesterโs-nightmare
โข #ot1-perplexing-regexing
โข #ot0-psvmโs-eternal-disapproval
Their names change randomly every 24 hours, but you can always find them under the OFF-TOPIC/GENERAL category in the channel list.
Please read our off-topic etiquette before participating in conversations.
ah man
await self.db.execute("Update thxcounter set thanks = thanks + 1 where user_id = ? and guild_id = ?", (member.id, ctx.guild.id))
await self.db.commit()
All good but the thanks set to 0
k back to topic
pretty serious
I KEEP GETTING CONFUSED WITH SQL
we were trying to figure out what was going on though...
asc decs is confusing ๐ถ
Then u can ignore the message (:
alr kekw
yeah uh huh i agree with the cyan person
ahem ahem these talks have been happening here since a few min already
cyan person
i know you? your the cyan person
yes now THIS is ot
closer to turquoise but yes
!ot
Off-topic channels
There are three off-topic channels:
โข #ot2-never-nesterโs-nightmare
โข #ot1-perplexing-regexing
โข #ot0-psvmโs-eternal-disapproval
Their names change randomly every 24 hours, but you can always find them under the OFF-TOPIC/GENERAL category in the channel list.
Please read our off-topic etiquette before participating in conversations.
I am not participating
and I have a question
shoot
if your talks are over
they're not but shoot anyway
go already
go on
Any help?
How do I reconnect my bot like disconnect it and connect it again
it should do it itself
oof
I want to hard restart it ,-,
if
with a flask server ig
You didn't mess up the black magic internals
idrk
yeah better idea
why u wanna hard reset it yourself tho
what does client.connect() do?
why not
why yes
makes a connection with the gateway as the name suggests
If I were to hard reset my bot myself, I would waste more than 2 hours per day ;-;
yes
why lol
i just settled on sys.exit() to close the bot, then maybe execute another file that waits a few second before sys.exit(), then run the bot file
it disconnects too much lol
damn
async def restart_bot(ctx):
exec('restart.py')
sys.exit()
not a bad idea
then in restart.py: import asyncio async def restart(): await asyncio.sleep(10) exec('bot.py') print('restarted bot.py') sys.exit()
why do you need to sleep
just to be safe and run the bot file after a few seconds
are you making a restart command or something?
yes
i suggested it for @upbeat otter , idk if it works
yeah?
this
restart idea
import os
async def restart(ctx):
await bot.close()
os.system('python main.py')
``` easy
=uptime
Ghost ping
thank youuu
im not sure if it'll work though
brb
uh the close thing works but the bot doesnt go back online ๐ค
The bot closed but the script didn't
because it closes before it opens it
i just tried the method i made, but it gives me this error-Traceback (most recent call last): File "C:\Users\shake\AppData\Local\Programs\Python\restart.py", line 11, in <module> exec(open('bot.py').read()) File "<string>", line 3, in <module> File "C:\Users\shake\AppData\Local\Programs\Python\Python310\Lib\site-packages\disnake\__init__.py", line 23, in <module> from .client import * File "C:\Users\shake\AppData\Local\Programs\Python\Python310\Lib\site-packages\disnake\client.py", line 25, in <module> from __future__ import annotations File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1002, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 945, in _find_spec File "<frozen importlib._bootstrap_external>", line 1430, in find_spec File "<frozen importlib._bootstrap_external>", line 1402, in _get_spec File "<frozen importlib._bootstrap_external>", line 1535, in find_spec File "<frozen importlib._bootstrap_external>", line 147, in _path_stat KeyboardInterrupt
i didn't do ctrl+c or anything
it decided to give me an error
why does isinstance(member,discord.ClientUser) return False even if the member given is a ClientUser?
you sure it is client user?
why is that member then? isn't it a member object?
I'm using this code on replit
from threading import Thread
app = Flask('')
@app.route('/')
def index():
return render_template("filli.html")
return render_template("index.html")
def run():
app.run(host='0.0.0.0',port=8080)
def keep_alive():
t = Thread(target=run)
t.start()
I want it to be able to allow the user to view a couple different html files, but I can only get it to show one. Is there any way for that or no?
await ctx.send("Provide me with a title!", ephemeral=True)
why the heck does ephemeral gets rendered invalid ,-,
wow question kamikaze
Not related to discord bots
that's what i thought
Only for buttons and slash commands and stuff
Ephemerals can only be sent with interactions afaik
well yeah, after the check there's some code that requires the member to NOT be a ClientUser, and my code throws an error saying ClientUser object has no attribute "create_dm", even though the object has passed the check
huhhhh
Okay it is part of my discord bot so i figured I'd write it here sorry
So only buttons and slash commands
fine....
When a interaction is done
alright
Yep
It does not make it related to this channel, sorry
well I'm running multiple bots in a single script, so apparently its a ClientUser
lol how....
it might belong in #web-development
put multiple bot objects in the event loop, easy
is it possible to learn this power?
smh not a good idea
bot.run()
bot2.run() ?
WONT WORK
Hmm
it will only trigger the first run
NO
absolutely
loop = asyncio.get_event_loop()
for member,token in zip(self.team,tokens):
loop.create_task(member.bot.start(token))
loop.run_forever()
loop.run_forever()?
member is bot object
thats not a good idea
welp i have Algae-BRUH and imma carry my classmates
no, not necessarily, just because I named the variable "member" doesn't mean it has to be a member object
why
it's confusing
you didn't show us how you got the user object so we would assume 'member' is a member object
single script for multiple bots has more downsides than ............smh nvm
not necessarily
that's why I specified it after I sent the code
well i assumed it was a member before that
downsides? such as?
lol, why you guys fighting?
when have you thought that an object, member, is a user object?
error in a single bot could result in the termination of the whole code
idk
all the bots use the same code for the most part so that isn't an issue
peace
make a single bot
not to mention if someone decided to spam invalid values for a command that you didn't set try/except blocks for, then that command would be rendered useless
I need multiple lol. That's what my whole application, that I'm building, is based on.
of course
the code isn't supposed to be for public bots so that again isn't an issue
the useless effort perfectly defined in:
did you post it anywhere, like github or smth
you don't know the context my dude
ye
I know Eevee's answer to this
everybody be dudeing me lmao
well then they can just create an instance of the bot
kind of yes
brute force, just keep spamming different commands 'til you find a command that isn't defensively programmed
Bruh
I didn't post the token. If they'll be harming anyone, it's gonna be their own bot so it doesn't really matter
tl;dr, running multiple bots at once isn't really good, but you could ahead and do that
Keep spamming till the bot gets ratelimited?
It's the perfect choice for what I'm doing
huhh, okay, sorry, your choice, we wont argue
well, they have the code, and assuming you commit to the repo regularly, if there is a bug then they can exploit in your (bot)
Okay so what is even happening here? @slate swan what do u need help with?
the application is dynamically programmed, there's no identification or anything that can be found in my code to exploit anything that I own
lol
k
even so, they have the same code you have, so if they find a bug, and you have the same bug they could exploit in your bot before you find it
nothing I just can't figure out why isinstance(member,discord.ClientUser) returns False even if the member in question is a ClientUser
welp, send code
then why u both talking about brute forcing and stuff ๐คจ
nvm
if member.bot:
continue
if isinstance(member,discord.ClientUser):
continue
I know why
lol
why
can you send where you got the member object?
continue kills the current iteration and starts the next iteration
yes that's what is does, pass does the opposite it does literally nothing
well yeah, so it wouldn't execute the following code in the current iteration right?
Is it possible to have 2 rows and 2 columns with 4 fields?
!e
for num in range(0, 5):
if num == 3:
continue
print(num)
@maiden fable :white_check_mark: Your eval job has completed with return code 0.
001 | 0
002 | 1
003 | 2
004 | 4
it wouldn't
See
use the inline kwarg in add_field
I'm using that.
!d discord.Embed.add_field
add_field(*, name, value, inline=True)```
Adds a field to the embed object.
This function returns the class instance to allow for fluent-style chaining.
embedA = Embed(color=discord.Color.purple(),title=f"{ctx.author} - Payment Details")
embedA.set_thumbnail(url=ctx.author.avatar_url)
embedA.add_field(name="RSN",value="ok",inline=True)
embedA.add_field(name="F2P World",value="ok",inline=True)
embedA.add_field(name="Location",value="ok",inline=False)
embedA.add_field(name="Combat Level",value="ok",inline=True)
embedA.set_footer(text="We don't cover any transaction fees")
await ctx.channel.send(embed=embedA)```
I want the last 2 embed field in the same "inline"
Seems like a discord issue tbh. it happens when fields don't fit together in a single line
in the OAuth2 Tab
uu
Not their just general
In App Modal or smth idr
sadly my bot is not public but nice feature
Yea
awww, i guess it can't read me a bedtime story
does your bot have that?
yea
lucky
Just noticed that
?
lol
you said your bot can read you a bedtime story
huh
uuhhhh when
light mode on github?!
idk how to do dark
btw it's browser even tho i have the desktop im just really lazy
source lines of code @quaint epoch
settings -> appearance
wuts dat
total lines including comments and todo's and stuff
ah
my bot wont reply to my commands anyone help?
Do you have an on_message?
This is Python
await client.process_commands(message)
put this ?
Not JavaScript
its java rip
thats not even python lol
No itโs JavaScript
idk java
Itโs not Java
javas
Probably missing the await
bro im lazy to type script ;-;
Anyone with ideas on what i have done wrong?
Typescript?
it must be an int
Typescript is also JavaScript
the id*
Just strongly typed
that is the role id tho
get_role(role_id, /)```
Returns a role with the given ID.
It has to be an int
!ydtl
We donโt help with ytdl, it violates TOS
my bad
ok
how do I fix redgifs not loading
await ctx.reply
await ctx.send
how do I count total members of all guilds combined
TypeError: list indices must be integers or slices, not str
show code
Is the Cog loaded
Morning yall
bot.guilds helps you get started with that.
Could you provide more information?
Have your debugged the command? Put in a print to see if it gets executed?
would for guild.members in client.guilds work?
Yeah i'd make something like this
members_total = sum([len([member for member in guild.members if not member.bot]) for guild in client.guilds])
Means it isn't used.
You are not allowed to ask this here please remove your message.
Nope you actually need ctx for the syntax
No where we don't allow anyone here to ask for paid work of any kind.
So, if you could delete it :3
output is 0
That's what we recommend.
You got intents on?
How to access roles of a user in on_raw_reaction_add event?
payload.member.roles
Thanks
Be careful though this is only valid if the user does this in a guild.
DM for example will crash it.
What will crash?
The event.
i see
Disallow the cmd in DM or add a check for it.
pandabweer โค๏ธ

@slate swanhello, as other users stated, asking of offering paid work is against our #rules
mina being a moderator
No mina is a human being.
This man invented a new kind of spoiler
space
inside the spoiler there's a lot of spaces
!raw 920763077392236554
== Raw message ==
inside the spoiler there's a lot of spaces
whats raw
so for example
!raw 568276116062863405
You are not allowed to use that command here. Please use the #bot-commands channel instead.
!raw 920763316362698794
== Raw embeds (1/1) ==
description: [link](https://www.google.com/)
type: rich
ta-da
wow
why does it take forever tho
amazing
that idk. we've had some hiccups with bot this morning but idk if this is related.
mm
Discord really gotta add this syntax to chats but the again, ppl will def abuse it.
they gotta put that untrusted domain prompt
link ๐
wait, do they?
like the <a title="hover text">?
i think discord.py already has parser for that tho
Yee, that's the format for it.
Small detail, but quite powerfull.
mwahahaha
whats that shit
do you really need a """Sends a wonderful welcome message"""
you could just do # sends a wonderful welcome message
what even is listeners
I was gonna ask the same thing
They will invade your privacy.
cool
if its a third party extension, its in the right place
All works... but it doesnt show the number, any idea?
code
K wait
ยฏ\_(ใ)_/ยฏ
Imagine someone else using this code and uses docstrings to see what func this is and the onliest info they get is Sends a wonderful welcome message
wow
thanks = await self.db.execute("SELECT thanks from thxcounter where user_id = ?",(member.id,))
counter = await thanks.fetchall()
This is all we need though.
tbf I wouldn't even have added any comments apart from listeners.Cog.listener() but ig thats uneeded
shit ok
Give us the output of counter and you got a solution.
wtf does db.execute do
Print that?
I was gonna say thanks before realizing it's already there
yes ๐ฆ
Most likely a bot var, using postgre or a really nice sqlite wrapper.
Output: []
List i guess
What db are you using? All db's return a tuple..?
wdym what db?
Yeah what db are you using?
mongodb?
No
then which
Nah that isn't sql syntax based.
sqlite i guess
it's the only one I know
I guess..?
Oh okay i guess
Lmao
lmao I guess
Is the user inside the database?
yea
maybe showing the full database
My id and thanks
yes
Yes i have
Execute this inside the SQL query ```sql
SELECT * from thxcounter where user_id = 904579763836944404
But i dont want just my id
D:
Well i know but we need to get some data first.
getting your ID gets your thanks afaik
also
I was gonna code a similar thing
but no db
๐
JSON's my db
Same, Output []
I won't help you lol
What about ```py
SELECT * from thxcounter
What datatype is user_id?
INTEGER
If he had it set as str inside the db it wouldn't return anything.
bye~
You are always welcome back here.
how sweet and touching
touching ||
||
Oh okay
dont be dirty minded
Can't help it
have a beer then

why does it show that int object is not subscriptable on this?
if cardcoins[0]['balance'] >= amount*100000:
anyone?
nvm fixed it
Ngl sql is very simple and good
Can anyone help me code a bot ? Plesse dm me
I mean you can ask here
Not really hard
please don't solicit users to write bots for you
All you got to learn is asynchronous programming oop and basic python which we can deliver for you
this server is for learning/teaching, not offering or asking for jobs
Donโt really see a issue
The issue is that this isnt a marketplace but a place you learn
!rule 9 it's one of our rules and we will enforce it
Who said itโs paid lol
Still not right
ah yeah i'm referencing the other user in pygen that offered to do it for pay
Okay sorry
np!
If you have any questions about discord bots feel free to ask them here
Is there a way to pull the source image from an emoji?
not really
you cant pull the 'source image' per se
you can however get the url
which you can save as an image
!d discord.Emoji.url
Sorry, an unexpected error occurred. Please let us know!
RedisSessionClosed: attempting to access connections pool after it has been closed.
Sorry, an unexpected error occurred. Please let us know!
RedisSessionClosed: attempting to access connections pool after it has been closed.
Seems like something broke
really? o.O

oh
embed=discord.Embed(title="Shop", url="https://google.com", description="TEST", color=discord.Color.blue()())
TypeError: 'Colour' object is not callable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'Colour' object is not callable```
eh, that woks
dont use unicode in your name please
show code
!d tuple
Sorry, an unexpected error occurred. Please let us know!
RedisSessionClosed: attempting to access connections pool after it has been closed.
lmao
discord.Color.blue()()
!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.
Do they have a support server?
If they don't ask in #python-discussion
Ah shit a special weather advisory in my area
discord.py, why
if TYPE_CHECKING:
from enum import Enum
else:
class Enum(metaclass=EnumMeta):
@classmethod
def try_value(cls, value):
try:
return cls._enum_value_map_[value]
except (KeyError, TypeError):
return value
WHY are you defining your own enum class
Afaik you can't get images only unless the url ends with video file
ah
Yep
how do i find out if its a video or not?
You check the submission url
sync def picture(ctx):
embed = discord.Embed(description="Picture") # ,color=Hex code
embed.add_image(url="https://imgur.com/a/6JdtJVd")
return await ctx.send(embed=embed)
Sorry but why doesn't this work? I get an error, I just want a picture shown in an embed
!d discord.Embed.set_image || set_image not add_image
set_image(*, url)```
Sets the image for the embed content.
This function returns the class instance to allow for fluent-style chaining.
Changed in version 1.4: Passing [`Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty") removes the image.
gotcha, thanks
almost needed an error there :o
Does it load not in the preview?
Sorry I don't understand what you mean๐ this is the preview I think and it only loads
like it doesnt depict the picture
If I click on it and open the link it shows the picture but I wanted it to show it on the preview
Try restarting your discord client
Nope, it won't work
sync def picture(ctx):
embed = discord.Embed(description="Picture") # ,color=Hex code
embed.set_image(url="https://imgur.com/a/6JdtJVc")
return await ctx.send(embed=embed)
I used a link which doesn't work lol so you wont see the picture
you need to find a different image
you can test it - if you send it here and it converts to image it should work fine
i think that would work
It works here but if I use it in my discord it will be in an infinite lopo

@bot.command()
async def picture(ctx):
embed = discord.Embed(title="New Moderator")
embed.set_image(url="https://imgur.com/a/zV2FjsZ")
return await ctx.send(embed=embed)
idk
weird
why does it show that int object is not subscriptable on this?
if cardcoins[0]['balance'] >= amount*100000:
I don't get it, this works for me:
sync def picture(ctx):
embed = discord.Embed(title="Neuer Post!",
description=str(medias[0].caption_text)).set_image(url=medias[0].thumbnail_url)
await channel.send("@everyone\n", embed=embed)
but the other piece of code doesn't work
i have a question can dpy make bot advanced economy system like:
when the player use !transfer (the user)(the amount) the bot checks if he has the amount if he has enough the bot go to a roblox group (my roblox group) then transfer (the amount) to (the user) automatically and take a picture and put it in claim channel?
Hi is there any module thats for import error?
async def reload(ctx, *, msg ):
if ctx.message.author.id == 506940530333057025:
await ctx.message.delete()
try:
if os.path.exists("custom_cogs/{}py".format(msg)):
client.reload_extention("custom_cogs.{}".format(msg))
elif os.path.exists("cogs/{}py".format(msg)):
client.reload_extention("cogs.{}".format(msg))
else:
raise importError("No module named '{}'".format(msg))
except Exception as e:
await ctx.send('Failed to reload module: `{}.py`'.format(msg))
await ctx.send('{}: {}'.format(type(e).__name__, e))
else:
await ctx.send('Dev only')
Hello
Service depends on how well you ask a question, right now you're not doing a good job of it
Your issue is that you used discord.Client() rather than discord.ext.commands.Bot()
discord.Client() does not work with commands
That's discord.ext.commands.Bot()'s job
anyone know bots with drop down menus
Yes
Select menus are a special type of component similar to buttons
They're part of the bot UI kit
discord.py 2.0 supports them
well ik I have the github example rn
but im trying to figure out how if I can edit the original message that has the dropdown menu on it
If it's the one on the official github, then that's authored by me :P
interaction.edit_original_message()
disnakes?
It was my first and last contribution to the library before it shut down 
"inter has not been responded to"
oh yeah you gotta defer it first
:p
in the command, or in the class
async def reload(ctx, *, msg ):
if ctx.message.author.id == 506940530333057025:
await ctx.message.delete()
try:
if os.path.exists("custom_cogs/{}py".format(msg)):
client.reload_extention("custom_cogs.{}".format(msg))
elif os.path.exists("cogs/{}py".format(msg)):
client.reload_extention("cogs.{}".format(msg))
else:
raise importError("No module named '{}'".format(msg))
except Exception as e:
await ctx.send('Failed to reload module: `{}.py`'.format(msg))
await ctx.send('{}: {}'.format(type(e).__name__, e))
else:
await ctx.send('Dev only')```
what are u trying to do
What's the problem
ok but what are u expecting as a response
whats ur client
copy paste the code its easier to read
client = commands.Bot(command_prefix="b!")
and import commands
make sure u also have from disnake.ext import commands
from discord.ext import commands
use f-strings, also syntax highlight
it improves readability tenfold
Can we see the full code?
this?
Preferably with syntax highlighting and proper codeblocks
Like i said syntax highlighting and code blocks
Code here...
async def reload(ctx, *, msg ):
if ctx.message.author.id == 506940530333057025:
await ctx.message.delete()
try:
if os.path.exists("custom_cogs/{}py".format(msg)):
client.reload_extention("custom_cogs.{}".format(msg))
elif os.path.exists("cogs/{}py".format(msg)):
client.reload_extention("cogs.{}".format(msg))
else:
raise importError("No module named '{}'".format(msg))
except Exception as e:
await ctx.send("Failed to reload module: `{}.py`".format(msg))
await ctx.send("{}: {}'".format(type(e).__name__, e))
else:
await ctx.send(f"Dev only")```
import os
import discord
from discord.ext import commands
import csv
import random
client = commands.Bot(command_prefix="b!")
@client.event
async def on_ready():
print(f"{client.user} logged in now!")
@client.command()
async def prefix(ctx):
await ctx.send("the prefix for me is b!")
my_secret = os.environ['TOKEN']
client.run(my_secret)
Done it for you
name the variable bot instead of client
code LGTM, maybe the token isn't working properly
also pass in intents
then it's probably intents
So?
Then include intents
What error do you get?
Also consider using f-strings
never i got in available channel someone there helped me out
Gotcha
@client.command()
async def reload(ctx, *, msg ):
if ctx.message.author.id == client.owner.id:
await ctx.message.delete()
try:
if os.path.exists(f"custom_cogs/{msg}py"):
client.reload_extention(f"custom_cogs.{msg}")
elif os.path.exists(f"cogs/{msg}py"):
client.reload_extention(f"cogs.{msg}")
else:
raise importError(f"No module named '{msg}'")
except Exception as e:
await ctx.send(f"Failed to reload module: `{msg}.py`")
await ctx.send(f"{type(e).__name__}: {e}'")
else:
await ctx.send(f"Dev only")
f strings easier to read
Also less prone to you making mistakes
async def callback(self, inter: disnake.MessageInteraction):
await inter.defer()
await inter.edit_original_message(content="test")
nvm thats wrong
docs confuse me idk why
it wont let me reload my bot.py file
i have a question can dpy make bot advanced economy system like:
when the player use !transfer (the user)(the amount) the bot checks if he has the amount if he has enough the bot go to a roblox group (my roblox group) then transfer (the amount) to (the user) automatically and take a picture and put it in claim channel?
async def callback(self, inter: disnake.MessageInteraction):
await inter.response.defer()
await inter.edit_original_message(content="test")
but on the discord side, yes you can
If Roblox has an API like that
woohoo, now I gotta screw shit up
how can i interact with roblox api
it is bc someone has already made this bot but he doesnt answear me when i ask him
does the module have a setup() function?
WHat setup()function?
something like
def setup(bot: CustomBot):
bot.add_cog(TasksCog(bot))
Does anyone have codes for a standard bot with cogs, without any commands? Iโm on a phone rn, takes too long time to write it.
right
define ur bot smh
typecasting it?
causes circular import so i wouldn't
main file imports cog file when you load it, cog file imports main file to typehint to bot class, circular imports = bad
maybe in discord.py, disnake is built around it so
you don't need it
u leaked ur token?
circular import is a python problem, not with the libraries
U saw nothing
regen it
So?
already will do
.
writing code on mobile?
yikes
Yes ik, works for test bots
yikes run away from replit as fast as possible
lol
Hard to run away from repl when you are in bed with a phone, and not your computer ๐คจ
that's why buy a computer
I have a computer, but I use my phone
then use it :l
Because im in bed
Repl is easy quick and go service too, so really nice for night coding lol
u coding in bed?
frig replit, just away for 20 minutes and got disconnected
Ofc, coding on my phone while dreaming about coding, while getting good sleep
so.....
coding in dream
Which coin?
lol, from last night, wait imma screenshot it
Okay
there, result and code
Hey i need help with this
what?
Iโm not so known in this area, so I do not know.
what is taskCog
also why CustomBot not used there
the person did the video didnt say
send link but actually most of the coding tutorial vid always (most ok, not all) giev the source code link in the desc
My discord server โบ https://discord.gg/BN6WaDs
(If you have any questions or just want to have a chat with us)
(Some Cool Stuff)
Nertivia โบ https://nertivia.supertiger.tk/
My server in Nertivia โบ https://nertivia.supertiger.tk/invites/B4tMwO
Install discord.py โบ pip install discord.py or py -3 pip install discord.py
Discord.py documentation โบ...
?
what is misc E
I dont know i am just trying to do a reload cmd so what i dont have to close vs code and restart it again
it could just get passed through a cmd
You can remove custombot @jade tartan
And i doubt you have cogs in your main, so you do not need to add it to cogs, due to the main file being the source of cogs
And TasksCog as well?
Ohh so you make a cog like this hold upo
In this video, we learn about cogs and how to implement them in a discord bot.
If you have any suggestions for future videos, leave it in the comments below.
GITHUB: https://github.com/Rapptz/discord.py
DOCUMENTATION: https://discordpy.readthedocs.io/en/latest/
OFFICIAL DISCORD.PY SERVER: https://discord.gg/r3sSKJJ
JOIN MY HELP SERVER: https:...
Like this?
Nope lol
where the TaskCog E
Then you do not need to add it to a cog that does not exist
You dont need to do that, because your command is in your main, where your cog should be located, so it is already a part of your cog
Ill try to look up in docs
sleep..
is it possible to make a bot change a server name using discord.py?
Iโm pretty sure the code you made is used to get options from a list that is not there, but I canโt figure out how to solve this from only seeing this part of the code.
Canโt say if iโm right or not.
waht
If your bot has sufficient permissions you can call Guild.edit and pass a name kwarg which would be the new name to change it to
!d discord.Guild.edit
await edit(*, reason=..., name=..., description=..., icon=..., banner=..., splash=..., discovery_splash=..., community=..., region=..., afk_channel=..., owner=..., ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the guild.
You must have the [`manage_guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_guild "discord.Permissions.manage_guild") permission to edit the guild.
Changed in version 1.4: The rules\_channel and public\_updates\_channel keyword-only parameters were added.
Changed in version 2.0: The discovery\_splash and community keyword-only parameters were added.
Changed in version 2.0: The newly updated guild is returned.
Okay so what I mean is that cur.fetchall() is suppost to get information from a list, but you donโt have a list that the command can take from, then it will not show anything in the results.
That is what I think is happening with the code. I have no clue if Iโm right or not, so Iโm not the right one to help you.
so all i would put is Guild.edit("Epic gaming server") or something?
Nope, the edit method of Guild takes keyword-arguments only
You'd do name=...
And make sure to await it as it is a coroutine
No, you do not say what you want to edit, you need to specify it
alright thanks
bru- i have that list in DB
Mhm, then I do not know
With fetchall you are going to get every row in your db, but I assume you want to do only one of them, which is the person you want to know the coins of.
You might know that already, but just making sure.
yes
Where is the code sending the results to the chat?
wait
or i must use string
If you see here, you can see how this person did it.
Wait nvm
That one can make errors I see
so now that i have my code i cant get into the discord dev portal anymore like every time i login it takes me to browser discord anyone know how to fix?
After you logged in try entering discord.com/developers
If you logged in before it shouldn't even prompt you to authorise
so basically fetchall just for test exist or no????
tried that does the same thing again
ah now it worked thanks
Can you show the code for database.check_coin?
Fetchall gets the results from db, if there is something there, you can use it in your code, if not you got to handle the case
And the issue is that it's returning [] right?
And are they sure they store NAME as USER#DISCRIM?
Because casting a User to str returns in that format, not just USERNAME
So the whole code basically just wipes it self each time?
I don't see the part where they wipe it each time
Although there is an un-needed commit in the code
As you are only doing a query to find stuff, not inserting stuff
uh, it's there?
eh what
what what
I'm asking for the code of check_coin
You sent the code of a command profile
Like I said earlier, the query you do is only to find data, not to modify nor insert any data. Thus you have an un-needed commit
so now the bot does everything but changes the name i put name= then a name it runs properly except for that
Can you show your code?
And perhaps a traceback provided if there is one
This is prob where the last half part of this code is what he needs to do, or somethibg that is near to that.
1 sec
This is their code?
But actually get the data for the db.
No, one i found on the internet

How are you storing the NAME of the user? E.g what format is it inserted as
NAME#DISCRIM? NAME?
Can you try to do SELECT * FROM USERS_DATA and see if the name corresponding to the user is actually there?
Perhaps you didn't insert correctly, or inserted the wrong data
(ctx.author is name#discrim right)
No, ctx.author is a User instance or a Member instance
But you cast ctx.author to str
:) what
Which returns NAME#DISCRIM
oh, so like
name = str(ctx.author)
database.check_coin(name)
No, you are already doing that in your code
If you don't believe me, print user inside of check_coin
but when i add username, i not using str xd
So when you are adding a new user to USERS_DATA you save the name not as a string??
maybe that's my fault
Can you show the code where you are actually inserting data into USERS_DATA
So that I can see what query you did
No this is just useless code, it's un-needed as I said earlier you ALREADY do this
:l ok
also consider an async sqlite wrapper like https://github.com/Rapptz/asqlite
Here you are inserting into a column users_data, but in the code where you actually query back the data you select from USERS_DATA
iirc, and I'm not a huge expert, but column names are case-sensitive unlike many other things in the SQL Lang
hi
hi
ow ok, case sensitive, noted
Try selecting from users_data instead of USERS_DATA
Or otherwise, change the insert to insert into USERS_DATA, rather than the lowercased
k, thanks
Don't store their name/tag, store their ID, usually as a (big)int
IDs don't get changed, usernames/discriminators can

wait, why still empty
uh ctx.author.id?
TIL
In general CBA to know all the inconsistencies, at least with case-sensitivity in SQL


