Why is my kick command not working? (discord.js) - discord.js

I've tried using a command handler and the other commands work fine. It's just the kick command that doesn't, can anyone help? https://sourceb.in/8d4f78e43a is the code, thanks!

Since the code is pretty small, you should post it on SO instead of an external link, for archiving for the future and some other reasons you can look up
Also you should mention if you get any error logs, in this case I don't think you would have
The issue is let member = message.guild.members.cache.get(args);
You are passing in an the array args, not a string (which <Collection>.get() requires, you probably meant args[1]:
let member = message.guild.members.cache.get(args[1]);

Related

Nextcord: I want to mention the sender of the slash command I made. How would I go about that?

I'm trying to make this command notify my admins of a bot test and need it to mention the user who called the command. How would I go about that? I don't fully understand how to get that information with slash commands.
#client.slash_command(name= "test", description="(For Deputies or Leader only) Checks the operational state of the client.", guild_ids=[806043206030589952])
#has_any_role(leader_id, deputy_id)
async def test(interaction:Interaction):
bot_log = channel_up(940125176723554394)
await bot_log.send(f'<#&806045254834847776>,{} has started diagnostics for the bot. Please ignore any possible disturbances for the next minute or so.')
Thanks in advance for the advice, it's the first discord bot I've ever created.
EDIT:
In documentation, I found the solution. I have to use interaction.user.mention to get it to mention the user who sent the command. Or at least in theory, I'm dealing with a different issue now. Hopefully this helps people who also were as confused as me out.
You can use the interaction.user.name function with an # at the beginning.
The code should look something like this:
await interaction.response.send_message("#"+str(interaction.user.name))

One time only command possible?

I was wondering if its possible to have a command that can be used only once by a user on discord, if so please can someone give me the code for it I would much appreciate it.
First of all, SO is not a code-as-a-service platform or whatever. You give code, you tell your problem, and we help you. It's how it works. Here's my answer.
Of course, yes, it is possible. Anything that is based on logic can be reproduced by a computer. You just need to learn how to think as a computer would. In your case, it'd look like that in pseudo-code.
when the command is received:
has the user already used this command?
yes:
return "You've already used this command!"
no:
do the work
You would need to save the users who already have used the command. For simplicity reasons, the database you would like to use will be represented as an array.
let blockList = []
client.on('message', msg => {
if (msg.content === "!command") {
if (blockList.includes(msg.author.id)) return msg.reply("You've already used this command!");
msg.reply("This is the first time you're using this command! You won't be able to do it again. BUT since the blocklist is stored as an array, the list will be cleared when the program will stop.")
return blockList.push(msg.author.id)
}
})
Here you have the logic. It's up to you to integrate it into your code, with your database.
I hope I helped, and please, do not post another question that looks like that. Try, search, and ask! It'll be much nicer to help you, and I'm sure you would learn much more.

discord.collection is not a constructor

I'm trying to write a discord bot and am constantly getting this error whenever i try to run it.
TypeError: discord.collection is not a constructor
It's from this line of code
bot.commands = new discord.collection();
I'm not the best at JavaScript and have looked around google and can't find anything that matches my exact issue, all the ones I find have the same error but are something completely different.
whether or not this command is outdated or no longer in use I am unsure of but any help would be greatly appreciated!
It's Collection, not collection. The standard for naming classes is always first letter capitalized.

Not able to set list2 in Adobe Launch in custom code

I am trying to set list2 in my analytics call through custom code but it is not getting set.
This issue comes with s.tl() only while with s.t() method, it is triggered correctly.
Below is the code :-
s.addEvent("event12", true);
s.linkTrackVars = "list2";
s.list2 = "Data"
s.tl(this, "d", "Download", s);
If I place logger just before beacon call, it shows the value. However, when I click the button and check for same, only "event12" get fired and not "list2".
Any help would be highly appreciated.
Just tested your code on lululemon:
Conclusion:
You're overwriting either the listvar or the linkTrackVars somewhere else. As #Crayton Mentioned above, doPlugins would be a good spot for it.
But it actually can be overwritten anywhere. In any rule that fires prior, or the s code, or any DE affected.
Paste your code into the console. Execute. Do you see the listvar populated? If yes, then your problem is in rules, so check them. You're not supposed to reassign linktrackvars. Always use the s.apl() plugin.
If no, however, then your problem is definitely in doPlugins. Sometimes I have it when I have silent catches in s code. Pageviews would have all vars populated, but links would have mixed results. Check your error reporting in the catches in doPlugins. I suggest having all code in doPlugins in a try catch.

Trouble with Rails array methods

I have a block of deprecated Ruby on Rails code which is the beginning of a rake file and doesn't depend on anything except accessing the Protein class, which it can (inherited from an earlier version of the project)
task :import_merops_cleavages do
require "#{Rails.root}/config/environment"
require 'bio'
require 'merops'
require_relative '../../app/models/protein.rb'
proteases = Protein.includes(:drs).map(&:drs).where(db_name: 'MEROPS').uniq
#total = proteases.count
puts "starting import of #{#total} proteases"
#added = 1
#padded =1
Every time I try to rake this particular task, the rake aborts and I get the same error message
NoMethodError: undefined method where for #<Array:0x00007f88a625d290> Did you mean? when
I have tried to use other methods to get rid of the where or rearrange things but keep the logic the same, but am at a loss. If anyone has an idea how to resolve this, I would be very grateful
Edit: this is the main visual relational documentation for the application, but I can explain anything that may not make sense.
The error is correct, the where method is not available on Arrays.
It can only be used on rails models.
The map method returns an array, so I reckon you're issue is there.. try removing the .map and see if that solves this issue.
So I'd imagine something like this might work:
proteases = Protein.all.where(db_name: 'MEROPS').uniq
Tell us more about what Protein is.. better yet share the code for it.

Resources