discord

DiscordAPIError: Unknown Message

拈花ヽ惹草 提交于 2019-12-02 03:14:07
I have made a freeze command using discord.js and commando, that gives the user a role, and keeps them from talking and chatting. It seems that every time I run it though, it tosses an error: (node:7352) UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Message I haven't been able to find what it is, but maybe i'm just a nub. Code: async run(message, { user }) { message.delete() const member = message.guild.member(user); if (!message.member.hasPermission("MUTE_MEMBERS")) return message.say("Sorry, but you do not have the Mute Members Permission! If you beleive this is a error, contact

Discord.py - How to make a role specific command?

浪尽此生 提交于 2019-12-02 03:12:48
I need to make a command that can only be executed by someone that has a certain role. I searched around on google and youtube to find a answer but came up with nothing hopethatsacleanwet You can add a decorator on the command to restrict it to only members with specific roles or permissions. The documentation for it is here . It would look like this: @bot.command() @commands.has_role('RoleName') async def command_name(): Keep in mind that the RoleName string you pass is case sensitive. 来源: https://stackoverflow.com/questions/49351509/discord-py-how-to-make-a-role-specific-command

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

爷,独闯天下 提交于 2019-12-02 02:59:34
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) To check for roles in on_message , you can access the author's roles attribute. if message.content.lower().startswith('/role'): user = message.author if message.channel.is_private or

Read contents of an embed message from a discord server

雨燕双飞 提交于 2019-12-01 22:13:59
Scenario : I am trying to read various fields in an embed message posted to a sever, do some processing, and log results in a DB. Testing : Using a testBot for sending relevant messages everything works when using a normal text message, but when an "embed message" is used (theoretically making it much easier to identify fields for processing etc), I can't retrieve the data. I'm at an total loss how to access the "embed" from the message object. I realize that it is about now I should pop in some code for you to examine, but I'm not even that far along ! Reading the documentation (linked to at

Discord.js setGame() not working anymore

醉酒当歌 提交于 2019-12-01 21:02:55
I have been coding my Discord bot using Discord.JS for about 2 months now and I've just recently noticed that my bot isn't saying that it's playing what I'm telling it. When I first coded the bot up until recently it worked just fine. Now the 3 discord bots I have aren't showing their games. This is the code I'm using: const Discord = require("discord.js"); const bot = new Discord.Client(); bot.on("ready", () => { console.log("Ready"); bot.user.setGame("Type !help"); } .setGame() is deprecated now but you could use .setPresence() or you could use the .setActivity() which is the same thing and

Python [Invalid syntax] with async def

我的未来我决定 提交于 2019-12-01 14:55:48
I am trying write discord bots using Python, I have come across and threw together this bot. import discord import asyncio import random client = discord.Client() inEmail = input("Email:") inPassword = input("Passwd:") async def background_loop(): await client.wait_until_ready() while not client.is_closed: channel = client.get_channel("************") messages = ["Hello!", "How are you doing?", "Testing!!"] await client.send_message(channel, random.choice(messages)) await asyncio.sleep(120) client.loop.create_task(background_loop()) client.run(inEmail, inPassword) Yet when I tried to run it, I

Python [Invalid syntax] with async def

北城余情 提交于 2019-12-01 13:41:14
问题 I am trying write discord bots using Python, I have come across and threw together this bot. import discord import asyncio import random client = discord.Client() inEmail = input("Email:") inPassword = input("Passwd:") async def background_loop(): await client.wait_until_ready() while not client.is_closed: channel = client.get_channel("************") messages = ["Hello!", "How are you doing?", "Testing!!"] await client.send_message(channel, random.choice(messages)) await asyncio.sleep(120)

Discord bot check if user is admin

帅比萌擦擦* 提交于 2019-12-01 12:11:08
Hi i'm new to python coding with discord and I have tried to make a command that tells the user if they are a admin or not but well... its not working in the slightest @client.command(name="whoami",description="who are you?") async def whoami(): if message.author == client.user: return if context.message.author.mention == discord.Permissions.administrator: msg = "You're an admin {0.author.mention}".format(message) await client.send_message(message.channel, msg) else: msg = "You're an average joe {0.author.mention}".format(message) await client.send_message(message.channel, msg) I then get this

Permission System for Discord.py Bot

你。 提交于 2019-12-01 04:25:31
I am in the process of making a discord bot using discord.py and asyncio. The bot has commands like kick and ban which obviously should not be available to normal users. I want to make a simple system which will detect what permissions the user's role has using ctx.message.author to get the user who sent the command. I do not want the bot to detect a specific role name as these vary across servers. I also prefer not to have multiple files for the bot to keep it simple. I have seen the discord.py documentation and various other sources but none contain examples of how to implement the various

Permission System for Discord.py Bot

╄→гoц情女王★ 提交于 2019-12-01 02:43:54
问题 I am in the process of making a discord bot using discord.py and asyncio. The bot has commands like kick and ban which obviously should not be available to normal users. I want to make a simple system which will detect what permissions the user's role has using ctx.message.author to get the user who sent the command. I do not want the bot to detect a specific role name as these vary across servers. I also prefer not to have multiple files for the bot to keep it simple. I have seen the discord