discord

Command to send text to a specific channel

孤街醉人 提交于 2019-12-11 04:51:49
问题 I want to make a command that sends the text to a channel of my choosing. Example: !command "text" Then the "text" is sent to the channel I chose. 回答1: That's the same code from this thread, I just modified a little part as I told you in the comments. client.on('message', msg => { if (msg.guild && msg.content.startsWith('/log')) { let text = msg.content.slice('/log'.length); // cuts off the /log part let channel = msg.guild.channels.find('name', 'channel_name_here'); if (channel) channel.send

Using find_all in BS4 to get text as a list

拟墨画扇 提交于 2019-12-11 04:38:06
问题 I'll start by saying I'm very new with Python. I've been building a Discord bot with discord.py and Beautiful Soup 4. Here's where I'm at: @commands.command(hidden=True) async def roster(self): """Gets a list of CD's members""" url = "http://www.clandestine.pw/roster.html" async with aiohttp.get(url) as response: soupObject = BeautifulSoup(await response.text(), "html.parser") try: text = soupObject.find_all("font", attrs={'size': '4'}) await self.bot.say(text) except: await self.bot.say("Not

How do I put a member's image and nick on embed? (w/ discord.py)

人盡茶涼 提交于 2019-12-11 04:27:18
问题 I want to put the avatar and nick of the person who ran a command in the embed, something like this: requested by: (avatar) (nick) but I do not know how to start.... 回答1: sounds like you should read more documentation, here are a few links: rewrite: embed, send async: embed, send_message otherwise here is the code that I recommend using em = discord.Embed(description='requested by:\n{0}'.format(ctx.author)) em.set_thumbnail(url=ctx.author.avatar_url) # for rewrite (1.0.0a) do await ctx.send

Check if user ID exists in Discord server

夙愿已清 提交于 2019-12-11 04:11:39
问题 My Discord bot needs to check whether a user is in the server or not. I'm using node.js and discord.js. var USER_ID = randomNumbers if (client.guild.member(USER_ID).exists){ do something } Is there a way to do this? 回答1: If you have the Guild object, you can use the Guild.member() method. let guild = client.guilds.get('guild ID here'), USER_ID = '123123123'; if (guild.member(USER_ID)) { // there is a GuildMember with that ID } 回答2: This is very similar to Way to check if a channel exists and

Adding a role (autorole) on join from a json file

你。 提交于 2019-12-11 04:08:20
问题 I am fairly new to JS, and to learn I decided to make a bot for Discord, I have learned a lot and am continuing to learn. I had the idea for an "autorole". I know the conventional way of doing it. bot.on('guildMemberAdd', member => { var role = member.guild.roles.find('name', 'Member'); member.addRole(role); }); However, I want it to get the role from a .json file. The rest of the code is fine, I can write to the json with >autorole Role . I am just unsure on how to incorporate the json into

Syntax error at new Script (vm.js:51:7) whilst running code for a discord bot in javascript

做~自己de王妃 提交于 2019-12-11 03:37:28
问题 I get an error whilst running my node index.js here is my code const botconfig = require("./botconfig.json"); const Discord = require("discord.js"); const bot = new Discord.Client({disableEveryone: true}); bot.on("ready", async () => { console.log(`${bot.user.username} is online!`); }}; bot.login(botconfig.token); here is my error message SyntaxError: missing ) after argument list at new Script (vm.js:51:7) at createScript (vm.js:138:10) at Object.runInThisContext (vm.js:199:10) at Module.

How do I host my discord.py bot on heroku?

為{幸葍}努か 提交于 2019-12-11 03:10:39
问题 I am currently trying to get my discord bot on to Heroku and host it 24/7 but I am having problems. I uploaded my bot to github https://github.com/zemocode/flankebot/tree/master I have created the two main files I needed I clicked deploy branch on Heroku and I'm getting this error. ! No default language could be detected for this app. HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically. See https://devcenter.heroku.com/articles/buildpacks ! Push

Discord Oauth2 Join Guild

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 02:42:25
问题 const guildMembersResponse = fetch(`http://discordapp.com/api/guilds/440494010595803136/members/278628366213709824`, { method: 'PUT', headers: { Authorization: `Bearer TOKEN`, }, }); setTimeout(() => { console.log(guildMembersResponse) }, 500); I want to join a user to my Discord server with his userid and his token in nodejs, but if I request the Dicord api I get an error: Promise { Response { size: 0, timeout: 0, [Symbol(Body internals)]: { body: [PassThrough], disturbed: false, error: null

Sending an image without the link showing with discord library

梦想与她 提交于 2019-12-11 00:55:54
问题 I would like my discord bot to send an image (from a url), but have the url be hidden from the message that is sent in chat. For sending messages, im using a switch statement that only uses the writing after an "!" case 'happy': bot.sendMessage({ to: channelID, message: 'https://pictureexample.jpg' }); How would I send messages without having the link show in chat? 回答1: As user4261590 wrote, you can use embeds to achieve this. Here's an example that might work for you: case 'happy': const

TypeError: Object of type TextIOWrapper is not JSON serializable

夙愿已清 提交于 2019-12-11 00:46:39
问题 If the code was to work properly then whenever someone types something in the chat they get 5 experience and that information gets put into a .json file, but instead what happens is whenever someone types something into the chat it gives me this error. on_message users = json.dumps(f) TypeError: Object of type TextIOWrapper is not JSON serializable Here is the code that I am using: import discord from discord.ext import commands from discord.ext.commands import Bot import asyncio import json