discord

How to tag users?

孤者浪人 提交于 2019-12-13 09:55:43
问题 I am looking to create a command in order to tag certain users. This is what I have tried: var players = [ "@RYAN#9602" ] switch(args[0].toLowerCase()){ case "play": message.channel.send(players.join('\n')); break; } However, it just sends a message into the text channel without actually tagging the user. In summmary, I am looking to be able to tag a user through a discord.js bot. Any help would be greatly appreciated, thanks! 回答1: You have two options. You can either use the toString method

How to count json into html span

北城余情 提交于 2019-12-13 09:48:28
问题 i try to count my members on discord into my website with a HTML Span. I can't get it to work Source code: https://discordapp.com/api/guilds/366996506563051520/embed.json 回答1: Got a barebones script for you here mate. Just insert it in the <body> of your page <span id="discord-counter"></span> <script type="text/javascript"> var request = new XMLHttpRequest(); request.open('GET', 'https://discordapp.com/api/guilds/366996506563051520/embed.json', true); request.onload = function() { if

Discord.py bot wont print a SIMPLE variable in the chat

自古美人都是妖i 提交于 2019-12-13 09:38:35
问题 What I want is for the bot to say Snacktoshis: 5 , but it won't print the variable in the chat. Here is my code: from discord import * from discord.ext import * from discord.ext.commands import Bot from discord.ext.commands import * import random import asyncio from discord import Game from discord.ext.commands import Bot import aiohttp import discord import requests import time BOT_PREFIX = ("?", "!") client = Bot(command_prefix=BOT_PREFIX) TOKEN =

How to read XML file in Javascript? [duplicate]

删除回忆录丶 提交于 2019-12-13 08:49:07
问题 This question already has answers here : The best node module for XML parsing [closed] (2 answers) How to parse xml file to array in JavaScript node.js (1 answer) Closed 11 months ago . I'm creating a bot for the Discord. I'm downloading a horoscope XML-file from the Internet. The XML-file structure is as follows: <?xml version="1.0" encoding="utf-8"?> <horo> <date yesterday="04.01.2019" today="05.01.2019" tomorrow="06.01.2019"/> <aries> <yesterday> Text 1 </yesterday> <today> Text 2 </today>

Discord Bot Python ffmpeg error

孤街醉人 提交于 2019-12-13 08:04:11
问题 So I'm running the following code which is part of a bigger file. It keeps throwing up the below error even though I've installed ffmpeg and set it to the $PATH variable. I'm on a Mac running OSX El Capitan. This code uses the discord module for python 3.5.2. author_channel = (message.author).voice_channel voice = await media_bot.join_voice_channel(author_channel) player = await voice.create_ytdl_player(video) player.start() Traceback (most recent call last): File "/Library/Frameworks/Python

How to give a command multiple names?

旧街凉风 提交于 2019-12-13 05:09:34
问题 I have a command: @bot.command(pass_context=True) async def hellothere(ctx): await Bot.say("Hello {}".format(ctx.message.author)) I want to make a copy of this command that is shorter. I tried: @bot.command(pass_context=True) async def hello(ctx): hellothere(ctx) But I received an error stating that Command is not callable. Does anyone know how to do this? 回答1: You should be able to use the Command.invoke coroutine. Something like @bot.command(pass_context=True) async def hello(ctx): await

Sqlite Discord.js: Cannot read property 'run' of null

谁说我不能喝 提交于 2019-12-13 04:12:37
问题 So I am trying to make a SQLite database for my Discord.js bot, but I keep getting this error (Cannot read property of 'run' of null) when I try to use SQLite. Non of my friends seem to have this problem, so I thought to come here. Sorry if this is like a noobish question.. I'm still a little new to this Here is my code: const Discord = require("discord.js"); const client = new Discord.Client(); const bot = new Discord.Client(); const sql = require("sqlite") const fs = require("fs"); const

Get total number of members in Discord using PHP

夙愿已清 提交于 2019-12-13 03:18:30
问题 I have a Discord servern with 1361 members and on my website I want to display a total number of joined users. I have figured out how to get all online Members on the server using: <?php $jsonIn = file_get_contents('https://discordapp.com/api/guilds/356230556738125824/widget.json'); $JSON = json_decode($jsonIn, true); $membersCount = count($JSON['members']); echo "Number of members: " . $membersCount; ?> What should I do differently to get a total number of ALL users that have joined the

How to send a message to a different server | Discord Bot

跟風遠走 提交于 2019-12-13 03:02:48
问题 I am very curious because I have seen other bots do this, the food bot command would be: "!Order" and then it would send another embed to a different server and a specific channel. How do I code that? 回答1: You can get a guild and then get a channel from the guild. client.guilds.get(<guild id>).channels.get(<channel id>).send(<message>) Notice this requires the bot to be in both guilds 来源: https://stackoverflow.com/questions/51112006/how-to-send-a-message-to-a-different-server-discord-bot

Check if User has a certain role

社会主义新天地 提交于 2019-12-13 02:17:59
问题 I have code in which you can type -giverole <user> <rolename> e.g. -giverole @Soup Board of Executives . What I need now is a method that checks to see if the user typing the command has a certain role. I have code that can give a role to someone: @client.command(pass_context=True) async def giverole(ctx, member: discord.Member, *, role: discord.Role): await client.add_roles(member, role) await client.say("The role '" + str(role) + "' has been given to " + member.mention + " .") It should do