my test account have a selfbot And no matter how hard I tried I couldn't figure out how to send a friend request
My selfbot can't send a friend request to someone.
My code :
#bot.command()
async def FR(ctx):
with open("id.txt") as infile:
for line in infile:
try:
id = int(line)
user = bot.get_user(id)
await user.friends(id)
except:
print("error")
My error : discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'friends'
How do I send a friend request?
You can use any module as long as it is python and for selfbot
I searched everywhere but could not find an answer to my question please help me
Related
I am using Replit to make a discord bot.
if msgtxt in listBadWords:
await message.channel.send(mention + ", your message has been reported to Arunga")
await message.channel.send("Please do not repeat the same mistake again. Do not say bad words!")
user = client.get_user(int(userid))
await user.send("Arunga, someone said a bad word!")
listBadWords contains a list of bad words. I want to send a dm to the owner, Arunga, saying 'Someone said a bad word!' But when I run the code, and test it out, an error comes
AttributeError:'NoneType' object has no attribute 'send' for
await user.send("Arunga, someone said a bad word!")
I did put the user is in userid, I just didn't want to post the id here.
How do I fix this? Also, this is under async def on_message():
This is because User has no method send, Member has that, so What I did was get the owner of the server (which stored in member) and then send the message.
So I am trying to create a code that bans a member for banning a member without being whitelisted, here is the code.
#client.event
async def on_member_ban(guild, user):
with open('whitelisted.json') as f:
whitelisted = json.load(f)
async for banner in guild.audit_logs(limit=1, action=discord.AuditLogAction.ban):
if str(banner.user.id) in whitelisted[str(guild.id)]:
return
await guild.ban(banner.user, reason="Banning too many members")
return
The error occurs on this line
whitelisted = json.load(f)
The code worked perfectly fine without the json part but I need it since if someone is whitelisted then I don't want them to get banned.
Here is the exact error message "json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)"
The json file was empty so all I had to do was put the "{}" in the file.
I have implemented my own functions/checks in my bot. Anyway, there is no normal AttributeError as output in the console, but for example: 'NoneType' object has no attribute 'requested_by', so without the AttributeError, because it is my own function.
Is there a way to output this error also via bot and possibly handle it with a try/except statement? (I did try it without success)
Here is an example:
#commands.command(aliases=["disconnect"])
#commands.guild_only()
#commands.check(is_audio_requester) # check what it is about
async def leave(self, ctx):
"""Leaves the voice channel, if currently in one."""
client = ctx.guild.voice_client
state = self.get_state(ctx.guild)
if client and client.channel:
await client.disconnect()
del self.states[ctx.guild.id]
else:
raise commands.CommandError("Not in a voice channel.")
await ctx.send(
embed=discord.Embed(title=":wave::skin-tone-3: I left the voice channel.",
color=self.bot.get_embed_color(ctx.guild)))
And partly I still get, for whatever reason:
'NoneType' object has no attribute 'requested_by'
The function that causes the error:
async def is_audio_requester(ctx):
"""Checks that the command sender is the song requester."""
music = ctx.bot.get_cog("Music")
state = music.get_state(ctx.guild)
permissions = ctx.channel.permissions_for(ctx.author)
if permissions.administrator or state.is_requester(ctx.author):
return True
else:
raise commands.CommandError(
"You need to be the song requester to do that.")
(None of this is printed!)
I can't handle this error and then I may have to remove the bot from the channel or restart it. If I execute a command leave without the commands.check it works of course. Is there any way to fix this?
I already tried my own custom errors via leave.error, but that doesn't seem to work. Even passing something like if XXX is None did not work, as expected. I can also not use the Cog.cog.command_error docs in this case, at least that is what it looks like.
So I have ran into a problem where I get this error. In the documentation there is clearly a message attribute.
Here is my code (a part of it which doesn't work):
#client.command()
async def reg(message, oktaz):
message.message.delete()
How could I fix this?
Your code worked for me, except it wouldn't delete unless I added await on message delete (message.message.delete() -> await message.message.delete()), but even if I didn't add await, I wouldn't get that type of error. The only problem why it wouldn't delete the message for you is because you didn't add await. You shouldn't be getting an error saying "type object 'Context' has no attribute 'message'" if I'm correct. Are you sure you're not getting the error from a different part of the code that isn't the one you gave? Or maybe while pputting the code in stackoverflow you removed the part where the error is coming from in the reg command? Or you made a change but never saved?
#client.command()
async def reg(message, oktaz):
await message.message.delete()
ctx is the first parameter of every command. So you should change your code to this:
#client.command()
async def reg(ctx, message, oktaz):
await ctx.message.delete()
I want to delete a singular message when triggered but I cannot figure it out. I got purge working with await ctx.channel.purge but that's not what I want since that requires an amount
The old version was written like await self.bot.delete_message(ctx.message) but that now brings the error object has no attribute 'bot'
Reading the documentation all I could find was Message.delete but that brings the error: NameError: name 'Message' is not defined
I am sure this is a simple solution but I cannot work it out. Thanks in advance
My current code is:
#commands.command(pass_context=True)
async def say(self, ctx, *args):
'''Make Bot repeat your messages'''
mesg = ' '.join(args)
await Message.delete(ctx.message)
await ctx.send(mesg)`
If you are talking about the message that triggered the command, then you can do:
await ctx.message.delete()
You can use await message.delete() to delete the trigger message
(for example, user sends !say hi, bot says hi, and it deletes the user's message "!say hi")
really late here but ok