#discord-bots
1 messages ยท Page 971 of 1
maybe this helps? Due to an API change Discord is now forcing developers who want member caching to explicitly opt-in to it. This is a Discord mandated change and there is no way to bypass it. In order to get members back you have to explicitly enable the members privileged intent and change the Intents.members attribute to true.
yeah i read that but it seems like extra work to do the same thing
define it how exactly?
Can you specify a guild on async def kick?
sure but take it up with the discord devs
r u trying to remotely kick?
id = ... or make it an argument in the command
Yes, I'm trying to have it kick the user from another server on_member_ban
@commands.command()
@commands.is_owner()
async def leave(self,ctx):
id = ''
guild = self.bot.get_guild(id)
await guild.leave()
give this
sorry, I assumed you would use your brain a little lol
you need to use the ID of the guild
why would a blank ID work?
Its kinda fried from uni lol sorry
Damn-
@primal fox it still didnt work do i have to add the extra lines of code in all my cogs or just the main file
wouldnt I be able to get the bot to fetch it and store it into id tho?
you need to pass the intents to your bot like it shows in the code example, and enable them in the discord web portal
that's what context is for, you can use the guild from the context, id = ctx.guild.id
no, just your bot
2022-04-12T00:14:54.565638+00:00 app[worker.1]: gerald#2492
this is the only line it gives
which is it returning it checked itself
again, show the code where you create the intents and pass them to your bot
feel free to use a pastebin
@commands.command()
@commands.has_role(950613237739708476)
async def game_s(self,ctx):
guild = ctx.message.author.guild
Signed_up = ctx.guild.get_role(950611405986480208)
channel = self.bot.get_channel(950613102100086854)
if ctx.message.channel.id == 950613102100086854:
for member in ctx.guild.members:
print(member)
if Signed_up in member.roles:
print(member)
await member.remove_roles(Signed_up)
await member.add_roles(ctx.guild.get_role(950611491101483089))
await self.bot.get_channel(950614806702985296).send('The game has started <@&950611491101483089>')
elif ctx.message.channel.id != 950613102100086854:
await ctx.send(f'{channel.mention}')
it skips the loop on
if Signed_up in member.roles:
? that's not what I'm talking about
intents.members = True
where is your code for this?
I'm asking to see that code
import discord
from discord.ext.commands import Bot
from discord.ext import commands
import asyncio
import time
import datetime
import emoji
import os
import random
client = discord.Client()
bot = commands.Bot(command_prefix = "$")
bot.remove_command("help")
intents = discord.Intents.default()
intents.members = True
that?
as the docs said, you need to pass the intents to the bot when you create it. what you're doing is creating the bot, then the intents, and never passing them in, so they are lost forever
bot = commands.Bot(command_prefix='!', intents=intents)
Yea
Why do you have to import Bot
also remove client = discord.Client()
this is reused code i made like 4 years ago so i just kinda left whats working alone
you really just need from discord.ext import commands
๐
Seems useless
i use it later on i see
@bot.event
async def on_ready():
print("Im online")
Bot.wait_until_ready
client.wait_until_ready
game = discord.Game("with your feelings")
guild = bot.get_guild(950610895371915294)
await bot.change_presence(status=discord.Status.online, activity=game)
extenstions = ['events','fun','help','levels','stats','In_game_roles','role_management','game_shift']
if __name__ == '__main__':
for extension in extenstions:
try:
bot.load_extension(extension)
print(extension)
except Exception as error:
print(error)
bot.run(os.environ['token'])
discord.Client is a parent class of commands.Bot; you don't need it
focus on one problem at a time; you could definitely clean your code up
yeah i def could but i never access this file and its never caused a problem
if i work on code i just make a new cog and add it to extensions and problem solve in the new cog
and to make yall more disappointed i use heroku to host it all
most people who can't self host do that
I use pterodactyl
how many hours do you get for free there @frozen patio
None
You need to install it all
Takes like 5 hours
@primal foxyour a god man i wouldve never got this done without your help
petrodacyl is not a host, it's a panel gui for hosting services
I host on there
unfortunately
literally every free hosting services uses it for their gui.....
That doesn't make it a host.
Anyways can someone PLEASE help me with this?
happy to help, but I'm sure someone else here would have helped you too ;P
0
Yea
Lemme show you my code for the answers here ig
I'm guessing you didn't add anything to the list then
No, because the answers you enter yourself
Like the time, channel, and what is being gaven away
yeah, probably your code isn't pushing that to the array properly
Hmm, i put my code up there above.
That part isn't where it's pushing to the list
So I can't really tell if there's something wrong with it
Well, I tried some things but it did not work.

@commands.command()
@commands.is_owner()
async def leave(self,ctx, guild):
id = ctx.guild.id
guild = self.get_guild(id)
await guild.leave()
ignore indentation vsc cant copy to clipboard properly
Can we see the code for the entire function?
Yea it is up there tho
Ye that is it
thx so much man
nvm it worked lmfao, but it didnt leave the guild with id I set lmfao
@frozen patio why not send each message and wait for each response?
but yes its a cog
Because I cant it to be like this
for question in questions:
await ctx.send(...)
answer = await bot.wait_for(...)
answers.append(answer)
I do not see that in my code.
I know, I'm suggesting that
It might help fix the issue
Since you're taking it one at a time instead of everything at once
Because as of right now, your wait_for only waits for the first message
Yeah
You either have to copy paste that line twice more or use the method I suggested
I do not think it being in an else statement affects it
Calling what once?
wait_for
I have that line in 3 times now
You either have to:
a1 = bot.wait_for(...)
a2 = bot.wait_for(...)
a3 = bot.wait_for(...)
answers.append(a1)
answers.append(a2)
answers.append(a3)
or, use my method:
for question in questions:
await ctx.send(...)
answer = await bot.wait_for(...)
answers.append(answer)
I need the append thing 3 times too OH
i got this error:
Yeah you're referencing c_id outside the try block
If it's inside a try block, it has a chance to not be defined
!e
try:
x = 5/0
except:
print("Oops, something went wrong :(")
print(x)
@sick birch :x: Your eval job has completed with return code 1.
001 | Oops, something went wrong :(
002 | Traceback (most recent call last):
003 | File "<string>", line 5, in <module>
004 | NameError: name 'x' is not defined
Python won't let you do that because of how scoping works
..
Python also doesn't let you allocate memory to them, but not give them a value like Java might:
String myString;
myString = "hello, world!";
I did have to move it up so it would be defined ig
I know, you're defining it inside, but you're accessing it outside
Okay so put it in the try function?
Yes
Lol
anyone know how to get the channel id out of hikari.GuildMessageCreateEvent?
so i can send a message without the ctx context
ZeroDivisionError ๐
message.channel or smth?
@commands.command()
@commands.is_owner()
async def leave(self,ctx, guild=None):
if guild is None:
id = ctx.guild.id
guild = self.bot.get_guild(id)
await guild.leave()
print(f"Successfully left guild: {guild.name}")
else:
id = guild.guild.id
guild = self.bot.get_guild(id)
await guild.leave()
print(f"Successfully left guild: {guild.name}")
Ok so the bot leaves the guild it currently is in but when I pass the guild param, it will still leave the guild its in and not the guild with the id i passed in the param
when i modify code to be:
@commands.command()
@commands.is_owner()
async def leave(self,ctx, guild=None):
if guild is None:
id = ctx.guild.id
guild = self.bot.get_guild(id)
await guild.leave()
print(f"Successfully left guild: {guild.name}")
else:
id = guild.guild.id
guild = self.bot.get_guild(id)
await guild.leave()
print(f"Successfully left guild: {guild.name}")
ignore indents again cos vsc problems
you can either fetch the channel, or get the channel from cache using its Id
# fetch method
channel = await event.message.fetch_channel()
# get method
c_id = event.message.channel_id
channel = bot.cache.get_guild_channel(c_id)
or if you're using lightbulb and have a context then ```
channel = ctx.get_channel()
Hey @muted dagger!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
Hey @muted dagger!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
@slate swan what do you think of this?
lemme see
cool enough, some points
line 3 import discord, useless import
@bot.command()
@lightbulb.command("ping", "See Akuma's latency.", auto_defer=True)
@lightbulb.implements(lightbulb.SlashCommand)
async def ping(ctx: lightbulb.Context) -> None:
embed=hikari.Embed(title=f"My ping is {bot.heartbeat_latency * 1_000:.0f} ms.", color=0x6100FF)
await ctx.respond(embed=embed)
i switched from discord to hikari so i forgot that lol
@bot.command()
@lightbulb.add_checks(lightbulb.owner_only)
@lightbulb.option("text", "Text to repeat")
@lightbulb.command("echo", "Repeats the user's input")``` make the `text` option a required one so the command actually serves it purpose
@lightbulb.option("text", "Text to repeat", required=True)```
other things seems fine ๐
โ
its only for me, since other users can just easily send bypassed messages through it
makes sense then, good job!
you can now try using plugins, they are like cogs in discord.py but a lot easier
thanks man, any ideas on how to make a ban command? im not familiar with events other than hikari.GuildMessageCreateEvent
yo what are those
basically, you can have a single main file only with your bot defination and you have your commands and events in other files ```py
main.py
import lightbulb as lb
bot = lb.BotApp(prefix="", token="")
bot.load_extensions("other_file")
bot.run()
other_file.py
import lightbulb as lb
plugin = lb.Plugin(name="some commands", description="my first plugin")
@plugin.command
@lb.command("name", "desc")
@lb.implements(...)
async def command(ctx):
...
def load(bot):
bot.add_plugin(plugin)
eh, i just do it in one fine
file
well thats helpful when you make a big bot, or need to make command categories
rightt
is it possible to make a ban command in hikari-lightbulb
?
try using discord.File("path") or utilise BytesIO
yeah why not
take a hikari.Member/User type argument from the user as an option
guys is this a thing in python: x = not x
how is x = !x then done in python?
!e print(1 != 2)
because its a variable?
@slate swan :white_check_mark: Your eval job has completed with return code 0.
True
its !=
no but like assign the exact opposite to it
Oh, then thats easy
!e x = x != True
i thought you meant "x = not x" exactly
!e x = False; x = x != True
ah my bad yes i meant
bool x = true
x = !x results in false
hikari-lightbulb : https://hikari-lightbulb.readthedocs.io/en/latest/guide.html
hikari docs: https://www.hikari-py.dev/
thanks
!e x = False; x = x != True; print(x)
you can use the not keyword
use x = x != True
if its a bool, its possible
ah ok thank u
!e py a = True print(not a)
@slate swan :white_check_mark: Your eval job has completed with return code 0.
False
the jjk movie was so good btw
ikr
Traceback (most recent call last):
File "c:\Users\zgrew\OneDrive - Brisbane Catholic Education\Documents\Python\bot.py", line 5, in <module>
bot = lightbulb.BotApp(
AttributeError: module 'lightbulb' has no attribute 'BotApp'
@slate swan
whats the right way to see if the @commands.check_any() has passed true at least once?
is it possible to make someone get a role if they answer the question that has a part of a text that i select, ex
!verify
user: something@gmail.com and if it has @ gmail.com in it it will give them a role?
did you pip install lightbulb or hikari-lightbulb?
yea
dont worry, fixed
i was messing with lightbulb files
ee
if "@gmail.com" in response:
await member.add_roles(...)
how do you get attached files with hikari and attach files to a message?
where could i put this
Probably after your wait_for
can i have an example?
and how could i make the rest of the message disband after if gmail isnt in the text
i want it to go after that and disband before checking info
m = await bot.wait_for(...)
if "@gmail.com" in m.content:
# give user role
else:
return # "disbands" the rest of the code
can i just shove that in after the part for email
Yeah it just has to be after your wait_for
@commands.command()
@commands.is_owner()
async def leave(self,ctx, guild=None):
if guild is None:
id = ctx.guild.id
guild = self.bot.get_guild(id)
await guild.leave()
print(f"Successfully left guild: {guild.name}")
else:
id = guild.guild.id()
guild = self.bot.get_guild(id)
await guild.leave()
print(f"Successfully left guild: {guild.name}")
This makes the bot leave if no guild id is given but will spit out Command raised an exception: AttributeError: 'str' object has no attribute 'guild' when I use an id, not sure where I've gone wrong here
i dont have a waitfor
Then how are you getting a user's answer?
Ah, well you have your answer to that then
i have it like this so far
bad indentation
Fix the indents, and also pass in the proper arguments to wait_for
!d discord.Client.wait_for see here for more information
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.10)"). 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.10)") 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.10)") 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**...
im a bit confused
I'm more than happy to explain, ask away
alright
I just have one question, are you ony going to be using that bot?
i want to know how to make it so that if you respond to the question A PART of the text it will continue the rest of the text that will lead to you getting the role
is that to me lol
Yes
Right, so we have this part:
m = await bot.wait_for(...)
``` yes?
It waits for the user's message, and stores said message in variable m
From there, you can access m.content, and check to see if @gmail.com is in that content
What? This honestly makes no sense, my serverinfo command is similiar to this.
im going to be using it to check usernames and things, this is just a general example
So far so good, make sure you indent it properly and fill in what's supposed to go in wait_for according to the documentation
Also time.sleep() is blocking
where would i add the wait_for
And with 15 second sleepers you're bound to forget to HEARTBEAT to the gateway and get yourself kicked off the socket
well, i wanted to make it so you have 15 seconds to respond, if you respond earlier it will delete and start the other process\
That's why timeout exists on wait_for
anyone able to enlighten my smol brain?
Because if others would use that command, i don't think everyone would want to verify with their email address sending in publicly (this isn't anything wrong with the code, just my thoughts on the purpose)
yea its for a private server
You need a guild object
Can you send the full traceback?
im still a bit confused on what to do
No problem, do you get why we're using wait_for, and how it works?
I get that we are using it to wait for the user response
Right, and you understand what this bit does:
m = await bot.wait_for(...)
specifically m?
in basic english please?
Your bot waits for a message, then stores that message object within m for you to access
I thought it would pass it from the parameter guild=None if I gave the optional parameter
Traceback (most recent call last):
File "C:\Users\Student\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\ext\commands\core.py", line 168, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\Student\Desktop\Lofi-Chill Rewrite\main.py", line 548, in userinfo
await ctx.reply(embed=embed)
File "C:\Users\Student\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\ext\commands\context.py", line 400, in reply
return await self.message.reply(content, **kwargs)
File "C:\Users\Student\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\message.py", line 1613, in reply
return await self.channel.send(content, reference=self, **kwargs)
File "C:\Users\Student\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\abc.py", line 1418, in send
data = await state.http.send_message(
File "C:\Users\Student\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\http.py", line 337, in request
raise HTTPException(response, data)
nextcord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embeds.0.fields.4.value: This field is required
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Student\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\ext\commands\bot.py", line 1055, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Student\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\ext\commands\core.py", line 933, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\Student\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\ext\commands\core.py", line 177, in wrapped
raise CommandInvokeError(exc) from exc
nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
not really
In embeds.0.fields.4.value: This field is required
Embed 0 field 4 seems to be where the issue is
thats where im getting confused
Can you send the code where you construct the embed?
In the arguments first, typehint guild to discord.Guild.
guild : discord.Guild =None
Alright, basically wait_for waits for the first message it sees
When it sees that message, it'll get the message and store it within m
Yeah, lemme get the whole command:
Then you can do regular stuff on it like m.contents
so m is message basically
Same as you might for, say, on_message(message)
@client.command()
async def userinfo(ctx, user: nextcord.Member=None):
if ctx.author.id in blacklist:
bl = nextcord.Embed(title="You are blacklisted!", description="You have been blacklisted from Slytherin!", color=0xff0000)
bl.set_footer(text=footer)
bl.timestamp = datetime.now()
await ctx.send(embed=bl)
else:
if user is None:
user = ctx.author
if user.id in staff:
staff_status = True
else:
staff_status = False
role_count = len(ctx.guild.roles)
roles_count = len(user.roles)
role_list = [r.mention for r in user.roles if r != ctx.guild.default_role]
roles = ", ".join(role_list)
perm_list = [perm[0] for perm in user.guild_permissions if perm[1]]
embed = nextcord.Embed(title=f"User Info for {user.name}", color=0x003fff)
embed.add_field(name="User ID", value=user.id, inline=False)
embed.add_field(name="Creation Date", value={user.created_at}, inline=False)
embed.add_field(name="Joined Server", value=user.joined_at, inline=False)
embed.add_field(name="Server Manager Staff", value=staff_status, inline=False)
embed.add_field(name="Roles List", value=roles, inline=False)
embed.add_field(name="Roles Count", value=roles_count, inline=False)
embed.add_field(name="Permissions", value=perm_list, inline=False)
embed.set_footer(text=footer)
embed.timestamp = datetime.now()
embed.set_thumbnail(url=user.avatar.url)
await ctx.reply(embed=embed)
yup. Rename it to message if that helps
ok so where can i store that in the command
@sick birch Here
@bot.event
async def on_member_join(member):
verifychannel = bot.get_channel(963258610815733830)
await verifychannel.send(f"{member}, verify to gain access to the server!")```
why does my join message does not do anytbing?
Code?
Enable intents
i do
!intents
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
embed.add_field(name="Server Manager Staff", value=staff_status, inline=False)
``` seems to be where it is
In both the discord developer portal and code?
Either that or embed.add_field(name="Roles List", value=roles, inline=False)
Depending on if discord 0 indexes their fields
Yea, how do I fix that?
I'm guessing roles is an empty list, and by extension and empty string
You're passing None in one field value
There is 1 role in the server
Looks like it's an intents problem where it's not giving you the proper roles maybe?
so it's not empty
Is it the default role?
Maybe if I make a role
It's the bot role
and the person you're running the command on has the bot role?
im still a bit confused when it comes to the whole role and deleting message thing lol
Take it step by step and set up a proper wait_for first
@commands.command()
@commands.is_owner()
async def leave(self,ctx, guild: discord.Guild=None):
if guild is None:
id = ctx.guild.id
guild = self.bot.get_guild(id)
await guild.leave()
print(f"Successfully left guild: {guild.name}")
else:
id = guild.guild.id()
guild = self.bot.get_guild(id)
await guild.leave()
print(f"Successfully left guild: {guild.name}")
Indentation a bit off here cos vsc
I'd also suggest making a command check
i dont know where i should put that
Remove py id = guild.guild.id()
@blissful sparrow
No I fixed it
Yeah that's good. I suggest you read the documentation for wait_for though
!d discord.Client.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.10)"). 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.10)") 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.10)") 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**...
alright
what next? il check that out in a lil
You need to get a proper wait for going first
Do you have that? With a proper check and a timeout along with error handling
Just do for the roles py user.roles[1:]
@blissful sparrow in the guild.leave in the else statement put leave(guild.id)
@commands.command()
@commands.is_owner()
async def leave(self,ctx, guild: discord.Guild=None):
if guild is None:
id = ctx.guild.id
guild = self.bot.get_guild(id)
await guild.leave()
print(f"Successfully left guild: {guild.name}")
else:
guild = self.bot.get_guild(id)
await guild.leave(guild.id)
print(f"Successfully left guild: {guild.name}")
same error
Why get the guild?
You don't need to get the guild
!d discord.ext.commands.Context returns a guild object with the guild attribute
class discord.ext.commands.Context(*, message, bot, view, args=..., kwargs=..., prefix=None, command=None, invoked_with=None, invoked_parents=..., invoked_subcommand=None, ...)```
Represents the context in which a command is being invoked under.
This class contains a lot of meta data to help you understand more about the invocation context. This class is not created manually and is instead passed around to commands as the first parameter.
This class implements the [`Messageable`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable "discord.abc.Messageable") ABC.
wdym
i have messages in the wait
You also need a check and a timeout
I want it so if I do $leave without passing guild id, itll leave the guild its in, if i do pass an id, itll leave the guild with that id
By default wait_for picks up the FIRST message it sees, regardless of where or whom it's from
which is undeseriable
oh wait u mean in the else statement?
@slate swan i need your help please, sorry if im makin you spoonfeed or annoyed, but can you show me how to make a ban command
@blissful sparrow remove the get_guild in the else statement
tried that already
https://caught-lackin-in-8k-by-cyberghost.cf/3refz7Nn
And change it to in the first part ```py
if guild is None:
await ctx.guild.leave()
Code
not tried this yet sec
How can I let my bot check if the authors id is in the text file and if not send a message like youre not in the list buddy and if hes in the list it just goes with it and does what it should do?
I use aiofiles
Ah in the second else statement, for leaving remove that and put await guild.leave()
say what now?
Not await guild.leave(guild.id)
@commands.command()
@commands.is_owner()
async def leave(self,ctx, guild: discord.Guild=None):
if guild is None:
id = ctx.guild.id
guild = self.bot.get_guild(id)
await ctx.guild.leave()
print(f"Successfully left guild: {guild.name}")
else:
await guild.leave(guild.id)
print(f"Successfully left guild: {guild.name}")
where exactly?
Wrong
what do you have till now?
i mean, did you write anything yet?
for the check could i keep it as this
no, i was working on the little plugin thing
then it popped into my mind
oh well you would have to use a member option with hikari.Member type py @lightbulb.option("member", "member to ban", type=hikari.Member) you can access it with ctx.options.member & ban the member using await ctx.options.member.ban()
so like
I tried to derive my ban command from my kick command but it didnt go to plan
just wait
@bot.command
@lightbulb.add_checks(lightbulb.owner_only)
@lightbulb.option("member", "member to ban", type=hikari.Member)
@lightbulb.command("ban", Ban a user")
@lightbulb.implements(lightbulb.SlashCommand)
async def ban(ctx: lightbulb.Context) -> None:
await ctx.respond(ctx.options.member.ban()```
nah, you dont create a response with it
ohh
first, you need to ban that user py async def ban(context): await context.options.member.ban() # then create a response if you want to await context.respond(...)
and you didnt open the " in the command decorator
The quotes are messed up btw.
@lightbulb.command("ban", Ban a user")
# should be
@lightbulb.command("ban", "Ban a user")
yeah
if you dont like using context.options again and again, you may use the pass_options arg to the command decorator, makes life easier
@bot.command
@lightbulb.add_checks(lightbulb.owner_only)
@lightbulb.option("member", "Member to ban", type=hikari.Member)
@lightbulb.command("ban", "Ban a user")
@lightbulb.implements(lightbulb.SlashCommand)
async def ban(context):
await context.options.member.ban()
await context.respond(Banned User Successfully)```
afk brb
@option("my_arg", "description")
@command("command", "desc", pass_options=True)
@implements(...)
async def command(context, my_arg):
``` is another way to access the arg
correct, except for the respond part needs to be a string or any object that .respond takes with its kwarg
ik sorry i just forget that usually
thanks so much man, im indebted to you
pleasure
how would i add buttons using reactions to an embed?
Add reactions to the embed and use wait_for to wait for the users reaction and change the embed depending on what the user wants
could i see an example of the waiting for?
!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.10)"). 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.10)") 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.10)") 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**...
so.... await wait_for(event)?
await ctx.send("What's your name?")
msg = await bot.wait_for("message", check = lambda message: message.author == ctx.author)
await ctx.send(f"Hello {msg.content}")
That sucked absolute ass typing with only one hand
ok so who will be the author when the bot is doing a command?
and what about multiple reactions
The person who invoked the command
ok and how do i check for multiple reactions line true or false
You can have variables set to boolean values
And just switch them inside of a if statement
what will it return when using it with reactions?
The reaction
like the emoji?
its always reaction& user., or payload if you use the raw event
Oh yeah right user
I forgot about user
TypeError: GatewayBot.wait_for() got an unexpected keyword argument 'check'
ye
Bruh
Well shit
I can't help you
I got no clue how to help with hikari
Maybe ask sarth i saw him helping with hikari
you gotta use the predicate kwarg instead of check
Good luck sarth
what unit the the timeout in?
reaction_event = await bot.wait_for(hikari.ReactionAddEvent, predicate=your_check, timeout= float/int)```
i meant like seconds/minutes
Seconds , and it's 180 by default
ok
i dont get it request is clearly None yet it doesnt print rundr2
why the () around the placeholders
remove them, and make sure you get the correct data type there
you can use the sqlite viewer extension to check that
like the db browser?
DB Visualiser for all databases is good ๐
nah vsc has an extension for viewing sqlite files im talking about that
But VCS has some extensions for viewing databases inside
Not very convenient imho cuz you can't execute scripts
Maybe you can but I didn't find it
true, thats a read-only
so uh the datatype for computer is text
expand the user_id column so you can see if the complete user id is entered
i doubt if the full id was inserted since INT doesnt allow that
it matches cause
can i see your "CREATE TABLE" statement?
Did you remove those brackets in your queries
i just used the db browser to create the table btu sure
but the request is none
mhm then those brackets may be the issue, remove them
so why isnt it executing the if statemtn
even without the brackets wont the result be the same?
so the request variable is ((None))
if None rone this but it didnt
which is None
because request is (None,)
yea and python can read through tuples
!e py print(None == (None,)) is false
@slate swan :white_check_mark: Your eval job has completed with return code 0.
False
because that was just None
ty that worked
how to add?
for fn in os.listdir("./cogs"):
if fn.endswith(".py"):
bot.load_extension(f"cogs.{fn[:-3]}")
```AttributeError: module 'cogs.venture' has no attribute 'setup'
How to check if a URL contains audio file...?
For example how to differentiate between
https://audd.tech/example.mp3
and this
https://open.spotify.com/track/6nLEcwqpVNOGRGtnV2pElc?si=idk.mp3
thanks to you , i made a kick command, thanks agains sarth, and is there a py await context.options.member.mute thing?
msg = await bot.wait_for(hikari.ReactionAddEvent, timeout=180) how do i check who added the reaction
Not a mute, but yes you can timeout a member
msg.author_id gives you the id of the usee
Get the user from cache using bot.cache.get_user(id)
for hikari right
Yessir
AttributeError: 'GuildReactionAddEvent' object has no attribute 'author_id'
Try user_id
right, so i was reading a lightbulb documentation and is there a way to make a meme command such as dank memers?
File "/home/runner/tester/cogs/rostermenu.py", line 86, in rostermenu
await ctx.respond(embed=embed)
AttributeError: 'Context' object has no attribute 'respond'
``` any idea?
event.author.id```
could you please specify what LINE 86 is?
and what are you trying to make? if its an embed i can give you an example
i know how to make an embed its saying context has no attriubite to respond
e.g await ctx.respond(embed=embed)
no
above the await?
just async def ping(ctx)
thats the problem
async def rostermenu(self, ctx):
async def rostermenu(ctx: lightbulb.Context) -> None:
try that
pycord
ohhh
beta branch
context.send /reply in discord.py
well, pycord is heavily outdated
!?
pycord is a fork of discord.py so basically you cant do context.respond there
well you wont usually find somebody who can stimulate what your looking for in a heavily outdated library
The irony that pycord has the worst naming of classes and functions out of all forks
That's for application command context , not a general one
ah
@slash_command seems pretty easy too me, actually id say disnake or discord components does
@mossy charmbulb.command
basically the same
Well py lightbulb.SlashCommand is not bad either
guess so.
i could just use visual to just replace everything
just use hikari. all we can say
and btw, sarth, have you used dank memer?
Yep
alright, then you do know the meme command right?
well i tried to replicate it in lightbulb but its giving me errors
tried to do a little plugins thing
show code
import hikari
import lightbulb
fun_plugin = lightbulb.Plugin("Fun")
@fun_plugin.command
@lightbulb.command("fun", "All the entertainment commands you'll ever need")
@lightbulb.implements(lightbulb.SlashCommandGroup, lightbulb.PrefixCommandGroup)
async def fun_group(ctx: lightbulb.Context) -> None:
pass # as slash commands cannot have their top-level command ran, we simply pass here
@fun_group.child
@lightbulb.command("meme", "Get a meme")
@lightbulb.implements(lightbulb.SlashSubCommand, lightbulb.PrefixSubCommand)
async def meme_subcommand(ctx: lightbulb.Context) -> None:
async with ctx.bot.d.aio_session.get(
"https://meme-api.herokuapp.com/gimme"
) as response:
res = await response.json()
if response.ok and res["nsfw"] != True:
link = res["postLink"]
title = res["title"]
img_url = res["url"]
embed = hikari.Embed(colour=0x3B9DFF)
embed.set_author(name=title, url=link)
embed.set_image(img_url)
await ctx.respond(embed)
else:
await ctx.respond(
"Could not fetch a meme :c", flags=hikari.MessageFlag.EPHEMERAL
)
def load(bot: lightbulb.BotApp) -> None:
bot.add_plugin(fun_plugin)```
The error?
The / at end too
Why does my bot only read the newest line with aiofiles?
In the second screenshot you can see i am on the list but my bot doesnt read all lines
right
Did it work?
How do you run your code? The play button?
i might juse just switch back to discord.py..
Yep, ive also tried py bot.py
its a seperate branch but it could work!
please do mate
use the run option on the top of vscode
i do, i also do it with and without debugging
would you recon disnake to me atleast!?
brb
i honestly blame the owner for all this mishap.
If I were to sort it accordingly to my preference it would be
- hikari
- Disnake
- discord.py master
- pycord
Causing for everyone to switch libs then he wants to come back and then not be friendly to forks. even if their fork is lisenced under MIT
discord.py app commands are too weird like what in the world is a CommandTree
anyway, is there a way to make a meme command like dank memers without an extension
but im happy with my results anyway
i dont know i hate disnake classes maybe i didn't get too the part of the docs i wanted too.
Ill check it out once more.
What was the thing actually?
Yeah ofcourse
how
it would be same as discord.py or any other library except for how you send it
๐ง = 0.1
finally got my little blackjack minigame working with its visuals 
can only fit 5 cards on screen but thatll have to do
for regular commands or slash or inter?
Nah I'm Asking what did you not find
Look cool ngl
Nothing in particular something that spikes me and makes me want too use it. Its usually something I dont understnad
Pycord spiked me with their new beta release, where commands automatically can get translated to both slash and regular command
and their auto components pagination. I wish discord had a offical libaries.
Ignoring exception in on_ready
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/nextcord/client.py", line 415, in _run_event
await coro(*args, **kwargs)
File "/Volumes/FLASH DRIVE/Palisade2.0/main.py", line 103, in on_ready
setattr(bot, "db", await aiosqlite.connect("levels.db"))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/aiosqlite/core.py", line 137, in _connect
self._connection = await future
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/aiosqlite/core.py", line 102, in run
result = function()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/aiosqlite/core.py", line 397, in connector
return sqlite3.connect(loc, **kwargs)
sqlite3.OperationalError: unable to open database file
???
What would you guys say about NextCord?
please np
did you do it anytime before?
I see
is it more updated?
never, my brain amounts to 0.69
nextcord? No
no
so its below pycord?
oh hell yea
i mean its a very good alternative to discord.py
Hikari--
Discord.py (M)--
Pycord--
Disnake--
NextCord--
lets say "competitor"
I think im going to select disnake.
๐
more features
I believe pycord has the best features.
like?
it may not be updated but pycord has the best features imo
๐๐ผ
the ones ive listed before **addition features not like slash_commands dropdowns **
nextcord also have those
i said not like
like autopagination, and like automatic converting
!pip discord-ext-menus
An extension module to make reaction based menus with discord.py
The auto pagination
Talking about paginators, https://hikari-lightbulb.readthedocs.io/en/latest/api_references/utils.html#module-lightbulb.utils.nav
could u show me a callback example
in hikari
not my forte unfortunately
A command callback?
my brain isnt smart enough for hikari
someone help?
Sarth, and dont worry this is the last time i'll annoy you, but could you show me a example or create an example of a meme command
Whats a way to see if @commands.check_any() has been satisfied?
How do I react to a message with the message ID?
!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.
And use .add_reactions on it
im using @bot.command @lb.command('quiz', 'quiz') @lb.implements(lb.PrefixCommand) async def quiz(ctx): how could i get the id of the channel from ctx?
how to get guild id?
ctx.channel_id ( not sure if works)
ctx.get_channel().id (will work)
what are the reqirements needed to run a basic bot?
wdym?
why does it not detect anyone but the first guy?
why name not id?
i tried to use the id but it didnt change anything
Requirements.txt
?
How is the list layed out like this? content=[2132547,76655689]
Pro Coders Here 
What pip packets do i need
Do u mean
content = ["id", "id"]?
My list is a .txt file with a member name every new line @echo wasp
Go Ahead
It's too much but you need discord module
do I need a Database?
nope
Your Wish
Np
Yep but " " is not needee it an int
ok but how could i make it so my other command could add an id to it / is it possible? i have a command to add people to the list
try this i use to have a user .txt file py with open('User list.txt','r') as file: ids = tuple((int(x.strip()) for x in file.readlines() if x.strip().isdecimal())) if ctx.message.author.id in ids:
try what i sent ya and adding is fine just add id not name
ah yes dpy
It worked! Thank you very much!
np i had others help me before i might aswell pass it on
also just a reminder never do name because you can have 2 alike if you use id never will happen
ok
nextcord...
how do i reply to a message in discord.py with just it's id?
Heroku requirements.txt needed to run a discord bot what all them
let me look it up
LOL, you think I haven't already?
well i haven't done it before so i'm looking
what are you trying todo
@slate swan
!d discord.Message.reply
await reply(content=None, **kwargs)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A shortcut method to [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") to reply to the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message").
New in version 1.6.
Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") or [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError "(in Python v3.10)") instead of `InvalidArgument`.
I already figured it out.
using requests how can I change the color of the embed wehook?
ok
wdym using json
like sending the webhook with requests
I didn't mean to type json
what are you sending rn as a embed
just variables
discord api
@slate swan
Don't wanna use it
then you have no other way lol
you are incorrect
you specify the embed before you send it so something like this
You want to send a webhook using requests but not via discord api?

I'm not here to be scolded at ๐คท
I'm not scolding, i'm confused, you want to do something that is very hard to do.
Why can't you use discord api?
Why can't you use discord.py?
I don't see why it's so hard
I want to learn how to do it with requests. That way is super easy
Discord API uses requests....
embed=discord.Embed(title="hello", description="whatever")
webhook = Webhook.from_url('url-here', adapter=AsyncWebhookAdapter(session))
await webhook.send(username='Foo', embed=embed)``` something like that?
then i'm confused
Why?
why not
Because it's annoying, and you're going out of your way to make it different and the end product is the same.
walks away
๐คท here's some documentation I found if you want to actually help https://birdie0.github.io/discord-webhooks-guide
Comprehensive Guide about using Discord Webhooks
Ok.
I've sent that before. Lol.
.
not the same thing
Yes it is.
sure
comes back with ๐ฟ and sits and watches
this is the only topical channel will cooldown ๐
@slate swan If you wanna see the code I figured it out ๐
@echo wasp I just realized that the command to see all user in that list is now only showing the ids, do you know how i could make it to mentions/names again? sorry for the ping
The most active one as well.
If you want to mention them, you can just do <@id>
Or if you want name, get the user using bot.get_user(id) and use the name property
well for me i think this wont work
all the ids are in a txt file
Iterate thru content.split("\n")
That would be a list of ids
and then do a list comprehension which mentions the user's
what is the class name for custom raise error slashcommand in nextcord?
you figure it out?
yup
kk
I donโt understand this error
check the doc should be something like SlashCommandError or ApplicationCommandError or ApplicationError
It works for my other bot
But this one no
hi, I m new to discord.py , I don't know why this error coming. Help me to figure out friends.
that is a python exception btw you are trying to import two or more times, by a circular import, the same package
why does this not work? there is no error
Do u have another command name delpremium check
ehhh maybe bc u used the "a" modus?
no why should I have that?
..
idk I will check later
then how to catch the error using the on_application_command_error or on_command_error event?
can you people tell me how this works
adding images onto images AT A CERTAIN POSITION
you get the image
you place another image onto the other image at a certain coordinate
At this very moment, with unswerving and immaculate penetration, you are on the verge between being an absolute shithead and a dumbo.
Honetly, use a API Wrapper and a Command Handler correctly, ffs
please explain
and how do i do that
but do that in code
thats the point
I just did
This may be a stupid question but is it possible for example to make a help command with drop menus an ephemeral?
yes

Hi friends, how can i get the channel with webhooks?
a=webhook.channel(825463704384438283)
webhook.send(f"{a}")
already figured it out on my own.
whats the library?
from discord import SyncWebhook
yea
oh your using dpy
do you NEED it with WEBHOOKS
or do you accept other methods?
right
unfortunately i don't understand webhooks
What do you exactly want to do, please elaborate
Intention?
i try mention other channel in 1 server
?
sorry I do not understand.
I think he meant hes trying to mention the channel through webhook
if english is not your first language perhaps use a translator
So i have 2 channel, i try mention channel 2 with channel 1 intention (in dpy -> (channel.mention) but i need this in webhook)
???
you trying to do like #discord-bots ?
You can use Discohook?
why is my bot not sending the embed? everything else works fine but it just wont send the embed
from discord import SyncWebhook
import discord
webhook = SyncWebhook.from_url("url")
a=webhook.channel(825463704384438283)
webhook.send(f"{a}")
could you show me the end result?
@slate swan
So nothing appears
yes
this would just send 825463704384438283 ?
right, what ide are you using?
so this is the mention, my bot use it
Pycharm, Visual Studio.
@tacit token you could use requests instead of discord.py
pycharm
alr, do you have a terminal, because i dont use pycharm usually
aiohttp*
yes there is a terminal
I did mine with requests ๐คท
if you have a terminal, there should be a error message, could you show us that?
Requests bad for async
works for me
If the server takes long to respond it will block your whole bot
there is no error
oh mine isn't a bot
right, just change the title of your embed to something,
Anyways if you are using requests in async app that's bad practice
i tried that and it didnt work
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/nextcord/ext/commands/core.py", line 168, in wrapped
ret = await coro(args, **kwargs)
File "/Volumes/FLASH DRIVE/Palisade2.0/main.py", line 599, in afk
await cursor.execute("INSERT INTO afk (user, guild reason) VALUE (?, ?, ?)", (ctx.author.id, ctx.guild.id, reason,))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/aiosqlite/cursor.py", line 37, in execute
await self._execute(self._cursor.execute, sql, parameters)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/aiosqlite/cursor.py", line 31, in _execute
return await self._conn._execute(fn,args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/aiosqlite/core.py", line 129, in _execute
return await future
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/aiosqlite/core.py", line 102, in run
result = function()
sqlite3.OperationalError: near "reason": syntax error
???
SQL query wrong
color is optional, the standard color is grey if there is no color specified
Print the query you are submitting
@bot.command()
async def afk(ctx, *, reason = None):
if reason == None:
reason = "No reason provided"
async with bot.db.cursor() as cursor:
await cursor.execute("SELECT reason FROM afk WHERE user = ? AND guild = ?", (ctx.author.id, ctx.guild.id,))
data = await cursor.fetchone()
if data:
if data[0] == reason:
return await ctx.send("You are already afk with the same reason!")
await cursor.execute("UPDATE afk reason = ? WHERE user = ? AND guild = ?", (reason, ctx.author.id, ctx.guild.id,))
else:
await cursor.execute("INSERT INTO afk (user, guild reason) VALUE (?, ?, ?)", (ctx.author.id, ctx.guild.id, reason,))
await ctx.send(f"You are now afk for {reason}")
await bot.db.commit()
You forgot SET
??
Right, i dont usually transpire with discord.py, i use hikari, but let me go check my code
hmm
And yeah VALUES not VALUE
title=f"",
didnt change anything
try to move the embed out of the with block
didnt work
One message removed from a suspended account.
One message removed from a suspended account.
@bot.command()
async def servericon(ctx):
embed = discord.Embed(title = f"{ctx.guild.name}'s icon", color=0x36393F)
embed.set_image(url=ctx.guild.icon)
await ctx.send(embed = embed)
why doesnt this work?
doesn't send the embed?
yeah
it doesnt send anything
and there arent any errors in the ide
Ok thought that discord had some problem with embed but mine works fine xD
One message removed from a suspended account.
i need help
when you casted the command you didn't set the guild
Can anyone help me for a code in python? So I have a jail cmd and if I get him out he has no roles roles I can write that in code that he gets his roles back when he is released
Does my bot need an extra intent for creating and deleting webhooks?
you'll have to save the list of roles which user had before beeing jailed, then loop through them and adding them back
you'll need guild_webhooks if you want to use the update webhook event
Yeah but how?
database 
I have json
json is not a storage method, json represents javascript object as text
But how do I do that in code can't you help me I'm new to the scene
Which database is better?
!d discord.Member.add_roles
this is used to add roles to a member
await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
sqlite is fine for discord bots and it is builtin in python
The guild name.
you can't define it, every guild has it's own name
can i use on_message and edit the message without using ctx?
discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") is created and sent.
This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.
Warning
Your botโs own messages and private messages are sent through this event. This can lead cases of โrecursionโ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
yea but like can i edit the message afterwards with it
can i use f string in it?
alright thanks lemme try
yea im aware of that
anyone have any bot ideas?
maybe you can fetch user by checking if the message has mentions
!d discord.Message.mentions
A list of Member that were mentioned. If the message is in a private message then the list will be of User instead. For messages that are not of type MessageType.default, this array can be used to aid in system messages. For more information, see system_content.
Warning
The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.
simple is better than complicated
simple to code but harder to use
harder to code but simple to use
two different things
what am I doing wrong with these events? They don't seem to be sending when I mute/defa/self_mute my alt, I don't think I really need to be checking if before != after but I'm doing it more out of habit```py
if before.mute != after.mute: # Member muted/unmuted
embed.title = "Muted",
embed.description = f"{'Unmuted' if after.muted else 'Muted'}",
if before.deaf != after.deaf: # Member deafened/undeafened
embed.title = "Deaf",
embed.description = f"{'Undeaf' if after.deaf else 'Deaf'}",
if before.self_mute != after.self_mute: # Member self-muted/unmuted
embed.title = "Self Muted",
embed.description = f"{'Unmuted' if after.self_mute else 'Muted'}",
if before.self_deaf != after.self_deaf: # Member self-deafened/undeafened
embed.title = "Self Deaf",
embed.description = f"{'Undeaf' if after.self_deaf else 'Deaf'}",
if before.self_stream is not after.self_stream:
embed.title = "Self Stream",
embed.description = f"{'Unstreamed' if after.self_stream else 'Streamed'}",
if before.self_video is not after.self_video:
embed.title = "Self Video",
embed.description = f"{'Unvideoed' if after.self_video else 'Videoed'}",
if before.suppress is not after.suppress:
embed.title = "Suppressed",
embed.description = f"{'Unsuppressed' if after.suppress else 'Suppressed'}",
if before.requested_to_speak_at is not after.requested_to_speak_at:
embed.title = "Requested to speak at",
embed.description = f"<t:{int(after.requested_to_speak_at)}:R> ",```
what's member.mute?
don't think I have one of those, is is the docsI'm reading https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceState
what's the event you're using?
voice state updatepy @Cog.listener() async def on_voice_state_update( self, member: Member, before: VoiceState, after: VoiceState ):https://discordpy.readthedocs.io/en/master/api.html?highlight=on_voice_state_update#discord.on_voice_state_update
Me*
This is for discord bots.
Oh
You could open a help channel #โ๏ฝhow-to-get-help , or go to another channel like #game-development or #python-discussion .
nvm figured out the issue, i wasn't using the correct mute settings to test it
guys I just made a discord bot
nice
it gives info on programming langs and gives their website link
@slate swan i making a pokemon discord bot
great. i actually have a meme bot
guys do you wanna join my server?
i need more programmers in it
if youre a pro, pls join it
Not the correct server for the same
hunter youre a pro
@commands.Cog.listener()
async def on_raw_reaction_remove(self, payload):
messageID=962844879044628510
if messageID== payload.message_id:
guild= self.bot.get_guild(payload.guild_id)
member = guild.get_member(payload.user_id)
if str(payload.emoji) == ":black_drip:":
role = get(guild.roles, name='evnt')
elif str(payload.emoji) == ":Uzi_spin:":
role = get(guild.roles, name='chat revive')
elif str(payload.emoji) == ":BlackFire:":
role = get(guild.roles, name='gw')
elif str(payload.emoji) == ":Black_LV:":
role = get(guild.roles, name=':Black_LV:')
else:
role = discord.utils.get(guild.roles, name=payload.emoji)
if role is not None:
await member.remove_roles(role)
print(f"Removed {role} from {member}.")
print(str(payload.emoji))
so i have this code here
!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.
and basically when i try to remove it
why use reactions? and not buttons?
idk
i lke reactions
send the link in my dms
what
i like reactions
more than buttons
you probably like having a bigger ratelimit as well?
isnt reactions like 1/1s
well idk
?
tl:dr Should I keep my log colours consistent across different type of logs?
Okay so I have a aesthetic question. I'm currently using discord.Colour.teal() for members joining a vc/stage, discord.Colour.dark_magenta() for members leaving a vc/stage and discord.Colour.dark_teal() for members moving between vcs/stages. I'm not too sold on the dark_teal and teal posistions so might swap them around.
This brings me onto my question: What colour(s) should I make guild mute, self mute, guild def, self deaf, self stream, self video, supressed and requested to speak? I'm thinking that the mutes should be a red but two different shades and the deafs should be greys not I'm not too sure on the stream, video etc. I'm also not sure if I should keep all of 'true' type logs in a green/teal colour, all of the 'false' logs in a red/magenta colour and 'misc' in a blue/orange colour (talking about all logs here not just vc/stage logs) as I'm currently using
diiscord.Colour.green()anddiiscord.Colour.red()for bot joining/leaving guilds respectively,diiscord.Colour.green(),diiscord.Colour.red(),diiscord.Colour.orange()anddiiscord.Colour.yellow()for my bots shard ready/disconnects/connects/resumes respectivelydiiscord.Colour.red(),diiscord.Colour.dark_orange()anddiiscord.Colour.dark_red()for message deletes/edits/bulk deletes respectively
So as you can see it's not really that consistent across my logs and I'm not sure if it should be. On one hand I think it's important to have consistencies across the logs and on the other hand I'm thinking these events are similar enough to have some crossed colours but they are also different enough not not need crossed colours.
it basically prints removed None instead of actually removing a role
yes
just use standard colors like red yellow and green so red for mutes etc or keep doing what youre doing
Ignoring exception in command afk:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/nextcord/ext/commands/core.py", line 168, in wrapped
ret = await coro(args, **kwargs)
File "/Volumes/FLASH DRIVE/Palisade2.0/main.py", line 597, in afk
await cursor.execute("UPDATE afk reason = ? WHERE user = ? AND guild = ?", (reason, ctx.author.id, ctx.guild.id,))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/aiosqlite/cursor.py", line 37, in execute
await self._execute(self._cursor.execute, sql, parameters)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/aiosqlite/cursor.py", line 31, in _execute
return await self._conn._execute(fn,args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/aiosqlite/core.py", line 129, in _execute
return await future
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/aiosqlite/core.py", line 102, in run
result = function()
sqlite3.OperationalError: near "reason": syntax error
this da error
@bot.command()
async def afk(ctx, *, reason = None):
if reason == None:
reason = "No reason provided"
async with bot.db.cursor() as cursor:
await cursor.execute("SELECT reason FROM afk WHERE user = ? AND guild = ?", (ctx.author.id, ctx.guild.id,))
data = await cursor.fetchone()
if data:
if data[0] == reason:
return await ctx.send("You are already afk with the same reason!")
await cursor.execute("UPDATE afk reason = ? WHERE user = ? AND guild = ?", (reason, ctx.author.id, ctx.guild.id,))
else:
await cursor.execute("INSERT INTO afk (user, guild, reason) VALUES (?, ?, ?)", (ctx.author.id, ctx.guild.id, reason,))
await ctx.send(f"You are now afk for {reason}")
await bot.db.commit()
this da code
not sure but i dont think that's how u make an UPDATE query
Hello, the syntax of UPDATE statement is: "UPDATE table SET column=value", you don't have the SET keyword there.
can someone tell me whats wrong with this
@commands.command()
async def ban(self, ctx, member: int, *, reason=None):
user = await self.bot.get_user(int(member))
if user in ctx.guild:
e = discord.Embed()
e.description = f"banned {user.mention}"
e.colour = 0x2f3235
await ctx.send(embed=e)
m = discord.Embed()
m.description = "you have been banned."
m.colour = 0x2f3235
await user.send(embed=m)
await ctx.guild.ban(user)
else:
e = discord.Embed()
e.description = f"banned"
e.colour = 0x2f3235
await ctx.send(embed=e)
await ctx.guild.ban(member)
it wont give an error :(( + it wont ban & send the embed
what is ur main premise with this code?
nothing, just that and uh the class thing
wait what- but it worked b4
hmm
w/o a title
Does it run?
the code? yes
like any output
it works even without a title
hmm
Embeds can have no title
bot.get_user isn't a coro
ctx.guild is a guild object so if user in ctx.guild will never be true
i see
oh
does ctx.guild.members work?
Yeah
so i should add set there?
it works tysm
Just typehint member to discord.Member so you don't have to get the member
is there a way I can iterate over all of the colours in discord.Colour? I tried for colour in discord.Colour and gotpy Ignoring exception in on_ready Traceback (most recent call last): File "C:\Users\Teagan\Documents\Coding\Zupie\env\lib\site-packages\discord\client.py", line 375, in _run_event await coro(*args, **kwargs) File "C:\Users\Teagan\Documents\Coding\Zupie\bot\cogs\events.py", line 60, in on_ready for colour in Colour: TypeError: 'type' object is not iterable
show code
Hmm i don't think showing code will be necessary for this
Snowy already said what they did already
I have, I'm literally just doing```py
from discord import Colour
for colour in Colour:```and I'm running this inside my ready event (as a test use case since testing it here was a quick way to check if the code is valid if not why not)
i want to ban members outside the server
why u want to import colour?
try via discriminator
discriminator?
Transil asking the wrong questions
?
ur 4 digit no
ik that but
You can get the user with their id and bank the user object
????
this
for use in embeds, it's just saving my namespace so I don't just dopy import discordI can just import the things I actually need in my namespace likepy from discord import Colour, Embed, app_commands
Lmfao
i dont think u need to import embed and colour
man make things easier and do from discord import *
from discord import commands ?
๐
or import discord
@supple thorn do you have any advice?
I've never seen anyone iterate through all of the different discord colours and i don't know if you even can
same here
me too
wth
