#discord-bots
1 messages · Page 70 of 1
@commands.command()
async def poll(ctx,*,message):
em = discord.Embed(title="Server Poll", description="{message}")
msg = await ctx.channel.send(emebd=em)
await msg.add.reaction('👍')
await msg.add.reaction('👎')``` Anyone know why my poll cmd wont work
If this command is part of a cog, you need to add self as the first parameter, since it's part of a class
If that method is also part of the class, it also needs self as it's first parameter
any functions that are part of a class need the self parameter as their first parameter, unless if is a staticmethod or classmethod
@commands.command()
async def poll(self, ctx,*,message):
em = discord.Embed(title="Server Poll", description="{message}")
msg = await ctx.channel.send(emebd=em)
await msg.add.reaction('👍')
await msg.add.reaction('👎')```
Add self to on_command_error
Hmm, no, it actually looks like on_command_error is being called with less arguments than it should be, which is weird
async def on_command_error(self, ctx, error):
if isinstance(error, commands.MissingPermissions):
em = discord.Embed(color=discord.Color.orange(), description=f"{ctx.author.mention}: You're **missing** permission: `{error.missing_permissions}`")
await ctx.send(embed=em)
else:
raise error```
I have self
Oh wait yeah didn’t realize that
are you in a cog? if not, use bot.slash_command
class MusicCog(commands.Cog, name='Music'):
'''play, pause, resume, stop, disconnect'''
def __init__(self, bot):
self.bot = bot
bot.loop.create_task(self.node_connect())
async def node_connect(self):
await self.bot.wait_until_ready()
await wavelink.NodePool.create_node(bot=self.bot,host= 'lavalinkinc.ml',port=443,password='incognito',https=True)
@commands.Cog.listener()
async def on_wavelink_node_ready(self, node:wavelink.Node):
print(f'Node {node.identifier} is ready!')
#play
@commands.command()
async def play(self,ctx:commands.Context,*, search: wavelink.YouTubeTrack):
if not ctx.voice_client:
vc:wavelink.Player=await ctx.author.voice.channel.connect(cls= wavelink.Player)
elif not getattr(ctx.author.voice, 'channel', None):
await ctx.send('Join a voice channel first...')
return
else:
vc:wavelink.Player=ctx.voice_client
await vc.play(search)
await ctx.send(f'Now playing {search.title}!')
whenever i try to play something, my bot joins the voice call, it sends the "now playing" message, but it doesnt play anything. theres no input or anything and my bot's icon doesnt light up green. does anyone know what's happening?
@commands.command()
async def poll(self, ctx,*,message):
em = discord.Embed(title="Server Poll", description=f"{message}")
msg = await ctx.channel.send(embed=em)
await msg.add.reaction('👍')
await msg.add.reaction('👎')``` **It sends the embed/poll but no reactions**
its add_reaction
oh
We can't help with this as it's in violation of YouTube's terms of service
oh youtube doesnt allow any discord bots to play their videos?
No, it doesn't. That's the reason why Rhythm and Groovy got taken offline
Any kind of downloading of youtube videos is against youtube TOS
Not all
If your YouTube premium, you can download videos
I’m gonna assume YouTube didn’t make that against TOS…
for i in self.children:
i.style = # ur style
# edit the message with the view
!d discord.ui.View.children
property children```
The list of children attached to this view.
!d help
help([object])```
Invoke the built-in help system. (This function is intended for interactive use.) If no argument is given, the interactive help system starts on the interpreter console. If the argument is a string, then the string is looked up as the name of a module, function, class, method, keyword, or documentation topic, and a help page is printed on the console. If the argument is any other kind of object, a help page on the object is generated.
Note that if a slash(/) appears in the parameter list of a function when invoking [`help()`](https://docs.python.org/3/library/functions.html#help "help"), it means that the parameters prior to the slash are positional-only. For more info, see [the FAQ entry on positional-only parameters](https://docs.python.org/3/faq/programming.html#faq-positional-only-arguments).
This function is added to the built-in namespace by the [`site`](https://docs.python.org/3/library/site.html#module-site "site: Module responsible for site-specific configuration.") module.
nvm
your add_cog line only runs when the command runs, but the cog hasnt been added to the bot so it cant run
you can use the setup_hook method to add it before your bot connects to discord
e.g. ```py
bot = commands.Bot(...)
@bot.event # hacky way to override the setup_hook
async def setup_hook():
await bot.add_cog(...)```
i see, thanks a lot
that is truly some janky code, but were you getting an error with it? given that its a disnake slash command i dont think that send() is meant to return anything, so editing the response after the duration should be done with Interaction.edit_original_message()
also time.sleep() is a blocking function and should be replaced with the async variant await asyncio.sleep(...)
or just add the command and run it too? seemed like that was the motive
seems they wanted to try out the cog system so its fine to me, plus their code looks pretty similar to the guide in the documentation
If disnake's views are similar enough to discord.py (looks like it from your code snippet), you haven't initialized the superclass
@slate swan you'll have to use edit_original_message since slash command interactions dont work the same as regular commands with their Context
well they havent defined __init__ at all so it inherits from View as normal
Ah, is the superclass initialized by default?
normally in init using super only timeout is set
so in this timeout is none by default
i thought it was 180s
!d discord.ui.View
class discord.ui.View(*, timeout=180.0)```
Represents a UI view.
This object must be inherited to create a UI within Discord.
New in version 2.0.
oh yes
View.__init_subclass__ and View.__init__ take care of the button decorators so you dont have to override anything necessarily
🎉
hi what is the difference between @bot.event and @client.event?
okay thank you
I don't understand the problem could you help me?
erase it and write it again, make sure to save your code as well
Didn't understand
I am French I struggle a little
u can use latency property u k?
type it again..
!d discord.ext.commands.Bot.latency
property latency```
Measures latency between a HEARTBEAT and a HEARTBEAT\_ACK in seconds.
This could be referred to as the Discord WebSocket protocol latency.
I don't know what I'm starting out
and outdated code... bot.say is not a thing anylonger
well now u know
Anybody able to assist me with setting up websockets inside a discord bot? 🤔
Websocket with the discord gateway or your own server?
I want to use websockets to get a feed from a website (battlemetrics.com), I have the code for it to work without a discord bot, but now I need to integrate it into a discord bot xD
Not sure if you can have multiple websockets on the same process
Worth a shot though as long as you use asynchronous websockets
aiohttp has built in sockets
I would like to learn to make bots but I have only worries and I am French so it is boring translate who could tell me why its makes me its while the bot is online and the cmd works nickel so why does the command not work? please
idk i dont think i can. maybe I am just doing it wrong tho 🤔
@sick birchSo I couldnt figure out how to do the websocket thing inside of a discord bot. So I did one step better. I will use my webhook discordbot bot with my websocket code and have the websocket stuff send to my server ;D
Which version of discord.py.are you using?
"bot.say", "bot.logs_from" etc are from an older version of discord.py which doesn't work anymore
I agree but the normally sa must work?
you need to enable message_content intents
?
in the code as well, add ```py
intents.message_content = True
thank you
Hi! So I'm in need of a free hosting, I tried replit but I get rate limited like every 10 minutes. Is there anything else I can use that does suck too much?
On different VPS services
GCP and AWS have free tiers, if you're a student you can consider applying for the github student developer pack which will give you ~300$ in azure credits and 200$ in digital ocean credits
Does GCP and AWS require linking credit cards?
aside from that I'd say get a raspi, the newer ones are really good and you can use them for a bunch of stuff
for taking a user as an argument, like: !foo @someuser, this should work right? user : discord.Member
probably
Sad, what's raspi?
afaik Azure from the gh student developer pack is the one free one which won't require cc verification
Is it easy to get the student pack?
if you're a student with a valid school/university email and ID card then you just need to apply and they'll respond in 1-2 weeks
Alright, I don't have a ID card.
But if I need to, online, for free host a discord bot, without any credit card information, is replit the only way?
Yeah, suppose.
Yes
how do i check if a channel has new messages
what do you mean by "new messages"?
like when people send new messages, my bot needs to detect it
on_message?
i think im high or smth was that it
even a screenshot of your profile on the school's student portal works
ValueError: could not find open space for item
could someone help with this error im getting?
heres my code
from discord.ext import commands
import json
# Get configuration.json
with open("configuration.json", "r") as config:
data = json.load(config)
token = data["token"]
prefix = data["prefix"]
intents = discord.Intents.default()
intents.typing = False
intents.presences = False
intents.members = True
bot = commands.Bot(prefix, intents = intents)
# Load cogs
initial_extensions = [
"Cogs.help",
"Cogs.ping"
]
print(initial_extensions)
if __name__ == '__main__':
for extension in initial_extensions:
try:
bot.load_extension(extension)
except Exception as e:
print(f"Failed to load extension {extension}")
@bot.event
async def on_ready():
print(f"We have logged in as {bot.user}")
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name =f"{bot.command_prefix}help"))
print(discord.__version__)
@bot.command
async def ping(ctx):
await ctx.send("respond")
bot.run(token)```
and here is the error
```Traceback (most recent call last):
File "/Users/User/Desktop/Discord/discord-network-test/main.py", line 43, in <module>
bot.run(token)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/client.py", line 723, in run
return future.result()```
ValueError: could not find open space for item
this is the full traceback?
can someone help me?
2022-08-31 12:28:58 ERROR discord.ui.view Ignoring exception in view <menu timeout=180.0 children=1> for item <Button style=<ButtonStyle.success: 3> url=None disabled=False label='test' emoji=None row=None>
!rule 4
4. Use English to the best of your ability. Be polite if someone speaks English imperfectly.
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
Lmao you sent a value error, code and full traceback
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ui\view.py", line 425, in _scheduled_task
await item.callback(interaction)
File "c:\Users\User\Desktop\imp\AstralRp-Bot\slashcoms.py", line 46, in menu1
await interaction.response.send_modal(modal())
File "C:\Users\User\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ui\modal.py", line 135, in __init__
super().__init__(timeout=timeout)
File "C:\Users\User\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ui\view.py", line 184, in __init__
self.__weights = _ViewWeights(self._children)
File "C:\Users\User\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ui\view.py", line 99, in __init__
self.add_item(item)
File "C:\Users\User\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ui\view.py", line 116, in add_item
index = self.find_open_space(item)
File "C:\Users\User\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ui\view.py", line 106, in find_open_space
raise ValueError('could not find open space for item')
ValueError: could not find open space for item```
2022-08-31 12:28:58 ERROR discord.ui.view Ignoring exception in view <menu timeout=180.0 children=1> for item <Button style=<ButtonStyle.success: 3> url=None disabled=False label='test' emoji=None row=None>
class menu(ui.View):
def __init__(self):
super().__init__()
self.value = None
@ui.button(label="test",style=discord.ButtonStyle.green)
async def menu1(self,interaction:discord.Interaction,button:ui.Button):
await interaction.response.send_modal(modal())```
a row cannot have more than 5 buttons
what do you mean?
is that all of your code? ( for the view)
here is the full error
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiohttp/connector.py", line 999, in _create_direct_connection
hosts = await asyncio.shield(host_resolved)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiohttp/connector.py", line 865, in _resolve_host
addrs = await self._resolver.resolve(host, port, family=self._family)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiohttp/resolver.py", line 31, in resolve
infos = await self._loop.getaddrinfo(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 860, in getaddrinfo
return await self.run_in_executor(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/socket.py", line 955, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/User/Desktop/Discord/discord-network-test/main.py", line 43, in <module>
bot.run(token)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/client.py", line 723, in run
return future.result()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/client.py", line 702, in runner
await self.start(*args, **kwargs)
await self.login(*args, bot=bot)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/client.py", line 511, in login
await self.http.static_login(token.strip(), bot=bot)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/http.py", line 300, in static_login
data = await self.request(Route('GET', '/users/@me'))
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/http.py", line 192, in request
async with self.__session.request(method, url, **kwargs) as r:
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiohttp/client.py", line 1117, in __aenter__
self._resp = await self._coro
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiohttp/client.py", line 520, in _request
conn = await self._connector.connect(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiohttp/connector.py", line 535, in connect
proto = await self._create_connection(req, traces, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiohttp/connector.py", line 892, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiohttp/connector.py", line 1011, in _create_direct_connection
raise ClientConnectorError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host discord.com:443 ssl:default [nodename nor servname provided, or not known]```
class menu(ui.View):
def __init__(self):
super().__init__()
self.value = None
@ui.button(label="test",style=discord.ButtonStyle.green)
async def menu1(self,interaction:discord.Interaction,button:ui.Button):
await interaction.response.send_modal(modal())
@client.command()
async def test(ctx):
view=menu()
await ctx.send(view=view)
(sorry for spamming channel)
you cant send just a view, add some message or embed to the send too...
check the pins, there's a pin about fixing SSL issue
still not working dude
show updated code
same error Traceback (most recent call last): File "C:\Users\User\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ui\view.py", line 425, in _scheduled_task await item.callback(interaction) File "c:\Users\User\Desktop\imp\AstralRp-Bot\slashcoms.py", line 46, in menu1 await interaction.response.send_modal(modal()) File "C:\Users\User\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ui\modal.py", line 135, in __init__ super().__init__(timeout=timeout) File "C:\Users\User\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ui\view.py", line 184, in __init__ self.__weights = _ViewWeights(self._children) File "C:\Users\User\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ui\view.py", line 99, in __init__ self.add_item(item) File "C:\Users\User\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ui\view.py", line 116, in add_item index = self.find_open_space(item) File "C:\Users\User\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ui\view.py", line 106, in find_open_space raise ValueError('could not find open space for item') ValueError: could not find open space for item
class menu(ui.View):
def __init__(self):
super().__init__()
self.value = None
@ui.button(label="test",style=discord.ButtonStyle.green)
async def menu1(self,interaction:discord.Interaction,button:ui.Button):
await interaction.response.send_modal(modal())
@client.command()
async def test(ctx):
view=menu()
await ctx.send("hello",view=view)```
any clue where the certificate is held in files, i found it once before but i dont remember
Check your token, and what version of discord.py are you using?
seems like an issue with the modal then
#discord-bots message
check this message
the modal has 9 questions
it's not much right?
depends on how you place that question
im guessing its this ?
are they all TextInput s?
yes it is
yes
k thanks!
ight gimme a moment
ok, and to get the ID of the user, i have to use user.id?
i believe it is to do with my internet connection
yeah that as well
you found a solution mr. sarth?
well the limit is 25, i wonder why 8 text inputs would be an issue
even 6 is giving me problem
guys i tried uptimerbot and its not working
class modal(ui.Modal,title = "Testing App"):
Discordname = ui.TextInput(label="Discord Username",style = discord.TextStyle.short,placeholder="(ex. Slump#0001)",required=True)
howlong = ui.TextInput(label="How long have you been a part of AstralRP?",style = discord.TextStyle.short,placeholder="Your Answer?",required=True)
everkickedorbanned = ui.TextInput(label="Have you ever been kicked or banned from AstralRP? if yes, Explain",style = discord.TextStyle.short,placeholder="Your Answer?",required=True)
whydoyouwannabestaff = ui.TextInput(label="Why do you want to be a staff member? and what can you bring to the staff team?",style = discord.TextStyle.long,placeholder="Minimum 50 words",required=True)
hadanypastexperience = ui.TextInput(label="Have you had Past experience being staff or management in other rp servers?",style = discord.TextStyle.long,placeholder="Your Answer?",required=True)
whataretwothingsyoulike = ui.TextInput(label="What are two things you like about AstralRP",style = discord.TextStyle.short,placeholder="Your Answer?")
``` any idea?
when i try to re-run the certificate i get error message
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at >: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known')': /simple/certifi/
mr. sarth
if user is a discord.User or discord.Member object, equivalent, all discord.abc.Snowflake has an id, almost all discord models meet this abstract class
?
personally i found replit can be very buggy overall
ah but pycharm cant load discord.py in my case
its says paths not found
ah ok
wtf?
are you using a venv? pycharm creates a new one with every project as default
can you show your code ?
i did create a new project yes and i tried to load discord.py but it wont come in pycharm
okay 1 sec
wdym with load? just importing it doesn't mean anything, you need to install it with pip
did you add those textinputs to the modal using self.add_item?
i went to the terminal and did that as well
so this is the keep alive code
i basically just copied it
which means the textinput has not been added yet, you need to self.add_item(variable used for textinput) for all those modals
ok
can you send main file please?
Don't have a student portal
@slate swan do i need to do it in the modals class?
yeah wherever you defined those variables
import discord
import random
from keep_alive import keep_alive
TOKEN = "........"
intents = discord.Intents.default()
intents.members = True
intents.message_content = True
client = discord.Client(intents=intents, command_prefix='!')
@client.event
async def on_ready():
print("we have logged in as {0.user}".format(client))
keep_alive()
client.run(TOKEN)
"message": ""self" is not defined",
adding it to the modals class
oh
so what is your main problem again?
me like it
Sell your data to oracle and enjoy free tier idk
oh yea doesnt oracle have like free servers
it was all good until i tried to use uptimerbot and copied the code from a youtube video
now it doesnt work
class modal(ui.Modal,title = "Testing App"):
Discordname = ui.TextInput(label="Discord Username",style = discord.TextStyle.short,placeholder="(ex. Slump#0001)",required=True)
howlong = ui.TextInput(label="How long have you been a part of AstralRP?",style = discord.TextStyle.short,placeholder="Your Answer?",required=True)
everkickedorbanned = ui.TextInput(label="Have you ever been kicked or banned from AstralRP? if yes, Explain",style = discord.TextStyle.short,placeholder="Your Answer?",required=True)
whydoyouwannabestaff = ui.TextInput(label="Why do you want to be a staff member? and what can you bring to the staff team?",style = discord.TextStyle.long,placeholder="Minimum 50 words",required=True)
```if i add self.add_item it will throw an error
im new to this stuff but how did you do that
like type it in monospace
by writing the code
!codeblock
ooooooooooooooooo
i may be wrong but it could have something to do with replits specs which are very low
ah
one of my friends told me to use replit as pychram eats at your storage
although maybe try get someone else's opinion who is more knowledgable on this
for now imma just try to get discord.py to work on pycharm
guys how check if player have permissions administrator in py @bot.slash_command(name='channel', description="lock Or UnLock The Channel!") async def channel(ctx, mode): if mode == "lock" or "Lock": perms = ctx.channel.overwrites_for(ctx.guild.default_role) perms.send_messages=False await ctx.channel.set_permissions(ctx.guild.default_role, overwrite=perms) await ctx.send(f'**Channel Locked!**') if mode == "unlock" or "Unlock" or "UnLock" or "unLock": perms = ctx.channel.overwrites_for(ctx.guild.default_role) perms.send_messages=True await ctx.channel.set_permissions(ctx.guild.default_role, overwrite=perms) await ctx.send(f'**Channel UnLocked!**')
personally i use visual studio code which i found to work well, and host my stuff via one of my friend who owns a server
the ide doesnt really matter
true
i did try that but the whole importing python and the shell window looking a bit too familiar to IDLE dint seem right
maybe the video is just outdated?
i just did it through extensions
ah
damn looks like imma have to download vsc again
im just getting started with python really
help
i mean pick what ever u feel fits u best
in terms of software
ah
the first one is the actual one provided by microsoft, you won't need others
!d discord.ext.commands.has_permissions
@discord.ext.commands.has_permissions(**perms)```
A [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member has all of the permissions necessary.
Note that this check operates on the current channel permissions, not the guild wide permissions.
The permissions passed in must be exactly like the properties shown under [`discord.Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions").
This check raises a special exception, [`MissingPermissions`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingPermissions "discord.ext.commands.MissingPermissions") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
!d discord.app_commands.checks.has_permissions
@discord.app_commands.checks.has_permissions(**perms)```
A [`check()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.check "discord.app_commands.check") that is added that checks if the member has all of the permissions necessary.
Note that this check operates on the permissions given by [`discord.Interaction.permissions`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.Interaction.permissions "discord.Interaction.permissions").
The permissions passed in must be exactly like the properties shown under [`discord.Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions").
This check raises a special exception, [`MissingPermissions`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.MissingPermissions "discord.app_commands.MissingPermissions") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CheckFailure "discord.app_commands.CheckFailure").
New in version 2.0...
The code:
#balanace:
@client.command(aliases=['bal'])
async def balance(ctx):
with open("balance.json", "r") as bal:
user = ctx.author
users = await get_balance_data()
balance = users[str(user.id)]["balance"] = 0
embedbalance = discord.Embed(titles=f"{ctx.author.name}'s balance", color=discord.Color.blue())
embedbalance.add_field(name="balance", value=balance)
await ctx.send(embed=embedbalance)
async def get_balance_data():
with open("balance.json", "r+") as bal:
users = json.loads(bal.read())
json.dump(users, bal)
Error:
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
oh wait he uses pycord
Um if want if player don't have perrison it send message
ew
Thank god disnake exists
Lmao
i also found this extension which is really good stops me wasting time doing the boring stuff
discord.py moment
i had a similar problem what python version is this
but these extensions seem really helpful
i had to do pip3.10 install discord as it didnt work althouwise
bruh pycharm has a terminal for python and pip 
the problem is that he is using a venv and probably using the pip command outside of that venv
ooo
No
ill try that
um i want If user don't have this permsion it snd something i check all links in this pages D:
That extension is terrible
yup, in that docs there is everything to do that
like ```py
if discord.member has perm(administrator=true)
I can't find D:
bruh 
this not pyhton btw
um
still doesnt work
bruh 
@command(name="ban")
@has_permissions(administrator=True)
async def ban(ctx: discord.ext.commands.Context, user: discord.Member):
#your stuff
#somewhere else
@Cog.listen()
async def on_command_error(ctx: discord.ext.commands.Context, error):
if isinstance(error, discord.MissingPermissions):
ctx.send("you don't have the permissions to use this command")
yup
You made all by your self?
yup 

@placid skiff wow, u 22 years :lmao: :kek: :noway_bruh:
ah
Hello DUNMB, I am RXhlbmlmaXg=
you named him wrong
Oh yeah
he is DUNMB
like you face
oh rip
Cat face literally
how can i generate a random number that is always 16 digits long?
my face, not my cat's
i have cameras Every where >:)
Ya necessary need digits?
Yup, this october i turn 22
You could generate like hex stuff
ANY HELP D:
random.randint(1000000000000000, 999999999999999+1)
o
I mean like a number that is 1234567890123456
this like java 
English is not my main language so mb

Me too 0 understand what they saying
but i have
so i can traslte it to arabic xD
!e ```py
from random import randint
print("".join(map(str, [randint(1000, 9999) for i in range(4)])))```
@vale wing :white_check_mark: Your 3.11 eval job has completed with return code 0.
1591381678124602
no offense, your english is way worse than TesticalCutter's
💀
LOL
No, me english are a baddest
Really i glad to hear that
on mye inglesh are badddder
badder*
send code
@bot.slash_command(name='channel', description="lock Or UnLock The Channel!")
@has_permissions(administrator=True)
async def channel(ctx, mode):
if mode == "lock" or "Lock":
perms = ctx.channel.overwrites_for(ctx.guild.default_role)
perms.send_messages=False
await ctx.channel.set_permissions(ctx.guild.default_role, overwrite=perms)
await ctx.send(f'**Channel Locked!**')
if mode == "unlock" or "Unlock" or "UnLock" or "unLock":
perms = ctx.channel.overwrites_for(ctx.guild.default_role)
perms.send_messages=True
await ctx.channel.set_permissions(ctx.guild.default_role, overwrite=perms)
await ctx.send(f'**Channel UnLocked!**')```
from discord.ext.commands import has_permissions, MissingPermissions
i think
im not gonna be surprised if that is actually what you think worse is
@Cog.listen()
async def on_command_error(ctx: discord.ext.commands.Context, error):
if isinstance(error, discord.MissingPermissions):
ctx.send("you don't have the permissions to use this command")```
i think it should work in cogs
@commands.has_permissions
a
this will make if player have that perrmission right?
ya
what lib did u use?
and i think u have to remove the discord infront of MissingPermissions but im not sure.. atleast thats what i have in my code
oh it's discord
what is lib 
import commands from discord.ext
from discord.ext import commands
then do this
it is pycord 😭
i fix it
Library
nextcord
It's where you get books
gah im never right
a b c d e fu-
oh nextcord
from Time to know
eyes
i told you 123456 thousand times
im not using cogs, so idk
Cog is a way to connect more files of your bot 
not true
0 star bad.
More like commands container
ah i then oh fix it ;/
And listeners
i think it's @commands.Cog.listener()
Even loops
ok
Almost for everything lmao
oh 0 error
0************************************************************
Just use your bot instance bot.listener()
listen()
SO I USE listen() or bot.listener() THIS SO WERIDO THINgs
Yup listen
What's your native language @slate swan
alot
arabic egyption
Understandable
Um My english not that bad
my sister is going england to study there english cambrigh so xD
me still small D;
we can tell
xD
Oh god
xD Hi angad
Really
No, it should be @event
grammer is trash
yes lol
bruh you have to use your bot instance
haha
yes
event and listen both dispatch an event, but with event only the first one executed will be resolved
oh
instead, listeners will always be resolved
so what i import
0 understand
0 understand
now any one help
it make error if i don't import
@slate swan your name- ImportError: module Life has no attribute Friendship
how to edit embed multiple times ?
yes
message.edit()
messsage = ctx.send(embed=embed)
xD
how
boot.listen() bro
bruh, bot.listen()
ez thank byeee
ez lmao
oh work
lol
Bot*
no boot
LOL
🤨

It look like it work
🤯
🤨
ah it not send py ctx.send("you don't have the permissions to use this command")
If you are the owner of the server you've all permissions 
i know i not owner i member
i not that dumb
U r awaiting it?
No
Then how it will send
in your dreams
💀
👎
What 👎
@bot.slash_command(name='channel', description="lock Or UnLock The Channel!")
@commands.has_permissions(administrator=True)
async def channel(ctx, mode):
if mode == "lock" or "Lock":
perms = ctx.channel.overwrites_for(ctx.guild.default_role)
perms.send_messages=False
await ctx.channel.set_permissions(ctx.guild.default_role, overwrite=perms)
await ctx.send(f'**Channel Locked!**')
if mode == "unlock" or "Unlock" or "UnLock" or "unLock":
perms = ctx.channel.overwrites_for(ctx.guild.default_role)
perms.send_messages=True
await ctx.channel.set_permissions(ctx.guild.default_role, overwrite=perms)
await ctx.send(f'**Channel UnLocked!**')
bot.listen()
async def on_command_error(ctx: discord.ext.commands.Context, error):
if isinstance(error, discord.MissingPermissions):
await ctx.send("you don't have the permissions to use this command")```
it not working
It is slash command so how it will go to on_command_error

and bot.listen is a deco
You didn't tell that it was a slash command 
rip sorrrry
!d discord.app_commands.CommandTree
class discord.app_commands.CommandTree(client, *, fallback_to_global=True)```
Represents a container that holds application command information.
nope
Go there and see what method is for error handling
where is deco or what is deco
b r u h
Be quiet
What "nope"
Nope
it meean 0 understand
you = 🇮🇱
Use interaction
Do you know classes?
um
Oh
decorators are functions that take another function as argument, to use them you do @deco
You need to know classes to read docs , u should learn them
I love Israel
ok
I sent you a simple class ...
....

where
DMs
And you used classes for buttons
what class mean
what school mean
and home mean
what i am mean 
i feel everyone dead
How to make loop
u can get the CommandTree instance from bot.tree
Write interaction: Interaction instead of ctx
Use from nextcord import Interaction
and change to interaction.response.send_message(message)
can be classes too it takes only an init and call dunder
this channel for discord boots, u shuld get help channel frm #❓|how-to-get-help
boots 👀
u can kick ppl with them
yesh
how u know they are using the NextCOOrd :?
loop in discord bot
!d discord.ext.tasks.Loop
class discord.ext.tasks.Loop```
A background task helper that abstracts the loop and reconnection logic for you.
The main interface to create this is through [`loop()`](https://discordpy.readthedocs.io/en/latest/ext/tasks/index.html#discord.ext.tasks.loop "discord.ext.tasks.loop").
hi
discord.ext.tasks.loop?
dude 0 understand D;
i tell u to learn classes so u can understand, did u do that
blvck master in understanding context from stuff 
do u want youtube guide on classes
lmao
i think he is Legilimens
mhm 
i know what is classes in java
this is java?
no lol
because u r lazy
spoonfeed me i will tell u how it tastes
lol i not
dont want to learn classes
wtf ;/
only want spoonfeeding like weee weee baby
so change to discord
i every oone send me code and i understand
nextcord is better
so u shuld understand without ppl sending u code
i can't ;/
i not joking 
then u need to learn python so u can understand
can i change the "{BotName} is thinking" message
can't you send code me read it
wdym?
when you defer interaction? no
no stop asking for spoonfeed
Sad
dude the problem that i always do this send code me read = me understand
maybe i can make it send a message then edit it ?
sure
InteractionResponse.send_message returns Message obj, you can put that in variable and edit when you need to
ok Thx
first u stop ignore me
wtf
im not helping u anymore u dont even listen to what im saying
this how i learn skript and java
bc i don't even understand what you saying
u not "learn" anything lol u just gluing togther code
nope
so learn classes and then ull understand
nothing mean that ;/
yeyp
want to learn from some code?
Study this https://github.com/Tvrsier/BaseBot
Base bot setup for discord.py and relative forks. Contribute to Tvrsier/BaseBot development by creating an account on GitHub.
your mom who will cry today at night :)
u either learn or keep begging
Ah This bad way to treat people
dont care lol
dude i can't learn like read book or something i need get code or answers frist
<@&831776746206265384>
Black literally sent you code and said to read it if you want to "learn from code"
go ahead
o bye
are you trying to ban yourself?
ahaha xdd
lmao
he disrespect D:
i say u to learn so u can understand me, how that is disrespect xdd
you are not giving any respect either
you say i don't care
then i ping stuff
yes i dont care about ur whininhg
people are trying to help and you are just yelling saying that u wont learn anything you want to be spoonfeeded and you will understand the code
for disrespectful
they are doing this so we can ensure you actually learn, not just steal code and put it in your codebase
ah 60% of your message understand ;/
u r frm egypt?
oh yes this true
what does that even mean?
no usa
it mean your mom lagagues
hmm so when ur teacher gives u question paper in exam do u say give answer key first then I'll studying for exam💀
how usa education system is so trash
be quiet
um i 13?
i not 101% know all english
when i said anything about english
yeah you know it all 911%
your mom say
good for you
it wasn't about your english but the process of learning things.
send code = me read it = learn
in usa education system teacher do all homework fr student?
now be quiet me want read @placid skiff code
how can we make sure that you don't just steal the code?
he is from egypt?
he say usa
ohok
france
now be quiet
If you can't be civil you should take a break
how about
learn the basics of code
think, and write your own code
test the code:
works: yay!
doesn't work: help!!!!
and doesn't work will be his description to the problems :lmao:
stop ping me
i think he is lying about age im pretty sure he is not allow on discord
why did u reply to my country? 🤨
https://www.youtube.com/watch?v=F1HbEOp-jdg&list=PLYeOw6sTSy6ZGyygcbta7GcpI8a5-Cooc
Here, follow him
From so far this is one of the best tutorials i have ever saw
Welcome to the updated discord.py series - the series where I teach you how to build a discord.py bot for your server! Below are some links to get you started.
Series requirements can be found here:
https://files.carberra.xyz/requirements/discord-bot-2020
You'll also need an IDE; I use Sublime Text in this series:
https://www.sublimetext.com/
...
yt tutorials 🤢 🤢 🤮
that dude did a good job tbh
carberra's tutorials are actually nice :p
no i'm just stating that he's most likely lying
well, yeah, no lies
Oh i got point
bc it slash_command we can't use bot._listen
this your mom dream when she sleep?
lmfao it was a joke, and how does that make sense
Could you stop joking about mom please? Let's be civil
only in your trash dream world
they disrespect me D:
sorry had a lesson try do pip3.10 list
You disrespect them either. Please let's all respect each other
ok bye now :D
IF I DOn't KNOW SOMETHING THEY WILL MAKE JOKE OF ME D:
xD
so i can't just be respectful and them not
No, that is because you don't want to learn something you don't know
noone is making joke of u we are just asking u to learn the basics so u can understand what we r saying to you
we are already civil u should try this in dpy server
i feel we chating about who will start war3
What
when you said "only in your trash dream world", don't you think that was disrespecting me (and my mom)? I did nothing to you
!shhh
✅ silenced current channel for 6 minute(s).
Things need to settle down. Please stick to the channel topic. Any more disruptive or insulting behaviour is not acceptable.
!unshhh
✅ unsilenced current channel.
what
Suggest more topics here!
oh ok.
discord.gg/dpy they will spoonfeed u
These topics are ass bro, there are probably only 4
they like giving code for free
i don't want freesh code
i want some thing like this https://github.com/Tvrsier/BaseBot/blob/master/lib/bot/__init__.py
Base bot setup for discord.py and relative forks. Contribute to Tvrsier/BaseBot development by creating an account on GitHub.
You are free to suggest more in #community-meta
this kinda explane what is going on
yes they will give u
can I submit a PR?
this just example not the code
they will give u full code
yes they r much nicer ppl than us
wasn't that exactly what you wanted as you said earlier?
i want some thing like that https://github.com/Tvrsier/BaseBot/blob/master/lib/bot/__init__.py
Base bot setup for discord.py and relative forks. Contribute to Tvrsier/BaseBot development by creating an account on GitHub.
You can create an issue on the meta repo
they even give candy if u ask nicely
lol
🍬
then copy it ig
now be quiet good bye everyone!
this example
yes all of them use the same code
disnake
you know what
i will work in other thing :D
great.
I'm not going to school tomorrow 🎉
I can code my bot freely... well only for one more day, but still cool
school?
my teacher announced that tomorrow will be online class, but they changed it
im not going to school either but I can't code.for a year.
bruh you start school on first september? lmao
You are in the university?
oh xD i forget school start in Eu countrys
why
w-what?
a perfect time to abandon all my projects
nah here school will start after month
my birthday 🥳
early happy birthday
yes
tyy :D
Happy early bday
studies :p
but you said you're not going to school
don't you join college the same day?
dude i so lucky me have 5 month hoilday 
exams ig
yeah... no schools
its a drop year with some coaching
i did some thing like this
ah 👁️ 👀
off-topic anyways
i see
like it sounds like that
like this
my college started aug 23
i is
ah
(eye eyes)
lmao why send an image
this video
it activity
chnage stream activity to name and link
cool
lol
and !joke for random jokes
your bot uses slash commands as I see though
and this !user
or maybe that's a hybrid
i start set slah commands today
so some !
and some /
what, why
um i still changes
you should be consistent and choose one for all of your commands
ah yes, lucas.
yes i changing rn from ! to /
you recognize the embed?
Well that because discord.py handles normal commands and slash ones in different ways
In disnake it's a pretty normal stuff
this loop for amout of times right? py for i in range(count):
hikari has a deco that set a command bot as slash and chat one
count is amout of time
its like the 50th time im seeing this so yes
lmao
yeah I see that but personally I would take the time to switch to slash commands
but when i put it in this code py @bot.slash_command(name='count', description="Make Bot Count Until A Number!") async def count(ctx, mode: str, number: int): if (mode) == 'down': await ctx.channel.purge(limit=1) editmessage = await ctx.send(f'OK We Will Count Until **{number}**') (count2) = 1 for i in range(count): sleep(1) await editmessage.edit(content=f'**{count2}**') (count2) = (count2) + 1 sleep(1) await ctx.send (f'OK I Count To **{number}**') if (mode) == 'up': await ctx.channel.purge(limit=1) editmessage = await ctx.send(f'OK We Will Count Until **{number}**') (count2) = (count) for i in range(count): sleep(1) await editmessage.edit(content=f'**{count2}**') (count2) = (count2) - 1 sleep(1) await ctx.send (f'OK I Count To **{count}**') the loop not work and it give me error
and before change it from ! to / it was working
so idk why
he uses nextcord but ig they're pretty much similar... but not in slash commands... idk
yes nextcord is good
why are you using parentheses everywhere
yes but i lazy to chnage it
and please use asyncio.sleep instead of time.sleep, it's blocking
literally a simple find-and-replace
ok
if you're using VSCode, Ctrl+Shift+R
ctrl r?
😂
be quiet
await asyncio.sleep
await asyncio.sleep(1)?
yes
he'll have to import asyncio in every file
he'll be lazy
no problem
so what, just import it ig?
and then you rant about people being disrespectful
can you be respectful i resepectfl rn
etzeitet is watching
be quiet isn't disrespectful
it shut up but nice way
sure.
hi etzeitet
sssh? it more nice
at this point of time, yea
ah
shh, shut up, and be quiet is most definitely not nice
lmao
hm fuck off more nice :)
he really wants to type it out right now
i have /channel lock in my bot :D
cool
that is not nicer
that's even worse than "shut up"
NOW STOP BE DISRESPECTFUL TO EVERYONE THAT TRY GET HELP | bye don't ping me :D
i don't do bots anymore but the last one i made had just 5-6 commands
ok
btw do you guys know why is #764232549840846858 called like that if i cant stream there
can't be doing that if they keep saying "be quiet"
i mean bruh
you need to be voice verified ig
i am
voice verification
hee hee
i got the role
that is just not possible
yep sadly i dead
RIP angad 🙏
I feel like that is against a rule but please check for yourself if you wish
be quiet
be quiet
um actually yes spoonfeeding is against rule 8
im reading through all the old messages right now
why no one tell me that ;/
if i was know that i will not beg ;/
LOL
me need read rules
;/ be quiet
lmao
you get blocked
:(
where
here
prove its his code?
use asyncio then
says noob
YOU USE SLEEP(1) LOPL
and your using my code
;/
LOL
bye
bye
bye
um
...
if i block you i can't get help D:
so you not blocked :D
por what
nope blocked to be fair
nice
good who next
wtf
lol
blocked for say lol
RIP
jk hard block angad
congrats @tawdry karma
only when he ping me 69 itmes
<@&831776746206265384> disrespectful
NO
you just pinged the mods for that
just let them ban me i have 10 other acounts
Why were mods pinged?
ah disrepsectful
Where?
everywhere I try respect
I don't see a problem. Please only ping mods for an actual issue.
;/
oh i thought i'll have a first punishment in this server
he say congrats @tawdry karma this disrespectfuk ;/
ok gud im still clean :)
;/
HE DISREPCFUL
I think you need to take a break @slate swan. You're the common denominator in all the bickering today.
YOU Can't JUST KEEP HIM AND HE BROKEN RULES
wtf
Oh wow.
where did I break the rules?
DISREPECTFUL
tell me, if that's true, ill punish myself
um congrats @tawdry karma?
!mute @slate swan 12h Please take a break.
:incoming_envelope: :ok_hand: applied mute to @slate swan until <t:1661981096:f> (12 hours).
oh thanks
really
isn't that rude?
Oh no
xD
!ban 1001147045274464386 mute evasion.
:incoming_envelope: :ok_hand: applied ban to @near nymph permanently.
Someone caused a little disruption. I won't go into details ¯_(ツ)_/¯
omg thank god
That is just his alt
hmm ok
yes but it is IP ban
so his main prolly not be able to access server
@slate swan
Rip
arent u going to ban his main too
breaking so many rules and all he gets is a mute
Moderator just modded ¯_(ツ)_/¯
Oh
He is watching right now btw
ik he dm me "L" xd
.topic
nop
Oh the guy was muted 
ban is ip ban in discord so he can join again only with vpn
ip address changes when you restart your modem, unless you have set a static ip address
and for some reason my discord client doesn't work if i have vpn on sometimes so its a pain in the ass
yesh that too
discord web 👀
that ur LAN ipv4 not WAN (external) one
bruh i was in your shoes yesterday, the same annoying guy ;-;
but nothing happened ffs
So I put the same code in replit, and in bot-hosting.net, in replit it worked fine, but in the other one I got his error:```py
Traceback (most recent call last):
File "/home/container/bot.py", line 5, in <module>
from cogs.services import tickets, ticket_closes
File "/home/container/cogs/services.py", line 25
(*[discord.ui.InputText(style = discord.InputTextStyle.long, label = i[0], placeholder = i[1], min_length = 2) for i in questions[ttype]]),
SyntaxError: cannot use starred expression here
i have a question, is it possible to run a discord bot scrip running 24/7 without having to make a server for it?
#965291480992321536 you host it ( and you're not getting any good free option without a credit card)
show line 25
It's in the error```py
(*[discord.ui.InputText(style = discord.InputTextStyle.long, label = i[0], placeholder = i[1], min_length = 2) for i in questions[ttype]]),
update the python version for that service
go to startup, and choose python 3.9 or 3.10 as your image
Thanks
It's already at 3.10 tho
or if thats not possible how do i make a server without having use my device as a server
as the error says
Error:
UnboundLocalError: local variable 'member' referenced before assignment
Code:
async def balance(ctx, user:discord.User=None):
if user is None:
user = ctx.author
db = sqlite3.connect('ab.sqlite')
cb = db.cursor()
cb.execute[f"SELECT Yen from ab WHERE user_id = {u.id}"]
bal = cb.fetchone()
try:
Yen = bal[0]
except:
Yen = 0
await ctx.send(f"Yen: {Yen}")
oh right
if member is None you have user as parameter not member
kk
and it is discord.Member
ye, mb. I pressed ctrl+z, after correcting the typo, so...
What does SyntaxError: cannot use starred expression here mean?
- is not usable in that context
So bot-hosting.net just sucks? Since the same code works everywhere else.
haven't used the host so can't say, mind sending the full exception and related code?
or is that all
ValueError: could not find open space for item``` what is the fix to this error?
class ticket_creation(discord.ui.Modal):
def __init__(self, ttype, member):
super().__init__(
(*[discord.ui.InputText(style = discord.InputTextStyle.long, label = i[0], placeholder = i[1], min_length = 2) for i in questions[ttype]]),
title = "Ticket Creation")
self.timeout = None
!d discord.ui.Modal
class discord.ui.Modal(*, title=..., timeout=None, custom_id=...)```
Represents a UI modal.
This object must be inherited to create a modal popup window within discord.
New in version 2.0.
Examples...
hm, it doesn't take any TextInputs
what library are you using
py-cord==2.0.0
what's the limit for discord modals questions?
Code:
from event import Event
intents = discord.Intents.all()
bot = commands.Bot(command_prefix = 'a ', intents=intents, case_insensitive=True)
async def setup(bot):
await bot.add_cog(Event(bot))
@bot.event
async def on_ready():
await bot.change_presence(status=discord.Status.online, activity=discord.Game('Anime Botto'))
print('Logged in as {0.user}'.format(bot))
@bot.command()
async def balance(ctx, user:discord.User=None):
if user is None:
user = ctx.author
db = sqlite3.connect('ab.sqlite')
cb = db.cursor()
cb.execute(f"SELECT Yen from ab WHERE user_id = {user.id}")
bal = cb.fetchone()
try:
Yen = bal[0]
except:
Yen = 0
await ctx.send(f"Yen: {Yen}")
Error:
OperationalError: no such table: ab
CREATE DATABASE ab;

