I copied my bot to another project and didn't change any code, when I startup my bot it shows:
Traceback (most recent call last):
File "main.py", line 15, in <module>
slash = SlashCommand(bot, sync_commands=True)
File "/home/runner/dcbot-Jiang-Ying/venv/lib/python3.8/site-packages/discord_slash/client.py", line 96, in __init__
raise error.DuplicateSlashClient("You can't have duplicate SlashCommand instances!")
discord_slash.error.DuplicateSlashClient: You can't have duplicate SlashCommand instances!
and this is my line 15:
bot = commands.Bot(command_prefix='sl')
slash = SlashCommand(bot, sync_commands=True)
How can I solve this problem?
Related
Hi I'm trying to make an executable using py2exe, I checked my script but cannot find the actual issue why below error is keep getting pop-up during building of exe
Building 'dist\py.exe'.
Traceback (most recent call last):
File "C:\Users\User\PycharmProjects\Test\pyexe\setup.py", line 15, in <module>
freeze(
File "C:\Python39\lib\site-packages\py2exe\__init__.py", line 176, in freeze
builder.build()
File "C:\Python39\lib\site-packages\py2exe\runtime.py", line 254, in build
self.build_archive(exe_path)
File "C:\Python39\lib\site-packages\py2exe\runtime.py", line 479, in build_archive
base = dist_path.rsplit('\\', 1)[0]
AttributeError: 'NoneType' object has no attribute 'rsplit'
Below is my setup.py script
from py2exe import freeze
from py_version import VERSION, DESCRIPTION # This is my own script
freeze(
console=[{"script": "py.py"}],
options={
"py2exe": {
"dist_dir": "dist",
"bundle_files": 1, # bundle as much as possible
"compressed": True,
}},
version_info={"version":VERSION,
"description":DESCRIPTION,
"company_name":"Priyanshu Kumar",
"copyright":"Opensource, credit goes to David Manthey",
"product_name":"Stand-Alone Python3 Interpreter",
"product_version":VERSION},
zipfile=None)
UPDATE:
I was searching on google for help and found that it should be <<<zipfile="None">>> instead of <<<zipfile=None>>>.
I changed it in my code but now got new error
Traceback (most recent call last):
File "C:\Users\User\PycharmProjects\Test\pyexe\setup.py", line 29, in <module>
options={
File "C:\Python39\lib\site-packages\py2exe\__init__.py", line 176, in freeze
builder.build()
File "C:\Python39\lib\site-packages\py2exe\runtime.py", line 273, in build
self.build_archive(libpath, delete_existing_resources=True)
File "C:\Python39\lib\site-packages\py2exe\runtime.py", line 397, in build_archive
resource.add(type=os.path.basename(pydll), name=1, value=pydll_bytes)
File "C:\Python39\lib\site-packages\py2exe\resources.py", line 49, in add
raise WindowsError(details) from None
OSError: [WinError 87] The parameter is incorrect.
Press any key to continue . . .
I'm trying to get the 4-digit tag of the person who used the command !hours, but discord won't recognize user.tag
import discord
from discord import message
from discord.ext import commands
client = commands.Bot(command_prefix = '!')
##########HOURS##########
chung_victor = [21, 10]
##########HOURS##########
# chung_victor
if usertag == 5308:
h = chung_victor[0]
m = chung_victor[1]
await ctx.send(f'> You currently have {h} hours and {m} minutes!')
And when I use !hours, I get the error message
Ignoring exception in command hours:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 36, in hours
usertag = message.user.tag
AttributeError: module 'discord.message' has no attribute 'user'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'discord.message' has no attribute 'user'
Well, as you see to get user name you need to use it as user.name and same goes for the discriminator user.discriminator. You can refer to the code below :
#bot.command()
async def test(ctx, member : discord.Member, *,reason = None) :
user = member.discriminator
await ctx.send(f" User Tag is : {user} ")
In the example above, I set a command test and user must tag someone after a command like:
!test #Victor Chung and ! is a command_prefix.
Thank You :)
I was making a bot just for fun and tested it on my Test Server and everything worked perfect. But when I try to get it into another server it crashes.
I get this in the cmd:
Traceback (most recent call last):
File "botardo.py", line 19, in <module>
client.run('token')
File "C:\Users\kakob\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 598, in run
return future.result()
File "C:\Users\kakob\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 579, in runner
await self.start(*args, **kwargs)
File "C:\Users\kakob\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 543, in start
await self.connect(reconnect=reconnect)
File "C:\Users\kakob\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 457, in connect
await self._connect()
File "C:\Users\kakob\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 421, in _connect
await self.ws.poll_event()
File "C:\Users\kakob\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\gateway.py", line 469, in poll_event
await self.received_message(msg)
File "C:\Users\kakob\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\gateway.py", line 423, in received_message
func(data)
File "C:\Users\kakob\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\state.py", line 663, in parse_guild_create
guild = self._get_create_guild(data)
File "C:\Users\kakob\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\state.py", line 641, in _get_create_guild
return self._add_guild_from_data(data)
File "C:\Users\kakob\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\state.py", line 255, in _add_guild_from_data
guild = Guild(data=guild, state=self)
File "C:\Users\kakob\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\guild.py", line 280, in __init__
self._from_data(data)
File "C:\Users\kakob\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\guild.py", line 391, in _from_data
self._sync(guild)
File "C:\Users\kakob\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\guild.py", line 420, in _sync
self._add_channel(VoiceChannel(guild=self, data=c, state=self._state))
File "C:\Users\kakob\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\channel.py", line 504, in __init__
self._update(guild, data)
File "C:\Users\kakob\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\channel.py", line 535, in _update
self._fill_overwrites(data)
File "C:\Users\kakob\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\abc.py", line 271, in _fill_overwrites
self._overwrites.append(_Overwrites(id=overridden_id, **overridden))
TypeError: __new__() got an unexpected keyword argument 'deny_new'
I've seen some other posts about this error, but what most intrigues me is that it works on my Test server but not on any other. Any ideas?
Thanks!
Reinstalling discord.py should fix the problem
I am getting the below error while restoring the couchbase database to my local mac from a server.
Traceback (most recent call last):
File "/Applications/Couchbase Server.app/Contents/Resources/couchbase-core/lib/python/cbrestore", line
12, in <module>
pump_transfer.exit_handler(pump_transfer.Restore().main(sys.argv))
File "/Applications/Couchbase Server.app/Contents/Resources/couchbase-core/lib/python/pump_transfer.py", line 80, in main
rv = pumpStation.run()
File "/Applications/Couchbase Server.app/Contents/Resources/couchbase-core/lib/python/pump.py", line 136, in run
rv = self.transfer_bucket_msgs(source_bucket, source_map, sink_map)
File "/Applications/Couchbase Server.app/Contents/Resources/couchbase-core/lib/python/pump.py", line 233, in transfer_bucket_msgs
source_map)
File "/Applications/Couchbase Server.app/Contents/Resources/couchbase-core/lib/python/pump_bfd.py", line 546, in total_msgs
rv, db, ver = connect_db(x, opts, CBB_VERSION)
ValueError: need more than 2 values to unpack
Any help is appreciated.
Thanks,
Emraan
I am trying to use rqt_graph in ROS kinetic and I am getting the following error. I am not sure what is causing it and have no idea how to fix it.
It seems to be a problem with an undefined symbole but not sure how this would happen.
rosrun rqt_graph rqt_graph
Traceback (most recent call last):
File "/opt/ros/kinetic/lib/rqt_graph/rqt_graph", line 8, in <module>
sys.exit(main.main(sys.argv, standalone='rqt_graph.ros_graph.RosGraph'))
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rqt_gui/main.py", line 59, in main
return super(Main, self).main(argv, standalone=standalone, plugin_argument_provider=plugin_argument_provider, plugin_manager_settings_prefix=str(hash(os.environ['ROS_PACKAGE_PATH'])))
File "/opt/ros/kinetic/lib/python2.7/dist-packages/qt_gui/main.py", line 340, in main
from python_qt_binding import QT_BINDING
File "/opt/ros/kinetic/lib/python2.7/dist-packages/python_qt_binding/__init__.py", line 55, in <module>
from .binding_helper import loadUi, QT_BINDING, QT_BINDING_MODULES, QT_BINDING_VERSION # #UnusedImport
File "/opt/ros/kinetic/lib/python2.7/dist-packages/python_qt_binding/binding_helper.py", line 252, in <module>
getattr(sys, 'SELECT_QT_BINDING_ORDER', None),
File "/opt/ros/kinetic/lib/python2.7/dist-packages/python_qt_binding/binding_helper.py", line 98, in _select_qt_binding
raise ImportError("Could not find Qt binding (looked for: %s):\n%s" % (', '.join(["'%s'" % b for b in binding_order]), '\n'.join(error_msgs)))
ImportError: Could not find Qt binding (looked for: 'pyqt', 'pyside'):
ImportError for 'pyqt': /usr/lib/python2.7/dist-packages/PyQt5/QtCore.x86_64-linux-gnu.so: undefined symbol: _ZTI13QFileSelector
Traceback (most recent call last):
File "/opt/ros/kinetic/lib/python2.7/dist-packages/python_qt_binding/binding_helper.py", line 89, in _select_qt_binding
QT_BINDING_VERSION = binding_loader(required_modules, optional_modules)
File "/opt/ros/kinetic/lib/python2.7/dist-packages/python_qt_binding/binding_helper.py", line 131, in _load_pyqt
_named_import('PyQt5.%s' % module_name)
File "/opt/ros/kinetic/lib/python2.7/dist-packages/python_qt_binding/binding_helper.py", line 111, in _named_import
module = builtins.__import__(name)
ImportError: /usr/lib/python2.7/dist-packages/PyQt5/QtCore.x86_64-linux-gnu.so: undefined symbol: _ZTI13QFileSelector
ImportError for 'pyside': /usr/lib/x86_64-linux-gnu/libQt5Network.so.5: undefined symbol: _ZN16QLoggingCategoryD1Ev
Traceback (most recent call last):
File "/opt/ros/kinetic/lib/python2.7/dist-packages/python_qt_binding/binding_helper.py", line 89, in _select_qt_binding
QT_BINDING_VERSION = binding_loader(required_modules, optional_modules)
File "/opt/ros/kinetic/lib/python2.7/dist-packages/python_qt_binding/binding_helper.py", line 163, in _load_pyside
_named_import('PySide2.%s' % module_name)
File "/opt/ros/kinetic/lib/python2.7/dist-packages/python_qt_binding/binding_helper.py", line 111, in _named_import
module = builtins.__import__(name)
ImportError: /usr/lib/x86_64-linux-gnu/libQt5Network.so.5: undefined symbol: _ZN16QLoggingCategoryD1Ev
code here
From What I can See In The Log Your pyqt and main Qt5 libs are missing And It's Not ROS Based Error
I Suggest You Install Or Reinstall Those Libs and Make Sure That Python Can Find Them