discord

Discord.js reply to message then wait for reply

风流意气都作罢 提交于 2019-12-03 22:16:16
问题 Right so what i want my bot to do is wait for a message from the user so "!spec" when it gets that message i want it to respond with "See or Change?" then wait for you to type back "see" or "change" but i cant get it to work, the docs arent clear to me and im not sure on how to do it. this has to be able to work in PM as i dont want to spam the discord with what i plan to do. i have already tried this: if (command === 'spec'){ message.author.send("See or Change?"); const collector = new

Runtime error: Event loop is running

匿名 (未验证) 提交于 2019-12-03 02:56:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I get the following error when I call the function send_message . Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner self.run() File "/usr/lib/python3.4/threading.py", line 868, in run self._target(*self._args, **self._kwargs) File "/home/joffe/Documents/discord/irc/ircbot.py", line 44, in get_message mydiscord.send_message(line[1]) File "/home/joffe/Documents/discord/irc/mydiscord.py", line 37, in send_message client.loop.run_until_complete(client.send

TypeError: send() takes from 1 to 2 positional arguments but 3 were given

空扰寡人 提交于 2019-12-03 00:05:01
问题 Here is part of code @client.event async def on_message(message): # we do not want the bot to reply to itself if message.author == client.user: return # The command /patch return a link with the latest patch note if message.content.startswith('/patch'): await message.channel.send(message.channel, 'Last patchnotes: https://www.epicgames.com/fortnite/en/news') # The command /rank return attribute a rank according to the K/D of the user used discord.py when you type /patch here's what the

Discord.js // Filtering message startsWith and work around DiscordAPIError for bulkDelete

孤街醉人 提交于 2019-12-02 20:40:19
问题 This is my current code. Credit goes to @André Dion for the help. if (message.channel.type == 'text') { message.channel.fetchMessages().then(messages => { const botMessages = messages.filter(msg => msg.author.bot) message.channel.bulkDelete(botMessages); messagesDeleted = botMessages.array().length; // number of messages deleted // Logging the number of messages deleted on both the channel and console message.channel.send("Deletion of messages successful. Total messages deleted: " +

Issue saving message to json file discord.py rewrite

淺唱寂寞╮ 提交于 2019-12-02 18:35:55
问题 I am attempting to save the most recent message of every user to a JSON file attached to their user ID. Something will be written to the file but it's not the raw message. async def on_message(self, msg): if msg.author == self.client.user: return with open("users.json") as f: users = json.load(f) users[str(msg.author.id)]['response'] = str(msg) with open('users.json', 'w') as f: json.dump(users, f) I expect the output to be the raw message of what the user sends but instead I get something

heroku deployment, libopus not found

时间秒杀一切 提交于 2019-12-02 18:24:26
问题 I am trying to host a discord music bot in heroku, but even if it works fine in my local machine, it doesnt seem to be able to find the libopus library deployed. Here is my requirements.txt file: aiohttp==1.0.5 async-timeout==2.0.1 beautifulsoup4==4.6.0 certifi==2018.1.18 cffi==1.11.5 chardet==3.0.4 cycler==0.10.0 discord.py[voice]==0.16.12 matplotlib==2.1.0 multidict==4.1.0 numpy==1.13.3 opuslib==3.0.1 pycparser==2.18 PyNaCl==1.0.1 pyparsing==2.2.0 python-dateutil==2.6.1 pytz==2017.3 scikit

Trying to create a Discord Welcome/Leave Bot

a 夏天 提交于 2019-12-02 18:15:32
问题 I'm trying to create a bot that publicly and privately (via DM) welcomes a new user to a Discord server AND sends a message to the Moderator channel when a user leaves the server. I can get the welcome dm and welcome message working, but when I add the code after #Mod Leave Announcement nothing happens. import all necessary commands and libraries import discord import asyncio import logging @client.event async def on_ready(): print('logged in as') print(client.user.name) print(client.user.id)

Discord.py Invalid arguments inside member.server_default_channel

試著忘記壹切 提交于 2019-12-02 16:48:15
问题 My current code is @client.event async def on_member_join(member): serverchannel = member.server.default_channel msg = "Wuss poppin', {0}. Welcome to {1}".format(member.mention, member.server.name) await client.send_message(member.server.default_channel, msg)` @client.event async def on_member_remove(member): serverchannel = member.server.default_channel msg = "Well. Cya, {0}!".format(member.mention) await client.send_message(serverchannel, msg) As well as the other necessary lines (like

Did Discord.py change its API?

流过昼夜 提交于 2019-12-02 14:54:05
For some reason the code that I have for a Discord bot worked perfectly fine just a few months ago, but now I am getting something saying that 'Bot' has no attribute to certain commands like 'say' discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Bot' object has no attribute 'say' Yes. discord.py version 1.0, the "rewrite" version, was officially released on April 8th, and has supplanted the older "async" version 0.16. You should review the migration guide in the documentation to familiarize yourself with the changes. 来源: https://stackoverflow.com

How to check if a user has a specific role in on_message?

不羁岁月 提交于 2019-12-02 13:51:52
问题 Currently I have a bot will give you a role if you do a command. I want to make the bot check if the user that does the command has a specific role. As of now I've only seen people do it with permissions. Basic examples would be also great! if message.content.lower().startswith('/role'): user = message.author role = discord.utils.get(user.server.roles, id="437923291047526402") await client.add_roles(user, role) 回答1: To check for roles in on_message , you can access the author's roles