Added leave announce and info when bot is PMed
This commit is contained in:
parent
c848bd2ff2
commit
ce24c6e783
@ -298,6 +298,8 @@ namespace NadekoBot.Modules
|
||||
.Do(e => {
|
||||
NadekoBot.client.Servers.ForEach(async s => { if (s.Name == "NadekoLog" || s.Name == "Discord Bots") return; await s.Leave(); });
|
||||
});
|
||||
|
||||
|
||||
cgb.CreateCommand(".prune")
|
||||
.Parameter("num", ParameterType.Required)
|
||||
.Description("Prunes a number of messages from the current channel.\n**Usage**: .prune 50")
|
||||
@ -353,13 +355,13 @@ namespace NadekoBot.Modules
|
||||
.Description("Enables or Disables anouncements on the current channel when someone joins the server.")
|
||||
.Do(async e => {
|
||||
if (e.User.Id != NadekoBot.OwnerID) return;
|
||||
announcing = !announcing;
|
||||
announcingGreet = !announcingGreet;
|
||||
|
||||
if (announcing) {
|
||||
if (announcingGreet) {
|
||||
announceChannel = e.Channel;
|
||||
joinServer = e.Server;
|
||||
NadekoBot.client.UserJoined += Client_UserJoined;
|
||||
await e.Send("Announcements enabled on this channel.");
|
||||
await e.Send("Greet announcements enabled on this channel.");
|
||||
} else {
|
||||
announceChannel = null;
|
||||
joinServer = null;
|
||||
@ -368,6 +370,25 @@ namespace NadekoBot.Modules
|
||||
}
|
||||
});
|
||||
|
||||
cgb.CreateCommand(".bye")
|
||||
.Description("Enables or Disables anouncements on the current channel when someone leaves the server.")
|
||||
.Do(async e => {
|
||||
if (e.User.Id != NadekoBot.OwnerID) return;
|
||||
announcingLeave = !announcingLeave;
|
||||
|
||||
if (announcingLeave) {
|
||||
announceLeaveChannel = e.Channel;
|
||||
leaveServer = e.Server;
|
||||
NadekoBot.client.UserJoined += Client_UserJoined;
|
||||
await e.Send("Leave announcements enabled on this channel.");
|
||||
} else {
|
||||
announceLeaveChannel = null;
|
||||
leaveServer = null;
|
||||
NadekoBot.client.UserLeft -= Client_UserLeft;
|
||||
await e.Send("Leave announcements disabled.");
|
||||
}
|
||||
});
|
||||
|
||||
cgb.CreateCommand(".greetmsg")
|
||||
.Description("Sets a new announce message. Type %user% if you want to mention the new member.\n**Usage**: .greetmsg Welcome to the server, %user%.")
|
||||
.Parameter("msg",ParameterType.Unparsed)
|
||||
@ -380,7 +401,7 @@ namespace NadekoBot.Modules
|
||||
|
||||
}
|
||||
|
||||
bool announcing = false;
|
||||
bool announcingGreet = false;
|
||||
Channel announceChannel = null;
|
||||
Server joinServer = null;
|
||||
string announceMsg = "Welcome to the server %user%";
|
||||
@ -394,5 +415,19 @@ namespace NadekoBot.Modules
|
||||
}
|
||||
|
||||
}
|
||||
bool announcingLeave = false;
|
||||
Channel announceLeaveChannel = null;
|
||||
Server leaveServer = null;
|
||||
string announceLeaveMsg = "Welcome to the server %user%";
|
||||
|
||||
private void Client_UserLeft(object sender, UserEventArgs e) {
|
||||
if (e.Server != leaveServer) return;
|
||||
try {
|
||||
announceLeaveChannel?.Send(announceLeaveMsg.Replace("%user%", e.User.Mention));
|
||||
} catch (Exception) {
|
||||
Console.WriteLine("Failed sending leave message to the specified channel.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -95,8 +95,9 @@ namespace NadekoBot.Modules {
|
||||
|
||||
if (video?.Uri != "" && video.Uri != null) {
|
||||
SongQueue.Add(video);
|
||||
if(SongQueue.Count > 1)
|
||||
await e.Send("**Queued** " + video.FullName);
|
||||
} else {
|
||||
await e.Send("Failed to load that song.");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -6,8 +6,9 @@ using Parse;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Modules;
|
||||
using Discord.Modules;
|
||||
using Discord.Legacy;
|
||||
using Discord.Audio;
|
||||
using System.Threading.Tasks;
|
||||
using System.Timers;
|
||||
|
||||
namespace NadekoBot
|
||||
{
|
||||
@ -63,6 +64,8 @@ namespace NadekoBot
|
||||
Console.WriteLine("Parse key and/or ID not found. Bot will not log.");
|
||||
}
|
||||
|
||||
//reply to personal messages
|
||||
client.MessageReceived += Client_MessageReceived;
|
||||
|
||||
//add command service
|
||||
var commands = client.Services.Add<CommandService>(commandService);
|
||||
@ -93,5 +96,20 @@ namespace NadekoBot
|
||||
Console.WriteLine("Exiting...");
|
||||
Console.ReadKey();
|
||||
}
|
||||
static bool repliedRecently = false;
|
||||
private static async void Client_MessageReceived(object sender, MessageEventArgs e) {
|
||||
if (e.Server != null) return;
|
||||
if (repliedRecently = !repliedRecently) {
|
||||
await e.Send("You can type `-h` or `-help` or `@MyName help` in any of the channels I am in and I will send you a message with my commands.\n Or you can find out what i do here: https://github.com/Kwoth/NadekoBot\nIf you don't want me on your server, you can simply ban me ;(");
|
||||
Timer t = new Timer();
|
||||
t.Interval = 2000;
|
||||
t.Start();
|
||||
t.Elapsed += (s, ev) => {
|
||||
repliedRecently = !repliedRecently;
|
||||
t.Stop();
|
||||
t.Dispose();
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user