discord.js欢迎消息每次重新启动仅选择一条随机消息

时间:2020-05-24 10:16:37

标签: javascript bots discord.js

到目前为止,我需要我的机器人在每次重新启动时选择一个以上的欢迎消息,而我有多个选择,而机器人只选择了一个,我如何让机器人刷新每个加入的人的选择?

var departmentSheet = excel.Workbook.Worksheets.Add("department");
departmentSheet.Cells["A1"].Value = "Management";
departmentSheet.Cells["A2"].Value = "Administrator";
departmentSheet.Cells["A3"].Value = "Quality Engineering";
departmentSheet.Cells["A4"].Value = "Enablers";

var designationSheet = excel.Workbook.Worksheets.Add("designations");
designationSheet.Cells["A1"].Value = "Developer 1";
designationSheet.Cells["A2"].Value = "Developer 2";
designationSheet.Cells["A3"].Value = "Developer 3";
designationSheet.Cells["A4"].Value = "Developer 4";

// add a validation and set values
// the range of cells that will contain the validation
var validation = departmentSheet.DataValidations.AddListValidation("B1:B4");

// set validation rules as required
validation.ShowErrorMessage = true;
validation.ErrorStyle = ExcelDataValidationWarningStyle.warning;
validation.ErrorTitle = "An invalid value was entered";
validation.Error = "Select a value from the list";

// set the range that contains the validation list
validation.Formula.ExcelFormula = $"={ designationSheet.Name }!$A$1:$A$4";

1 个答案:

答案 0 :(得分:3)

放置var wtl = Math.floor(Math.random() * welcometext.length);

在您的客户内部,on应该这样做。这样,每次都会重新生成随机数。

亲切问候 BloodSKreaper