discord

How to get the sum and the names of all the users from all voice channels Disocrd?

孤人 提交于 2019-12-02 13:45:12
I use : import discord I need to get from each voice channel amount all users and then get their names (usernames). How to do it? You need to access the voice channel object. I recommend you use the voice channel's id. The command could look as follows: @client.command(pass_context = True) async def vcmembers(ctx, voice_channel_id): #First getting the voice channel object voice_channel = discord.utils.get(ctx.message.server.channels, id = voice_channel_id) if not voice_channel: return await client.say("That is not a valid voice channel.") members = voice_channel.voice_members member_names = '

Add cooldown / timer to on_message [Discord.py]

蹲街弑〆低调 提交于 2019-12-02 13:16:59
问题 I got into making a Discord bot in Python very recently (testing the grounds of Python with it) and created a functioning one with several commands myself. To widen its uses, I have added a level/XP system, which is working so far. [...] @bot.event async def on_message(message): user_add_xp(message.author.id, 2) await bot.process_commands(message) # commands go here def user_add_xp(user_id, xp): if os.path.isfile('users.json'): try: with open('users.json', 'r') as fp: users = json.load(fp)

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

陌路散爱 提交于 2019-12-02 12:58:59
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 console shows Ignoring exception in on_message Traceback (most recent call last): File "C:\Users\FeNka

Experience (XP) not working for all users JSON Discord.PY

会有一股神秘感。 提交于 2019-12-02 12:23:52
I'm trying to give points for messages typed in a room that has around 50-60 people that type in it. It will add the user to the JSON file the first time, but it won't add any more points for the messages they type. I tested it again and only one user was getting points for the messages they typed and the rest remained the same. Here is the code: @client.event async def on_message(message): if message.content.lower().startswith('!points'): await client.send_message(message.channel, "You have {} points!".format(get_points(message.author.id))) user_add_points(message.author.id,1) def user_add

heroku deployment, libopus not found

半城伤御伤魂 提交于 2019-12-02 11:26:47
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-learn==0.19.1 scipy==0.19.1 six==1.11.0 sklearn==0.0 websockets==3.4 youtube-dl==2018.4.9 My Aptfile

Overlapping commands?

旧时模样 提交于 2019-12-02 11:20:47
I'm trying to make a fun little discord chat bot with JavaScript and node.js and I'd like to put in a specific command without it affecting another one I already have set up. She works wonderfully on all the servers I have her on, and I've got it set up so that when someone in the server says anything with "rei are", she responds with a constant from areResponses. //const!!! const areResponses = ["HELL yeah!", "Yep!", "I'm pretty sure that's true!", "I\'m not gonna put all the responses here because then it'd be too long..."]; //theres some other bot stuff (console log, now playing) under here

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

陌路散爱 提交于 2019-12-02 10:45:09
问题 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 回答1: 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:/

Print friends-list to console Discord.py

China☆狼群 提交于 2019-12-02 10:17:22
How would I go about printing to console a list of all my friends? I'm hoping to be able to achieve this with the Discord.py library, hopefully someone here knows. I currently get the error: for user in discord.ClientUser.friends: TypeError: 'property' object is not iterable Program: token = "" prefix = "::" import discord import asyncio import codecs import sys import io from discord.ext import commands from discord.ext.commands import Bot print ("waiting") bot = commands.Bot(command_prefix=prefix, self_bot=True) bot.remove_command("help") @bot.event async def on_ready(): print ("Friends")

Trying to create a Discord Welcome/Leave Bot

无人久伴 提交于 2019-12-02 10:16:11
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) print('-----') newUserDMMessage = "Welcome DM" #Public Welcome @client.event async def on_member_join

Raise custom error message for

房东的猫 提交于 2019-12-02 10:11:33
So below code blocks server and user id in the list when they use ?hello , so I am trying to raise custom error message. If user id is in list, it will tell User Blacklisted and if server id is in list, it will tell Server has been Blacklisted . LIST_OF_USER_IDS = ['34534545546', '34534545546'] LIST_OF_SERVER_IDS = ['34534545546', '34534545546'] def blacklists(users, servers): def predicate(ctx): return ctx.message.author.id not in users and ctx.message.server.id not in servers return commands.check(predicate) @bot.command(pass_context=True) @blacklists(LIST_OF_USER_IDS, LIST_OF_SERVER_IDS)